2014-12-04 06:11:01 +00:00
|
|
|
open nat prod sigma
|
|
|
|
|
|
|
|
-- We will define the following example by well-foudned recursion
|
|
|
|
-- g 0 := 0
|
|
|
|
-- g (succ x) := g (g x)
|
|
|
|
definition g.F (x : nat) : (Π y, y < x → Σ r : nat, r ≤ y) → Σ r : nat, r ≤ x :=
|
|
|
|
nat.cases_on x
|
2014-12-20 02:23:08 +00:00
|
|
|
(λ f, ⟨zero, le.refl zero⟩)
|
2014-12-04 06:11:01 +00:00
|
|
|
(λ x₁ (f : Π y, y < succ x₁ → Σ r : nat, r ≤ y),
|
|
|
|
let p₁ := f x₁ (lt.base x₁) in
|
2014-12-20 02:23:08 +00:00
|
|
|
let gx₁ := pr₁ p₁ in
|
2015-01-08 02:26:51 +00:00
|
|
|
let p₂ := f gx₁ (lt_of_le_of_lt (pr₂ p₁) (lt.base x₁)) in
|
2014-12-20 02:23:08 +00:00
|
|
|
let ggx₁ := pr₁ p₂ in
|
2015-01-08 02:26:51 +00:00
|
|
|
⟨ggx₁, le_succ_of_le (le.trans (pr₂ p₂) (pr₂ p₁))⟩)
|
2014-12-04 06:11:01 +00:00
|
|
|
|
|
|
|
definition g (x : nat) : nat :=
|
2014-12-20 02:23:08 +00:00
|
|
|
pr₁ (well_founded.fix g.F x)
|
2014-12-04 06:11:01 +00:00
|
|
|
|
|
|
|
example : g 3 = 0 :=
|
|
|
|
rfl
|
|
|
|
|
|
|
|
example : g 6 = 0 :=
|
|
|
|
rfl
|
|
|
|
|
|
|
|
theorem g_zero : g 0 = 0 :=
|
|
|
|
rfl
|
|
|
|
|
|
|
|
theorem g_succ (a : nat) : g (succ a) = g (g a) :=
|
2014-12-20 02:23:08 +00:00
|
|
|
have aux : well_founded.fix g.F (succ a) = sigma.mk (g (g a)) _, from
|
2014-12-04 06:11:01 +00:00
|
|
|
well_founded.fix_eq g.F (succ a),
|
2014-12-20 02:23:08 +00:00
|
|
|
calc g (succ a) = pr₁ (well_founded.fix g.F (succ a)) : rfl
|
2015-01-20 02:00:14 +00:00
|
|
|
... = pr₁ (sigma.mk (g (g a)) _) : {aux}
|
2014-12-04 06:11:01 +00:00
|
|
|
... = g (g a) : rfl
|
|
|
|
|
|
|
|
theorem g_all_zero (a : nat) : g a = zero :=
|
|
|
|
nat.induction_on a
|
|
|
|
g_zero
|
|
|
|
(λ a₁ (ih : g a₁ = zero), calc
|
|
|
|
g (succ a₁) = g (g a₁) : g_succ
|
|
|
|
... = g 0 : ih
|
|
|
|
... = 0 : g_zero)
|