2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department of the University of Bologna, Italy.
7 ||A|| This file is distributed under the terms of the
8 \ / GNU General Public License Version 2
10 V_______________________________________________________________ *)
12 include "pts_dummy_new/subst.ma".
14 inductive subterm : T → T → Prop ≝
15 | appl : ∀M,N. subterm M (App M N)
16 | appr : ∀M,N. subterm N (App M N)
17 | lambdal : ∀M,N. subterm M (Lambda M N)
18 | lambdar : ∀M,N. subterm N (Lambda M N)
19 | prodl : ∀M,N. subterm M (Prod M N)
20 | prodr : ∀M,N. subterm N (Prod M N)
21 | dl : ∀M,N. subterm M (D M N)
22 | dr : ∀M,N. subterm N (D M N)
23 | sub_trans : ∀M,N,P. subterm M N → subterm N P → subterm M P.
25 inverter subterm_myinv for subterm (?%).
27 lemma subapp: ∀S,M,N. subterm S (App M N) →
28 S = M ∨ S = N ∨ subterm S M ∨ subterm S N.
29 #S #M #N #subH (@(subterm_myinv … subH))
30 [#M1 #N1 #eqapp destruct /4/
31 |#M1 #N1 #eqapp destruct /4/
32 |3,4,5,6,7,8: #M1 #N1 #eqapp destruct
33 |#M1 #N1 #P #sub1 #sub2 #H1 #H2 #eqapp
35 [* [* /3/ | #subN1 %1 %2 /2/ ]
41 lemma sublam: ∀S,M,N. subterm S (Lambda M N) →
42 S = M ∨ S = N ∨ subterm S M ∨ subterm S N.
43 #S #M #N #subH (@(subterm_myinv … subH))
44 [1,2,5,6,7,8: #M1 #N1 #eqH destruct
45 |3,4:#M1 #N1 #eqH destruct /4/
46 |#M1 #N1 #P #sub1 #sub2 #H1 #H2 #eqH
48 [* [* /3/ | #subN1 %1 %2 /2/ ]
54 lemma subprod: ∀S,M,N. subterm S (Prod M N) →
55 S = M ∨ S = N ∨ subterm S M ∨ subterm S N.
56 #S #M #N #subH (@(subterm_myinv … subH))
57 [1,2,3,4,7,8: #M1 #N1 #eqH destruct
58 |5,6:#M1 #N1 #eqH destruct /4/
59 |#M1 #N1 #P #sub1 #sub2 #H1 #H2 #eqH
61 [* [* /3/ | #subN1 %1 %2 /2/ ]
67 lemma subd: ∀S,M,N. subterm S (D M N) →
68 S = M ∨ S = N ∨ subterm S M ∨ subterm S N.
69 #S #M #N #subH (@(subterm_myinv … subH))
70 [1,2,3,4,5,6: #M1 #N1 #eqH destruct
71 |7,8: #M1 #N1 #eqH destruct /4/
72 |#M1 #N1 #P #sub1 #sub2 #_ #H #eqH
74 [* [* /3/ | #subN1 %1 %2 /2/ ]
80 lemma subsort: ∀S,n. ¬ subterm S (Sort n).
81 #S #n % #subH (@(subterm_myinv … subH))
82 [1,2,3,4,5,6,7,8: #M1 #N1 #eqH destruct
87 lemma subrel: ∀S,n. ¬ subterm S (Rel n).
88 #S #n % #subH (@(subterm_myinv … subH))
89 [1,2,3,4,5,6,7,8: #M1 #N1 #eqH destruct
94 theorem Telim: ∀P: T → Prop. (∀M. (∀N. subterm N M → P N) → P M) →
96 #P #H #M (cut (P M ∧ (∀N. subterm N M → P N)))
100 [@H #N1 #subN1 @False_ind /2/
101 |#N #subN1 @False_ind /2/
104 [@H #N1 #subN1 @False_ind /2/
105 |#N #subN1 @False_ind /2/
107 |#M1 #M2 * #PM1 #Hind1 * #PM2 #Hind2
108 (cut (∀N.subterm N (App M1 M2) → P N))
109 [#N1 #subN1 (cases (subapp … subN1))
110 [* [* // | @Hind1 ] | @Hind2 ]]
112 |#M1 #M2 * #PM1 #Hind1 * #PM2 #Hind2
113 (cut (∀N.subterm N (Lambda M1 M2) → P N))
114 [#N1 #subN1 (cases (sublam … subN1))
115 [* [* // | @Hind1 ] | @Hind2 ]]
117 |#M1 #M2 * #PM1 #Hind1 * #PM2 #Hind2
118 (cut (∀N.subterm N (Prod M1 M2) → P N))
119 [#N1 #subN1 (cases (subprod … subN1))
120 [* [* // | @Hind1 ] | @Hind2 ]]
122 |#M1 #M2 * #PM1 #Hind1 * #PM2 #Hind2
123 (cut (∀N.subterm N (D M1 M2) → P N))
124 [#N1 #subN1 (cases (subd … subN1))
125 [* [* // | @Hind1 ] | @Hind2 ]]
134 |App P Q ⇒ size P + size Q + 1
135 |Lambda P Q ⇒ size P + size Q + 1
136 |Prod P Q ⇒ size P + size Q + 1
137 |D P Q ⇒ size P + size Q + 1
141 (* axiom pos_size: ∀M. 1 ≤ size M. *)
143 theorem Telim_size: ∀P: T → Prop.
144 (∀M. (∀N. size N < size M → P N) → P M) → ∀M. P M.
145 #P #H #M (cut (∀p,N. size N = p → P N))
147 #p @(nat_elim1 p) #m #H1 #N #sizeN @H #N0 #Hlt @(H1 (size N0)) //
150 (* size of subterms *)
152 lemma size_subterm : ∀N,M. subterm N M → size N < size M.
153 #N #M #subH (elim subH) normalize //
154 #M1 #N1 #P #sub1 #sub2 #size1 #size2 @(transitive_lt … size1 size2)