Documentation

CslibFrontier.Algorithms.WordRAM.DPLL.Refutation

The DPLL solver on the word RAM writing its search tree #

This file gives a variant of the word-RAM DPLL solver (Cslib.Algorithms.WordRAM.DPLL.program) that also writes the tree its search explores (Cslib.Algorithms.WordRAM.DPLL.programLog), and uses it to transfer the lower bound of Beyersdorff, Galesi and Lauria [BeyersdorffGalesiLauria2010, Theorem 2] on tree-like refutations of the pigeonhole formulas to a lower bound on instructions.

The output #

The variant runs the same steps of the search with an explicit trail (Cslib.Algorithms.Lean.DPLL.Trail.run), and logs one word at each node of the tree it explores (Cslib.Algorithms.Lean.DPLL.searchTree), in preorder (Cslib.Algorithms.WordRAM.DPLL.treeWords):

The words thus tell leaves from branchings, name the clause at each leaf and the variable and the first branch at each branching, and so determine the tree: reading them back (Cslib.Algorithms.WordRAM.DPLL.decodeTree) gives the tree (Cslib.Algorithms.WordRAM.DPLL.decodeTree_treeWords). On an unsatisfiable formula this tree finds a falsified clause on every assignment (Cslib.Algorithms.Lean.DPLL.findsFalsifiedClause_searchTree), and so is a tree-like resolution refutation in decision-tree form (Cslib.DecisionTree.FindsFalsifiedClause.exists_derivation). The output (Cslib.Algorithms.WordRAM.DPLL.refutationWords) is that of the solver, [0] or 1 followed by the model, followed for an unsatisfiable formula by these words. The log grows from T + 4 N + 2, after the trail; the register lg points past it.

The lower bound #

Every word of the tree is at least 2, and is written to a cell above the input, which starts at 0; so each costs a store (Cslib.WordRAM.Runs.block_lowerBound), and every halting run takes at least as many instructions as the tree has leaves (Cslib.Algorithms.WordRAM.DPLL.leafCount_searchTree_le_of_executes). On PHP^m_n, m > n, with its variables numbered by an injective map, the tree has at least (n / 2 + 1) ^ (n / 2) leaves (Cslib.Algorithms.Lean.DPLL.pow_half_le_leafCount_searchTree_pigeonhole), and so the variant takes at least (n / 2 + 1) ^ (n / 2) instructions (Cslib.Algorithms.WordRAM.DPLL.programLog_pigeonhole).

Writing the tree costs a pass over the clauses at each leaf, to find the falsified clause, and a few instructions at each node, so the variant halts within 2 ^ (d + 1) (60 E + 78) + 10 N + 15 instructions, d the number of distinct variables and E the length of the input (Cslib.Algorithms.WordRAM.DPLL.programLog_spec), and within 301 · 2 ^ N · E (Cslib.Algorithms.WordRAM.DPLL.programLog_spec_pow). The word size must fit the addresses of the log, up to E + 5 N + 3 + 2 ^ (d + 1).

Main definitions #

Main results #

References #

The program #

One clause of the search for a falsified clause: the literal loop counts the literals of the clause at ptr not falsified; with none, the search stops at it, and otherwise moves on.

The search for the first falsified clause from ptr.

Log the address of the first falsified clause.

Log the cell of the literal on top of the trail in the literal array.

Set the length of the output [0, …] to cover the log.

One step of the search, logged: the step of Cslib.Algorithms.WordRAM.DPLL.stepBody, logging the first falsified clause before backtracking and the pushed literal after branching.

The logged search: logged steps while go = 1.

The DPLL solver writing its search tree on the input encode N φ, leaving the address of its output in out.

The DPLL solver writing its search tree as a flat program returning its output list.

The log #

The address in the input encode N φ of the clause i of φ: its length word.

The words logged at the partial assignment π: at a falsified clause, the address of the first falsified clause; at a branching on l, the address T + 2 v + b of the cell of l = (v, b) in the literal array, where T is the end of the clauses.

The words of the search tree: the words of its nodes in preorder, the address of a falsified clause at each leaf and the literal array cell of the first branch at each branching.

The output of the variant: the output of the solver, [0] or the model, followed for an unsatisfiable formula by the words of the search tree.

The output for an answer of the search and the log: the model, or 0 followed by the log.

The log log is stored from T + 4 N + 2, and lg points past it.

theorem Cslib.Algorithms.WordRAM.DPLL.MemAt.update_ge {φ : Logic.PL.CNF ℕ} {N T : ℕ} {mem : ℕ → ℕ} {t : Lean.DPLL.Trail} (h : MemAt φ N T mem t) {a : ℕ} (ha : T + 4 * N ≤ a) (v : ℕ) :
MemAt φ N T (Function.update mem a v) t

