Resolution
Resolution is a proof system with a single rule, working on clauses. It is the form in which the solver hands over its evidence: when it says a formula is valid, it gives a resolution refutation that a few lines of code can check.
The rule
A clause is a disjunction of literals. If one clause contains and another contains , then whichever way goes, one of the remaining parts must be true:
The clause below the line is the resolvent on . Resolving against leaves the empty clause , which nothing satisfies. A list of clauses is unsatisfiable exactly when can be reached from it by resolution: such a derivation is a refutation.
import { clause, resolve, showClause } from "@ratmath/logic";
showClause(resolve(clause("p, q"), clause("~p, r"), "p")); // "q ∨ r"
Proofs from the solver
To show that premises entail a conclusion, refute the premises together with the negated conclusion. entails and valid do this and return the refutation.
import { entails } from "@ratmath/logic";
const result = entails("p -> q, q -> r", "p -> r");
result.status; // "valid"
String(result.refutation);
// 1. p premise
// 2. ¬p ∨ q premise
// 3. ¬q ∨ r premise
// 4. ¬r premise
// 5. ¬q resolve 4, 3 on r
// 6. ¬p resolve 5, 2 on q
// 7. □ resolve 6, 1 on p
result.refutation.check(); // { ok: true, refutation: true, errors: [] }
The premises of the refutation are the clauses of . For a large formula the clauses come from the Tseitin form, and the refutation records the definitions it used in definitions.
The solver is a DPLL search: it sets a variable, simplifies, and backs out when a clause becomes false. Each time it backs out it has, in effect, resolved two clauses, and the refutation is the record of those steps. The search is the complicated part and the check is the simple part, so a mistake in the search cannot produce a wrong "valid".
Checking a refutation written by hand
import { checkResolution } from "@ratmath/logic";
const text = `
1. {p, q} premise
2. {~p, q} premise
3. {~q} premise
4. {q} resolve 1, 2 on p
5. {} resolve 4, 3 on q`;
checkResolution(text); // { ok: true, refutation: true, errors: [] }
checkResolution(text.replace("on p", "on q")).errors[0].message;
// "line 4: lines 1 and 2 do not clash on q: one must contain q and the other ¬q"
Clauses may be written with braces and commas or as disjunctions. Pass { premises } to require that every premise line is one of the clauses you were given. refutation is true when the proof is correct and reaches the empty clause.
Reference
| Export | What it does |
|---|---|
clause(text or literals), literal(text) | A clause as a sorted list of literals such as "p" and "¬q". |
resolve(c1, c2, atom) | The resolvent on that atom; refuses if the clauses do not clash on it. |
showClause(c) | "p ∨ ¬q", or "□" for the empty clause. |
ResolutionProof | steps of { n, clause, from, pivot }, premises, definitions, method, check(), toString(). |
parseResolution(text), checkResolution(proof, { premises }) | Read and check a refutation: { ok, refutation, errors }. |
satisfiableClauses(clauses, { budget }) | The solver on clauses directly: a model or a refutation. |
@ratmath/logic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.