1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "pts_dummy/rc_hsat.ma".
17 (* THE EVALUATION *************************************************************)
19 (* The arity of a term t in an environment E *)
20 let rec aa E t on t ≝ match t with
22 | Rel i ⇒ nth i … E SORT
23 | App M N ⇒ pred (aa E M)
24 | Lambda N M ⇒ let Q ≝ aa E N in ABST Q (aa (Q::E) M)
25 | Prod N M ⇒ aa ((aa E N)::E) M
29 interpretation "arity assignment (term)" 'Eval1 t E = (aa E t).
31 (* The arity of a type context *)
32 let rec caa E G on G ≝ match G with
34 | cons t F ⇒ let D ≝ caa E F in 〚t〛_[D] :: D
37 interpretation "arity assignment (type context)" 'Eval1 G E = (caa E G).
39 lemma aa_app: ∀M,N,E. 〚App M N〛_[E] = pred (〚M〛_[E]).
42 lemma aa_lambda: ∀M,N,E. 〚Lambda N M〛_[E] = ABST (〚N〛_[E]) (〚M〛_[〚N〛_[E]::E]).
45 lemma aa_prod: ∀M,N,E. 〚Prod N M〛_[E] = 〚M〛_[〚N〛_[E]::E].
48 lemma aa_rel_lt: ∀D,E,i. (S i) ≤ |E| → 〚Rel i〛_[E @ D] = 〚Rel i〛_[E].
49 #D #E (elim E) -E [1: #i #Hie (elim (not_le_Sn_O i)) #Hi (elim (Hi Hie)) ]
50 #C #F #IHE #i (elim i) -i // #i #_ #Hie @IHE @le_S_S_to_le @Hie
53 lemma aa_rel_ge: ∀D,E,i. (S i) ≰ |E| →
54 〚Rel i〛_[E @ D] = 〚Rel (i-|E|)〛_[D].
55 #D #E (elim E) -E [ normalize // ]
56 #C #F #IHE #i (elim i) -i [1: -IHE #Hie (elim Hie) -Hie #Hie (elim (Hie ?)) /2/ ]
57 normalize #i #_ #Hie @IHE /2/
60 (* weakeing and thinning lemma arity assignment *)
61 (* NOTE: >commutative_plus comes from |a::b| ↦ S |b| rather than |b| + 1 *)
62 lemma aa_lift: ∀E,Ep,t,Ek.
63 〚lift t (|Ek|) (|Ep|)〛_[Ek @ Ep @ E] = 〚t〛_[Ek @ E].
66 | #i #Ek @(leb_elim (S i) (|Ek|)) #Hik
67 [ >(lift_rel_lt … Hik) >(aa_rel_lt … Hik) >(aa_rel_lt … Hik) //
68 | >(lift_rel_ge … Hik) >(aa_rel_ge … Hik) <associative_append
69 >(aa_rel_ge …) (>length_append)
70 [ >arith2 // @not_lt_to_le /2/ | @(arith3 … Hik) ]
73 | #N #M #IHN #IHM #Ek >lift_lambda >aa_lambda
74 >commutative_plus >(IHM (? :: ?)) /3/
75 | #N #M #IHN #IHM #Ek >lift_prod >aa_prod
76 >commutative_plus >(IHM (? :: ?)) /3/
81 (* substitution lemma arity assignment *)
82 (* NOTE: >commutative_plus comes from |a::b| ↦ S |b| rather than |b| + 1 *)
83 lemma aa_subst: ∀v,E,t,Ek. 〚t[|Ek|≝v]〛_[Ek @ E] = 〚t〛_[Ek @ 〚v〛_[E]::E].
86 | #i #Ek @(leb_elim (S i) (|Ek|)) #H1ik
87 [ >(aa_rel_lt … H1ik) >(subst_rel1 … H1ik) >(aa_rel_lt … H1ik) //
88 | @(eqb_elim i (|Ek|)) #H2ik
89 [ >(aa_rel_ge … H1ik) >H2ik -H2ik H1ik >subst_rel2
90 >(aa_lift ? ? ? ([])) <minus_n_n /2/
91 | (lapply (arith4 … H1ik H2ik)) -H1ik H2ik #Hik
92 (>(subst_rel3 … Hik)) (>aa_rel_ge) [2: /2/ ]
93 <(associative_append ? ? ([?]) ?)
94 >aa_rel_ge >length_append (>commutative_plus)
95 [ <minus_plus // | @not_le_to_not_le_S_S /2/ ]
99 | #N #M #IHN #IHM #Ek >subst_lambda > aa_lambda
100 >commutative_plus >(IHM (? :: ?)) /3/
101 | #N #M #IHN #IHM #Ek >subst_prod > aa_prod
102 >commutative_plus >(IHM (? :: ?)) /4/
126 (* extensional equality of the interpretations *)
127 definition eveq: T → T → Prop ≝ λt1,t2. ∀E,K. 〚t1〛_[E, K] ≅ 〚t2〛_[E, K].
130 "extensional equality of the type interpretations"
131 'napart t1 t2 = (eveq t1 t2).
134 axiom ev_lift_0_S: ∀t,p,C,E,K. 〚lift t 0 (S p)〛_[C::E, K] ≅ 〚lift t 0 p〛_[E, K].
136 theorem tj_ev: ∀G,t,u. G ⊢t:u → ∀E,l. l ∈ 〚G〛_[E] → t[l] ∈ 〚u[l]〛_[[], []].
137 #G #t #u #tjtu (elim tjtu) -G t u tjtu
138 [ #i #j #_ #E #l #_ >tsubst_sort >tsubst_sort /2 by SAT0_sort/
139 | #G #u #n #tju #IHu #E #l (elim l) -l (normalize)
141 | #hd #tl #_ #H (elim H) -H #Hhd #Htl
142 >lift_0 >delift // >lift_0
146 (@mem_rceq_trans) [3: @symmetric_rceq @ev_lift_0_S | skip ]
150 theorem tj_sn: ∀G,A,B. G ⊢A:B → SN A.
151 #G #A #B #tjAB lapply (tj_trc … tjAB (nil ?) (nil ?)) -tjAB (normalize) /3/
156 theorem tev_rel_S: ∀i,R,H. 〚Rel (S i)〛_(R::H) = 〚Rel i〛_(H).
160 theorem append_cons: ∀(A:Type[0]). ∀(l1,l2:list A). ∀a.
161 (a :: l1) @ l2 = a :: (l1 @ l2).