2014-11-26 00:53:09 +00:00
|
|
|
import logic data.nat.basic
|
|
|
|
open nat
|
|
|
|
|
|
|
|
inductive inftree (A : Type) : Type :=
|
|
|
|
leaf : A → inftree A,
|
|
|
|
node : (nat → inftree A) → inftree A → inftree A
|
|
|
|
|
|
|
|
namespace inftree
|
|
|
|
inductive dsub {A : Type} : inftree A → inftree A → Prop :=
|
|
|
|
intro₁ : Π (f : nat → inftree A) (a : nat) (t : inftree A), dsub (f a) (node f t),
|
|
|
|
intro₂ : Π (f : nat → inftree A) (a : nat) (t : inftree A), dsub t (node f t)
|
|
|
|
|
|
|
|
definition dsub.node.acc {A : Type} (f : nat → inftree A) (hf : ∀a, acc dsub (f a))
|
|
|
|
(t : inftree A) (ht : acc dsub t) : acc dsub (node f t) :=
|
|
|
|
acc.intro (node f t) (λ (y : inftree A) (hlt : dsub y (node f t)),
|
2014-12-03 23:28:22 +00:00
|
|
|
by cases hlt; apply (hf a); apply ht)
|
2014-11-26 00:53:09 +00:00
|
|
|
|
|
|
|
definition dsub.leaf.acc {A : Type} (a : A) : acc dsub (leaf a) :=
|
|
|
|
acc.intro (leaf a) (λ (y : inftree A) (hlt : dsub y (leaf a)),
|
2014-12-03 23:28:22 +00:00
|
|
|
by cases hlt)
|
2014-11-26 00:53:09 +00:00
|
|
|
|
|
|
|
definition dsub.wf (A : Type) : well_founded (@dsub A) :=
|
|
|
|
well_founded.intro (λ (t : inftree A),
|
2015-02-11 20:49:27 +00:00
|
|
|
inftree.rec_on t
|
2014-11-26 00:53:09 +00:00
|
|
|
(λ a, dsub.leaf.acc a)
|
|
|
|
(λ f t (ihf :∀a, acc dsub (f a)) (iht : acc dsub t), dsub.node.acc f ihf t iht))
|
|
|
|
|
|
|
|
end inftree
|