Deduplicated Output Scope Materialization (buildOutScope) #
Deduplicates a flattened bucket-scope buffer backwards (dedupFilterBack) skipping the eliminated
variable x, producing bucketOutScope x bucket in exact canonical order.
Main definitions #
Cslib.Algorithms.WordRAM.VariableElimination.buildOutScope: output-scope builderMemory.Prog.
Arguments (x, bucketPtr, bucketLen) for buildOutScope.
- x : ℕ
Field
xofBuildOutScopeArgs. - bucketPtr : ℕ
Field
bucketPtrofBuildOutScopeArgs. - bucketLen : ℕ
Field
bucketLenofBuildOutScopeArgs.
Instances For
Product equivalence encoding BuildOutScopeArgs as words.
Materialize the deduplicated output scope bucketOutScope x bucket.
theorem Cslib.Algorithms.WordRAM.VariableElimination.buildOutScope_spec {w : ℕ} {args : BuildOutScopeArgs} {bucket : List (Logic.PL.CSP.FactorTable ℕ ℕ)} {maxScope W_out : ℕ} {s : DataStructure.Memory.State} (hwf : DataStructure.Memory.WellFormed w s) (hb : HoldsFactorList args.bucketPtr bucket s) (hlen : bucket.length = args.bucketLen) (hmax : ∀ f ∈ bucket, f.scope.length ≤ maxScope) (hW : (Lean.CSP.bucketOutScope args.x bucket).length ≤ W_out) (hfit : WordRAM.Fits w (s.frontier + 2 * (args.bucketLen * maxScope))) :
have res := (DataStructure.Memory.spec 0).clientResult s (buildOutScope args);
have s' := (DataStructure.Memory.spec 0).clientState s (buildOutScope args);
have outScope := Lean.CSP.bucketOutScope args.x bucket;
(DataStructure.Memory.spec w).ValidHistory s ((DataStructure.Memory.spec w).clientHistory s (buildOutScope args)) ∧ s'.frontier ≤ s.frontier + 2 * (args.bucketLen * maxScope) ∧ WordRAM.Realization.PreservesBelow s.frontier s s' ∧ s.frontier ≤ res.1 ∧ res.2 = outScope.length ∧ WordRAM.Realization.HoldsIn res.1 outScope s' ∧ WordRAM.Realization.memoryCost (buildOutScope args) s ≤ 2 + args.bucketLen * (3 + 2 * maxScope + maxScope * (2 + W_out))
theorem Cslib.Algorithms.WordRAM.VariableElimination.buildOutScope_realizes :
WordRAM.Realization.Realizes WordRAM.Basis.exact buildOutScope WordRAM.Realization.WordEncoding.encode
WordRAM.Realization.WordEncoding.encode
(fun (w : ℕ) (args : BuildOutScopeArgs) (s : DataStructure.Memory.State) =>
WordRAM.Fits w 1 ∧ ∃ (bucket : List (Logic.PL.CSP.FactorTable ℕ ℕ)),
bucket.length = args.bucketLen ∧ HoldsFactorList args.bucketPtr bucket s ∧ WordRAM.Fits w (s.frontier + 2 * (List.flatMap Logic.PL.CSP.FactorTable.scope bucket).length))
fun (x : BuildOutScopeArgs) (x_1 : DataStructure.Memory.State) => 0