lean4-htt/tests/lean/run/issue2883.lean
Joachim Breitner 260eaebf4e
fix: PackMutual: Eta-Expand as needed (#2902)
The `packMutual` code ought to reliably replace all recursive calls to
the functions in `preDefs`, even when they are under- or over-applied.
Therefore eta-expand if need rsp. keep extra arguments around.

Needs a tweak to `Meta.transform` to avoid mistaking the `f` in
`f x1 x2` as a zero-arity application.

Includes a test case.

This fixes #2628 and #2883.
2023-11-22 14:25:56 +00:00

25 lines
525 B
Text

/-!
Test that PackMutual isn't confused when a recursive call has more arguments than is packed
into the unary argument, which can happen if the return type is a function type.
-/
mutual
inductive A : Type
| baseA : A
| fromB : B → A
inductive B : Type
| fromA : A → B
end
mutual
def foo : B → Prop
| .fromA a => bar a 0
def bar : A → Nat → Prop
| .baseA => (fun _ => True)
| .fromB b => (fun (c : Nat) => ∃ (t : Nat), foo b)
end
termination_by
foo x => sizeOf x
bar x => sizeOf x