Fix: enable bool(x) == y equality resolution#951
Draft
keyboardDrummer-bot wants to merge 1 commit intomainfrom
Draft
Fix: enable bool(x) == y equality resolution#951keyboardDrummer-bot wants to merge 1 commit intomainfrom
bool(x) == y equality resolution#951keyboardDrummer-bot wants to merge 1 commit intomainfrom
Conversation
This was referenced Apr 16, 2026
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.
Summary
Fixes #945 — the analyzer could not resolve
bool(x) == yequality assertions because Python'sbool()builtin was not mapped to any Laurel function.Changes
1.
PythonRuntimeLaurelPart.leanfloattoAny_to_bool— the precondition and body were missing thefloatbranch, soAny_to_boolcouldn't handle float inputs. This also partially addresses Soundness bug:PNotreturnsexceptionforNoneandDictStrAnyinputs instead of computingnot#934.to_bool_anyfunction — a wrapper that returnsfrom_bool(Any_to_bool(v)), converting theboolresult back toAnyso it can be compared with otherAnyvalues likefrom_bool(true).2.
PythonToLaurel.lean\"bool\" => \"to_bool_any\"toreMapFunctionName— previously,bool()calls had no name mapping, sohasModelreturned false and the call was translated toHole. Now it maps to the newto_bool_anyfunction.Why this fixes the issue
When Python code like
assert bool(None) == Falseis analyzed:bool(None)is now translated toto_bool_any(from_None())instead ofHoleto_bool_anycallsAny_to_boolwhich returnsfalseforNone, then wraps it asfrom_bool(false)from_bool(false) == from_bool(false)is trivially resolved by the SMT solverVerification
Full
lake buildpasses (508 jobs). All existing test modules build successfully:VerifyPythonTest✅ToLaurelTest✅PreludeVerifyTest✅