Documentation

CslibFrontier.Algorithms.WordRAM.LRAT.Propagate

An LRAT checker on the word RAM: unit propagation along hints #

This file proves that the propagation loop of the word-RAM LRAT checker (Cslib.Algorithms.WordRAM.LRAT.propagate) computes Cslib.Logic.PL.CNF.propagateHints.

The database of numbered clauses is represented by a table (TableAt): the cell T + 2 i holds the address of the encoding of the clause numbered i, found by List.find? as propagateHints finds it, or 0. The trail is represented by stamps (TrailAt): the cell T + 2 c + 1 of the literal with code c holds the current stamp exactly when the literal is on the trail, and never more than the stamp.

Main definitions #

Main results #

The memory representation #

@[reducible, inline]

The cell of the table for clause number i.

@[reducible, inline]

The cell of the assignment for the literal with code c.

The table at base T represents the database db: the cell of a clause number holds 0 when db has no clause of that number, and otherwise the address, below T, of the encoding of the first such clause.

The assignment at base T represents the trail trail with stamp s: the cell of a literal holds s exactly when the literal is on the trail, and never more than s.

Memory mem' differs from mem only in assignment cells.

theorem Cslib.Algorithms.WordRAM.LRAT.OnlyAsg.trans {T : ℕ} {m₁ m₂ m₃ : ℕ → ℕ} (h₁ : OnlyAsg T m₁ m₂) (h₂ : OnlyAsg T m₂ m₃) :
OnlyAsg T m₁ m₃
theorem Cslib.Algorithms.WordRAM.LRAT.OnlyAsg.eq_of_lt {T : ℕ} {mem mem' : ℕ → ℕ} (h : OnlyAsg T mem mem') {a : ℕ} (ha : a < T) :
mem' a = mem a
theorem Cslib.Algorithms.WordRAM.LRAT.OnlyAsg.tcell_eq {T : ℕ} {mem mem' : ℕ → ℕ} (h : OnlyAsg T mem mem') (i : ℕ) :
mem' (tcell T i) = mem (tcell T i)
theorem Cslib.Algorithms.WordRAM.LRAT.TableAt.of_onlyAsg {mem mem' : ℕ → ℕ} {T : ℕ} {db : List (ℕ × Logic.PL.Clause ℕ)} (h : TableAt mem T db) (hm : OnlyAsg T mem mem') :
TableAt mem' T db

The table survives changes to the assignment.

theorem Cslib.Algorithms.WordRAM.LRAT.TrailAt.update {mem : ℕ → ℕ} {T s : ℕ} {trail : List (Logic.PL.Literal ℕ)} (h : TrailAt mem T s trail) (l : Logic.PL.Literal ℕ) :
TrailAt (Function.update mem (acell T (ClauseCode.litCode l)) s) T s (l :: trail)

Assigning a literal the stamp puts it on the trail.

Work #

The length of the clause the hint h names in db, or 0.

The total length of the clauses the hints name.

Scanning a hinted clause #

Scanning a clause at cl leaves in has, unit and bad the abstract state of its literals that F does not mark, and leaves memory unchanged.

@[reducible, inline]

The trail marks of a trail: F l says that the complement of l is on the trail.

theorem Cslib.Algorithms.WordRAM.LRAT.hintLoop_spec {w : ℕ} (db : List (ℕ × Logic.PL.Clause ℕ)) (hints : List ℕ) (trail : List (Logic.PL.Literal ℕ)) (x : WordRAM.Data 28) (M T s : ℕ) (hzero : x.regs Reg.zero = 0) (hone : x.regs Reg.one = 1) (hT : x.regs Reg.tbase = T) (hst : x.regs Reg.stamp = s) (hres : x.regs Reg.res = 0) (hl : WordRAM.Block.HoldsList (x.regs Reg.ptr) hints x.mem) (hhe : x.regs Reg.hend = x.regs Reg.ptr + hints.length) (hhT : x.regs Reg.hend ≤ T) (htab : TableAt x.mem T db) (htr : TrailAt x.mem T s trail) (hhM : ∀ h ∈ hints, h ≤ M) (hdbM : ∀ e ∈ db, ∀ l ∈ e.2, ClauseCode.litCode l + 1 ≤ M) (hw : WordRAM.Fits w (T + 2 * M + 2)) :

The hint loop computes propagateHints db trail hints for the hints in [ptr, hend), changing only assignment cells, and leaves ptr at hend.

theorem Cslib.Algorithms.WordRAM.LRAT.propagate_spec {w : ℕ} (db : List (ℕ × Logic.PL.Clause ℕ)) (hints : List ℕ) (trail : List (Logic.PL.Literal ℕ)) (x : WordRAM.Data 28) (M T s : ℕ) (hzero : x.regs Reg.zero = 0) (hone : x.regs Reg.one = 1) (hT : x.regs Reg.tbase = T) (hst : x.regs Reg.stamp = s) (hl : WordRAM.Block.HoldsList (x.regs Reg.ptr) (encodeNums hints) x.mem) (hpT : x.regs Reg.ptr + 1 + hints.length ≤ T) (htab : TableAt x.mem T db) (htr : TrailAt x.mem T s trail) (hhM : ∀ h ∈ hints, h ≤ M) (hdbM : ∀ e ∈ db, ∀ l ∈ e.2, ClauseCode.litCode l + 1 ≤ M) (hw : WordRAM.Fits w (T + 2 * M + 2)) :
∃ (y : WordRAM.Data 28), WordRAM.ExecWithin w propagate x y (40 * hints.length + 20 * hintsWork db hints + 6) ∧ y.regs Reg.res = (Logic.PL.CNF.propagateHints db trail hints).toNat ∧ y.regs Reg.ptr = x.regs Reg.ptr + 1 + hints.length ∧ OnlyAsg T x.mem y.mem ∧ (∃ (trail' : List (Logic.PL.Literal ℕ)), TrailAt y.mem T s trail') ∧ y.regs Reg.zero = 0 ∧ y.regs Reg.one = 1 ∧ y.regs Reg.tbase = T ∧ y.regs Reg.stamp = s

Unit propagation along hints: from the hints encodeNums hints at ptr, propagate leaves propagateHints db trail hints in res and ptr past the hints, changing only assignment cells.