The positive CNF game
Lax689614.PositiveCNF · concepts/Lax689614/PositiveCNF.lean · lax-689614
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A positive CNF formula is a list of clauses, each a set of variables. True and False alternately choose an unassigned variable, assigning it their own truth value. True starts and wins exactly when each clause contains a variable assigned true. Empty clauses and unused variables are allowed. At an intermediate position, is the set of unassigned variables and the set already assigned true.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Data.Finset.Card |
| 2 | import Mathlib.Data.Fintype.Basic |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: The positive CNF game |
| 7 | type: definition |
| 8 | --- |
| 9 | A positive CNF formula is a list of clauses, each a set of variables. |
| 10 | True and False alternately choose an unassigned variable, assigning it |
| 11 | their own truth value. True starts and wins exactly when each clause |
| 12 | contains a variable assigned true. Empty clauses and unused variables are |
| 13 | allowed. At an intermediate position, `U` is the set of unassigned |
| 14 | variables and `T` the set already assigned true. |
| 15 | -/ |
| 16 | |
| 17 | namespace Lax689614.PositiveCNF |
| 18 | |
| 19 | structure Formula where |
| 20 | nvars : ℕ |
| 21 | clauses : List (Finset (Fin nvars)) |
| 22 | |
| 23 | def Satisfied (φ : Formula) (T : Finset (Fin φ.nvars)) : Prop := |
| 24 | ∀ C ∈ φ.clauses, ∃ x ∈ C, x ∈ T |
| 25 | |
| 26 | /-- Whether True can force satisfaction from the specified position and turn. -/ |
| 27 | def TrueWins (φ : Formula) (U T : Finset (Fin φ.nvars)) (trueTurn : Bool) : Prop := |
| 28 | if U = ∅ then Satisfied φ T |
| 29 | else if trueTurn then |
| 30 | ∃ x : U, TrueWins φ (U.erase x.val) (insert x.val T) false |
| 31 | else |
| 32 | ∀ x : U, TrueWins φ (U.erase x.val) T true |
| 33 | termination_by U.card |
| 34 | decreasing_by all_goals exact Finset.card_erase_lt_of_mem x.property |
| 35 | |
| 36 | def FirstWins (φ : Formula) : Prop := TrueWins φ Finset.univ ∅ true |
| 37 | |
| 38 | end Lax689614.PositiveCNF |
| 39 |
Builds on
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments