Bug fix: Properly handling sort universe at smt level#42
Open
Bug fix: Properly handling sort universe at smt level#42
Conversation
Base automatically changed from
opaque-as-free-vars
to
assertions-for-global-lambda-undeclare-fun
December 4, 2025 19:51
Base automatically changed from
assertions-for-global-lambda-undeclare-fun
to
main
December 4, 2025 20:00
RSoulatIOHK
requested changes
Dec 5, 2025
Collaborator
There was a problem hiding this comment.
I don't have specific lines to point this to but I wrote a serie of tests and some of them are showing some difference between the Lean universe types, and the SMT encoding
variable (β : Type u)
theorem universe_given_fixed_test0 :
(∀ (x : β) (f : β → Nat), f x > 10) →
(∀ (α : Type u) (x : α) (f : α → Nat), f x > 10) := by
sorry
#solve [universe_given_fixed_test0]Caution
Blaster solves this. I don't think it should because the premise is about a particular β from Type u, not all "Type u"
As expected, using an axiom leads to the same result
axiom FixedType : Type u
theorem universe_given_fixed_test (FixedType : Type u) :
(∀ (x : FixedType) (f : FixedType → Nat), f x > 10) →
(∀ (α : Type u) (x : α) (f : α → Nat), f x > 10) := by
intro h a x f
sorry
#solve [universe_given_fixed_test]Caution
Same as before
Blaster reaches an error on this example:
theorem exists_must_match_forall :
∀ (α : Type u), (∃ (β : Type u), α = β) := by
intro α
exact ⟨α, rfl⟩
#solve [exists_must_match_forall]Caution
genExistsTerm: only one predicate qualifier premise expected but got []
And another error on this one
theorem doesBlasterFindsNat :
∃ (α : Type), α = Nat := by
exact ⟨Nat, rfl⟩
#solve [doesBlasterFindsNat]Caution
translateConst: unexpected inductive datatype Lean.Expr.const `Nat []
Which I think is unrelated to this PR, but I just mention it anyway
3ebe474 to
a78af92
Compare
a78af92 to
fbe4658
Compare
…at the smt level + generalize mvar instanitation at preprocessing phase
fbe4658 to
e16b587
Compare
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.
Bug fixing Smt translation of sort universe
Description
This PR addresses issue #43 and perform the following modifications:
Optimization:
normMVar. This function expects that eachmvarmust be assigned in the Lean4 environment whenoptimizeExpris invoked. Otherwise an error is triggerednormFVarhas been simplified to directly optimize any assigned value (if any). Indeed, anymvarin the assigned value will now be handled bynormMVar.normLevelhas been updated to only normalize any universe level meta variable present in a given Level.Smt Translation
typeUniversehas been removed from the Translation environmentsortCachehas been renamed totypeParamCacheto avoid any confusionindTypeInstCacheis used to cache type universe instances that have already been defined at the smt level instance.defineTypeSortis now generictypeSymbolandtypeSorthave been removedsortNamtToSmtSymbolhas been renamed totypeParamNameToSmtSymbolto avoid any confusiondeclareTypeSorthas been removeddefinedSortAndCachehas been renamed todefineTypeParamAndCacheto avoid any confusion and now also accepts anIndTypeDeclarationinstance as argument.generateSortInstDeclhas been updated to declare a unique type universe instance at the smt level for each unique sort instance considered as type universe.Blaster tactic
mvarinstantiation at the preprocessing phase.Test suite:
Issue31.leanhas been added to show that we are not wrongly unifying sorts with different universes at the smt level.Issue25.leanhas been updated to avoid wrong sort unificationIssue27.leanhas been updated to reflect current implementationCloses #32
Checklist