cfahlgren1's picture
cfahlgren1 HF Staff
mirror at 11b6c7e3c927df2658f513b6b68ea7f8929c62c5
e639140 verified
Raw History Blame Contribute Delete
2.09 kB

Reading one clause from a block of k slots of w bits is polynomial-time.

26
@[fun_prop] theorem clauseDec_polyT (k : ℕ) {w : α → ℕ} {b : α → List Bool} (hw : PolyT w) (hb : PolyT b) :
    PolyT fun x => clauseDec k (w x) (b x) := by
proof · 1 line
  unfold clauseDec; fun_prop

Reading the list of clauses from the body b of the input, one block of k·w bits per clause, is polynomial-time. This is the second component of decK k.

33
theorem clauses_polyT (k : ℕ) {w : α → ℕ} {b : α → List Bool} (hw : PolyT w) (hb : PolyT b) :
    PolyT fun x => ((List.range (b x).length).take ((b x).length / (k * w x))).map fun c =>
      clauseDec k (w x) (block (k * w x) c (b x)) := by
proof · 4 lines
  have hr : PolyT fun x => List.range (b x).length := PolyT.range (Unary.of_length hb)
  have ht : PolyT fun x => (List.range (b x).length).take ((b x).length / (k * w x)) :=
    PolyT.take (by fun_prop) hr
  exact PolyT.map (f := fun x c => clauseDec k (w x) (block (k * w x) c (b x))) (by fun_prop) ht

The decoder decK k, which reads the input of the algorithm, is polynomial-time.

42
theorem decK_polyT (k : ℕ) : PolyT (decK k) := by
proof · 3 lines
  have hn : PolyT fun x : List Bool => (x.takeWhile id).length := by fun_prop
  have hb : PolyT fun x : List Bool => (x.dropWhile id).tail := by fun_prop
  exact PolyT.prodMk hn (clauses_polyT k (width_polyT hn) hb)