source: LTS/stack_monostack_pass.ma @ 3582

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

assembly pass in place

File size: 3.9 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 "mono_stack.ma".
16include "Simulation.ma".
17
18let rec mono_env_store_rel (s1 : list (list ℕ)) (s2 : list ℕ) (fp : ℕ) on s1 : Prop ≝
19match s1 with
20[ nil ⇒ s2 = nil ?
21| cons x xs ⇒ ∃old_fp,s21,s22.s2 = s21 @ [old_fp] @ s22 ∧
22              x= s21 @ [O] ∧
23              mono_env_store_rel xs s22 old_fp ∧ |s22| = fp
24].
25
26definition mono_store_rel : frame_store_t → mono_stack_store_t → Prop ≝
27λst1,st2.mono_env_store_rel (\fst st1) (\fst st2) (\fst (\snd st2)) ∧ (\snd (\snd st1)) = (\snd (\snd st2)).
28
29definition mono_stack_relations :
30∀prog : Program stack_env_params stack_instr_params flat_labels.∀bound.
31relations flat_labels
32(operational_semantics stack_state_params (stack_sem_state_params bound) prog)
33(operational_semantics mono_stack_state_params (mono_stack_sem_state_params bound) prog) ≝
34λprog.λbound.
35mk_relations … (λs1,s2.mono_store_rel … (store … s1) (store … s2) ∧ code … s1 = code … s2 ∧ cont … s1 = cont … s2)
36  (λ_.λ_.True).
37
38lemma minus_right_cancellable : ∀n,m,p : ℕ.n = m → n-p = m -p. //
39qed.
40
41
42lemma read_frame_ok :
43∀st1,st2,fp,env,x,n.
44mono_env_store_rel st1 st2 fp → option_hd … st1 = return env →
45to_shift + x < |env| →
46read_frame env (to_shift+x) O = return n →
47read_frame st2 (to_shift+x) fp = return n.
48#st1 elim st1 [ #H1 #H2 #H3 #H4 #H5 #H6 #H7 #H8 #H9 normalize in H7; destruct]
49#env #tl #IH #st2 #fp #env' #x #n * #old_fp * #s21 * #s22 *** #EQ1 #EQ2 destruct #H #EQ destruct
50whd in ⊢ (??%% → ?); #EQ destruct #H1
51change with (nth_opt ???) in ⊢ (??%? → ?);  <minus_n_O >length_append normalize in ⊢ (??(??%?)? → ?);
52>nth_first
53[2: normalize >minus_minus_comm >commutative_plus <(plus_minus … 1) // normalize <(minus_Sn_m … (S (S x)))
54   [2: >length_append in H1; normalize >(commutative_plus) normalize  /2/]
55   normalize /2/
56]
57#H2 change with (nth_opt ???) in ⊢ (??%?); >nth_first
58[2: >length_append >length_append normalize <plus_n_Sm normalize <(minus_minus_comm ? (|s22|))
59    >commutative_plus <(plus_minus … (|s22|)) [2: //] <minus_n_n normalize >minus_plus <(minus_Sn_m … (S x +1))
60    [2: normalize >commutative_plus normalize normalize in H1; >length_append in H1; normalize >commutative_plus
61        normalize /2/ ]
62    <commutative_plus normalize /2/
63]
64>length_append >length_append
65cut((|s21|+(|[old_fp]|+|s22|)-(to_shift+x)-|s22|-1) = (|s21|+1-S (S x)-1))
66[ normalize @minus_right_cancellable  >minus_minus_comm >commutative_plus <(plus_minus … (|s22|)) [2: //]
67  <(minus_Sn_n … (|s22|)) >commutative_plus %
68] #EQ >EQ assumption
69qed.
70
71definition stack_mono_stack_simulation : ∀prog : Program stack_env_params stack_instr_params flat_labels.∀bound.
72simulation_conditions … (mono_stack_relations prog bound) ≝λprog.λbound.mk_simulation_conditions ….
73(*[4: #s1 #s2 #s1' #H inversion H
74   [ #st1 #st2 * #lab #instr #tl #EQcode_st1 #EQcond_st1 #EQ1 #EQ2 destruct #EQstore *)
75cases daemon
76qed.
Note: See TracBrowser for help on using the repository browser.