Skip to content

update to Lean 4.16#529

Merged
cdisselkoen merged 10 commits intomainfrom
cdisselkoen/lean-4.16
Feb 7, 2025
Merged

update to Lean 4.16#529
cdisselkoen merged 10 commits intomainfrom
cdisselkoen/lean-4.16

Conversation

@cdisselkoen
Copy link
Contributor

Biggest change for us is (quoting from the Lean changelog):

leanprover/lean4#6379 replaces the inductive predicate List.lt with an upstreamed version of List.Lex from Mathlib.
(Previously Lex.lt was defined in terms of <; now it is generalized to take an arbitrary relation.)
This subtly changes the notion of ordering on List α.

List.lt was a weaker relation: in particular if l₁ < l₂, then a :: l₁ < b :: l₂ may hold according to List.lt even if a and b are merely incomparable (either neither a < b nor b < a), whereas according to List.Lex this would require a = b.

When < is total, in the sense that ¬ · < · is antisymmetric, then the two relations coincide.

Mathlib was already overriding the order instances for List α, so this change should not be noticed by anyone already using Mathlib.

We simultaneously add the boolean valued List.lex function, parameterised by a BEq typeclass and an arbitrary lt function. This will support the flexibility previously provided for List.lt, via a == function which is weaker than strict equality.

Separately, Lean introduced its own DecidableLT. For now, to get things working, I kept our DecidableLT and just qualified it as Cedar.Data.DecidableLT when ambiguous. In a future PR we can look at replacing our DecidableLT with the Lean one.

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
…ke command?

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
exact List.slt_trans h₃ h₆

theorem List.lt_asymm [LT α] [StrictLT α] {xs ys : List α} :
theorem List.lt_asymm' [LT α] [StrictLT α] [Cedar.Data.DecidableLT α] {xs ys : List α} :
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this renaming was necessary to avoid a conflict with a newly introduced theorem in Lean?

Can we rename it to List.slt_asymm to be consistent with List.slt_trans (which we also had to rename because of a conflict in the last update)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. What does the s stand for?

apply List.lt_asymm'
transitive a b c := by
simp [LT.lt, Name.lt]
simp only [LT.lt]
Copy link
Contributor

@emina emina Feb 7, 2025

Choose a reason for hiding this comment

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

Curious why we need to consecutive simp onlys here. Stylistic choice or Lean does the wrong thing if we use a single simp only that calls both sets of theorems?

Edited to add: this is not a blocker, just curiosity :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if we combine it all then Lean throws maximum recursion depth has been reached

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 think that LT.lt and Name.lt recurse infinitely with each other, so those are the two that needed separating

Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
@cdisselkoen cdisselkoen merged commit 2481def into main Feb 7, 2025
6 checks passed
@cdisselkoen cdisselkoen deleted the cdisselkoen/lean-4.16 branch February 7, 2025 19:37
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.

3 participants