Documentation

CslibFrontier.Algorithms.WordRAM.VariableElimination

Bucket (variable) elimination on the Word-RAM #

This module implements bucket (variable) elimination (Cslib.Algorithms.Lean.CSP.eliminateOrder) over materialized radix-indexed factor tables (FactorTable ℕ ℕ) on the exact-basis Word-RAM (Cslib.WordRAM.Basis.exact). Basis.exact supplies unit-cost multiplication, division, and remainder for mixed-radix indexing and exact ℕ weight products while certifying non-underflowing subtraction and non-zero divisors in the machine semantics.

Every operation of the algorithm is genuinely executed and charged on word-addressed memory:

Using the amortized bucket-count invariant Cslib.Algorithms.Lean.CSP.sum_bucketFactors_le, the total Word-RAM instruction count along an arbitrary elimination order order is bounded exponentially only in the actual intermediate joint bucket width W = maxJointScopeLen domain order initState, with at most |factors| + |order| total factor evaluations across the entire run.

The implementation and proof are organized into focused submodules under CslibFrontier.Algorithms.WordRAM.VariableElimination:

Main definitions #

Main results #

theorem Cslib.Algorithms.WordRAM.VariableElimination.exists_program_variableElimination :
∃ (r : ℕ) (C : ℕ) (prog : WordRAM.Program WordRAM.Basis.exact r), prog.ComputesInTime (fun (x : ℕ) (inst : ElimInstance) => inst.encode) (fun (inst : ElimInstance) (x : ℕ) => C * (inst.stepBound + 1) + 1) (fun (inst : ElimInstance) (w : ℕ) => WordRAM.Fits w inst.wordBound) ElimInstance.result

One fixed exact-basis Word-RAM program computes bucket (variable) elimination ElimInstance.result in ≤ C * (inst.stepBound + 1) + 1 instructions for every word width w satisfying Fits w inst.wordBound and InputFits w inst.encode.

Uniform exact-basis Word-RAM computability certificate for ElimInstance.result.

theorem Cslib.Algorithms.WordRAM.VariableElimination.exists_program_csp_partitionFunctionOn :
∃ (r : ℕ) (C : ℕ) (prog : WordRAM.Program WordRAM.Basis.exact r), ∀ {Rel : Type u_1} {D : Type u_2} [inst : Fintype D] [inst_1 : Inhabited D] (d : ℕ) (e : D ≃ Fin d) (wt : Rel → List D → ℕ) (F : Logic.PL.CSP Rel ℕ) (declared order : List ℕ), F.vars.toFinset ⊆ declared.toFinset → declared.toFinset ⊆ order.toFinset → ∀ (w : ℕ), have inst_2 := ElimInstance.ofCSP d e wt F declared order; WordRAM.Fits w inst_2.wordBound → WordRAM.InputFits w inst_2.encode → ∃ (n : ℕ), WordRAM.Executes w prog (WordRAM.State.init inst_2.encode) (Logic.PL.CSP.partitionFunctionOn wt F declared.toFinset) n ∧ n ≤ C * (inst_2.stepBound + 1) + 1

One fixed exact-basis Word-RAM program computes the weighted CSP partition function F.partitionFunctionOn wt declared.toFinset by variable elimination along any supplied order order covering declared (whenever F.vars.toFinset ⊆ declared.toFinset), within C * ((ElimInstance.ofCSP d e wt F declared order).stepBound + 1) + 1 instructions.