Skip to content

Fix: enable bool(x) == y equality resolution#951

Draft
keyboardDrummer-bot wants to merge 1 commit intomainfrom
fix/bool-equality-resolution-945
Draft

Fix: enable bool(x) == y equality resolution#951
keyboardDrummer-bot wants to merge 1 commit intomainfrom
fix/bool-equality-resolution-945

Conversation

@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator

Summary

Fixes #945 — the analyzer could not resolve bool(x) == y equality assertions because Python's bool() builtin was not mapped to any Laurel function.

Changes

1. PythonRuntimeLaurelPart.lean

2. PythonToLaurel.lean

  • Added \"bool\" => \"to_bool_any\" to reMapFunctionName — previously, bool() calls had no name mapping, so hasModel returned false and the call was translated to Hole. Now it maps to the new to_bool_any function.

Why this fixes the issue

When Python code like assert bool(None) == False is analyzed:

  1. bool(None) is now translated to to_bool_any(from_None()) instead of Hole
  2. to_bool_any calls Any_to_bool which returns false for None, then wraps it as from_bool(false)
  3. The equality from_bool(false) == from_bool(false) is trivially resolved by the SMT solver

Verification

Full lake build passes (508 jobs). All existing test modules build successfully:

  • VerifyPythonTest
  • ToLaurelTest
  • PreludeVerifyTest

- Add float support to Any_to_bool precondition and body
- Add to_bool_any wrapper function (returns from_bool(Any_to_bool(v)))
- Map Python bool() builtin to to_bool_any in reMapFunctionName

Fixes #945
Related: #934 (float gap in Any_to_bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Analyzer cannot resolve bool(x) == y equality assertions

1 participant