lean4-htt/tests/lean/interactive/terminationBySuggestion.lean
Joachim Breitner 32dcc6eb89
feat: GuessLex: avoid writing sizeOf in termination argument when not needed (#3630)
this makes `termination_by?` even slicker.

The heuristics is agressive in the non-mutual case (will omit `sizeOf`
if the argument is non-dependent and the `WellFoundedRelation` relation
is via `sizeOfWFRel`.

In the mutual case we'd also have to check the arguments, as they line
up in the termination argument, have the same types. I did not bother at
this point; in the mutual case we omit `sizeOf` only if the argument
type is `Nat`.

As a drive-by fix, `termination_by?` now also works on functions that
have only one plausible measure.
2024-03-10 22:57:10 +00:00

19 lines
496 B
Text

def ackermann (n m : Nat) := match n, m with
| 0, m => m + 1
| .succ n, 0 => ackermann n 1
| .succ n, .succ m => ackermann n (ackermann (n + 1) m)
termination_by?
--^ codeAction
-- Check hat we print this even if there is only one plausible measure
def onlyOneMeasure (n : Nat) := match n with
| 0 => 0
| .succ n => onlyOneMeasure n
termination_by?
--^ codeAction
def anonymousMeasure : Nat → Nat
| 0 => 0
| .succ n => anonymousMeasure n
termination_by?
--^ codeAction