A store at or above T + 4 N keeps the memory of a trail.

Reading the tree back #

The clause whose length word is at the address a of the input, for the clauses of φ from address 2; the empty clause if there is none.

Reading the words of a tree of the clauses φ: a word below the end T = 2 + (φ.flatMap encodeClause).length of the clauses is a leaf with the clause at that address; a word T + 2 v + b is a branching on v, its first branch (v, b) followed by its second branch. With k words to read at most, the tree and the words after it.

theorem Cslib.Algorithms.WordRAM.DPLL.decodeTree_preorder (φ : Logic.PL.CNF ℕ) (fuel : ℕ) (π : List (Logic.PL.Literal ℕ)) :
(Lean.DPLL.openVars φ π).length ≤ fuel → Lean.DPLL.dfs φ fuel π = none → ∀ (k : ℕ), (Lean.DPLL.preorder φ (logOut φ) fuel π).length ≤ k → ∀ (rest : List ℕ), decodeTree φ k (Lean.DPLL.preorder φ (logOut φ) fuel π ++ rest) = some (Lean.DPLL.searchTree φ fuel π, rest)

The words of a subtree read back to it, when it has no model.

The output determines a tree-like refutation: on an unsatisfiable formula, the words of the search tree read back to a decision tree that finds a falsified clause of φ on every assignment, which is a tree-like resolution refutation of φ (Cslib.DecisionTree.FindsFalsifiedClause.exists_derivation).

Finding the falsified clause #

The search for a falsified clause among the clauses ψ from ptr, one of which π falsifies, stops at the address of the first of them, and leaves memory unchanged.

theorem Cslib.Algorithms.WordRAM.DPLL.logConflict_spec {w : ℕ} (φ : Logic.PL.CNF ℕ) (N T : ℕ) (t : Lean.DPLL.Trail) (log : List ℕ) (x : WordRAM.Data 32) (hs : StateAt φ N T x t) (hl : LogAt N T x log) (hc : Lean.DPLL.status φ t.lits = Lean.DPLL.Status.conflict) (hfit : WordRAM.Fits w (T + 5 * N + 3 + log.length)) :

Logging a falsified clause: the address of the first clause falsified by the trail.

theorem Cslib.Algorithms.WordRAM.DPLL.logBranch_spec {w : ℕ} (φ : Logic.PL.CNF ℕ) (N T : ℕ) (l : Logic.PL.Literal ℕ) (t : Lean.DPLL.Trail) (log : List ℕ) (x : WordRAM.Data 32) (hs : StateAt φ N T x ({ lit := l, isSecond := false } :: t)) (hl : LogAt N T x log) (hfit : WordRAM.Fits w (T + 5 * N + 3 + log.length)) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w logBranch x y 5 ∧ StateAt φ N T y ({ lit := l, isSecond := false } :: t) ∧ LogAt N T y (log ++ [T + ClauseCode.litCode l])

Logging a branching: the cell of the literal on top of the trail.

The instructions of one logged step: those of Cslib.Algorithms.WordRAM.DPLL.stepTime, a search for the falsified clause, and the log.

theorem Cslib.Algorithms.WordRAM.DPLL.stepBodyLog_spec {w : ℕ} (φ : Logic.PL.CNF ℕ) (N T : ℕ) (t : Lean.DPLL.Trail) (log : List ℕ) (x : WordRAM.Data 32) (hs : StateAt φ N T x t) (hl : LogAt N T x log) (hfit : WordRAM.Fits w (T + 5 * N + 3 + log.length)) :
∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w stepBodyLog x y (stepTimeLog φ N t) ∧ match Lean.DPLL.Trail.step φ t with | Sum.inr t' => StateAt φ N T y t' ∧ LogAt N T y (log ++ logOut φ t.lits) | Sum.inl a => y.regs Reg.go = 0 ∧ y.regs Reg.out = T + 4 * N ∧ WordRAM.outputList y.mem (T + 4 * N) = answerLog N a (log ++ logOut φ t.lits)

One logged step of the search: the state and the log of the next trail, or the output of the answer and the log at T + 4 N.

theorem Cslib.Algorithms.WordRAM.DPLL.mainLoopLog_spec {w : ℕ} (φ : Logic.PL.CNF ℕ) (N T k : ℕ) (t : Lean.DPLL.Trail) (log : List ℕ) (x : WordRAM.Data 32) (a : Lean.DPLL.Trail.Answer) :
StateAt φ N T x t → LogAt N T x log → WordRAM.Fits w (T + 5 * N + 3 + log.length + k) → Lean.DPLL.Trail.run φ k t = some a → ∃ (y : WordRAM.Data 32), WordRAM.ExecWithin w mainLoopLog x y (k * (60 * (List.flatMap ClauseCode.encodeClause φ).length + 78) + 10 * N + 2) ∧ y.regs Reg.out = T + 4 * N ∧ WordRAM.outputList y.mem (T + 4 * N) = answerLog N a (log ++ Lean.DPLL.Trail.runLog φ (logOut φ) k t)

