Binary conversion (SUBSET-SUM reduction machine) to Statements of the SUBSET-SUM verifier
TheoremBinary conversion (SUBSET-SUM reduction machine)#✓fully proved
Let \(k\) be a natural number, \(v\) a value of the machine's Boolean flag and \(S\) an assignment of contents to the stacks, and list the binary digits of \(k\) least significant first, without leading zeros (so there are none for \(k = 0\)). Suppose stack \(A\) holds \(k\) copies of the unit symbol and stack \(H\) is empty. Then, starting at label \(\mathrm{hv}\) with flag \(v\) and stacks \(S\), the machine reaches label \(\mathrm{tem0}\) in at most \(6k + 1\) steps, with some flag \(v'\) and stacks \(S'\) such that \(S'(T)\) is the reverse of the list of input-bit symbols \(\mathrm{bit}(b)\) for these binary digits \(b\) of \(k\), followed by \(S(T)\), and every stack other than \(A\), \(H\), \(T\) holds the same contents as in \(S\).
The machine thus pushes the binary digits of \(k\) onto \(T\) least significant first.
theorem hv_run (k : ℕ) : ∀ (v : Bool) (St : ∀ k, List (Γ k)), St .A = cnt U k → St .H = [] →
∃ v' S', RunLe prog (6 * k + 1) ⟨some .hv, v, St⟩ ⟨some .tem0, v', S'⟩ ∧
S' .T = ((encodeNat k).map Sym.bit).reverse ++ St .T ∧
∀ j, j ≠ .A → j ≠ .H → j ≠ .T → S' j = St j
@[reducible] def Γ : K → Type
| .O => Bool
| _ => Sym
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:64
abbrev cnt {α : Type} (u : α) (n : ℕ) : List α := List.replicate n u
MathlibExt/Computability/TuringMachine/Program.lean:115
abbrev U : Sym := .cl
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:87
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt Γ Lab Bool
| .rdK => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .A (fun _ => U) (.goto fun _ => .rdK)) (.goto fun _ => .rdN)
| .rdN => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .N (fun _ => U) <| .push .L (fun _ => .val false) <| .goto fun _ => .rdN)
(.goto fun _ => .mv)
| .mv => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .tri) <|
.pop .X (fun _ o => isT o) <| .push .Y (fun s => .val s) <|
.push .T (fun _ => .bit false) <| .push .T (fun s => .bit s) <|
.push .C (fun _ => U) <| .goto fun _ => .mv
⋯
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:110
inductive Sym
| bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
deriving DecidableEq
CSLibExt/Computability/Complexity/SatVerifierSpec.lean:41
Uses 15 · Used by 3
TheoremRun of the target-bit loop of the subset-sum emitter#✓fully proved
Let \(l = (b_1, \dots, b_m)\) be a list of bits. Start the VERTEX-COVER to SUBSET-SUM machine at label \(\mathsf{tem}\) with any state bit and with stacks \(S\) in which stack \(\mathsf{T}\) holds exactly the bit symbols of \(b_1, \dots, b_m\), top first. Then after exactly \(m + 1\) steps the machine is at label \(\mathsf{done}\) with some state bit and stacks \(S'\) in which the output stack \(\mathsf{O}\) holds, top first, \(\mathrm{true}, b_m, \mathrm{true}, b_{m-1}, \dots, \mathrm{true}, b_1\) followed by the contents of \(\mathsf{O}\) in \(S\), and every stack other than \(\mathsf{T}\) and \(\mathsf{O}\) is as in \(S\). That is, each popped bit \(b\) is written as \(b\) and then \(\mathrm{true}\).
theorem tem_run : ∀ (l : List Bool) (v : Bool) (St : ∀ k, List (Γ k)), St .T = l.map Sym.bit →
∃ v' S', Run prog (l.length + 1) ⟨some .tem, v, St⟩ ⟨some .done, v', S'⟩ ∧
S' .O = l.reverse.flatMap (fun b => [true, b]) ++ St .O ∧
∀ j, j ≠ .T → j ≠ .O → S' j = St j
@[reducible] def Γ : K → Type
| .O => Bool
| _ => Sym
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:64
inductive Sym
| bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
deriving DecidableEq
CSLibExt/Computability/Complexity/SatVerifierSpec.lean:41
def Run (n : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
(flip bind (TM2.step M))^[n] (some c) = some d
MathlibExt/Computability/TuringMachine/Program.lean:84
def prog : Lab → TM2.Stmt Γ Lab Bool
| .rdK => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .A (fun _ => U) (.goto fun _ => .rdK)) (.goto fun _ => .rdN)
| .rdN => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .N (fun _ => U) <| .push .L (fun _ => .val false) <| .goto fun _ => .rdN)
(.goto fun _ => .mv)
| .mv => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .tri) <|
.pop .X (fun _ o => isT o) <| .push .Y (fun s => .val s) <|
.push .T (fun _ => .bit false) <| .push .T (fun s => .bit s) <|
.push .C (fun _ => U) <| .goto fun _ => .mv
⋯
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:110
Uses 9 · Used by 1
TheoremRun of the target-output phase of the subset-sum emitter#✓fully proved
Let \(l\) be a list of bits, let \(l'\) be \(l\) with its leading \(\mathrm{false}\) bits removed, and let \(o\) be a list of bits. Start the VERTEX-COVER to SUBSET-SUM machine at label \(\mathsf{tsk}\) with any state bit and with stacks \(S\) in which stack \(\mathsf{T}\) holds exactly the bit symbols of \(l\), first bit on top, and the output stack \(\mathsf{O}\) holds \(\mathrm{false}\) followed by \(o\). Then after exactly \(|l| + 1\) steps the machine is at label \(\mathsf{done}\) with some state bit and stacks \(S'\) in which \(\mathsf{O}\) holds the self-delimiting encoding of the reverse of \(l'\) followed by \(o\), and every stack other than \(\mathsf{T}\) and \(\mathsf{O}\) is as in \(S\). Here the self-delimiting encoding of a list replaces each bit \(b\) by \(\mathrm{true}, b\) and appends \(\mathrm{false}\).
theorem tsk_run : ∀ (l : List Bool) (v : Bool) (St : ∀ k, List (Γ k)) (o : List Bool),
St .T = l.map Sym.bit → St .O = false :: o →
∃ v' S', Run prog (l.length + 1) ⟨some .tsk, v, St⟩ ⟨some .done, v', S'⟩ ∧
S' .O = delimit (l.dropWhile (!·)).reverse ++ o ∧ ∀ j, j ≠ .T → j ≠ .O → S' j = St j
@[reducible] def Γ : K → Type
| .O => Bool
| _ => Sym
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:64
inductive Sym
| bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
deriving DecidableEq
CSLibExt/Computability/Complexity/SatVerifierSpec.lean:41
def Run (n : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
(flip bind (TM2.step M))^[n] (some c) = some d
MathlibExt/Computability/TuringMachine/Program.lean:84
def prog : Lab → TM2.Stmt Γ Lab Bool
| .rdK => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .A (fun _ => U) (.goto fun _ => .rdK)) (.goto fun _ => .rdN)
| .rdN => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .N (fun _ => U) <| .push .L (fun _ => .val false) <| .goto fun _ => .rdN)
(.goto fun _ => .mv)
| .mv => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .tri) <|
.pop .X (fun _ o => isT o) <| .push .Y (fun s => .val s) <|
.push .T (fun _ => .bit false) <| .push .T (fun s => .bit s) <|
.push .C (fun _ => U) <| .goto fun _ => .mv
⋯
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:110
def delimit : List Bool → List Bool
| [] => [false]
| b :: l => true :: b :: delimit l
MathlibExt/Computability/Complexity.lean:68
Uses 12 · Used by 3
TheoremRun of the VERTEX-COVER to SUBSET-SUM machine#✓fully proved
Let \(x\) be a bit string. Start the VERTEX-COVER to SUBSET-SUM machine at its start label with any state bit and with stacks in which the input stack \(\mathsf{X}\) holds the bit symbols of \(x\), first bit on top, and every other stack is empty. Then within at most \(40(|x| + 1)^4\) steps the machine reaches the label \(\mathsf{done}\) with some state bit and stacks in which the output stack \(\mathsf{O}\) holds, top first, the image of \(x\) under the bit-string reduction from VERTEX-COVER to SUBSET-SUM.
theorem run (x : List Bool) (v : Bool) (St : ∀ k, List (Γ k))
(hX : St .X = x.map Sym.bit) (h0 : ∀ k, k ≠ .X → St k = []) :
∃ v' S', RunLe prog (40 * (x.length + 1) ^ 4) ⟨some start, v, St⟩ ⟨some .done, v', S'⟩ ∧
S' .O = reduceSS x
@[reducible] def Γ : K → Type
| .O => Bool
| _ => Sym
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:64
inductive Sym
| bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
deriving DecidableEq
CSLibExt/Computability/Complexity/SatVerifierSpec.lean:41
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt Γ Lab Bool
| .rdK => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .A (fun _ => U) (.goto fun _ => .rdK)) (.goto fun _ => .rdN)
| .rdN => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .bad) <|
.pop .X (fun _ o => isT o) <| .branch id
(.push .N (fun _ => U) <| .push .L (fun _ => .val false) <| .goto fun _ => .rdN)
(.goto fun _ => .mv)
| .mv => .peek .X (fun _ o => o.isNone) <| .branch id (.goto fun _ => .tri) <|
.pop .X (fun _ o => isT o) <| .push .Y (fun s => .val s) <|
.push .T (fun _ => .bit false) <| .push .T (fun s => .bit s) <|
.push .C (fun _ => U) <| .goto fun _ => .mv
⋯
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:110
def start : Lab := .rdK
CSLibExt/Computability/Complexity/Karp/SubsetSumEmit.lean:181
def reduceSS (x : List Bool) : List Bool :=
match decodeKG x with
| some (k, n, bits) =>
if bits.length = (pairs n).length then encodeSS (ssNums n bits) (ssTarget k n bits)
else noSS
| none => noSS
CSLibExt/Computability/Complexity/Karp/SubsetSum.lean:80
Uses 54 · Used by 1
DefinitionWhether a bit string ends in false#✓fully proved
For a Boolean \(z\) and a list of bits \(p\), the value is \(z\) when \(p\) is empty and the negation of the last bit of \(p\) otherwise. So if \(z\) records whether the bits read so far end in false, the value records whether those bits followed by \(p\) end in false.
With \(z\) false the value is true exactly when \(p\) is non-empty and ends in false, that is, when \(p\) is not the canonical binary code of a number, least significant bit first.
Used by 9
TheoremCanonical binary strings are those not ending in zero#✓fully proved
For every bit string \(p\), encoding in binary (least significant bit first) the natural number that \(p\) decodes to gives back \(p\) if and only if the trailing-zero test, started with no trailing zero, reports that \(p\) does not end in \(0\); that is, \(p\) is empty or its last bit is \(1\).
theorem encodeNat_decodeNat_iff (p : List Bool) :
encodeNat (decodeNat p) = p ↔ lastF false p = false
def lastF : Bool → List Bool → Bool
| z, [] => z
| _, b :: p => lastF (!b) p
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:52
Uses 2 · Used by 4
DefinitionParsing number blocks, with fuel#✓fully proved
For a fuel \(n\) and a list of bits \(r\), the result is either a list of numbers or a failure. If \(r\) is empty, the result is the empty list. If \(r\) is non-empty and \(n = 0\), parsing fails. If \(r\) is non-empty and \(n = m + 1\), one prefix-coded number is decoded off the front of \(r\): if this gives a number \(a\) with remainder \(r'\), the result is \(a\) followed by the result for \(r'\) with fuel \(m\) (failing if that fails), and otherwise parsing fails. Here the prefix code of \(a\) is the canonical binary code of \(a\), least significant bit first, with each bit \(b\) written as the pair true, \(b\), followed by a final false.
def numsAux : ℕ → List Bool → Option (List ℕ)
| _, [] => some []
| 0, _ :: _ => none
| n + 1, b :: l => match decodeNatPrefix (b :: l) with
| some (a, r) => (numsAux n r).map (a :: ·)
| none => none
def decodeNatPrefix (input : List Bool) : Option (Nat × List Bool) := do
let (bits, rest) ← MetaMathlibExt.BitstringEncoding.undelimit input
let n := Computability.decodeNat bits
if Computability.encodeNat n = bits then some (n, rest) else none
CSLibExt/Computability/CookLevin.lean:57
DefinitionDecoding a SUBSET-SUM instance#✓fully proved
A block holding a bit string \(p\) writes each bit \(b\) of \(p\) as the two bits \(1, b\) and ends with a single \(0\). The decoder reads a bit string \(x\) as one block holding the target \(t\), followed by blocks holding numbers \(a_1, \dots, a_n\) that run exactly to the end of \(x\), where each block must hold the canonical binary representation of its number (least significant bit first, no trailing \(0\)). It returns the list \((a_1, \dots, a_n)\) together with \(t\), and fails if \(x\) does not split this way.
def decodeSS (x : List Bool) : Option (List ℕ × ℕ) :=
match decodeNatPrefix x with
| some (t, r) => (numsAux r.length r).map fun as => (as, t)
| none => none
def decodeNatPrefix (input : List Bool) : Option (Nat × List Bool) := do
let (bits, rest) ← MetaMathlibExt.BitstringEncoding.undelimit input
let n := Computability.decodeNat bits
if Computability.encodeNat n = bits then some (n, rest) else none
CSLibExt/Computability/CookLevin.lean:57
def numsAux : ℕ → List Bool → Option (List ℕ)
| _, [] => some []
| 0, _ :: _ => none
| n + 1, b :: l => match decodeNatPrefix (b :: l) with
| some (a, r) => (numsAux n r).map (a :: ·)
| none => none
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:79
Uses 2 · Used by 8
TheoremDecoding a SUBSET-SUM instance inverts its encoding#✓fully proved
For every bit string \(x\), every list \(a\) of natural numbers and every natural number \(t\), the SUBSET-SUM decoder returns the instance \((a, t)\) on \(x\) if and only if \(x\) is the encoding of the SUBSET-SUM instance with numbers \(a\) and target \(t\).
theorem decodeSS_eq_some {x : List Bool} {as : List ℕ} {t : ℕ} :
decodeSS x = some (as, t) ↔ encodeSS as t = x
def decodeSS (x : List Bool) : Option (List ℕ × ℕ) :=
match decodeNatPrefix x with
| some (t, r) => (numsAux r.length r).map fun as => (as, t)
| none => none
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:87
def encodeSS (as : List ℕ) (t : ℕ) : List Bool :=
delimit (encodeNat t) ++ as.flatMap fun a => delimit (encodeNat a)
CSLibExt/Computability/Complexity/Karp/SubsetSum.lean:43
Uses 10 · Used by 4
DefinitionNumbers chosen by a mask#✓fully proved
For a list of numbers \(a_0, \dots, a_{k-1}\) and a list of bits \(w\), the list of those \(a_i\) with \(w_i\) true, in their original order, where positions \(i\) beyond the end of \(w\) count as false.
def pick : List ℕ → List Bool → List ℕ
| [], _ => []
| a :: as, w => if w.headD false then a :: pick as w.tail else pick as w.tail
Used by 11
DefinitionThe SUBSET-SUM verifier#✓fully proved
For bit strings \(x\) and \(w\), the verifier accepts \((x, w)\) exactly when \(x\) is the encoding of a SUBSET-SUM instance with numbers \(a_0, \dots, a_{n-1}\) and target \(t\), and the sum of the \(a_i\) for which bit \(i\) of \(w\) is true equals \(t\); bits beyond the end of \(w\) count as false, and bits of \(w\) past position \(n - 1\) are ignored. If \(x\) is not the encoding of an instance, the verifier rejects.
def ssCheck (x w : List Bool) : Bool :=
match decodeSS x with
| some (as, t) => (pick as w).sum == t
| none => false
def decodeSS (x : List Bool) : Option (List ℕ × ℕ) :=
match decodeNatPrefix x with
| some (t, r) => (numsAux r.length r).map fun as => (as, t)
| none => none
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:87
def pick : List ℕ → List Bool → List ℕ
| [], _ => []
| a :: as, w => if w.headD false then a :: pick as w.tail else pick as w.tail
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:178
Uses 2 · Used by 3
TheoremEvery sublist is selected by a mask#✓fully proved
If \(l\) is a sublist of a list \(a\) of natural numbers, then there is a list \(w\) of Booleans of the same length as \(a\) such that the entries \(a_i\) of \(a\) with \(w_i\) true, taken in order, form exactly \(l\).
theorem exists_pick {l as : List ℕ} (h : l.Sublist as) :
∃ w : List Bool, w.length = as.length ∧ pick as w = l
def pick : List ℕ → List Bool → List ℕ
| [], _ => []
| a :: as, w => if w.headD false then a :: pick as w.tail else pick as w.tail
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:178
Uses 1 · Used by 1
TheoremSUBSET-SUM is characterized by its verifier#✓fully proved
A bit string \(x\) is a yes-instance of SUBSET-SUM if and only if there is a bit string \(w\) with \(|w| \le |x|\) such that the SUBSET-SUM verifier accepts \((x, w)\).
theorem subsetSumDec_iff (x : List Bool) :
subsetSumDec x = true ↔ ∃ w, w.length ≤ x.length ∧ ssCheck x w = true
noncomputable def subsetSumDec : MetaMathlibExt.ComplexityTheory.DecisionProblem := fun x =>
decide (∃ as t, encodeSS as t = x ∧ ∃ l : List ℕ, l.Sublist as ∧ l.sum = t)
CSLibExt/Computability/Complexity/Karp/SubsetSum.lean:48
def ssCheck (x w : List Bool) : Bool :=
match decodeSS x with
| some (as, t) => (pick as w).sum == t
| none => false
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:183
Uses 8 · Used by 1
DefinitionCarry bit of a full adder#✓fully proved
For bits \(a\), \(b\) and a carry-in \(c\), the carry out of adding \(a\), \(b\) and \(c\) is \((a \wedge b) \vee (c \wedge (a \oplus b))\), which is true iff at least two of \(a\), \(b\), \(c\) are true.
Used by 12
DefinitionAdding a carry bit#✓fully proved
For a carry bit \(c\) and a bit string \(u\) (least significant bit first), \(\mathrm{inc}(c, u)\) adds \(c\) to \(u\) by ripple carry: on the empty string it is \([1]\) if \(c\) is true and empty otherwise, and on a string with first bit \(a\) and rest \(u'\) it is the bit \(a \oplus c\) followed by \(\mathrm{inc}(a \wedge c, u')\).
def incB : Bool → List Bool → List Bool
| c, [] => if c then [true] else []
| c, a :: u => (a ^^ c) :: incB (a && c) u
Used by 9
DefinitionRipple-carry addition of bit lists#✓fully proved
For a carry-in bit \(c\) and bit lists \(u\) and \(p\), both least significant bit first, the ripple-carry sum walks \(p\). If \(p\) is empty, the result is \(u\) with the carry \(c\) added (a final carry becomes a new last bit). Otherwise, with \(a\) the first bit of \(u\) (\(a\) is false when \(u\) is empty) and \(b\) the first bit of \(p\), the result is the bit \(a \oplus b \oplus c\) followed by the ripple-carry sum of the rest of \(u\) and the rest of \(p\) with carry-in the carry out of \(a\), \(b\) and \(c\).
def addB : Bool → List Bool → List Bool → List Bool
| c, u, [] => incB c u
| c, u, b :: p =>
(u.headD false ^^ b ^^ c) :: addB (carry (u.headD false) b c) u.tail p
def incB : Bool → List Bool → List Bool
| c, [] => if c then [true] else []
| c, a :: u => (a ^^ c) :: incB (a && c) u
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:238
def carry (a b c : Bool) : Bool := a && b || c && (a ^^ b)
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:235
Uses 2 · Used by 7
TheoremAddition is correct on canonical numbers#✓fully proved
For every bit \(c\) and all natural numbers \(m\) and \(n\), the ripple-carry sum, with carry-in \(c\), of the canonical binary expansions of \(m\) and \(n\) (least significant bit first, no trailing false bit) is the canonical binary expansion of \(m + n + c\), where \(c\) counts as \(1\) if true and \(0\) if false. In particular the sum stays canonical.
theorem addB_encodeNat (c : Bool) (m n : ℕ) :
addB c (encodeNat m) (encodeNat n) = encodeNat (m + n + c.toNat)
def addB : Bool → List Bool → List Bool → List Bool
| c, u, [] => incB c u
| c, u, b :: p =>
(u.headD false ^^ b ^^ c) :: addB (carry (u.headD false) b c) u.tail p
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:244
Uses 4 · Used by 5
InductiveStacks of the SUBSET-SUM verifier#✓fully proved
The verifier has seven stacks: the input \(X\), the witness \(W\), the target \(T\) (most significant bit on top), the running sum \(A\) (least significant bit on top), the new sum \(B\) (most significant bit on top), and the scratch stacks \(P\) and \(Q\) of the final comparison.
inductive K | X | W | T | A | B | P | Q
deriving DecidableEq
Used by 51
InductiveLabels of the SUBSET-SUM verifier#✓fully proved
The verifier has the labels \(\mathrm{tgt}(z)\), reading the target; \(\mathrm{next}\), starting the next number; \(\mathrm{add}(c, z)\), adding a chosen number with carry \(c\); \(\mathrm{skip}(z)\), skipping an unchosen number; \(\mathrm{fin}(c)\), carrying \(c\) through the rest of the sum; \(\mathrm{back}\), moving the new sum back; \(\mathrm{fmove}\), moving the final sum for the comparison; \(\mathrm{cmp}\), comparing; \(\mathrm{yes}\), accepting; and \(\mathrm{no}\), rejecting, for all bits \(c\) and \(z\). In \(\mathrm{tgt}(z)\), \(\mathrm{add}(c, z)\) and \(\mathrm{skip}(z)\) the flag \(z\) records whether the bits of the current block read so far end in \(0\).
inductive Lab
| tgt (z : Bool) | next | add (c z : Bool) | skip (z : Bool) | fin (c : Bool) | back | fmove
| cmp | yes | no
deriving DecidableEq
Used by 50
AbbreviationStatements of the SUBSET-SUM verifier#✓fully proved
The statements of the SUBSET-SUM verifier machine are the statements of a multi-stack Turing machine in Mathlib's TM2 model whose stacks are the seven stacks \(X\), \(W\), \(T\), \(A\), \(B\), \(P\), \(Q\), each over the symbol alphabet of the SAT verifier, whose labels are the labels of the SUBSET-SUM verifier, and whose local state is a Boolean.
abbrev Stmt := TM2.Stmt (fun _ : K => Sym) Lab Bool
inductive K | X | W | T | A | B | P | Q
deriving DecidableEq
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:299
inductive Sym
| bit (b : Bool) | lit (p : Bool) | cl | val (b : Bool) | dead
deriving DecidableEq
CSLibExt/Computability/Complexity/SatVerifierSpec.lean:41
inductive Lab
| tgt (z : Bool) | next | add (c z : Bool) | skip (z : Bool) | fin (c : Bool) | back | fmove
| cmp | yes | no
deriving DecidableEq
CSLibExt/Computability/Complexity/Karp/SubsetSumVerify.lean:310
Uses 3 · Used by 7
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.