Gate clauses
Lax429075.Tseitin · concepts/Lax429075/Tseitin.lean · lax-429075
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
The Tseitin encoding assigns one variable to each gate. At most three clauses enforce a gate's truth table, and a unit clause requires a true output. Input gates have no constraints.
Concept map
In the paper
- page 2 of this submission's paper
Lean source view on GitHub
| 1 | import Lax429075.Circuits |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Gate clauses |
| 6 | type: definition |
| 7 | --- |
| 8 | The Tseitin encoding assigns one variable to each gate. At most three |
| 9 | clauses enforce a gate's truth table, and a unit clause requires a true |
| 10 | output. Input gates have no constraints. |
| 11 | -/ |
| 12 | |
| 13 | namespace Lax429075.Tseitin |
| 14 | |
| 15 | open CNF Circuits |
| 16 | |
| 17 | def positive (i : ℕ) : Literal := ⟨i, true⟩ |
| 18 | def negative (i : ℕ) : Literal := ⟨i, false⟩ |
| 19 | |
| 20 | def gateClauses (i : ℕ) : Gate → Formula |
| 21 | | .input => [] |
| 22 | | .constant b => [[⟨i, b⟩]] |
| 23 | | .neg a => [[positive i, positive a], [negative i, negative a]] |
| 24 | | .conj a b => [[negative i, positive a], [negative i, positive b], |
| 25 | [positive i, negative a, negative b]] |
| 26 | | .disj a b => [[positive i, negative a], [positive i, negative b], |
| 27 | [negative i, positive a, positive b]] |
| 28 | |
| 29 | def encode (C : Circuit) : Formula := |
| 30 | [[positive C.output]] ++ C.gates.zipIdx.flatMap (fun gi => gateClauses gi.2 gi.1) |
| 31 | |
| 32 | end Lax429075.Tseitin |
| 33 |
Builds on
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments