until around 7fe6881 the way to define well-founded recursions was to
specify a `WellFoundedRelation` on the argument explicitly. This was
rather low-level, for example one had to predict the packing of multiple
arguments into `PProd`s, the packing of mutual functions into `PSum`s,
and the cliques that were calculated.
Then the current `termination_by` syntax was introduced, where you
specify the termination argument at a higher level (one clause per
functions, unpacked arguments), and the `WellFoundedRelation` is found
using type class resolution.
The old syntax was kept around as `termination_by'`. This is not used
anywhere in the lean, std, mathlib or the theorem-proving-in-lean
repositories,
and three occurrences I found in the wild can do without
In particular, it should be possible to express anything that the old
syntax
supported also with the new one, possibly requiring a helper type with a
suitable instance, or the following generic wrapper that now lives in
std
```
def wrap {α : Sort u} {r : α → α → Prop} (h : WellFounded r) (x : α) : {x : α // Acc r x}
```
Since the old syntax is unused, has an unhelpful name and relies on
internals, this removes the support. Now is a good time before the
refactoring that's planned in #2921.
The test suite was updated without particular surprises.
The parametric `terminationHint` parser is gone, which means we can
match on syntax more easily now, in `expandDecreasingBy?`.
35 lines
738 B
Text
35 lines
738 B
Text
mutual
|
|
@[simp] def isEven : Nat → Bool
|
|
| 0 => true
|
|
| n+1 => isOdd n
|
|
@[simp] def isOdd : Nat → Bool
|
|
| 0 => false
|
|
| n+1 => isEven n
|
|
end
|
|
decreasing_by apply Nat.lt_succ_self
|
|
|
|
theorem isEven_double (x : Nat) : isEven (2 * x) = true := by
|
|
induction x with
|
|
| zero => simp
|
|
| succ x ih => simp [Nat.mul_succ, Nat.add_succ, ih]
|
|
|
|
def f (x : Nat) : Nat :=
|
|
match x with
|
|
| 0 => 1
|
|
| x + 1 => f x * 2
|
|
decreasing_by apply Nat.lt_succ_self
|
|
|
|
attribute [simp] f
|
|
|
|
theorem f_succ (x : Nat) : f (x+1) = f x * 2 := by
|
|
simp
|
|
|
|
theorem f_succ₂ (x : Nat) : f (x+1) = f x * 2 := by
|
|
fail_if_success simp [-f]
|
|
simp
|
|
|
|
attribute [-simp] f
|
|
|
|
theorem f_succ₃ (x : Nat) : f (x+1) = f x * 2 := by
|
|
fail_if_success simp
|
|
simp [f]
|