Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support BitVec.ofBool in bv_decide #5852

Merged
merged 8 commits into from
Oct 26, 2024
Merged

Conversation

hargoniX
Copy link
Contributor

This is the first step towards fixing the issue of not having mutual recursion between the Bool and BitVec fragment of QF_BV in bv_decide. This PR adds support for BitVec.ofBool by doing the following:

  1. Introduce a new mechanism into the reification engine that allows us to add additional lemmas to the top level on the fly as we are traversing the expression tree.
  2. If we encounter an expression BitVec.ofBool boolExpr we reify boolExpr and then abstract BitVec.ofBool boolExpr as some atom a
  3. We add two lemmas boolExpr = true -> a = 1#1 and boolExpr = false -> a = 0#1. This mirrors the full behavior of BitVec.ofBool and thus makes our atom a correctly interpreted again.

In order to do the reification in step 2 mutual recursion in the reification engine is required. For this reason I started pulling out logic from the, now rather large, mutual block into other files and document the invariants that they assume explicitly.

Copy link
Contributor

@tobiasgrosser tobiasgrosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me. Thank you, @hargoniX!

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc October 26, 2024 18:10 Inactive
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 26, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 8f0328b777e1bded512c1752fba94d4d03cecad0 --onto 193b6f2bec332ac0bce33e10856a96163d4be456. (2024-10-26 18:22:50)

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc October 26, 2024 19:04 Inactive
@hargoniX hargoniX added this pull request to the merge queue Oct 26, 2024
Merged via the queue into master with commit 8b5443e Oct 26, 2024
14 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Oct 27, 2024
Using the same strategy as #5852 this provides `bv_decide` support for
`Bool` and `BitVec` ifs
this in turn instantly enables support for:
- `sdiv`
- `smod`
- `abs`

and thus closes our last discrepancies to QF_BV!
tobiasgrosser pushed a commit to opencompl/lean4 that referenced this pull request Oct 27, 2024
This is the first step towards fixing the issue of not having mutual
recursion between the `Bool` and `BitVec` fragment of `QF_BV` in
`bv_decide`. This PR adds support for `BitVec.ofBool` by doing the
following:
1. Introduce a new mechanism into the reification engine that allows us
to add additional lemmas to the top level on the fly as we are
traversing the expression tree.
2. If we encounter an expression `BitVec.ofBool boolExpr` we reify
`boolExpr` and then abstract `BitVec.ofBool boolExpr` as some atom `a`
3. We add two lemmas `boolExpr = true -> a = 1#1` and `boolExpr = false
-> a = 0#1`. This mirrors the full behavior of `BitVec.ofBool` and thus
makes our atom `a` correctly interpreted again.

In order to do the reification in step 2 mutual recursion in the
reification engine is required. For this reason I started pulling out
logic from the, now rather large, mutual block into other files and
document the invariants that they assume explicitly.
tobiasgrosser added a commit to opencompl/lean4 that referenced this pull request Oct 27, 2024
Using the same strategy as leanprover#5852 this provides `bv_decide` support for
`Bool` and `BitVec` ifs
this in turn instantly enables support for:
- `sdiv`
- `smod`
- `abs`

and thus closes our last discrepancies to QF_BV!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants