Zulip Chat Archive

Stream: Is there code for X?

Topic: (a, b) < (c, d) from a ≤ c and b < d


Violeta Hernández (Aug 19 2024 at 22:05):

I hope I'm not going crazy, because I don't think we actually have this theorem for Prod.Lex

Violeta Hernández (Aug 19 2024 at 22:07):

That's the relation termination_by (a, b) uses by default, so the lack of this result is a large annoyance

Violeta Hernández (Aug 19 2024 at 22:08):

This for instance doesn't work

import Mathlib.Order.Basic
import Mathlib.Data.Nat.Defs

theorem recursion (a b : Nat) : True := by
  let (c, d) := (0, 0)
  have : c  a := sorry
  have : d < b := sorry
  exact recursion c d -- failed to prove termination
termination_by (a, b)

Violeta Hernández (Aug 19 2024 at 22:09):

Oddly enough, we have docs#Prod.Lex.right', but only when the first argument is a natural

Violeta Hernández (Aug 19 2024 at 22:12):

On a related note, is there any way to tell termination_by to just use the product order instead?

Violeta Hernández (Aug 19 2024 at 22:17):

Do we not have (a, b) < (c, d) → Prod.Lex _ _ (a, b) (c, d) either?

Daniel Weber (Aug 20 2024 at 04:00):

Violeta Hernández said:

Do we not have (a, b) < (c, d) → Prod.Lex _ _ (a, b) (c, d) either?

There's docs#Prod.Lex.toLex_strictMono

Joachim Breitner (Aug 20 2024 at 07:02):

Violeta Hernández said:

On a related note, is there any way to tell termination_by to just use the product order instead?

With docs#WellFounded.wrap you can specify a different order

Violeta Hernández (Aug 20 2024 at 07:52):

I guess I should mention my actual use case. I can't get this proof to work without the termination_by syntax.

Violeta Hernández (Aug 20 2024 at 07:52):

Without it, four of the five recursive applications work, but the fifth one (which has the form of the title) doesn't

Joachim Breitner (Aug 20 2024 at 07:55):

This might be due to the default decreasing_tactic only trying Prod.lex.left and Prod.lex.right but not Prod.lex.right'. Also see https://github.com/leanprover/lean4/issues/3906. Maybe just use termination_by and move on :)


Last updated: May 02 2025 at 03:31 UTC