With
set_option showInferredTerminationBy true
this prints a message like
Inferred termination argument:
termination_by
ackermann n m => (sizeOf n, sizeOf m)
it tries hard to use names that
* match the names that the user used, if present
* have no daggers (so that it can be copied)
* do not shadow each other
* do not shadow anything from the environment (just to be nice)
it does so by appending sufficient `'` to the name.
Some of the emitted `sizeOf` calls are unnecessary, but they are needed
sometimes with dependent parameters. A follow-up PR will not emit them
for non-dependent arguments, so that in most cases the output is pretty.
Somewhen down the road we also want a code action, maybe triggered by
`termination_by?`. This should come after #2921, as that simplifies that
feature (no need to merge termination arguments from different cliques
for example.)
25 lines
577 B
Text
25 lines
577 B
Text
/-!
|
|
Another “tricky” example from “Finding Lexicographic Orders for Termination Proofs in
|
|
Isabelle/HOL” by Lukas Bulwahn, Alexander Krauss, and Tobias Nipkow,
|
|
10.1007/978-3-540-74591-4_5.
|
|
|
|
Works out of the box!
|
|
-/
|
|
|
|
set_option showInferredTerminationBy true
|
|
|
|
mutual
|
|
def pedal : Nat → Nat → Nat → Nat
|
|
| 0, _m, c => c
|
|
| _n, 0, c => c
|
|
| n+1, m+1, c =>
|
|
if n < m
|
|
then coast n m (c + m + 1)
|
|
else pedal n (m + 1) (c + m + 1)
|
|
|
|
def coast : Nat → Nat → Nat → Nat
|
|
| n, m , c =>
|
|
if n < m
|
|
then coast n (m - 1) (c + n)
|
|
else pedal n m (c + n)
|
|
end
|