@arthur-adjedj was very confused when a mutually recursive definition didn't work as expected, and the reason was that he used different names for the fixed parameters. It seems plausible to simply allow that and calculate the fixed-prefix up to alpha renaming. It does mean, though, that, for example, termination proof goals will mention the names as used by the first function. But probably better than simply failing. And we could even fix that later (by passing down the actual names, and renmaing the variables in the context of the mvar, depending on the “current function”) should it bother our users.
34 lines
813 B
Text
34 lines
813 B
Text
namespace Structural
|
||
mutual
|
||
def f1 (α : Type) : List α → Nat
|
||
| [] => 0
|
||
| _ :: xs => f2 α xs + 1
|
||
termination_by structural n => n
|
||
|
||
-- NB β, not α. Used to prevent this from working (with an unhelpful error message)
|
||
def f2 (β : Type) : List β → Nat
|
||
| [] => 0
|
||
| _ :: xs => f1 β xs + 1
|
||
termination_by structural n => n
|
||
end
|
||
end Structural
|
||
|
||
namespace WF
|
||
|
||
mutual
|
||
def f1 (α : Type) : List α → Nat
|
||
| [] => 0
|
||
| _ :: xs => f2 α xs + 1
|
||
termination_by n => n
|
||
|
||
-- NB β, not α. Used to prevent this from working (with an unhelpful error message)
|
||
def f2 (β : Type) : List β → Nat
|
||
| [] => 0
|
||
| _ :: xs => f1 β xs + 1
|
||
termination_by n => n
|
||
decreasing_by
|
||
-- NB: The proof goal for `f2` mentions `α`, not `β`. Could be fixed in theory if we really care
|
||
guard_hyp α : Type
|
||
decreasing_tactic
|
||
end
|
||
end WF
|