The logged main loop runs the search: from the state of the trail t and the log log, if the run of k steps from t ends with the answer a, the loop writes at T + 4 N the output of a and of the log extended by the words of the run.

theorem Cslib.Algorithms.WordRAM.DPLL.solverLog_spec {w : ℕ} (N : ℕ) (φ : Logic.PL.CNF ℕ) (hN : ∀ c ∈ φ, ∀ l ∈ c, l.1 < N) (hfit : WordRAM.Fits w ((encode N φ).length + 5 * N + 3 + 2 ^ (Lean.DPLL.depth φ + 1))) :

The variant on the word RAM ends with the output refutationWords N φ at the address in out.

The program #

theorem Cslib.Algorithms.WordRAM.DPLL.programLog_spec (N : ℕ) (φ : Logic.PL.CNF ℕ) (hN : ∀ c ∈ φ, ∀ l ∈ c, l.1 < N) {w : ℕ} (hfit : WordRAM.Fits w ((encode N φ).length + 5 * N + 3 + 2 ^ (Lean.DPLL.depth φ + 1))) :
∃ n ≤ 2 ^ (Lean.DPLL.depth φ + 1) * (60 * (encode N φ).length + 78) + 10 * N + 15, WordRAM.ExecutesList w programLog (WordRAM.State.init (encode N φ)) (refutationWords N φ) n

The DPLL solver writing its search tree, on the word RAM. At any word size w that fits E + 5 N + 3 + 2 ^ (d + 1), the program run on the input encode N φ of length E, where every variable of φ is below N and d = Cslib.Algorithms.Lean.DPLL.depth φ is the number of distinct variables of φ, returns refutationWords N φ: the output of Cslib.Algorithms.Lean.DPLL.solve as in Cslib.Algorithms.WordRAM.DPLL.program_spec, followed for an unsatisfiable formula by the words of the search tree. It halts within 2 ^ (d + 1) (60 E + 78) + 10 N + 15 instructions, the final halt included.

theorem Cslib.Algorithms.WordRAM.DPLL.leafCount_searchTree_le_of_executes (N : ℕ) (φ : Logic.PL.CNF ℕ) (hN : ∀ c ∈ φ, ∀ l ∈ c, l.1 < N) (hφ : ¬φ.Satisfiable) {w : ℕ} (hfit : WordRAM.Fits w ((encode N φ).length + 5 * N + 3 + 2 ^ (Lean.DPLL.depth φ + 1))) {v n : ℕ} (h : WordRAM.Executes w programLog (WordRAM.State.init (encode N φ)) v n) :

The variant takes an instruction per leaf of the search tree: on an unsatisfiable formula, every halting run of the program on encode N φ takes at least as many instructions as the tree explored by the search has leaves. Each leaf and each branching of the tree is a word of the output, written to a cell above the input, which starts at 0; each such cell costs a store (Cslib.WordRAM.Runs.block_lowerBound).

theorem Cslib.Algorithms.WordRAM.DPLL.programLog_spec_pow (N : ℕ) (φ : Logic.PL.CNF ℕ) (hN : ∀ c ∈ φ, ∀ l ∈ c, l.1 < N) {w : ℕ} (hfit : WordRAM.Fits w ((encode N φ).length + 5 * N + 3 + 2 ^ (N + 1))) :

The running time in the form c · 2 ^ N · E: the variant halts within 301 · 2 ^ N · E instructions on the input encode N φ of length E.

The variant takes 2 ^ Ω(n log n) instructions on the pigeonhole formulas. For m > n, an injective map f numbering the variables of PHP^m_n below N, and a word size w that fits E + 5 N + 3 + 2 ^ (N + 1), where E is the length of the input encode N φ of the renamed formula φ, the variant returns refutationWords N φ, 0 followed by the words of its search tree, within 301 · 2 ^ N · E instructions, and every halting run of it on that input takes at least (n / 2 + 1) ^ (n / 2) instructions. The lower bound is that of [BeyersdorffGalesiLauria2010, Theorem 2] on the leaves of every tree-like refutation of PHP^m_n: the search tree is one with at most as many leaves, and each of its leaves costs a store (Cslib.Algorithms.WordRAM.DPLL.leafCount_searchTree_le_of_executes).