Documentation

LeanPool.BeyondBethe.BeyondBethe.MachineFPBasics

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.

theorem BeyondBethe.machinePrepend_mem_FP (bit : Bool) :
(fun (word : List Bool) => bit :: word) ∈ Complexity.FP

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) :
(fun (word : List Bool) => g (f word)) ∈ Complexity.FP
theorem BeyondBethe.machinePair_mem_FP {left right : List Bool → List Bool} (hleft : left ∈ Complexity.FP) (hright : right ∈ Complexity.FP) :
(fun (word : List Bool) => Complexity.pair (left word) (right word)) ∈ Complexity.FP
theorem BeyondBethe.machineAppend_mem_FP {left right : List Bool → List Bool} (hleft : left ∈ Complexity.FP) (hright : right ∈ Complexity.FP) :
(fun (word : List Bool) => left word ++ right word) ∈ Complexity.FP
theorem BeyondBethe.machineTake_mem_FP {ruler data : List Bool → List Bool} (hruler : ruler ∈ Complexity.FP) (hdata : data ∈ Complexity.FP) :
(fun (word : List Bool) => List.take (ruler word).length (data word)) ∈ Complexity.FP

Take a prefix of one computed word whose length is another computed word.

def BeyondBethe.machineIfHead (flag whenTrue whenFalse : List Bool) :

Select by the leading bit of a verified bitstring computation.

Equations
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]
    theorem BeyondBethe.machineIfHead_true (tail whenTrue whenFalse : List Bool) :
    machineIfHead (true :: tail) whenTrue whenFalse = whenTrue
    @[simp]
    theorem BeyondBethe.machineIfHead_false (tail whenTrue whenFalse : List Bool) :
    machineIfHead (false :: tail) whenTrue whenFalse = whenFalse
    def BeyondBethe.machineIfEmpty (test whenEmpty whenNonempty : List Bool) :

    Select the first branch exactly when test is empty.

    Equations
    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]
      theorem BeyondBethe.machineIfEmpty_nil (whenEmpty whenNonempty : List Bool) :
      machineIfEmpty [] whenEmpty whenNonempty = whenEmpty
      @[simp]
      theorem BeyondBethe.machineIfEmpty_cons (bit : Bool) (tail whenEmpty whenNonempty : List Bool) :
      machineIfEmpty (bit :: tail) whenEmpty whenNonempty = whenNonempty

      One-bit word equal to the head of word, defaulting to false on the empty word.

      Equations
      Instances For
        @[simp]
        theorem BeyondBethe.machineHeadBit_cons (bit : Bool) (tail : List Bool) :
        machineHeadBit (bit :: tail) = [bit]