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

chore: adaptations for nightly-2024-05-11 #12853

Closed
wants to merge 5 commits into from

Conversation

semorrison
Copy link
Contributor

@semorrison semorrison commented May 13, 2024

These are mostly adaptations for leanprover/lean4#4061.

Some are no problem: rfl proofs that no longer work, and we replace with proofs by the appropriate lemmas.

But I think the cases where we use unseal might need further attention.

@@ -779,6 +780,7 @@ theorem zero_ne_one' [NeZero n] : (0 : Fin (n + 1)) ≠ 1 := Fin.ne_of_lt one_po

#align fin.succ_zero_eq_one' Fin.succ_zero_eq_one

unseal Nat.modCore in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not particularly happy with this. How would I discover the need to add this unseal, after seeing the rfl fail on @Eq (Fin (n✝ + 1 + 1).succ) (succ 1) 2?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not happy either. Any ideas?

We could just make Nat.modCore semireducible again, of course.

Or try harder to make Nat.mod reduce when the first argument is any fully known value and it's reducibly smaller than the second.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or use a structurally recursive definition of Nat.mod (with fuel)

Copy link
Collaborator

@nomeata nomeata May 13, 2024

Choose a reason for hiding this comment

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

Ah, I think I found the snag why I couldn’t make that work initially. I tried

def mod' (n m : Nat) := match n with
  | 0 => 0
  | _ => if n < m then n else Nat.modCore n m

but it wouldn’t reduce where I wanted it to.

I now see why. Note that

example : decide (m+3 ≤ 2) = false := rfl -- does not work
example : decide (2 < m+3) = false := rfl -- works

So

def mod' (n m : Nat) := match n with
  | 0 => 0
  | _ => if m ≤ n then Nat.modCore n m else n

might do what we want (namely reduce when n is 0, or when n is known and m is known enough.) The definition of modCore should have given me a hint. Will try.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for nudging me to try harder, I think I found the right magic incarnation to make this work:
leanprover/lean4#4145

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, we will wait on this PR until nightly-2024-05-14 lands containing leanprover/lean4#4145!

mathlib-bors bot pushed a commit that referenced this pull request May 13, 2024
In leanprover/lean4#4061, well-founded definitions become irreducible by default, and hence some `rfl` proofs stop working.

This pre-emptively backports some of the adaptations from #12853.
nomeata added a commit to leanprover/lean4 that referenced this pull request May 13, 2024
this refined upon #4098 and makes `Nat.mod` reduce on even more
literals. The key observation that I missed earlier is that `if m ≤ n`
reduces better than `if n < m`.

Also see discussion at
leanprover-community/mathlib4#12853 (comment)
github-merge-queue bot pushed a commit to leanprover/lean4 that referenced this pull request May 13, 2024
this refined upon #4098 and makes `Nat.mod` reduce on even more
literals. The key observation that I missed earlier is that `if m ≤ n`
reduces better than `if n < m`.

Also see discussion at

leanprover-community/mathlib4#12853 (comment)
@semorrison
Copy link
Contributor Author

I'll open a new PR now that we're at nightly-2024-05-14.

@semorrison semorrison closed this May 14, 2024
callesonne pushed a commit that referenced this pull request May 16, 2024
In leanprover/lean4#4061, well-founded definitions become irreducible by default, and hence some `rfl` proofs stop working.

This pre-emptively backports some of the adaptations from #12853.
grunweg pushed a commit that referenced this pull request May 17, 2024
In leanprover/lean4#4061, well-founded definitions become irreducible by default, and hence some `rfl` proofs stop working.

This pre-emptively backports some of the adaptations from #12853.
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.

None yet

2 participants