Small verified polynomial-time bitstring combinators #
These lemmas are a thin project-local surface over Complexitylib's concrete Turing machines and Cobham soundness theorem. They are used to assemble the arithmetic and dynamic-state machines below without appealing to a semantic "all Lean programs are efficient" principle.
Replace every input bit by zero while preserving the input length.
theorem
BeyondBethe.machineCompose_mem_FP
{f g : List Bool → List Bool}
(hf : f ∈ Complexity.FP)
(hg : g ∈ Complexity.FP)
:
theorem
BeyondBethe.machinePair_mem_FP
{left right : List Bool → List Bool}
(hleft : left ∈ Complexity.FP)
(hright : right ∈ Complexity.FP)
:
theorem
BeyondBethe.machineAppend_mem_FP
{left right : List Bool → List Bool}
(hleft : left ∈ Complexity.FP)
(hright : right ∈ Complexity.FP)
:
theorem
BeyondBethe.machineTake_mem_FP
{ruler data : List Bool → List Bool}
(hruler : ruler ∈ Complexity.FP)
(hdata : data ∈ Complexity.FP)
:
Take a prefix of one computed word whose length is another computed word.
Select by the leading bit of a verified bitstring computation.
Equations
- BeyondBethe.machineIfHead flag whenTrue whenFalse = Complexity.Cobham.selectHead flag whenTrue whenFalse
Instances For
theorem
BeyondBethe.machineIfHead_mem_FP
{flag whenTrue whenFalse : List Bool → List Bool}
(hflag : flag ∈ Complexity.FP)
(htrue : whenTrue ∈ Complexity.FP)
(hfalse : whenFalse ∈ Complexity.FP)
:
(fun (word : List Bool) => machineIfHead (flag word) (whenTrue word) (whenFalse word)) ∈ Complexity.FP
@[simp]
@[simp]
Select the first branch exactly when test is empty.
Equations
- BeyondBethe.machineIfEmpty test whenEmpty whenNonempty = Complexity.Cobham.selectHead (Complexity.Cobham.emptyFlag test) whenEmpty whenNonempty
Instances For
theorem
BeyondBethe.machineIfEmpty_mem_FP
{test whenEmpty whenNonempty : List Bool → List Bool}
(htest : test ∈ Complexity.FP)
(hempty : whenEmpty ∈ Complexity.FP)
(hnonempty : whenNonempty ∈ Complexity.FP)
:
(fun (word : List Bool) => machineIfEmpty (test word) (whenEmpty word) (whenNonempty word)) ∈ Complexity.FP
@[simp]
@[simp]
One-bit word equal to the head of word, defaulting to false on the
empty word.
Equations
Instances For
@[simp]
@[simp]