Writing out a table #
Every stage of an algorithmic reduction writes a list: the edges of a graph, the
entries of a rotation table, the records of a gadget. The list encoder
listEncFn of Complexitylib.Classes.P.Range writes it from a polynomial-time
rule for its entries, with no bound on the loop to supply; this module names that
fact the way the reductions use it, and adds the unary comparisons they branch
on. The counting and searching loops that used to live here (countOver,
findFirst and their lemmas) moved to Complexitylib.Classes.P.Range under the
same names.
Main results #
Complexity.materialize_mem_FP— a record rule makes the list encoder polynomial timeComplexity.materialize_eq— and it writes the list it is meant toComplexity.ifEqLen,Complexity.ifLtLen— comparing two unary numbers, and branching on the answer
theorem
Complexity.materialize_eq
{α : Type}
[DataEncode α]
{E : List Bool → List Bool}
(l : List α)
(x : List Bool)
(h : ∀ (i : ℕ) (hi : i < l.length), E (pair x (List.replicate i true)) = DataEncode.bitstringEncode l[i])
:
The list encoder writes the list.
Comparing #
x when the two strings have the same length, y otherwise.
Equations
- Complexity.ifEqLen a b x y = Complexity.Cobham.selectHead (Complexity.Cobham.emptyFlag (List.drop a.length b ++ List.drop b.length a)) x y
Instances For
x when the first string is shorter than the second, y otherwise.
Equations
- Complexity.ifLtLen a b x y = Complexity.Cobham.selectHead (Complexity.Cobham.emptyFlag (List.drop a.length b)) y x