lean4-htt/tests/elab/structuralRec2.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

37 lines
993 B
Text

/-!
More tests related to structural indices depending on fixed parameters
-/
inductive T (n : Nat) : Nat → Type where
| zero : T n 0
| succ {i} : T n i → T n (i + n) → T n i
/--
error: cannot use specified measure for structural recursion:
its type is an inductive datatype
T (↑f) i
and the datatype parameter
↑f
depends on the function parameter
i
which is not fixed.
-/
#guard_msgs in
def foo (i : Nat) (f : Fin i) : T f i → Unit
| .zero => ()
| .succ t _ => foo i f t
termination_by structural t => t
def bar (a : Nat) (i : Nat) (f : Fin a) : T f i → Unit
| .zero => ()
| .succ t _ => bar a i f t
termination_by structural t => t
/--
info: bar.induct (a : Nat) (f : Fin a) (motive : (i : Nat) → T (↑f) i → Prop) (case1 : motive 0 T.zero)
(case2 : ∀ (i : Nat) (t : T (↑f) i) (a_1 : T (↑f) (i + ↑f)), motive i t → motive i (t.succ a_1)) (i : Nat)
(a✝ : T (↑f) i) : motive i a✝
-/
#guard_msgs in
#check bar.induct