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

simproc Nat.reduceAnd doesn't work properly #6772

Closed
3 tasks done
Rob23oba opened this issue Jan 25, 2025 · 2 comments · Fixed by #6773
Closed
3 tasks done

simproc Nat.reduceAnd doesn't work properly #6772

Rob23oba opened this issue Jan 25, 2025 · 2 comments · Fixed by #6773
Labels
bug Something isn't working

Comments

@Rob23oba
Copy link
Contributor

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The builtin simproc Nat.reduceAnd doesn't work. This is because of a typo in the definition:

builtin_dsimproc [simp, seval] reduceAnd ((_ &&& _ : Nat)) := reduceBin ``HOr.hOr 6 (· &&& ·)
-- should be
builtin_dsimproc [simp, seval] reduceAnd ((_ &&& _ : Nat)) := reduceBin ``HAnd.hAnd 6 (· &&& ·)

While there is a test for bitwise and reduction, it actually unintentionally uses lemmas other than Nat.reduceAnd:

#check_simp (3 : Nat) &&& (1 : Nat) ~> 1 -- uses Nat.and_one_is_mod, Nat.reduceMod

Example

/--
error: simp made no progress
-/
#guard_msgs in
example : 42 &&& 69 = 0 := by
  simp

Versions

This bug was introduced in v4.13.0-rc2 (the same version bitwise and reduction was introduced in).

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@Rob23oba Rob23oba added the bug Something isn't working label Jan 25, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 25, 2025

Sounds plausible, thanks for the analysis. Do you want to prepare a PR? Including a regression test?

@Rob23oba
Copy link
Contributor Author

Yeah, on it.

github-merge-queue bot pushed a commit that referenced this issue Jan 25, 2025
This PR fixes a typo that prevented `Nat.reduceAnd` from working
correctly.

Closes #6772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants