source: LTS/Language.ma @ 3574

Last change on this file since 3574 was 3574, checked in by piccolo, 4 years ago

assembly pass in place

File size: 70.7 KB
Line 
1(**************************************************************************)
2(*       ___                                                              *)
3(*      ||M||                                                             *)
4(*      ||A||       A project by Andrea Asperti                           *)
5(*      ||T||                                                             *)
6(*      ||I||       Developers:                                           *)
7(*      ||T||         The HELM team.                                      *)
8(*      ||A||         http://helm.cs.unibo.it                             *)
9(*      \   /                                                             *)
10(*       \ /        This file is distributed under the terms of the       *)
11(*        v         GNU General Public License Version 2                  *)
12(*                                                                        *)
13(**************************************************************************)
14
15include "basics/types.ma".
16include "Traces.ma".
17include "basics/lists/list.ma".
18include "../src/utilities/option.ma".
19include "basics/jmeq.ma".
20include "utils.ma".
21
22discriminator option.
23
24record instr_params : Type[1] ≝
25{ seq_instr : DeqSet
26; io_instr : DeqSet
27; cond_instr : DeqSet
28; loop_instr : DeqSet
29; act_params_type : DeqSet
30; return_type : DeqSet
31}.
32
33
34inductive Instructions (p : instr_params)
35  (l_p :label_params) : Type[0] ≝
36 | EMPTY : Instructions p l_p
37 | RETURN : return_type p → Instructions p l_p
38 | SEQ : (seq_instr p) → option (NonFunctionalLabel l_p) → Instructions p l_p → Instructions p l_p
39 | COND : (cond_instr p) → (NonFunctionalLabel l_p) → Instructions p l_p →
40                 (NonFunctionalLabel l_p) → Instructions p l_p → Instructions p l_p →
41                       Instructions p l_p
42 | LOOP : (loop_instr p) → NonFunctionalLabel l_p → Instructions p l_p →
43                  NonFunctionalLabel l_p → Instructions p l_p → Instructions p l_p
44 | CALL : FunctionName → (act_params_type p) → option (ReturnPostCostLabel l_p) →
45            Instructions p l_p → Instructions p l_p
46 | IO : NonFunctionalLabel l_p → (io_instr p) → NonFunctionalLabel l_p → Instructions p l_p →
47             Instructions p l_p.
48
49let rec eq_instructions (p : instr_params) (l_p : label_params) (i : Instructions p l_p)
50 on i : (Instructions p l_p) → bool ≝
51match i with
52[ EMPTY ⇒ λi'.match i' with [ EMPTY ⇒ true | _ ⇒ false ]
53| RETURN x ⇒ λi'.match i' with [ RETURN y ⇒ x == y | _ ⇒ false ]
54| SEQ x lab instr ⇒ λi'.match i' with
55                      [ SEQ y lab' instr' ⇒ x == y ∧ eq_instructions … instr instr' ∧
56                              match lab with [ None ⇒ match lab' with [ None ⇒ true | _ ⇒ false ]
57                                             | Some l1 ⇒ match lab' with [Some l2 ⇒ eq_nf_label … l1 l2 | _ ⇒ false]
58                                             ]
59                      | _ ⇒ false
60                      ]
61| COND x ltrue i1 lfalse i2 i3 ⇒ λi'.match i' with
62                          [ COND y ltrue' i1' lfalse' i2' i3' ⇒
63                             x == y ∧ eq_nf_label … ltrue ltrue' ∧
64                             eq_instructions … i1 i1' ∧ eq_nf_label … lfalse lfalse' ∧
65                             eq_instructions … i2 i2' ∧ eq_instructions … i3 i3'
66                         | _ ⇒ false
67                         ]
68| LOOP x ltrue i1 lfalse i2 ⇒ λi'.match i' with
69              [ LOOP y ltrue' i1' lfalse' i2' ⇒ x == y ∧
70                      eq_instructions … i1 i1' ∧ eq_nf_label … ltrue ltrue' ∧
71                      eq_instructions … i2 i2' ∧ eq_nf_label … lfalse lfalse'
72              | _ ⇒ false
73              ]
74| CALL f act_p r_lb i1 ⇒ λi'.match i' with
75             [ CALL f' act_p' r_lb' i1' ⇒ eq_function_name f f' ∧
76                       act_p == act_p' ∧ eq_instructions … i1 i1' ∧
77                       match r_lb with [ None ⇒ match r_lb' with [None ⇒ true | _ ⇒ false]
78                                       | Some z ⇒ match r_lb' with [Some w ⇒  eq_return_cost_lab … z w | _ ⇒ false ]
79                                       ]
80            | _ ⇒ false
81            ]
82| IO lin io lout i1 ⇒ λi'.match i' with
83             [ IO lin' io' lout' i1' ⇒ eq_nf_label … lin lin' ∧ io == io' ∧
84                                       eq_nf_label … lout lout' ∧ eq_instructions … i1 i1'
85             | _ ⇒ false                                       
86             ]
87].
88
89lemma eq_instructions_elim : ∀ P : bool → Prop.∀p,l_p,i1,i2.(i1 = i2 → P true) →
90(i1 ≠ i2 → P false) → P (eq_instructions p l_p i1 i2).
91#P #p #l_p #i1 lapply P -P elim i1
92[ #P * normalize [/2/ ] #x [|*: #y #z [2,3: #w1 #w2 [#w3] |4,5: #w1]] #_ #H2 @H2 % #EQ
93  lapply (eq_to_jmeq ??? EQ) #EQ' destruct(EQ')
94| #rt #P * normalize [2: #rt' cases (dec_eq … rt rt') #H [>(\b H) | >(\bf H) ] /2/
95  #_ #K @K % #abs lapply (eq_to_jmeq ??? abs) #abs' destruct(abs') @(absurd ?? H) //]
96  [|*: #x #y #z [2,3: #w1 #w2 [#w3] |4,5: #w1]] #_ #H2 @H2 % #EQ
97  lapply (eq_to_jmeq ??? EQ) #EQ' destruct(EQ')
98| #seq * [| #lbl] #i #IH #P *
99  [1,8: |2,9: #t_t |3,10: #seq1 #opt_l #i2 |4,11: #cond #ltrue #i_t #lfalse #i_f #i_c
100  |5,12: #cond #ltrue #i_t #lfalse #i_f |6,13: #f #act_p #ret #i3 |*: #lin #io #lout #i3]
101  #H1 #H2 try(@H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct) whd in match (eq_instructions ????);
102  normalize nodelta inversion(?==?) normalize nodelta
103  [2,4: #ABS @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
104        >(\b (refl …)) in ABS; #EQ destruct]
105  #EQseq @IH normalize nodelta [2,4: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
106  #EQ destruct cases opt_l in H1 H2; -opt_l normalize nodelta
107  [ #H1 #_ @H1 >(\P EQseq) %
108  | #lab #_ #H1 @H1 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
109  | #_ #H1 @H1 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
110  | #lab #H1 #H2 @eq_fn_label_elim [ #EQ destruct @H1 >(\P EQseq) % ]
111    * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %
112  ]
113| #cond #ltrue #i_true #lfalse #i_false #instr #IH1 #IH2 #IH3 #P *
114   [| #t_t | #seq1 #opt_l #i2 | #cond' #ltrue' #i_t' #lfalse' #i_f' #i_c'
115   | #cond' #ltrue' #i_t' #lfalse' #i_f' | #f #act_p #ret #i3 | #lin #io #lout #i3]
116   #H1 #H2 try(@H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct)
117   whd in match (eq_instructions ????); inversion(?==?) normalize nodelta
118   [2: #ABS @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
119        >(\b (refl …)) in ABS; #EQ destruct] #EQcond @eq_fn_label_elim
120   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
121   #EQ destruct @IH1 normalize nodelta
122   [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
123   #EQ destruct  @eq_fn_label_elim
124   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
125   #EQ destruct @IH2 normalize nodelta
126   [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
127   #EQ destruct @IH3 normalize nodelta
128   [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
129   #EQ destruct @H1 >(\P EQcond) %
130| #cond #ltrue #i_true #lfalse #instr #IH1 #IH2 #P *
131   [| #t_t | #seq1 #opt_l #i2 | #cond' #ltrue' #i_t' #lfalse' #i_f' #i_c'
132   | #cond' #ltrue' #i_t' #lfalse' #i_f' | #f #act_p #ret #i3 | #lin #io #lout #i3]
133   #H1 #H2 try(@H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct)
134   whd in match (eq_instructions ????); inversion(?==?) normalize nodelta
135   [2: #ABS @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
136        >(\b (refl …)) in ABS; #EQ destruct] #EQcond @IH1 normalize nodelta
137   [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
138   #EQ destruct  @eq_fn_label_elim
139   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
140   #EQ destruct @IH2 normalize nodelta
141   [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
142   #EQ destruct  @eq_fn_label_elim
143   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
144   #EQ destruct @H1 >(\P EQcond) %
145| #a #b #c #d #IH #P *
146   [| #t_t | #seq1 #opt_l #i2 | #cond' #ltrue' #i_t' #lfalse' #i_f' #i_c'
147   | #cond' #ltrue' #i_t' #lfalse' #i_f' | #f #act_p #ret #i3 | #lin #io #lout #i3]
148   #H1 #H2 try(@H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct) whd in match (eq_instructions ????);
149   @eq_function_name_elim [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
150   #EQ destruct inversion (?==?) normalize nodelta
151   [2: #ABS @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
152        >(\b (refl …)) in ABS; #EQ destruct] #EQcond @IH
153        [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
154   #EQ destruct normalize nodelta cases c in H1 H2; normalize nodelta cases ret normalize nodelta
155   [ #H1 #H2 @H1 >(\P EQcond) %
156   |2,3: #lab #H1 #H2 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %
157   | #lab1 #lab2 #H1 #H2 @eq_return_cost_lab_elim
158     [ #EQ destruct @H1 >(\P EQcond) %
159     | * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %
160     ]
161   ]
162| #a #b #c #d #IH #P *
163   [| #t_t | #seq1 #opt_l #i2 | #cond' #ltrue' #i_t' #lfalse' #i_f' #i_c'
164   | #cond' #ltrue' #i_t' #lfalse' #i_f' | #f #act_p #ret #i3 | #lin #io #lout #i3]
165   #H1 #H2 try(@H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct) whd in match (eq_instructions ????);
166    @eq_fn_label_elim
167   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
168   #EQ destruct inversion (?==?) normalize nodelta
169   [2: #ABS @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct
170        >(\b (refl …)) in ABS; #EQ destruct] #EQcond
171   @eq_fn_label_elim
172   normalize nodelta [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
173   #EQ destruct @IH
174        [2: * #H3 @H2 % #EQ lapply(eq_to_jmeq ??? EQ) -EQ #EQ destruct cases H3 %]
175   #EQ destruct @H1 >(\P EQcond) %
176]
177qed.
178
179record env_params : Type[1] ≝
180{ form_params_type : Type[0]
181}.
182
183record signature (p : env_params) (p' : instr_params) : Type[0] ≝
184{ f_name : FunctionName
185; f_pars : form_params_type p
186; f_ret : return_type p'
187}.
188
189record env_item (p : env_params) (p' : instr_params) (l_p : label_params) : Type[0] ≝
190{ f_sig :> signature p p'
191; f_lab : CallCostLabel l_p
192; f_body : Instructions p' l_p
193}.
194
195record state_params : Type[1] ≝
196{ i_pars :> instr_params
197; e_pars :> env_params
198; l_pars :> label_params
199; store_type : DeqSet
200}.
201
202record state (p : state_params) : Type[0] ≝
203{ code : Instructions p p
204; cont : list (ActionLabel p × (Instructions p p))
205; store : store_type p
206; io_info : bool
207}.
208
209definition is_io : ∀p.state p → Prop ≝ λp,st.io_info … st = true.
210
211record sem_state_params (p : state_params) : Type[0] ≝
212{ eval_seq : seq_instr p → (store_type p) → option (store_type p)
213; eval_io : io_instr p → store_type p → option (store_type p)
214; eval_cond_cond : cond_instr p → store_type p → option (bool × (store_type p))
215; eval_loop_cond : loop_instr p → store_type p → option (bool × (store_type p))
216; eval_call : signature p p → act_params_type p → store_type p → option (store_type p)
217; eval_after_return : return_type p → store_type p → option (store_type p)
218; init_store : store_type p
219}.
220
221
222let rec lookup (p : env_params) (p' : instr_params) (l_p : label_params) (l : list (env_item p p' l_p))
223 on l : FunctionName → option (env_item p p' l_p) ≝
224match l with
225[ nil ⇒ λ_.None ?
226| cons x xs ⇒  λf.if (eq_function_name f (f_name … x))
227                  then Some ? x
228                  else lookup … xs f
229].
230
231inductive execute_l (p : state_params) (p' : sem_state_params p) (env : list (env_item p p p)) :
232                                         ActionLabel p → relation (state p) ≝
233| empty : ∀st,st',hd,tl.(code ? st) = (EMPTY p p)→ (cont ? st) = hd :: tl →
234           (code ? st') = \snd hd → (cont … st') = tl → (store … st) = (store … st') →
235           (io_info … st = true → is_non_silent_cost_act … (\fst hd)) →  (io_info … st') = false → ¬ is_ret_call_act … (\fst hd) →  execute_l … (\fst hd) st st'
236| seq_sil : ∀st,st',i,cd,s,opt_l.(code ? st) = SEQ … i opt_l cd →
237             eval_seq … p' i (store … st) = return s → (code ? st') = cd →
238             (cont … st) = (cont … st') → (store … st') = s →
239             io_info … st = false →  io_info ? st' = false → execute_l … (cost_act … opt_l) st st'
240| cond_true : ∀st,st',exp,ltrue,i_true,lfalse,i_false,cd,new_m.
241   (code ? st) = COND … exp ltrue i_true lfalse i_false cd → eval_cond_cond … p' exp (store … st) = return 〈true,new_m〉 →
242   cont ? st' = 〈cost_act … (None ?),cd〉 ::(cont … st) → code … st' = i_true → store … st' = new_m →
243   io_info … st = false →  io_info … st' = false → execute_l … (cost_act … (Some ? ltrue)) st st'
244| cond_false : ∀st,st',exp,ltrue,i_true,lfalse,i_false,cd,new_m.
245   (code ? st) = COND … exp ltrue i_true lfalse i_false cd → eval_cond_cond … p' exp (store … st) = return 〈false,new_m〉 →
246   cont ? st' = 〈cost_act … (None ?),cd〉 ::(cont … st) → code … st' = i_false → store … st' = new_m →
247   io_info … st = false →  io_info … st' = false → execute_l … (cost_act … (Some ? lfalse)) st st'
248| loop_true : ∀st,st',exp,ltrue,i_true,lfalse,i_false,new_m.
249   code ? st = LOOP … exp ltrue i_true lfalse i_false → eval_loop_cond … p' exp (store … st) = return 〈true,new_m〉 →
250   cont ? st' = 〈cost_act … (None ?),LOOP … exp ltrue i_true lfalse i_false〉 :: (cont … st) →
251   code … st' = i_true → store … st' = new_m → io_info … st = false →  io_info … st' = false →
252   execute_l … (cost_act … (Some ? ltrue)) st st'
253| loop_false : ∀st,st',exp,ltrue,i_true,lfalse,i_false,new_m.
254   code ? st = LOOP … exp ltrue i_true lfalse i_false → eval_loop_cond … p' exp (store … st) = return 〈false,new_m〉 →
255   cont ? st' = cont … st → code … st' = i_false → store … st' = new_m →
256   io_info … st = false →  io_info … st' = false → execute_l … (cost_act … (Some ? lfalse)) st st'
257| io_in : ∀st,st',lin,io,lout,cd,mem.(code ? st) = IO … lin io lout cd →
258    eval_io … p' io (store … st) = return mem → code ? st' = EMPTY p p →
259    cont … st' = 〈cost_act … (Some ? lout),cd〉 :: (cont … st) → store … st' = mem →
260    io_info … st' = true → execute_l … (cost_act … (Some ? lin)) st st'
261| call : ∀st,st',f,act_p,r_lb,cd,mem,env_it.(code ? st) = CALL … f act_p r_lb cd →
262    lookup … env f = return env_it →
263    eval_call ? p' env_it act_p (store … st) = return mem →
264    store ? st' = mem → code … st' = f_body … env_it →
265     cont … st' =
266       〈(ret_act … r_lb),cd〉 :: (cont … st) → 
267    io_info … st = false →  (io_info … st') = false →
268    execute_l … (call_act … f (f_lab … env_it)) st st'
269| ret_instr : ∀st,st',r_t,mem,tl',rb,cd.code ? st = RETURN … r_t →
270   cont … st = 〈ret_act … rb,cd〉 :: tl' → cont ? st' = tl' →
271   io_info … st = false →  io_info ? st' = false →
272   eval_after_return … p' r_t (store … st) = return mem → code … st' = cd →
273   store … st' = mem → execute_l … (ret_act … rb) st st'.
274   
275let rec get_labels_of_code (p : instr_params) (l_p : label_params) (i : Instructions p l_p) on i : list (CostLabel l_p) ≝
276match i with
277[ EMPTY ⇒ [ ]
278| RETURN x ⇒ [ ]
279| SEQ x lab instr ⇒ let ih ≝ get_labels_of_code … instr in
280  match lab with [ None ⇒ ih | Some lbl ⇒ a_non_functional_label … lbl :: ih ]
281| COND x ltrue i1 lfalse i2 i3 ⇒
282   let ih3 ≝ get_labels_of_code … i3 in
283   let ih2 ≝ get_labels_of_code … i2 in
284   let ih1 ≝ get_labels_of_code … i1 in
285   ltrue :: lfalse :: (ih1 @ ih2 @ih3)
286| LOOP x ltrue i1 lfalse i2 ⇒
287   let ih2 ≝ get_labels_of_code … i2 in
288   let ih1 ≝ get_labels_of_code … i1 in
289   a_non_functional_label … ltrue :: a_non_functional_label … lfalse :: (ih1 @ ih2)
290| CALL f act_p r_lb i1 ⇒
291   let ih1 ≝ get_labels_of_code … i1 in
292   match r_lb with [ None ⇒ ih1 | Some lbl ⇒ a_return_post … lbl :: ih1]
293| IO lin io lout i1 ⇒
294   let ih1 ≝ get_labels_of_code … i1 in
295   a_non_functional_label … lin :: a_non_functional_label … lout :: ih1
296].
297   
298record Program (p : env_params) (p' : instr_params) (l_p : label_params) : Type[0] ≝
299{ env : list (env_item p p' l_p)
300; main : Instructions p' l_p
301}.
302
303
304
305definition no_duplicates_labels : ∀p,p',l_p.Program p p' l_p → Prop ≝
306λp,p',l_p,prog.
307   no_duplicates …
308    (foldr …
309      (λitem,acc.((a_call … (f_lab … item)) :: get_labels_of_code … (f_body … item)) @ acc)
310      (get_labels_of_code … (main … prog)) (env … prog)).
311
312lemma no_duplicates_domain_of_fun:
313 ∀p,p',l_p,prog.no_duplicates_labels … prog →
314 ∀f,env_it.lookup p p' l_p (env … prog) f = return env_it →
315 no_duplicates … (get_labels_of_code … (f_body … env_it)).
316#p #p' #l_p * #env elim env [ #main normalize #_ #f #env_it #EQ destruct(EQ)]
317#x #xs #IH #main whd in ⊢ (% → ?); whd in match (foldr ?????); #H #f #env_it
318whd in ⊢ (??%? → ?); @eq_function_name_elim normalize nodelta
319[ whd in ⊢ (? → ???% → ?); #EQ1 #EQ2 destruct(EQ1 EQ2) cases H #_ /2/ ]
320#H1 #EQenv_it @IH cases H /2/
321qed.
322
323
324definition is_synt_succ : ∀p.relation (state p) ≝ λp,s1,s2.cont … s1 = cont … s2 ∧
325 match (code … s1) with
326 [ CALL f act_p r_lb i1 ⇒ code … s2 = i1
327 | _ ⇒ False
328 ].
329
330definition operational_semantics : ∀p : state_params.∀p'.Program p p p → abstract_status p ≝
331λp,p',prog.mk_abstract_status …
332                (state p)
333                (execute_l ? p' (env … prog))
334                (is_synt_succ …)
335                (λs.match (code … s) with
336                    [ COND _ _ _ _ _ _ ⇒ cl_jump
337                    | LOOP _ _ _ _ _ ⇒ cl_jump
338                    | EMPTY ⇒ if io_info … s then cl_io else cl_other
339                    | _ ⇒ cl_other
340                    ])
341                (λs.match (code … s) with
342                    [CALL _ _ m _ ⇒ match m with [ Some _ ⇒ true | None ⇒ false ]
343                    | _ ⇒ false
344                    ])
345                (λs.eq_instructions … (code … s) (main … prog) ∧ isnilb … (cont … s) ∧ store … s == init_store … p' ∧ io_info … s)
346                (λs.match (cont … s) with
347                    [ nil ⇒ match (code … s) with
348                            [ EMPTY ⇒ true
349                            | RETURN _ ⇒ true
350                            | _ ⇒ false
351                            ]
352                    | _ ⇒ false
353                    ])
354                ???.
355@hide_prf
356[ #s1 #s2 #l #H #H1 inversion H1 #st #st'
357 [ #hd #tl
358 | #i #cd #s #opt_l
359 |3,4: #exp #ltrue #i_true #lfalse #i_false #cd #new_m
360 |5,6: #exp #ltrue #i_true #lfalse #ifalse #new_m
361 | #lin #io #lout #cd #mem
362 | #f #act_p #r_lb #cd #mem #env_it
363 | #r_t #mem #tl #rb #cd
364 ]
365 #EQcode
366 [ #EQ1 #EQ2 #EQ3 #EQ4 #x #EQ5 #H2 #EQ' #EQ6 #EQ7
367 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9
368 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9
369 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9
370 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9
371 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9
372 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8
373 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9 #EQ10
374 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQ7 #EQ8 #EQ9 #EQ10
375 ]
376 #_ destruct >EQcode in H; normalize nodelta /2 by ex_intro/
377 [ cases(io_info ??) normalize nodelta] #EQ destruct
378| #s1 #s2 #l #H #H1 inversion H1 #st #st'
379 [ #hd #tl
380 | #i #cd #s #opt_l
381 |3,4: #exp #ltrue #i_true #lfalse #i_false #cd #new_m
382 |5,6: #exp #ltrue #i_true #lfalse #ifalse #new_m
383 | #lin #io #lout #cd #mem
384 | #f #act_p #r_lb #cd #mem #env_it
385 | #r_t #mem #tl #rb #cd
386 ]
387 #EQcode
388 [ #EQ1 #EQ2 #EQ3 #EQ4 #x #EQiost' #H2 #EQ' #EQ6 #EQ7
389 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost' #EQ7 #EQ8 #EQ9
390 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost' #EQ7 #EQ8 #EQ9
391 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost' #EQ7 #EQ8 #EQ9
392 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost' #EQ7 #EQ8 #EQ9
393 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost' #EQ7 #EQ8 #EQ9
394 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost' #EQ6 #EQ7 #EQ8
395 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQ6 #EQiost' #EQ8 #EQ9 #EQ10
396 | #EQ1 #EQ2 #EQ3 #EQiost' #EQ5 #EQ6 #EQ7 #EQ8 #EQ9 #EQ10
397 ]
398 #_ destruct
399 cases(code ? st') in H; normalize nodelta >EQiost' normalize nodelta
400 #eq destruct try (#eq1 destruct) try (#eq2 destruct) try (#eq3 destruct)
401 try (#eq4 destruct) try (#eq5 destruct) try (#eq6 destruct) %{lin} %
402| #s1 #s2 #l #H #H1 inversion H1 #st #st'
403 [ #hd #tl
404 | #i #cd #s #opt_l
405 |3,4: #exp #ltrue #i_true #lfalse #i_false #cd #new_m
406 |5,6: #exp #ltrue #i_true #lfalse #ifalse #new_m
407 | #lin #io #lout #cd #mem
408 | #f #act_p #r_lb #cd #mem #env_it
409 | #r_t #mem #tl #rb #cd
410 ]
411 #EQcode
412 [ #EQ1 #EQ2 #EQ3 #EQ4 #x #EQiost' #H2 #EQ' #EQ6 #EQ7
413 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost #EQiost' #EQ7 #EQ8 #EQ9
414 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost #EQiost' #EQ7 #EQ8 #EQ9
415 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost #EQiost' #EQ7 #EQ8 #EQ9
416 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost #EQiost' #EQ7 #EQ8 #EQ9
417 | #EQ1 #EQ2 #EQ3 #EQ4 #EQiost #EQiost' #EQ7 #EQ8 #EQ9
418 | #EQ1 #EQ2 #EQ3 #EQiost #EQiost' #EQ6 #EQ7 #EQ8
419 | #EQ1 #EQ2 #EQ3 #EQ4 #EQ5 #EQiost #EQiost' #EQ8 #EQ9 #EQ10
420 | #EQ1 #EQ2 #EQiost #EQiost' #EQ5 #EQ6 #EQ7 #EQ8 #EQ9 #EQ10
421 ]
422 #_ destruct >EQcode in H; normalize nodelta [|*: #EQ destruct]
423 cases(io_info … st) in x; normalize nodelta [2: #_ #EQ destruct]
424 #H3 #_ @H3 %
425]
426qed.
427
428record call_post_info (p : instr_params) (l_p : label_params) : Type[0] ≝
429{ gen_labels : list (CostLabel l_p)
430; t_code : Instructions p l_p
431; fresh : l_p
432; lab_map : associative_list (DEQCostLabel l_p) (CostLabel l_p)
433; lab_to_keep : list (ReturnPostCostLabel l_p)
434}.
435
436let rec call_post_trans (p : instr_params) (l_p : label_params) (i : Instructions p l_p) (n : l_p) on i :
437list (CostLabel l_p) → call_post_info p l_p ≝
438λabs.
439match i with
440[ EMPTY ⇒ mk_call_post_info … abs (EMPTY …) n (nil ?) (nil ?)
441| RETURN x ⇒ mk_call_post_info … abs (RETURN … x) n (nil ?) (nil ?)
442| SEQ x lab instr ⇒
443   let ih ≝ call_post_trans … instr n abs in
444   match lab with
445   [ None ⇒ mk_call_post_info … (gen_labels ?? ih) (SEQ … x (None ?) (t_code … ih))
446             (fresh … ih) (lab_map … ih) (lab_to_keep … ih)
447   | Some lbl ⇒
448      mk_call_post_info … (nil ?) (SEQ … x (Some ? lbl) (t_code …  ih)) (fresh … ih)
449      (〈a_non_functional_label … lbl,((a_non_functional_label … lbl) :: (gen_labels … ih))〉 :: (lab_map … ih))
450      (lab_to_keep … ih)
451   ]
452| COND x ltrue i1 lfalse i2 i3 ⇒
453   let ih3 ≝ call_post_trans … i3 n abs in
454   let ih2 ≝ call_post_trans … i2 (fresh … ih3) (gen_labels … ih3) in
455   let ih1 ≝ call_post_trans … i1 (fresh … ih2) (gen_labels … ih3) in
456   mk_call_post_info p l_p (nil ?) (COND … x ltrue (t_code … ih1) lfalse (t_code … ih2) (t_code … ih3))
457    (fresh … ih1) 
458    (〈a_non_functional_label … ltrue,(a_non_functional_label … ltrue :: (gen_labels … ih1))〉::
459      〈a_non_functional_label … lfalse,(a_non_functional_label … lfalse :: (gen_labels … ih2))〉::
460       ((lab_map … ih1) @ (lab_map …  ih2) @ (lab_map … ih3)))
461    ((lab_to_keep … ih1) @ (lab_to_keep … ih2) @ (lab_to_keep … ih3))
462| LOOP x ltrue i1 lfalse i2 ⇒
463   let ih2 ≝ call_post_trans … i2 n abs in
464   let ih1 ≝ call_post_trans … i1 (fresh … ih2) (nil ?) in
465   mk_call_post_info p l_p (nil ?) (LOOP … x ltrue (t_code … ih1) lfalse (t_code … ih2)) (fresh … ih1)
466    (〈a_non_functional_label … lfalse,(a_non_functional_label … lfalse :: (gen_labels … ih2))〉 ::
467     〈a_non_functional_label … ltrue,(a_non_functional_label … ltrue :: (gen_labels … ih1))〉 ::
468      ((lab_map … ih1) @ (lab_map … ih2)))
469    ((lab_to_keep … ih1) @ (lab_to_keep … ih2))
470| CALL f act_p r_lb i1 ⇒
471   let ih ≝ call_post_trans … i1 n abs in
472   match r_lb with
473   [ None ⇒ let 〈l',f''〉 ≝ fresh_rc_label l_p (fresh … ih) in
474       mk_call_post_info p l_p ((a_return_post … l')::(gen_labels … ih))
475         (CALL … f act_p (Some ? l') (t_code … ih))  f'' (lab_map … ih) (lab_to_keep … ih)
476   | Some lbl ⇒
477      mk_call_post_info p l_p (nil ?) (CALL … f act_p (Some ? lbl) (t_code … ih)) (fresh … ih)
478       (〈a_return_post … lbl,(a_return_post … lbl :: (gen_labels … ih))〉 :: (lab_map … ih))
479       (lbl :: lab_to_keep … ih)
480   ]
481| IO lin io lout i1 ⇒
482    let ih ≝ call_post_trans … i1 n abs in
483    mk_call_post_info p l_p (nil ?) (IO … lin io lout (t_code … ih)) (fresh … ih)
484     (〈a_non_functional_label … lout,(a_non_functional_label … lout :: (gen_labels … ih))〉 ::
485      〈a_non_functional_label … lin,[a_non_functional_label … lin]〉 :: (lab_map … ih)) (lab_to_keep … ih)
486].
487
488
489let rec call_post_clean (p : instr_params) (l_p : label_params) (i : Instructions p l_p) on i :
490associative_list (DEQCostLabel l_p) (CostLabel l_p) → list (ReturnPostCostLabel l_p) → list (CostLabel l_p) →
491option ((list (CostLabel l_p)) × (Instructions p l_p)) ≝
492λm,keep,abs.
493 match i with
494[ EMPTY ⇒ Some ? 〈abs,EMPTY …〉
495| RETURN x ⇒ Some ? 〈abs,RETURN … x〉
496| SEQ x lab instr ⇒
497   ! 〈l,i1〉 ← call_post_clean … instr m keep abs;
498   match lab with
499   [ None ⇒ return 〈l,SEQ … x (None ?) i1〉
500   | Some lbl ⇒ if ((get_element … m lbl) == lbl :: l)
501                then return 〈nil ?,SEQ … x (Some ? lbl) i1〉
502                else None ?
503   ]
504| COND x ltrue i1 lfalse i2 i3 ⇒
505    ! 〈l3,instr3〉 ← call_post_clean … i3 m keep abs;
506    ! 〈l2,instr2〉 ← call_post_clean … i2 m keep l3;
507    ! 〈l1,instr1〉 ← call_post_clean … i1 m keep l3;
508    if ((get_element … m ltrue) == ltrue :: l1) ∧
509       ((get_element … m lfalse) == lfalse :: l2)
510    then return 〈nil ?,COND … x ltrue instr1 lfalse instr2 instr3〉
511    else None ?
512| LOOP x ltrue i1 lfalse i2 ⇒
513   ! 〈l2,instr2〉 ← call_post_clean … i2 m keep abs;
514   ! 〈l1,instr1〉 ← call_post_clean … i1 m keep (nil ?);
515   if ((get_element … m ltrue) == ltrue :: l1) ∧
516      ((get_element … m lfalse) == lfalse :: l2)
517   then return 〈nil ?,LOOP … x ltrue instr1 lfalse instr2〉
518   else None ?
519| CALL f act_p r_lb i1 ⇒
520  ! 〈l1,instr1〉 ← call_post_clean … i1 m keep abs;
521  match r_lb with
522  [ None ⇒ None ?
523  | Some lbl ⇒ if (lbl ∈ keep)
524               then if ((get_element … m lbl) == lbl :: l1)
525                    then return 〈nil ?,CALL … f act_p (Some ? lbl) instr1〉
526                    else None ?
527               else return 〈(a_return_post l_p lbl) :: l1,CALL … f act_p (None ?) instr1〉
528  ]
529| IO lin io lout i1 ⇒
530   ! 〈l1,instr1〉 ← call_post_clean … i1 m keep abs;
531   if ((get_element … m lout) == lout :: l1) ∧ ((get_element … m lin) == [lin])
532   then return 〈nil ?,IO … lin io lout instr1〉
533   else None ?   
534].
535
536
537definition ret_costed_abs : ∀p.list (ReturnPostCostLabel p) → option (ReturnPostCostLabel p) →
538option (CostLabel p) ≝
539λp,keep,x.
540 match x with
541              [ Some lbl ⇒ if lbl ∈ keep then return (a_return_post … lbl)
542                           else None ?
543              | None ⇒ None ?
544              ].
545
546
547definition check_continuations : ∀p : instr_params.∀l_p : label_params.
548∀l1,l2 : list ((ActionLabel l_p) × (Instructions p l_p)).
549associative_list (DEQCostLabel l_p) (CostLabel l_p) →
550list (ReturnPostCostLabel l_p) →  option (Prop × (list (CostLabel l_p)) × (list (CostLabel l_p))) ≝
551λp,l_p,cont1,cont2,m,keep.
552foldr2 ??? 〈True,nil ?,nil ?〉 cont1 cont2
553 (λx,y,z.
554   let 〈cond,abs_top',abs_tail'〉 ≝ x in
555   match call_post_clean p l_p (\snd z) m keep abs_top' with
556   [ None ⇒ 〈False,nil ?,nil ?〉
557   | Some w ⇒
558      match \fst z with
559       [ ret_act opt_x ⇒
560           match ret_costed_abs … keep opt_x with
561           [ Some lbl ⇒ 〈\fst y = \fst z ∧ cond ∧ \snd w = \snd y ∧
562                               get_element … m lbl = lbl :: (\fst w),(nil ?),abs_tail'〉
563           | None ⇒
564              〈\fst y = ret_act … (None ?) ∧ cond ∧ \snd w = \snd y,(nil ?),(\fst w) @ abs_tail'〉
565           ]
566       | cost_act opt_x ⇒
567           match opt_x with
568           [ None ⇒ 〈\fst y = \fst z ∧ cond ∧ \snd w = \snd y,\fst w,abs_tail'〉
569           | Some xx ⇒ 〈\fst y = \fst z ∧ cond ∧ \snd w = \snd y ∧
570                               get_element … m xx = xx :: (\fst w),(nil ?),abs_tail'〉]
571       | _ ⇒ (* dummy *) 〈False,nil ?,nil ?〉]]).
572
573(* in input :
574     abs_top is the list of labels to be propageted to the deepest level of the call stack
575             equivalently (?) is the list of labels I need to pay now
576
577     abs_tail are the lists of labels to be propagated to the levels "below" the deepest level
578              equivalently (?) is the list of labels I must have already payid in the
579              code already executed; generated by the continuations below me in the stack
580   in output :
581     abs_top is the list of labels to be propageted from the current level of the call stack
582             non empty only in the case of non-call stack frames (whiles, ifs, etc; but in
583             practice it is always nil!)
584     abs_tail are the lists of labels to be propagated from the levels "below" the current level
585             or equivalently (?) the list of labels I must have already paied in the code
586             already executed; generated by this level of the stack
587*)       
588       
589
590definition state_rel : ∀p : state_params.
591associative_list (DEQCostLabel p) (CostLabel p) → list (ReturnPostCostLabel p) →
592list (CostLabel p) → list (CostLabel p) →
593relation (state p) ≝ λp,m,keep,abs_top,abs_tail,st1,st2.
594match check_continuations … (cont ? st1) (cont … st2) m keep with
595[ Some x ⇒ let 〈prf1,abs_top',abs_tail'〉 ≝ x in
596           prf1 ∧ call_post_clean … (code … st2) m keep abs_top' = return 〈abs_top,(code … st1)〉
597           ∧ store … st1 = store … st2 ∧ io_info … st1 = io_info … st2 ∧ abs_tail = abs_tail'
598| None ⇒ False
599].
600
601let rec compute_max_n (p : instr_params) (l_p : label_params) (i : Instructions p l_p) on i : l_p ≝
602match i with
603[ EMPTY ⇒ e … l_p
604| RETURN x ⇒ e … l_p
605| SEQ x lab instr ⇒ let n ≝ compute_max_n … instr in
606                    match lab with
607                    [ None ⇒ n
608                    | Some l ⇒
609                        match l with
610                        [ a_non_functional_label n' ⇒ op … l_p n n' ]
611                    ]
612| COND x ltrue i1 lfalse i2 i3 ⇒
613  let n1 ≝ compute_max_n … i1 in
614  let n2 ≝ compute_max_n … i2 in
615  let n3 ≝ compute_max_n … i3 in
616  let mx ≝ op … l_p (op … l_p n1 n2) n3 in
617  match ltrue with
618  [ a_non_functional_label lt ⇒
619    match lfalse with
620    [a_non_functional_label lf ⇒  op … l_p (op … l_p mx lt) lf ] ]
621| LOOP x ltrue i1 lfalse i2 ⇒
622   let n1 ≝ compute_max_n … i1 in
623   let n2 ≝ compute_max_n … i2 in
624   let mx ≝ op … l_p n1 n2 in
625   match ltrue with
626  [ a_non_functional_label lt ⇒
627    match lfalse with
628    [a_non_functional_label lf ⇒ op … l_p (op … l_p mx lt) lf ] ]
629| CALL f act_p r_lb i1 ⇒
630   let n ≝ compute_max_n … i1 in
631   match r_lb with
632   [ None ⇒ n
633   | Some lbl ⇒ match lbl with [a_return_cost_label l ⇒ op … l_p l n ]
634   ]
635| IO lin io lout i1 ⇒
636  let n ≝ compute_max_n … i1 in
637  match lin with
638  [a_non_functional_label l1 ⇒
639    match lout with
640    [a_non_functional_label l2 ⇒ op … l_p (op … l_p n l1) l2 ] ]
641].
642
643
644definition same_fresh_map_on : ∀p.list (CostLabel p) →
645relation (associative_list (DEQCostLabel p) (CostLabel p)) ≝
646λp,dom,m1,m2.∀x.bool_to_Prop (x ∈ dom) → get_element … m1 x = get_element … m2 x.
647
648definition same_to_keep_on : ∀p. list (CostLabel p) → relation (list (ReturnPostCostLabel p)) ≝
649λp,dom,keep1,keep2.∀x. bool_to_Prop (a_return_post … x ∈ dom) → (x ∈ keep1) = (x ∈ keep2).
650
651
652lemma same_to_keep_on_append : ∀p.∀dom1,dom2,dom3 : list (CostLabel p).
653∀l1,l2,l3,l : list (ReturnPostCostLabel p).
654no_duplicates … (dom1@dom2@dom3) → (∀x.x ∈ l1 → a_return_post … x ∈ dom1) →
655(∀x.x ∈ l3 → a_return_post … x ∈ dom3) →
656same_to_keep_on … (dom1@dom2@dom3) (l1@l2@l3) l →
657same_to_keep_on … dom2 l2 l.
658#p #dom1 #dom2 #dom3 #l1 #l2 #l3 #l #no_dup #sub_set1 #sub_set3 #H2
659#x #Hx inversion (x ∈ l2)
660 [ #EQkeep <H2 [> memb_append_l2 // >memb_append_l1 // ]
661   >memb_append_l2 // >memb_append_l1 // >Hx //
662 | #EQno_keep <H2
663   [2: >memb_append_l2 // >memb_append_l1 // >Hx //
664   | @sym_eq @memb_not_append [2: @memb_not_append //]
665   [ <associative_append in no_dup; #no_dup ]
666   lapply(memb_no_duplicates_append … (a_return_post … x) … no_dup) #H
667   inversion(memb ???) // #H1 cases H
668   [1,4: [>memb_append_l2 | >memb_append_l1] // >Hx //
669   | @sub_set3 >H1 //
670   | @sub_set1 >H1 //
671   ]
672   ]
673 ]
674qed.
675
676lemma same_fresh_map_on_append : ∀p.∀dom1,dom2,dom3,l1,l2,l3,l.
677no_duplicates … (dom1 @dom2 @ dom3) → (∀x.x ∈ domain_of_associative_list … l1 → x ∈ dom1) →
678(∀x.x ∈ domain_of_associative_list … l3 → x ∈ dom3) →
679same_fresh_map_on p … (dom1 @dom2 @dom3) (l1 @l2 @ l3) l →
680same_fresh_map_on p … dom2 l2 l.
681#p #dom1 #dom2 #dom3 #l1 #l2 #l3 #l #no_dup #subset1 #subset3 whd in ⊢ (% → ?); #H1
682whd #x #Hx <H1
683[2: >memb_append_l2 // >memb_append_l1 // >Hx //]
684>get_element_append_r [ >get_element_append_l1 // ] % #K
685[ lapply(subset3 … K) | lapply(subset1 … K) ] #ABS
686[ <associative_append in no_dup; #no_dup] @(memb_no_duplicates_append … x … no_dup)
687// [>memb_append_l2 | >memb_append_l1 ] // >Hx //
688qed.
689
690
691lemma lab_to_keep_in_domain : ∀p,l_p.∀i : Instructions p l_p.
692∀x,n,l.
693x ∈ lab_to_keep … (call_post_trans … i n l) → a_return_post … x ∈ get_labels_of_code …  i.
694#p #l_p #i elim i //
695[ #seq #opt_l #instr #IH #x #n #l whd in match (call_post_trans ????);
696  cases opt_l -opt_l normalize nodelta [|#lbl]
697  whd in match (get_labels_of_code ??); #H [2: @orb_Prop_r] /2/
698| #cond #ltrue #i1 #lfalse #i2 #i3 #IH1 #IH2 #IH3 #x #n #l
699  whd in match (call_post_trans ????); whd in match (get_labels_of_code ??);
700  #H cases(memb_append … H) -H #H @orb_Prop_r @orb_Prop_r
701  [ >memb_append_l1 // @IH1 [3: >H // |*: ]
702  | >memb_append_l2 // cases(memb_append … H) -H #H
703     [>memb_append_l1 // @IH2 [3: >H // |*: ]
704     | >memb_append_l2 // @IH3 [3: >H // |*: ]
705     ]
706  ]
707| #loop #ltrue #i1 #lfalse #i2 #IH1 #IH2 #x #n #l
708  whd in match (call_post_trans ????); whd in match (get_labels_of_code ??);
709  #H cases(memb_append … H) -H #H @orb_Prop_r @orb_Prop_r
710  [ >memb_append_l1 | >memb_append_l2 ] // [ @IH1 | @IH2 ] [3,6: >H |*: ] //
711| #f #act_p * [|#lbl] #i1 #IH #x #n #l whd in match (call_post_trans ????);
712  whd in match (get_labels_of_code ??); /2/ whd in match (memb ???);
713  inversion(x == lbl) #Hlbl normalize nodelta
714  [*  >(\P Hlbl) @orb_Prop_l @eq_costlabel_elim // * #H @H %
715  | #H @orb_Prop_r @IH //
716  ]
717| #lin #io #lout #i1 #IH #x #n #l whd in match (call_post_trans ????);
718  whd in match (get_labels_of_code ??); #H @orb_Prop_r @orb_Prop_r @IH //
719]
720qed.
721
722lemma lab_map_in_domain: ∀p,l_p.∀i: Instructions p l_p.
723 ∀x,n,l.
724  x ∈ domain_of_associative_list … (lab_map … (call_post_trans … i n l)) →
725   x ∈ get_labels_of_code … i.
726#p #l_p #i elim i //
727[ #seq * [|#lbl] #i1 #IH #x #n #l whd in match(call_post_trans ????);
728  whd in match (get_labels_of_code ??); /2/ whd in match (memb ???);
729  inversion(x==lbl) #Hlbl normalize nodelta [#_ whd in match (memb ???); >Hlbl % ]
730  #H >memb_cons // @IH //
731| #cond #ltrue #i1 #lfalse #i2 #i3 #IH1 #IH2 #IH3 #x #n #l
732  whd in match (call_post_trans ????); whd in match (memb ???);
733  whd in match (get_labels_of_code ??); inversion(x == ltrue) #Hlbl normalize nodelta
734  [ #_ whd in match (memb ???); >Hlbl % ] whd in match (memb ???);
735  inversion(x == lfalse) #Hlbl1 normalize nodelta
736  [ #_ whd in match (memb ???); >Hlbl normalize nodelta whd in match (memb ???);
737    >Hlbl1 % ] #H >memb_cons // >memb_cons // >domain_of_associative_list_append in H;
738    #H cases(memb_append … H) [ #H1 >memb_append_l1 // @IH1 [3: >H1 // |*:] ]
739    >domain_of_associative_list_append #H1 cases(memb_append … H1)
740    #H2 >memb_append_l2 // [ >memb_append_l1 | >memb_append_l2 ] //
741    [ @IH2 | @IH3] /2 by eq_true_to_b/
742| #loop #ltrue #i1 #lfalse #i2 #IH1 #IH2 #x #n #l whd in match (call_post_trans ????);
743  whd in match (get_labels_of_code ??); whd in match (memb ???); inversion(x == lfalse)
744  #Hlfalse normalize nodelta [ #_ >memb_cons // whd in match (memb ???); >Hlfalse // ]
745  whd in match (memb ???); inversion(x==ltrue) normalize nodelta #Hltrue
746  [ #_ whd in match (memb ???); >Hltrue %] >domain_of_associative_list_append #H
747  cases(memb_append … H) #H1 >memb_cons // >memb_cons // [ >memb_append_l1 | >memb_append_l2 ]
748  // [ @IH1 | @IH2] /2/
749| #f #act_p * [|#lbl] #i1 #IH #x #n #l whd in match (call_post_trans ????);
750  whd in match (get_labels_of_code ??); /2/ whd in match (memb ???); inversion (x == lbl)
751  #Hlbl normalize nodelta [ #_ whd in match (memb ???); >Hlbl % ] #H >memb_cons // @IH /2/
752| #lin #io #lout #i1 #IH #x #n #l whd in match (memb ???); inversion(x == lout) #Hlout
753  normalize nodelta [ #_ >memb_cons // whd in match (memb ???); >Hlout % ]
754  whd in match (memb ???); inversion(x==lin) #Hlin normalize nodelta
755  [ #_ whd in match (memb ???); >Hlin % ] #H >memb_cons // >memb_cons // @IH /2/
756]
757qed.
758
759let rec is_fresh_for_return (p : label_params) (keep : list (CostLabel p)) (n : p) on keep : Prop ≝
760match keep with
761[ nil ⇒ True
762| cons x xs ⇒ let ih ≝ is_fresh_for_return … xs n in
763              match x with
764              [ a_return_post y ⇒ match y with [a_return_cost_label m ⇒ m ⊑^{p} n ∧ ih ]
765              | _ ⇒ ih
766              ]
767].
768
769lemma fresh_ok_call_post_trans : ∀p : instr_params.∀l_p.∀i1 : Instructions p l_p.∀n : l_p.∀l.
770n ⊑^{l_p} fresh … (call_post_trans … i1 n l).
771#p #l_p #i1 elim i1 normalize /2 by trans_po_rel, refl_po_rel/
772[ #seq * [|#lbl] #i2 #IH #n #l normalize /2 by /
773| #cond #ltrue #i_true #lfalse #i_false #i2 #IH1 #IH2 #IH3 #n #l
774  @(trans_po_rel … (IH3 …)) [2: @(trans_po_rel … (IH2 …)) [2: @(trans_po_rel … (IH1 …)) ]] //
775| #f #act_p * [|#lbl] normalize #i2 #IH /2 by / #n #l @(trans_po_rel … (IH … l …)) @lab_po_rel_succ
776]
777qed.
778
779lemma fresh_keep_n_ok : ∀p : label_params.∀n,m.∀l.
780is_fresh_for_return p l n → n ⊑^{p} m → is_fresh_for_return p l m.
781#p #n #m #l lapply n -n lapply m -m elim l // *
782[1,2,3: * #x] #xs #IH #n #m
783normalize [2: * #H1] #H2 #H3 [ %] /2 by trans_po_rel/ @(IH … H2) assumption
784qed.
785
786definition cast_return_to_cost_labels ≝ λp.map … (a_return_post p …).
787coercion cast_return_to_cost_labels.
788
789lemma succ_label_leq_absurd : ∀p : label_params.∀x : p.succ_label … p … x ⊑^{p} x → False.
790#p #x #ABS @(absurd ?? (no_maps_in_id … p x)) @(antisym_po_rel … (po_label … p)) //
791qed.
792
793lemma fresh_false : ∀p.∀n.∀l: list (ReturnPostCostLabel p).is_fresh_for_return … l n →
794a_return_cost_label p (succ_label … n) ∈ l = false.
795#p #n #l lapply n -n elim l // * #x #xs #IH #n whd in ⊢ (% → ??%?); * #H1
796#H2 @eq_return_cost_lab_elim
797[ #EQ destruct @⊥ @succ_label_leq_absurd //
798| #_ >IH //
799]
800qed.
801
802lemma inverse_call_post_trans : ∀p : instr_params.∀l_p : label_params.∀i1 : Instructions p l_p.∀n : l_p.
803let dom ≝ get_labels_of_code … i1 in
804no_duplicates … dom →
805∀m,keep.
806∀info,l.call_post_trans … i1 n l = info →
807same_fresh_map_on … dom (lab_map … info) m →
808same_to_keep_on … dom (lab_to_keep … info) keep →
809is_fresh_for_return … keep n →
810call_post_clean … (t_code … info) m keep l
811 = return 〈gen_labels … info,i1〉.
812#p #l_p #i1 elim i1
813[ #n #no_dup #m #keep * #gen_lab #t_code #fresh #lab_map #lab_keep #l whd in ⊢ (??%? → ?);
814  #EQ destruct(EQ) //
815| #x #n #no_dup #m #keep * #gen_lab #t_code #fresh #lab_map #lab_keep #l whd in ⊢ (??%? → ?);
816  #EQ destruct(EQ) //
817| #seq * [|#lbl] #instr #IH #n #no_dup #m #keep * #gen_lab #t_code #fresh #lab_map #lab_keep
818  #l whd in ⊢ (??%? → ?); #EQ destruct(EQ) #H1 #H2 #H3 whd in ⊢ (??%%); normalize nodelta
819  >IH //
820  [1,4: whd whd in H2; #x #Hx @H2 whd in match (get_labels_of_code ??); //
821  |2,5: whd whd in H1; #x #Hx [ @H1 // ] cases no_dup #H3 #_ <H1
822       [2: whd in match (get_labels_of_code ??); @orb_Prop_r // ]
823       whd in ⊢ (???%); cases(eqb_true … x lbl) inversion(x == lbl) normalize nodelta
824       [2: //] #_ #H4 >H4 in Hx; // #H5 >H5 in H3; * #ABS @⊥ @ABS %
825  |6: cases no_dup //
826  ]
827  normalize nodelta <(H1 lbl)
828  [2: whd in match (get_labels_of_code ??); @orb_Prop_l cases(eqb_true … (a_non_functional_label … lbl) lbl)
829      #H3 #H4 >H4 % ]
830  whd in match (get_element ????); >(\b (refl …)) normalize nodelta
831  >(\b (refl …)) %
832| #cond #ltrue #i1 #lfalse #i2 #i3 #IH1 #IH2 #IH3 #n normalize nodelta
833  #no_dup #m #keep * #gen_lab #t_code #fresh #lab_map #lab_keep #l whd in ⊢ (??%? → ?);
834  #EQ destruct(EQ) #H1 #H2 #H3 whd in ⊢ (??%?); >IH3 //
835  [2: whd  in match (get_labels_of_code ??) in H2;
836      change with ([?;?]@?) in match (?::?) in H2;
837      <associative_append in H2; <associative_append
838      <(append_nil … (?@?)) <associative_append in ⊢ (???%? → ?);
839      <(append_nil … (?@?)) in ⊢ (???%? → ?); >associative_append
840      >associative_append in ⊢ (???%? → ?); #H2
841      @(same_to_keep_on_append … H2) // [ >append_nil
842      whd in ⊢ (??%); whd in no_dup:(??%); >associative_append // ]
843      #x #Hx cases (memb_append … Hx) -Hx #Hx @orb_Prop_r @orb_Prop_r
844      [ >memb_append_l1 | >memb_append_l2 ] //
845      @(lab_to_keep_in_domain … (eq_true_to_b … Hx))
846  |3: -H2 whd in match (get_labels_of_code ??) in H1;
847      change with ([?;?]@?) in match (?::?) in H1;
848      <associative_append in H1; <associative_append     
849      <(append_nil … (?@?)) >associative_append
850      change with ([?;?]@?) in match (?::?::?) in ⊢ (???%? → ?);
851      <associative_append in ⊢ (???%? → ?);
852      <associative_append in ⊢ (???%? → ?);
853      <(append_nil … (?@?)) in ⊢ (???%? → ?);
854      >associative_append in ⊢ (???%? → ?); #H1
855      @(same_fresh_map_on_append … H1) //
856      [ >append_nil >associative_append // ]
857      #x whd in match (memb ???); inversion(x == ltrue)
858      [ #Hltrue normalize nodelta #_ whd in match (memb ???); >Hltrue %
859      | #Hltrue normalize nodelta whd in match (memb ???); inversion(x == lfalse)
860         [ #Hlfalse #_ @orb_Prop_r @orb_Prop_l >Hlfalse %
861         | #Hlfalse normalize nodelta #Hx @orb_Prop_r @orb_Prop_r
862           >domain_of_associative_list_append in Hx; #H
863           cases(memb_append … H) #H2 [ >memb_append_l1 | >memb_append_l2 ]
864           // @(lab_map_in_domain … (eq_true_to_b … H2))
865         ]
866      ]
867  |4: cases no_dup #_ * #_ #H @no_duplicates_append_r [2: @(no_duplicates_append_r … H) |]
868  ]
869  normalize nodelta >IH2
870  [5: %
871  |2: /2 by fresh_keep_n_ok/
872  |3: whd  in match (get_labels_of_code ??) in H2;
873   change with ([?;?]@?) in match (?::?) in H2;
874   <associative_append in H2; #H2
875   @(same_to_keep_on_append … H2) // #x #Hx [ @orb_Prop_r @orb_Prop_r ]
876   @(lab_to_keep_in_domain … (eq_true_to_b … Hx))
877  |4: whd  in match (get_labels_of_code ??) in H1;
878   change with ([?;?]@?) in match (?::?) in H1;
879   change with ([?;?]@?) in match (?::?::?) in H1 : (???%?);
880   <associative_append in H1; <associative_append in ⊢ (???%? → ?); #H1
881   @(same_fresh_map_on_append … H1) // [2: /2 by lab_map_in_domain/ ]
882   #x >domain_of_associative_list_append #H cases(memb_append … H)
883   [ whd in ⊢ (??%? → ?%); cases(x == ltrue) // normalize nodelta
884     whd in ⊢ (??%? → ?%); cases(x == lfalse) // normalize nodelta
885     normalize #EQ destruct
886   | #H1 @orb_Prop_r @orb_Prop_r
887     @(lab_map_in_domain … (eq_true_to_b … H1))
888   ]
889  |6: cases no_dup #_ * #_ #K lapply (no_duplicates_append_r … K) @no_duplicates_append_l
890  |*:
891  ]
892  >m_return_bind >IH1
893  [5: %
894  |2: /3 by fresh_keep_n_ok/
895  |3:  whd  in match (get_labels_of_code ??) in H2;
896   change with ([?;?]@?) in match (?::?) in H2;
897   change with ([ ] @ ?) in match (lab_to_keep ???) in H2;
898   >associative_append in H2 : (???%?); #H2
899   @(same_to_keep_on_append … H2) //  #x #Hx cases(memb_append … Hx)
900   -Hx #Hx [ >memb_append_l1 | >memb_append_l2] //
901   @(lab_to_keep_in_domain … (eq_true_to_b … Hx))
902  |4:  whd  in match (get_labels_of_code ??) in H1;
903   change with ([?;?]@?) in match (?::?) in H1;
904   change with ([?;?]@?) in match (?::?::?) in H1 : (???%?);
905    @(same_fresh_map_on_append … H1) // #x >domain_of_associative_list_append
906    #Hx cases(memb_append … Hx) -Hx #Hx [ >memb_append_l1 | >memb_append_l2 ]
907    // @(lab_map_in_domain … (eq_true_to_b … Hx))
908  |6: cases no_dup #_ * #_ @no_duplicates_append_l
909  |*:
910  ]
911  >m_return_bind normalize nodelta whd in H1; <H1
912  [2: whd in match (get_labels_of_code ??); whd in match (memb ???);
913      >(\b (refl …)) % ] whd in match (get_element ????); >(\b (refl …))
914      normalize nodelta >(\b (refl …)) <H1
915      [2: whd in match (get_labels_of_code ??); >memb_cons //
916      whd in match (memb ???); >(\b (refl …)) % ]
917      whd in match (get_element ????); @eq_costlabel_elim normalize nodelta
918      [ #ABS @⊥ cases no_dup >ABS * #H #_ @H @orb_Prop_l 
919      >(\b (refl ? (a_non_functional_label … ltrue))) % ] #_
920      whd in match (get_element ????); >(\b (refl …)) normalize nodelta
921      >(\b (refl …)) %
922| #loop #ltrue #i1 #lfalse #i2 #IH1 #IH2 #n #no_dup #m #keep #info #l whd in ⊢ (??%? → ?);
923  #EQ destruct(EQ) whd in match (get_labels_of_code ??); #fresh_map #keep_on #f_k
924  whd in ⊢ (??%?); >(IH2 … (refl …))
925  [ normalize nodelta >(IH1 … (refl …))
926    [ >m_return_bind <fresh_map [2: @orb_Prop_l >(\b (refl …)) % ]
927      whd in match (get_element ????);
928      inversion(a_non_functional_label … ltrue == a_non_functional_label … lfalse)
929      #Hltrue normalize nodelta
930      [ cases no_dup whd in match (memb ???);
931        cases(eqb_true … (a_non_functional_label … ltrue) (a_non_functional_label … lfalse))
932        #H1 #_ lapply(H1 Hltrue) #EQ destruct(EQ) >(\b (refl …)) * #ABS @⊥ @ABS % ]
933      whd in match (get_element ????); >(\b (refl …)) normalize nodelta >(\b (refl …))
934      <fresh_map [2: @orb_Prop_r @orb_Prop_l >(\b (refl …)) % ]
935      whd in match (get_element ????); >(\b (refl …)) normalize nodelta
936      >(\b (refl …)) %
937    | /2 by fresh_keep_n_ok/
938    | change with ([?;?]@?@?) in keep_on : (??%??); change with ((nil ?) @ ? @ ?) in keep_on : (???%?);
939      @(same_to_keep_on_append … keep_on) // #x /2 by lab_to_keep_in_domain/
940    | change with ([?;?]@?@?) in fresh_map : (??%%?); @(same_fresh_map_on_append … fresh_map)
941      /2 by lab_map_in_domain/ #x whd in match (memb ???); inversion(x==lfalse) #Hlfalse
942      normalize nodelta
943      [ #_ @orb_Prop_r whd in match (memb ???); >Hlfalse %
944      | whd in match (memb ???); inversion(x==ltrue) #Hltrue normalize nodelta [2: *] #_
945        @orb_Prop_l >Hltrue %
946      ]
947    | cases no_dup #_ * #_ /2/
948    ]
949  | //
950  | change with ([?;?]@?@?) in keep_on : (??%??); <associative_append in keep_on;
951    <(append_nil … (?@?)) <(append_nil … (?@?)) in ⊢ (???%? → ?);
952    >associative_append in ⊢ (??%%? → ?); >associative_append in ⊢ (???%? → ?);
953    #keep_on @(same_to_keep_on_append … keep_on) //
954    [ >associative_append >append_nil //
955    | #x #Hx @orb_Prop_r @orb_Prop_r /2 by lab_to_keep_in_domain/
956    ]
957  | change with ([?;?]@?@?) in fresh_map : (??%??); <associative_append in fresh_map;
958    <(append_nil … (?@?)) change with ([?;?]@?@?) in ⊢ (???%? → ?);
959    <associative_append in ⊢ (???%? → ?); <(append_nil … (?@?)) in ⊢ (???%? → ?);
960    >associative_append in ⊢ (??%%? → ?); >associative_append in ⊢ (???%? → ?);
961    #fresh_map @(same_fresh_map_on_append … fresh_map) //
962    [ >append_nil //
963    | #x >domain_of_associative_list_append #Hx cases(memb_append … Hx)
964      [2: #Hx1 @orb_Prop_r @orb_Prop_r @(lab_map_in_domain … (eq_true_to_b … Hx1)) ]
965      whd in match (memb ???); inversion(x == lfalse) normalize nodelta #Hlfalse
966      [ #_ @orb_Prop_r @orb_Prop_l >Hlfalse %
967      | whd in match (memb ???); inversion (x==ltrue) normalize nodelta #Hltrue
968        [ #_ @orb_Prop_l >Hltrue %
969        | whd in match (memb ???); #EQ destruct
970        ]
971      ]
972    ]
973  | cases no_dup #_ * #_ /2 by no_duplicates_append_r/
974  ]
975| #f #act_p * [|#r_lb] #i #IH #n #no_dup #m #keep #info #l whd in ⊢ (??%? → ?);
976  #EQ destruct(EQ) #fresh_map #same_keep #f_k whd in ⊢ (??%?);
977  >(IH … (refl …))
978  [1,6: normalize nodelta
979     [ >fresh_false [2: /2 by fresh_keep_n_ok/] %
980     | <same_keep
981       [ whd in match (memb ???); >(\b (refl …)) normalize nodelta
982         <fresh_map
983         [ whd in match (get_element ????); >(\b (refl …)) normalize nodelta
984           >(\b (refl …)) %
985         | whd in match (memb ???); >(\b (refl …)) %
986         ]
987       | whd in match (memb ???); >(\b (refl …)) %
988       ]
989    ]
990  |2,7: //
991  |3,8: whd in match (get_labels_of_code ???) in same_keep; // #x #Hx <same_keep
992        [2: >memb_cons // >Hx // ] cases no_dup * #ABS #_ whd in ⊢ (???%);
993        inversion(x==?) [2: #_ //] #ABS1 @⊥ @ABS <(\P ABS1) >Hx //
994  |4,9: whd in match (get_labels_of_code ???) in fresh_map; // #x #Hx <fresh_map
995        [2: >memb_cons // >Hx //] cases no_dup * #ABS #_ whd in ⊢ (???%);
996        inversion(x==?) [2: #_ //] #ABS1 @⊥ @ABS <(\P ABS1) //
997  |5,10: [ @no_dup | cases no_dup // ]
998  ]
999| #lin #io #lout #i #IH #n whd in match (get_labels_of_code ???); #no_dup
1000  #m #keep #info #l whd in ⊢ (??%? → ?); #EQ destruct(EQ) #fresh_map #same_keep
1001  #f_k whd in ⊢ (??%?); >(IH … (refl …))
1002  [ normalize nodelta <fresh_map [2: >memb_cons // >memb_hd // ]
1003    whd in match (get_element ????); >(\b (refl …)) normalize nodelta
1004    >(\b (refl …)) <fresh_map [2: >memb_hd //] whd in match (get_element ????);
1005    inversion(lin==lout)
1006    [ #ABS @⊥ cases no_dup * #ABS1 #_ @ABS1 whd in match (memb ???); >(\P ABS)
1007      >(\b (refl …)) //
1008    | #H inversion (a_non_functional_label … lin== ? lout)
1009      [ #ABS lapply(\P ABS) #EQ destruct >(\b (refl …)) in H; #EQ destruct
1010      | #_ normalize nodelta whd in match (get_element ????); >(\b (refl …))
1011        normalize nodelta >(\b (refl …)) %
1012      ]
1013    ]
1014  | //
1015  | #x #Hx >same_keep [2: >memb_cons // >memb_cons // >Hx % ] %
1016  | #x #Hx <fresh_map [2: >memb_cons // >memb_cons // >Hx %]
1017    cases no_dup * #ABS1 ** #ABS2 #_ whd in ⊢ (???%); inversion(x == lout)
1018    normalize nodelta
1019    [2: #_ whd in ⊢ (???%); inversion(x==lin) normalize nodelta //
1020        #H @⊥ @ABS1 >memb_cons // <(\P H) >Hx //
1021    | #H @⊥ @ABS2 <(\P H) >Hx //
1022    ]
1023  | cases no_dup #_ * #_ //
1024  ]
1025]
1026qed.
1027
1028definition fresh_for_prog_aux : ∀p,p',l_p.Program p p' l_p → l_p → l_p ≝
1029λp,p',l_p,prog,n.foldl … (λn,i.op … l_p … n (compute_max_n … (f_body … i))) n (env … prog).
1030
1031
1032lemma fresh_aux_ok : ∀p,p',l_p.∀prog : Program p p' l_p.∀n,m.n ⊑^{l_p} m →
1033fresh_for_prog_aux … prog n ⊑^{l_p} fresh_for_prog_aux … prog m.
1034#p #p' #l_p * #env #main elim env // #hd #tl #IH #n #m #H whd in ⊢ (???%%);
1035@IH whd in ⊢ (???%?); @(monotonic_magg … l_p … H)
1036qed.
1037
1038definition fresh_for_prog : ∀p,p',l_p.Program p p' l_p → l_p ≝
1039λp,p',l_p,prog.fresh_for_prog_aux … prog
1040(compute_max_n … (main … prog)).
1041
1042definition translate_env ≝
1043λp,p',l_p.λenv : list (env_item p p' l_p).λmax_all.(foldr ??
1044           (λi,x.let 〈t_env,n,m,keep〉 ≝ x in
1045           let info ≝ call_post_trans … (f_body … i) n (nil ?) in
1046                   〈(mk_env_item ???
1047                       (mk_signature ??(f_name ?? i) (f_pars … i) (f_ret … i))
1048                       (f_lab … i) (t_code … info)) :: t_env,
1049                     fresh … info, 〈a_call … (f_lab … i),(a_call … (f_lab … i)) :: (gen_labels ?? info)〉 ::
1050                                     ((lab_map … info) @ m),(lab_to_keep … info) @ keep〉)
1051          (〈nil ?,max_all,nil ?,nil ?〉) env).
1052
1053definition trans_prog : ∀p,p',l_p.Program p p' l_p →
1054((Program p p' l_p) × (associative_list (DEQCostLabel l_p) (CostLabel l_p)) × ((list (ReturnPostCostLabel l_p))))≝
1055λp,p',l_p,prog.
1056let max_all ≝ fresh_for_prog … prog in
1057let info_main ≝ (call_post_trans … (main … prog) max_all (nil ?)) in
1058let 〈t_env,n,m,keep〉 ≝ translate_env … (env … prog) (fresh … info_main) in
1059〈mk_Program ??? t_env (t_code … info_main),m @ (lab_map … info_main),keep @ (lab_to_keep … info_main)〉.
1060
1061definition map_labels_on_trace : ∀p : label_params.
1062(associative_list (DEQCostLabel p) (CostLabel p)) → list (CostLabel p) → list (CostLabel p) ≝
1063λp,m,l.foldr … (λlab,t.(get_element … m lab) @ t) (nil ?) l.
1064
1065lemma map_labels_on_trace_append:
1066 ∀p,m,l1,l2. map_labels_on_trace p m (l1@l2) =
1067  map_labels_on_trace p m l1 @ map_labels_on_trace p m l2.
1068#p #m #l1 elim l1 // #hd #tl #IH #l2 >associative_append <IH //
1069qed.
1070
1071include "../src/common/Errors.ma".
1072include "Permutation.ma".
1073
1074(*
1075
1076axiom is_permutation: ∀A.list A → list A → Prop.
1077axiom is_permutation_eq : ∀A.∀l : list A.is_permutation … l l.
1078axiom is_permutation_cons : ∀A.∀l1,l2,x.is_permutation A l1 l2 →
1079                                       is_permutation A (x :: l1) (x :: l2).
1080*)
1081(*
1082inductive is_permutation (A : Type[0]) : list A → list A → Prop ≝
1083| p_empty : is_permutation A (nil ?) (nil ?)
1084| p_append : ∀x,x1,x2,y,y1,y2.
1085               x = y → is_permutation A (x1 @ x2) (y1 @ y2) →
1086                 is_permutation A (x1 @ [x] @ x2) (y1 @ [y] @ y2).
1087
1088lemma is_permutation_eq : ∀A.∀l : list A.is_permutation … l l.
1089#A #l elim l // #x #xs #IH
1090change with ((nil ?) @ (x :: xs)) in ⊢ (??%%);
1091>append_cons >associative_append
1092@(p_append ? x (nil ?) xs x (nil ?) xs (refl …)) @IH
1093qed.
1094
1095lemma is_permutation_append : ∀A.∀l1,l2,l3,l4 : list A.
1096is_permutation A l1 l3 → is_permutation A l2 l4 →
1097is_permutation A (l1 @ l2) (l3 @ l4).
1098#A #l1 inversion (|l1|)  [2: #n lapply l1 elim n
1099[ #l2 #l3 #l4 #H inversion H // #x #x1 #x2 #y #y1 #y2 #EQ #H1 #_
1100 #ABS cases(nil_to_nil … (sym_eq ??? ABS)) -ABS #_ #ABS
1101 cases(nil_to_nil … ABS) #EQ1 destruct(EQ1) ]
1102#x #xs #IH #l2 #l3 #l4 #H inversion H
1103[#EQ lapply(jmeq_to_eq ??? EQ) -EQ #EQ destruct(EQ) ]
1104#y #y1 #y2 #z #z1 #z2 #EQ destruct(EQ) #H1 #_ #EQx_xs #EQ destruct(EQ) #_
1105*)
1106
1107
1108
1109lemma lookup_ok_append : ∀p,p',l_p,l,f,env_it.
1110lookup p p' l_p l f = return env_it → ∃l1,l2. l = l1 @ [env_it] @ l2 ∧
1111f_name … env_it = f.
1112#p #p' #l_p #l elim l [ #f #env_it normalize #EQ destruct]
1113#x #xs #IH #f #env_it whd in ⊢ (??%? → ?); @eq_function_name_elim
1114[ #EQ destruct(EQ) normalize nodelta whd in ⊢ (???% → ?); #EQ destruct
1115  %{(nil ?)} %{xs} /2/
1116| #Hno_f normalize nodelta #EQ_env_it cases(IH … EQ_env_it)
1117  #l1 * #l2 * #EQ1 #EQ2 %{(x :: l1)} %{l2} >EQ1 /2/
1118]
1119qed.
1120(*
1121lemma foldr_append :
1122  ∀A,B:Type[0]. ∀l1, l2 : list A. ∀f:A → B → B. ∀seed. foldr ?? f seed (l1 @ l2) = foldr ?? f (foldr ?? f seed l2) l1.
1123#A #B #l1 elim l1 //
1124#hd #tl #Hind #l2 #f #seed normalize >Hind @refl
1125qed.
1126*)
1127
1128
1129
1130(* aggiungere fresh_to_keep al lemma seguente??*)
1131
1132lemma fresh_for_subset : ∀p : label_params.∀l1,l2,n.l1 ⊆ l2 → is_fresh_for_return p … l2 n →
1133is_fresh_for_return p … l1 n.
1134#p #l1 elim l1 // * [1,2,3: * #x] #xs #IH #l2 #n * #H1 #H2 #H3 whd
1135try(@IH) // % [2: @IH //] elim l2 in H1 H3; normalize [*]
1136* [1,2,3: * #y] #ys #IH normalize
1137[2,3: * [2,4: #H3 [2: @IH //] * #H4 #H5 @IH //
1138|*: #EQ destruct * //
1139]]
1140*
1141[1,3: #EQ destruct ] #H3 #H4 @IH //
1142qed.
1143
1144lemma fresh_append : ∀p.∀n,l1,l2.is_fresh_for_return p l1 n → is_fresh_for_return p l2 n →
1145is_fresh_for_return p (l1@l2) n.
1146#p #n #l1 lapply n -n elim l1 // * [1,2,3: * #x] #xs #IH #n #l2 [2: * #H1 ] #H2 #H3
1147[ % // @IH //] @IH //
1148qed.
1149
1150definition labels_of_prog : ∀p,p',l_p.Program p p' l_p → ? ≝
1151λp,p',l_p,prog.foldr … (λx,l.l @ (get_labels_of_code … (f_body … x)))
1152 (get_labels_of_code … (main … prog)) (env … prog).
1153
1154lemma cast_return_append : ∀p.∀l1,l2.cast_return_to_cost_labels p … (l1 @ l2) =
1155(cast_return_to_cost_labels p … l1) @ (cast_return_to_cost_labels p … l2).
1156#p #l1 #l2 @(sym_eq … (map_append …)) qed.
1157
1158include alias "arithmetics/nat.ma".
1159
1160
1161lemma is_fresh_code : ∀p,l_p.∀i : Instructions p l_p.
1162is_fresh_for_return l_p (get_labels_of_code … i) (compute_max_n … i).
1163#p #l_p #main  elim main //
1164[ #seq * [| * #lbl] #i #IH normalize // @(fresh_keep_n_ok … IH) //
1165| #cond * #ltrue #i1 * #lfalse #i2 #i3 #IH1 #IH2 #IH3 whd in ⊢ (??%%);
1166  @fresh_append
1167  [ @(fresh_keep_n_ok … IH1) @max_1 @max_1 @max_1 @max_1 //
1168  | @fresh_append
1169    [ @(fresh_keep_n_ok … IH2) @max_1 @max_1 @max_1 @max_2 //
1170    | @(fresh_keep_n_ok … IH3) @max_1 @max_1 @max_2 //
1171    ]
1172  ]
1173| #cond * #ltrue #i1 * #lfalse #i2 #IH1 #IH2 whd in ⊢ (??%%); @fresh_append
1174  [ @(fresh_keep_n_ok … IH1) @max_1 @max_1 @max_1 //
1175  | @(fresh_keep_n_ok … IH2) @max_1 @max_1 @max_2 //
1176  ]
1177| #f #act_p * [| * #lbl] #i #IH whd in ⊢ (??%%); //
1178  change with ([?]@?) in ⊢ (??%?); @fresh_append
1179  [ whd % //
1180  | @(fresh_keep_n_ok … IH) @max_2 //
1181  ]
1182| * #lin #io * #lout #i #IH whd in ⊢ (??%%); @(fresh_keep_n_ok … IH)
1183  @max_1 @max_1 //
1184]
1185qed.
1186
1187lemma is_fresh_fresh_for_prog : ∀p,p',l_p.∀prog : Program p p' l_p.
1188is_fresh_for_return … (labels_of_prog … prog) (fresh_for_prog … prog).
1189#p #p' #l_p * #env #main whd in match fresh_for_prog; normalize nodelta whd in ⊢ (??%?);
1190elim env // * #sig #cost #i #tail #IH  whd in ⊢ (??%?); @fresh_append
1191[ @(fresh_keep_n_ok … IH) @fresh_aux_ok @max_1 //
1192| @(fresh_keep_n_ok … (is_fresh_code … i)) whd in match fresh_for_prog_aux; normalize nodelta
1193  whd in ⊢ (????%); elim tail [ @max_2 // ] #hd1 #tl1 #IH1 @(trans_po_rel …  IH1)
1194  whd in ⊢ (????%); change with (fresh_for_prog_aux ??? (mk_Program ??? tl1 main) ?) in ⊢ (???%%);
1195  @fresh_aux_ok @max_1 //
1196]
1197qed.
1198
1199lemma memb_cast_return : ∀p.∀keep,x.x ∈ cast_return_to_cost_labels p keep →
1200∃ y.x = a_return_post … y ∧ bool_to_Prop (y ∈ keep).
1201#p #keep elim keep
1202[ #x *] #x #xs #IH #y whd in match cast_return_to_cost_labels;
1203whd in match (map ????); whd in match (memb ???); inversion(y==x)
1204[ #Hx #_ %{x} >(\P Hx) %{(refl …)} >memb_hd //
1205| #Hx normalize nodelta #H cases(IH … H) #z * #H1 #H2 %{z} %{H1} >memb_cons // >H2 //
1206]
1207qed.
1208
1209lemma lab_to_keep_in_prog : ∀p,p',l_p.∀prog : Program p p' l_p.
1210∀t_prog,m,keep.trans_prog … prog = 〈t_prog,m,keep〉 →
1211(cast_return_to_cost_labels l_p keep) ⊆ (labels_of_prog p p' l_p prog).
1212#p #p' #l_p * #env #main #t_prog #m #keep whd in match trans_prog; normalize nodelta
1213@pair_elim * #env1 #fresh * #m1 #keep1 #EQenv1 normalize nodelta #EQ destruct
1214lapply EQenv1 -EQenv1 lapply keep1 -keep1 lapply m1 -m1 lapply fresh -fresh
1215lapply env1 -env1 generalize in match (fresh_for_prog ????); elim env
1216[ #n #t_env #n1 #m #keep whd in ⊢ (??%? → ?); #EQ destruct whd in match (append ???);
1217  @subset_def #x #H whd in match (labels_of_prog); normalize nodelta
1218  whd in match (foldr ?????); cases(memb_cast_return … H) -H #x1 * #EQ1 #H destruct
1219  @(lab_to_keep_in_domain … H)
1220| #x #xs #IH #n #t_env #n1 #m #keep whd in ⊢ (??%? → ?); @pair_elim
1221  * #t_env_tail #fresh_tail * #t_m_tail #t_keep_tail
1222  change with (translate_env ?????) in match (foldr ?????); #EQt_env_tail
1223  normalize nodelta #EQ1 destruct >cast_return_append @subset_append
1224  [ >cast_return_append @subset_append
1225    [ whd in match labels_of_prog; normalize nodelta whd in match (foldr ?????);
1226      @subset_def #y #H cases(memb_cast_return … H) -H #y1 * #EQ destruct #H
1227      >memb_append_l2 // @(lab_to_keep_in_domain … H)
1228    | whd in match labels_of_prog; normalize nodelta whd in match (foldr ?????);
1229      change with (labels_of_prog ??? (mk_Program ??? xs ?)) in match (foldr ?????);
1230      @subset_append_h1 @(transitive_subset … (IH … EQt_env_tail))
1231      >cast_return_append @subset_append_h1 //
1232    ]
1233  | whd in match labels_of_prog; normalize nodelta whd in match (foldr ?????);
1234    change with (labels_of_prog ??? (mk_Program ??? xs ?)) in match (foldr ?????);
1235    @subset_append_h1 @(transitive_subset … (IH … EQt_env_tail))
1236     >cast_return_append @subset_append_h2 //
1237  ]
1238]
1239qed.
1240
1241lemma fresh_call_post_trans_ok : ∀p,l_p.∀i : Instructions p l_p.∀n,l.
1242n ⊑^{l_p} fresh … (call_post_trans … i n l).
1243#p #l_p #i elim i //
1244qed.
1245
1246lemma fresh_translate_env_ok : ∀p,p',l_p.∀env,t_env : list (env_item p p' l_p).∀n,n1,m,keep.
1247translate_env … env n = 〈t_env,n1,m,keep〉 → n ⊑^{l_p} n1.
1248#p #p' #l_p #env elim env
1249[ #t_env #n #n1 #m #keep whd in ⊢ (??%? → ?); #EQ destruct // ]
1250#x #xs #IH #t_env #n #n1 #m #keep whd in ⊢ (??%? → ?);
1251change with (translate_env ?????) in match (foldr ?????); @pair_elim
1252* #t_env_tail #fresh_tail * #t_m_tail #t_keep_tail #EQt_env_tail normalize nodelta
1253#EQ destruct @(trans_po_rel … (IH … EQt_env_tail)) @fresh_call_post_trans_ok
1254qed.
1255 
1256
1257lemma trans_env_ok : ∀p : state_params.∀ prog.
1258no_duplicates_labels … prog →
1259let 〈t_prog,m,keep〉 ≝ trans_prog … prog in
1260∀f,env_it.lookup p p p (env … prog) f = return env_it →
1261let dom ≝ get_labels_of_code … (f_body … env_it) in
1262∃env_it',n.is_fresh_for_return p keep n ∧lookup p p p (env … t_prog) f = return env_it' ∧
1263let info ≝ call_post_trans … (f_body … env_it) n (nil ?) in
1264t_code … info = f_body … env_it' ∧
1265get_element … m (a_call … (f_lab … env_it')) = (a_call … (f_lab … env_it')) :: gen_labels … info ∧
1266f_sig … env_it = f_sig … env_it' ∧ f_lab … env_it = f_lab … env_it' ∧
1267same_fresh_map_on … dom m (lab_map … info) ∧ same_to_keep_on … dom keep (lab_to_keep … info).
1268#p #prog inversion(trans_prog … prog) * #t_prog0 #m0 #keep0 #EQt_prog
1269lapply EQt_prog normalize nodelta
1270generalize in match keep0 in ⊢ (% → ? → ? → ? → ? → ??(λ_.??(λ_.?%?)));
1271#keep1 #EQkeep1 inversion prog in EQt_prog; #env #main #EQprog
1272whd in match trans_prog; normalize nodelta
1273@pair_elim
1274cut(fresh_for_prog ??? prog ⊑^{p} fresh_for_prog ??? (mk_Program … env main)) [ >EQprog //]
1275generalize in match (fresh_for_prog ????) in ⊢ (????% → %);
1276lapply t_prog0 lapply m0 lapply keep0
1277elim env in ⊢ (?→ ? → ? → ? → ? → %);
1278[ #keep #m #t_prog #n #_ * #env' #fresh * #x #y #_ #_ #_ #f #env_it normalize in ⊢ (% → ?);  #ABS destruct]
1279* #hd_sig #hd_lab #hd_code #tail #IH #keep #m #t_prog #fresh1 #Hfresh1 * #env' #fresh * #m' #keep'
1280normalize in ⊢ (% → ?); normalize nodelta @pair_elim * #env_tail #fresh_tail
1281* #m_tail #keep_tail change with (translate_env ?????) in ⊢ (??%? → ?); #EQtail normalize nodelta #EQ1 destruct(EQ1) #EQ2 destruct(EQ2)
1282whd in ⊢ (% → ?); whd in match (foldr ?????); * #Hhd_lab #H lapply(no_duplicates_append_r … H)
1283change with (no_duplicates_labels p p p (mk_Program p p p tail main)) in match
1284(no_duplicates_labels p p p (mk_Program p p p tail main)); #no_dup_tail
1285lapply(no_duplicates_append_l … H) #no_dup_head normalize nodelta
1286#f #env_it whd in ⊢ (??%? → ?); @eq_function_name_elim normalize nodelta
1287[ #EQ destruct(EQ) whd in ⊢ (???% → ?); #EQ destruct(EQ)
1288  inversion (call_post_trans … hd_code fresh_tail [])
1289  #gen_labs #t_hd_code #t_fresh #t_lab_map #t_lab_to_keep #EQ_trans_code
1290  %{(mk_env_item … hd_sig hd_lab t_hd_code)} %{fresh_tail} %
1291  [ %
1292    [ @(fresh_keep_n_ok … fresh1)
1293      [ @(fresh_keep_n_ok … Hfresh1)
1294        @(fresh_for_subset … (labels_of_prog … prog))
1295        [ @(lab_to_keep_in_prog … EQkeep1) | @is_fresh_fresh_for_prog ]
1296       | @(trans_po_rel … (fresh_translate_env_ok … EQtail)) //
1297      ]
1298    | whd in ⊢ (??%?); @eq_function_name_elim [2: * #H @⊥ @H %] #_ normalize nodelta
1299      @eq_f cases hd_sig // ]] >EQ_trans_code % [% [ % [ % [% // whd in ⊢ (??%?); >(\b (refl …)) %] % ] % | whd
1300    #x #Hx whd in ⊢ (??%?); >(? : (x == hd_lab) = false)
1301    [2: inversion(x==hd_lab) // #EQx_hdlab cases Hhd_lab -Hhd_lab #Hhd_lab cases Hhd_lab
1302        >memb_append_l1 // <(\P EQx_hdlab) >Hx // ]
1303    normalize nodelta >get_element_append_l1
1304    [2: % #ABS @(memb_no_duplicates_append … x … H) // elim tail
1305        [ whd in match (foldr ?????); @lab_map_in_domain // ]
1306        #x #xs #IH whd in match (foldr ?????); @orb_Prop_r
1307        >memb_append_l2 // >IH %
1308    ] @get_element_append_l1
1309    % #H1 
1310    (* subproof with no nice statement *)
1311    lapply H1 -H1 lapply H -H lapply Hhd_lab -Hhd_lab lapply EQtail -EQtail
1312    generalize in match fresh1; lapply env_tail -env_tail lapply fresh_tail
1313    -fresh_tail lapply m_tail -m_tail lapply keep_tail -keep_tail elim tail
1314    normalize nodelta
1315    [ #keep_tail #m_tail #fresh_tail #env_tail #n whd in ⊢ (??%? → ?);
1316      #EQ destruct(EQ) whd in match (foldr ?????);
1317      #H1 #H2 * ]
1318    #head #tail #IH #keep_tail #m_tail #fresh_tail #env_tail #n whd in ⊢ (??%? → ?);
1319    whd in match (foldr ?????);
1320    @pair_elim * #env_tail_res #fresh_tail_res * #lab_map_res #keep_res #EQres
1321    normalize nodelta #EQ destruct(EQ) whd in match (foldr ?????);
1322    #H1 #H2 whd in match (memb ???); inversion(x == ?)
1323    [ #H3 #_ <(\P H3) in H2; change with ([?]@?) in match (?::?); #H2
1324      lapply(no_duplicates_append_commute … H2) -H2 ** #ABS #_ @ABS
1325      >memb_append_l2 // >Hx %
1326    | #H3 normalize nodelta #H4 @(IH … EQres)
1327      [3: >domain_of_associative_list_append in H4; #H4 cases(memb_append … H4) [2: #EQ >EQ %]
1328          #ABS @⊥ @(memb_no_duplicates_append … x … H2) // @orb_Prop_r >memb_append_l1 //
1329          @(lab_map_in_domain … (eq_true_to_b … ABS))
1330      | % #ABS elim H1 -H1 #H1 @H1 cases(memb_append … ABS)
1331        [ #H5 >memb_append_l1 //
1332        | #H5 >memb_append_l2 // @orb_Prop_r >memb_append_l2 //
1333        ]
1334      | lapply(no_duplicates_append_commute … H2) * #_ >associative_append
1335        #h @no_duplicates_append_commute @(no_duplicates_append_r … h)
1336      ]
1337    ]
1338    ]
1339  | whd #x #Hx >memb_append_l12
1340    [2: @notb_Prop % #ABS @(memb_no_duplicates_append … H … Hx) elim tail
1341        [ whd in match (foldr ?????); @lab_to_keep_in_domain // ]
1342        #x #xs #IH whd in match (foldr ?????); @orb_Prop_r
1343        >memb_append_l2 // >IH %
1344    ]
1345    >memb_append_l12 // inversion(memb ???) // #ABS @(memb_no_duplicates_append … (a_return_post … x) … H)
1346    // @⊥
1347    (* subproof with no nice statement *)
1348    lapply ABS -ABS lapply H -H lapply Hhd_lab -Hhd_lab lapply EQtail -EQtail
1349    generalize in match fresh1; lapply env_tail -env_tail lapply fresh_tail
1350    -fresh_tail lapply m_tail -m_tail lapply keep_tail -keep_tail elim tail
1351    normalize nodelta
1352    [ #keep_tail #m_tail #fresh_tail #env_tail #n whd in ⊢ (??%? → ?);
1353      #EQ destruct(EQ) whd in match (foldr ?????);
1354      #H1 #H2 whd in ⊢ (??%? → ?); #EQ destruct ]
1355    #head #tail #IH #keep_tail #m_tail #fresh_tail #env_tail #n whd in ⊢ (??%? → ?);
1356    whd in match (foldr ?????);
1357    @pair_elim * #env_tail_res #fresh_tail_res * #lab_map_res #keep_res #EQres
1358    normalize nodelta #EQ destruct(EQ) whd in match (foldr ?????);
1359    #H1 #H2 #H3 cases(memb_append … H3) -H3
1360    [ #H3 change with ([?]@?) in match (?::?) in H2;
1361      lapply(no_duplicates_append_commute … H2) -H2 * #_ #H4 @(memb_no_duplicates_append … (a_return_post … x) … H4)
1362      [ whd in match (append ???); >memb_append_l1 // >(lab_to_keep_in_domain … (eq_true_to_b … H3)) %
1363      | //
1364      ]
1365    | #H3 normalize nodelta @(IH … EQres)
1366      [3: //
1367      |  % #ABS elim H1 -H1 #H1 @H1 cases(memb_append … ABS)
1368        [ #H5 >memb_append_l1 //
1369        | #H5 >memb_append_l2 // @orb_Prop_r >memb_append_l2 //
1370        ]
1371      | lapply(no_duplicates_append_commute … H2) * #_ >associative_append
1372        #h @no_duplicates_append_commute @(no_duplicates_append_r … h)
1373      ]
1374    ]
1375  ]
1376| #Hf #Henv_it cases(IH … no_dup_tail … Henv_it)
1377  [9: >EQtail in ⊢ (??%?); %
1378  |13: %
1379  |6: assumption
1380  |10: %
1381  |*:
1382  ]
1383  #new_env_it * #new_fresh ** #is_fresh_newfresh #EQlook_new_env_it ***** #EQt_code #EQ_get_el
1384  #EQsign_env_it #EQ_f_lab #same_fresh_map #same_to_keep %{new_env_it} %{new_fresh}
1385  %
1386  [ %
1387     [ assumption
1388     | whd in ⊢ (??%?); @eq_function_name_elim [ #ABS >ABS in Hf; * #H @⊥ @H %]
1389        #_ normalize nodelta assumption ]]
1390   % [2: #x #Hx <same_to_keep // >associative_append @memb_append_l22
1391        inversion(memb ???) // #ABS lapply(lab_to_keep_in_domain … (eq_true_to_b … ABS))
1392        #ABS1 @(memb_no_duplicates_append … (a_return_post … x) … H) //
1393        cases(lookup_ok_append … Henv_it) #l1 * #l2 * #EQ1 #EQ2 destruct(EQ1 EQ2)
1394        >foldr_map_append >memb_append_l2 // >foldr_map_append >memb_append_l1 //
1395        whd in match (foldr ?????); @orb_Prop_r >memb_append_l1 // >Hx % ]
1396   % [2: #x #Hx <same_fresh_map // >cons_append <associative_append
1397         <associative_append in ⊢ (??(???(??%?)?)?); >associative_append
1398         @(get_element_append_r1)
1399         % >domain_of_associative_list_append #ABS cases(memb_append … ABS)
1400         [ whd in match (memb ???); inversion(x==hd_lab) normalize nodelta
1401           [2: #_ whd in match (memb ???); #EQ destruct ] #EQx_hdlab #_
1402               <(\P EQx_hdlab) in Hhd_lab; cases(lookup_ok_append … Henv_it)
1403               #tail1 * #tail2 * #EQ1 #EQ2 destruct >foldr_map_append >foldr_map_append
1404               * #ABS1 @ABS1 >memb_append_l2 // >memb_append_l2 //
1405               >memb_append_l1 // whd in ⊢ (??%?); cases(x==?) //
1406               normalize nodelta >memb_append_l1 // >Hx %
1407         | #ABS1 @(memb_no_duplicates_append … x … H)
1408           [ @(lab_map_in_domain … (eq_true_to_b … ABS1))
1409           | cases(lookup_ok_append … Henv_it)
1410             #tail1 * #tail2 * #EQ1 #EQ2 destruct >foldr_map_append >foldr_map_append
1411             >memb_append_l2 // >memb_append_l1 //
1412             whd in ⊢ (??%?); cases(x==?) //
1413             normalize nodelta >memb_append_l1 // >Hx %
1414           ]
1415         ]
1416     ] 
1417   % // % // % // <EQ_get_el >cons_append <associative_append  <associative_append in ⊢ (??(???(??%?)?)?);
1418   >associative_append
1419   @get_element_append_r1 % >domain_of_associative_list_append #ABS cases(memb_append … ABS)
1420         [ whd in match (memb ???); inversion(a_call … (f_lab … new_env_it)== a_call … hd_lab)
1421           #EQ_hdlab normalize nodelta
1422           [2: whd in ⊢ (??%? → ?); #EQ destruct ] 
1423           #_ <(\P EQ_hdlab) in Hhd_lab; cases(lookup_ok_append … Henv_it)
1424           #tail1 * #tail2 * #EQ1 #EQ2 destruct >foldr_map_append >foldr_map_append
1425           * #ABS1 @ABS1 >memb_append_l2 // >memb_append_l2 //
1426           >memb_append_l1 // whd in ⊢ (??%?); >EQ_f_lab >(\b (refl …)) //
1427         | #ABS1 @(memb_no_duplicates_append … (a_call … (f_lab … new_env_it)) … H)
1428           [ @(lab_map_in_domain … (eq_true_to_b … ABS1))
1429           | cases(lookup_ok_append … Henv_it)
1430             #tail1 * #tail2 * #EQ1 #EQ2 destruct >foldr_map_append >foldr_map_append
1431             >memb_append_l2 // >memb_append_l1 //
1432             whd in ⊢ (??%?); >EQ_f_lab >(\b (refl …)) //
1433           ]
1434         ]
1435]
1436qed.
1437
1438(*
1439axiom permute_ok : ∀A.∀l1,l2,l3,l4,l5,l6,l7,l8,l9,x,y.
1440  (is_permutation A ((l5 @l1) @l6@l7) ((l4 @[]) @l6@l7)
1441 →is_permutation A ((l6 @l2) @l7) ((l3 @l8) @l9)
1442 →is_permutation A
1443   (y ::((l6 @((x ::l5) @(l1 @l2))) @l7))
1444   (((x ::l4 @y ::l3) @l8) @l9)).
1445*)   
1446
Note: See TracBrowser for help on using the repository browser.