Add modules#5
Open
AmosNico wants to merge 4 commits into
Open
Conversation
AmosNico
marked this pull request as draft
May 15, 2026 12:57
Contributor
Author
|
I am struggling to port Sat.lean (and therefore also SatSolver.lean), to the module system. Adding lemma BDD_of_CNF_correct {n} {f : Fin n → Bool} (C : Std.Sat.CNF (Fin n)) :
Std.Sat.CNF.eval f C = (BDD_of_CNF C).denotation (n := n) (by simp) (Vector.ofFn f) := by
rcases C with ⟨⟨clauses⟩⟩
simp only [Std.Sat.CNF.eval, List.size_toArray, List.all_toArray', BDD_of_CNF, List.map_toArray,
List.length_map, List.foldr_toArray']
induction clauses with
| nil => simp only [List.all_nil, List.map_nil, List.foldr_nil, BDD.const_denotation,
Function.const_apply]
| cons head tail ih =>
simp only [List.all_cons, List.map_cons, List.foldr_cons, BDD.and_denotation]
rw [ih]
congr 1
induction head with
| nil => simp [BDD_of_clause]
| cons head tail ih =>
simp only [Std.Sat.CNF.Clause.eval_cons]
rw [ih]
simp only [BDD_of_clause, List.map_cons, List.foldr_cons, BDD.or_denotation]
congr 1
simp only [BDD_of_literal]
split
· simp only [beq_true, *, BDD.var_denotation] -- BDD.var_denotation seems to cause this
symm
apply Vector.getElem_ofFn
· simp only [beq_false, BDD.not_denotation, BDD.var_denotation, *, Bool.not_inj_iff]
symm
apply Vector.getElem_ofFn |
AmosNico
force-pushed
the
modules
branch
3 times, most recently
from
May 29, 2026 09:07
80500d0 to
05517ad
Compare
Contributor
Author
|
The issue mentioned above has been fixed in #4 , by adding an additional argument |
AmosNico
marked this pull request as ready for review
May 29, 2026 11:57
AmosNico
marked this pull request as draft
June 22, 2026 12:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add modules to the repository.
Lemmas and definitions are now private by default instead of public in most files (with the exception of Basic.lean, where I decided to make the section public, since most definitions are used in other files). I tried to keep the private/public settings the same as they were before, but it might make sense to make more of them private.
Currently BDD.lean publicly imports Bdd.Basic (via the public imports Bdd.Sim, Bdd.Lift and Bdd.Count), which is probably not wanted. The first two imports are needed for
instDecidableSimilar, the last one for the Fintype instance forVector, which is used in the lemmacount_eq_card. The imports forinstDecidableSimilarmight not be needed in the future, but I am not sure whether we can avoid them now. TheFintype-instance forVectorcould be moved to another file, which is then imported publicly (I think eventually this should be added to Mathlib, so I would place it in a separate file Upstream.lean/Preliminaries.lean, though it could probably also be placed in Nary).This pull request depends on #6.