You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: Parameters in termination_by #879
The default behavior of the termination checker is to tuple together all the arguments of the function, including variables (which cannot possibly change in recursive arguments). This can be problematic when it comes to supplying the relevant WellFoundedRelation, if this relation depends on some of the parameters. (For example, mathlib4 has a relation for doing upward recursion:
defUp (ub a i : ℕ) := i < a ∧ i < ub
but ub is a dependency of the relation, and it is difficult to use this on a function def foo (ub : nat) (i : nat) because the two arguments get tupled together.)
It is possible to work around this with a variation on lex that is dependent and skips some of the arguments, but I think a nicer default behavior is to check the recursive arguments to find out which ones change in recursive calls, and only tuple these up and leave the rest as parameters. That is, a function like this:
variable (a : Nat)
deffoo (b c : Nat) := if b = 0then a + c else foo (b - 1) c
termination_by ...
would get a goal of a c : Nat |- WellFoundedRelation Nat, because only b changes in recursive calls.
Activity