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

fix: ac_nf0, simp_arith: don't tempt the kernel to reduce atoms #5708

Merged
merged 6 commits into from
Oct 16, 2024

Conversation

nomeata
Copy link
Collaborator

@nomeata nomeata commented Oct 14, 2024

this fixes #5699 and fixes #5384.

this fixes #5699.

A similar fix should help with #5384.

TODO: Abstract this out a bit, document it.

Maybe this should even use a form of `opaque id`, just to be sure.
(`opaque betaBlocker`?…)
@nomeata nomeata mentioned this pull request Oct 14, 2024
3 tasks
@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 14, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 14, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 14, 2024
@nomeata
Copy link
Collaborator Author

nomeata commented Oct 14, 2024

This breaks handling of neutrals, it seems. Will need to have a closer look, but I think I know what to do.

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 14, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Oct 14, 2024

Mathlib CI status (docs):

@nomeata
Copy link
Collaborator Author

nomeata commented Oct 15, 2024

Is this tactic unused in mathlib? I am surprised mathlib CI passed before my latest commit!

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc October 15, 2024 16:02 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 15, 2024
@nomeata nomeata marked this pull request as ready for review October 15, 2024 16:11
@nomeata nomeata requested a review from leodemoura as a code owner October 15, 2024 16:11
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc October 15, 2024 16:32 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 15, 2024
@nomeata nomeata changed the title fix: ac_nf0: don't tempt the kernel to reduce atoms fix: ac_nf0, simp_arith: don't tempt the kernel to reduce atoms Oct 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 15, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc October 15, 2024 18:24 Inactive
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Oct 15, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Oct 15, 2024
@tobiasgrosser
Copy link
Contributor

Is this tactic unused in mathlib? I am surprised mathlib CI passed before my latest commit!

There are 70 uses in mathlib. I skimmed them quickly and many of them seem to be symbolic. I could not spot neutral elements being used.

Thank you for the quick turnaround. It is great to see this bug resolved.

@bollu
Copy link
Contributor

bollu commented Oct 15, 2024

@nomeata do you think a similar issue could be behind omega's mysterious slowdowns with subtraction with made us change toNat_sub to toNat_sub' (/~https://github.com/leanprover/lean4/blob/master/src/Init/Data/BitVec/Lemmas.lean#L1977-L1982), with the test case here(/~https://github.com/leanprover/lean4/blob/master/tests/lean/run/omega.lean#L492-L505), inlined below:

-- This example, reported from LNSym,
-- started failing when we changed the definition of `Fin.sub` in /~https://github.com/leanprover/lean4/pull/4421.
-- When we use the new definition, `omega` produces a proof term that the kernel is very slow on.
-- To work around this for now, I've removed `BitVec.toNat_sub` from the `bv_toNat` simp set,
-- and replaced it with `BitVec.toNat_sub'` which uses the old definition for subtraction.
-- This is only a workaround, and I would like to understand why the term chokes the kernel.
example
    (n : Nat)
    (addr2 addr1 : BitVec 64)
    (h0 : n ≤ 18446744073709551616)
    (h1 : addr2 + 18446744073709551615#64 - addr1 ≤ BitVec.ofNat 64 (n - 1))
    (h2 : addr2 - addr1 ≤ addr2 + 18446744073709551615#64 - addr1) :
    n = 18446744073709551616 := by
  bv_omega

@nomeata
Copy link
Collaborator Author

nomeata commented Oct 16, 2024

That’s somewhat likely. In general, the test I would apply here: If the runtime changes if you change the constants, although the proof terms look otherwise the same, then the kernel is looking at the atoms of the proof when it shouldn’t.

Do we have an actual not-worked-around issue with omega to investigate?

@nomeata nomeata added this pull request to the merge queue Oct 16, 2024
@nomeata nomeata removed this pull request from the merge queue due to a manual request Oct 16, 2024
@nomeata nomeata added this pull request to the merge queue Oct 16, 2024
Merged via the queue into master with commit a2d2977 Oct 16, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR 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.

kernel hangs on ac_nf expression unwanted reduction when checking simp_arith proof objects
4 participants