Documentation

CslibFrontier.Computability.MCSP.PartialHardness.Evaluator

Evaluating the CMMSA partial truth table from explicit tables #

FromCMMSA.entry f x reads its input x as a bit string and the functions f v of the variables as Boolean functions. This module computes the same entries from explicit data: the input is a number x < 2 ^ L, and the function of variable v is a list T[v] of its values in the order of BitString.equivFin. The definitions use only Nat.testBit, division and remainder by powers of two, List.getD and folds, so a polynomial-time proof can follow them directly.

The input fields are read arithmetically. The formula index is x mod 2 ^ indexWidth (formulaIndex_equivFin_symm). The slot (t, q) starts at bit slotOffset I Δ k lam t q = indexWidth + slotWidth · (q + Δ t), its k seeds of W bits come first, then its mask bit. A variable v evaluates a seed z at entry z mod 2 ^ ℓ v of T[v], reading false past the end of T[v].

Correctness is local. termParityN T x t equals termParity f x t as soon as T[v] is the table of f v for the variables v of term t alone (termParityN_eq), so a caller can evaluate a term from the tables of only some variables. With every table present (IsVarTable for all v), the entries agree (entryN_eq), and tables f, the list of all tables, gives the whole table of toInstance (tableN_tables).

The evaluator definitions are exposed because their polynomial-time proofs, in a separate module, follow their bodies.

Main definitions #

Main results #

References #

The evaluator #

The position of the first bit of slot (t, q): indexWidth + slotWidth · (q + Δ t).

The bit of slot (t, q) at a numeric input x, computed from the tables T: the mask bit of the slot plus, over its k seeds z, entry z mod 2 ^ ℓ v of T[v] for the variable v of its literal.

The parity of term t at a numeric input x: the sum of the bits of its occupied slots.

The entry at a numeric input x: b when the formula index j is below m and every term of φ_j has parity b; otherwise undefined.

The whole table: the entries at x = 0, …, 2 ^ L - 1.

T[v] is the table of f v in the order of BitString.equivFin, and reads false at 0 when v is not a variable.

The table of f v in the order of BitString.equivFin; empty when v is not a variable.

The tables of all variables.

Reading the input fields #

The formula index of the input numbered x is x mod 2 ^ indexWidth.

Correctness #

theorem Cslib.PartialMCSP.FromCMMSA.slotBitN_eq {I : Complexity.CMMSAInstance} {Δ k lam : ℕ} {f : VarFunctions I lam} {T : List (List Bool)} (x : Fin (2 ^ inputLength I Δ k lam)) (t q : Fin Δ) (hT : IsVarTable I lam f T (var I (↑x % 2 ^ indexWidth I) ↑t ↑q)) :
slotBitN I Δ k lam T ↑x ↑t ↑q = slotBit f ((BitString.equivFin (inputLength I Δ k lam)).symm x) t q

Local correctness of a slot. If T[v] is the table of f v for the variable v of slot (t, q), then slotBitN computes the slot bit.

theorem Cslib.PartialMCSP.FromCMMSA.termParityN_eq {I : Complexity.CMMSAInstance} {Δ k lam : ℕ} {f : VarFunctions I lam} {T : List (List Bool)} (x : Fin (2 ^ inputLength I Δ k lam)) (t : Fin Δ) (hT : ∀ (q : Fin Δ), ↑q < List.length (term I (↑x % 2 ^ indexWidth I) ↑t) → IsVarTable I lam f T (var I (↑x % 2 ^ indexWidth I) ↑t ↑q)) :
termParityN I Δ k lam T ↑x ↑t = termParity f ((BitString.equivFin (inputLength I Δ k lam)).symm x) t

Local correctness of a term. If T[v] is the table of f v for every variable v of term t of the indexed formula, then termParityN computes the parity of term t.

theorem Cslib.PartialMCSP.FromCMMSA.entryN_eq {I : Complexity.CMMSAInstance} {Δ k lam : ℕ} {f : VarFunctions I lam} {T : List (List Bool)} (hT : ∀ (v : ℕ), IsVarTable I lam f T v) (x : Fin (2 ^ inputLength I Δ k lam)) :
entryN I Δ k lam T ↑x = entry f ((BitString.equivFin (inputLength I Δ k lam)).symm x)

Correctness of an entry. With the table of every variable, entryN is entry.

theorem Cslib.PartialMCSP.FromCMMSA.tableN_eq_ofFn {I : Complexity.CMMSAInstance} {Δ k lam : ℕ} {f : VarFunctions I lam} {T : List (List Bool)} (hT : ∀ (v : ℕ), IsVarTable I lam f T v) (P : ℕ) :
tableN I Δ k lam T = List.ofFn (toInstance I Δ k lam P f).table

With every table, tableN lists the table of toInstance I Δ k lam P f.

The tables of all variables, as a list, at a number v.

theorem Cslib.PartialMCSP.FromCMMSA.IsVarTable.of_getD_eq {I : Complexity.CMMSAInstance} {lam : ℕ} {f : VarFunctions I lam} {T : List (List Bool)} {v : ℕ} (h : T.getD v [] = varTable f v) :
IsVarTable I lam f T v

A list of tables that agrees with tables f at v has the table of f v.

tables f has the table of every variable.

theorem Cslib.PartialMCSP.FromCMMSA.tableN_tables {I : Complexity.CMMSAInstance} {Δ k lam : ℕ} (f : VarFunctions I lam) (P : ℕ) :
tableN I Δ k lam (tables f) = List.ofFn (toInstance I Δ k lam P f).table

The table of toInstance from explicit tables.