lean4-htt/tests/lean/run/1228.lean
Joachim Breitner b5122b6a7b feat: per-function termination hints
This change

 * moves `termination_by` and `decreasing_by` next to the function they
   apply to
 * simplify the syntax of `termination_by`
 * apply the `decreasing_by` goal to all goals at once, for better
   interactive use.

See the section in `RELEASES.md` for more details and migration advise.

This is a hard breaking change, requiring developers to touch every
`termination_by` in their code base. We decided to still do it as a
hard-breaking change, because supporting both old and new syntax at the
same time would be non-trivial, and not save that much. Moreover, this
requires changes to some metaprograms that developers might have
written, and supporting both syntaxes at the same time would make
_their_ migration harder.
2024-01-10 17:27:35 +01:00

46 lines
998 B
Text

inductive Foo (n : Nat) : Type
| foo (t: Foo n): Foo n
namespace Foo
inductive Bar: Foo n → Prop
theorem ex₁ {s: Foo n} (H: s.Bar): True := by
cases h₁ : s
case foo s' =>
cases h₂ : n; sorry
have: Bar s' := sorry
exact ex₁ this
termination_by sizeOf s
theorem ex₂
{s: Foo n}
(H: s.Bar):
True := by
generalize hs': s = s'
match s' with
| foo s' =>
have: Bar s' := sorry
have hterm: sizeOf s' < sizeOf s := by simp_all_arith
exact ex₂ this
termination_by sizeOf s
theorem ex₃ {s: Foo n} (H: s.Bar): True := by
cases h₁ : s
case foo s' =>
match n with
| 0 => sorry
| _ =>
have: Bar s' := sorry
exact ex₃ this
termination_by sizeOf s
-- it works
theorem ex₄ {s: Foo n} (H: s.Bar): True := by
match s with
| foo s' =>
match n with
| 0 => sorry
| _ =>
have: Bar s' := sorry
exact ex₄ this
termination_by sizeOf s