source: src/joint/blocks.ma @ 2162

Last change on this file since 2162 was 2155, checked in by tranquil, 8 years ago

updates to blocks and RTLabs to RTL translation (which sidesteps pointer arithmetics issues for now)

Joint semantics and traces momentarily broken, concentrating on syntax now

File size: 19.6 KB
Line 
1include "joint/Joint_paolo.ma".
2include "utilities/bindLists.ma".
3
4inductive block_step (p : stmt_params) (globals : list ident) : Type[0] ≝
5  | block_seq : joint_seq p globals → block_step p globals
6  | block_skip : label → block_step p globals.
7
8definition if_seq : ∀p,globals.∀A:Type[2].block_step p globals → A → A → A ≝
9λp,g,A,s.match s with
10[ block_seq _ ⇒ λx,y.x
11| _ ⇒ λx,y.y
12].
13
14definition stmt_of_block_step : ∀p : stmt_params.∀globals.
15  ∀s : block_step p globals.if_seq … s (succ p) unit → joint_statement p globals ≝
16  λp,g,s.match s return λx.if_seq ??? x ?? → joint_statement ?? with
17  [ block_seq s' ⇒ λnxt.sequential … s' nxt
18  | block_skip l ⇒ λ_.GOTO … l
19  ].
20
21definition seq_to_block_step_list : ∀p : stmt_params.∀globals.
22  list (joint_seq p globals) →
23  list (block_step p globals) ≝ λp,globals.map ?? (block_seq ??).
24
25coercion block_step_from_seq_list : ∀p : stmt_params.∀globals.
26  ∀l:list (joint_seq p globals).
27  list (block_step p globals) ≝
28  seq_to_block_step_list
29  on _l:list (joint_seq ??)
30  to list (block_step ??).
31
32definition is_inr : ∀A,B.A + B → bool ≝ λA,B,x.match x with
33  [ inl _ ⇒ true
34  | inr _ ⇒ false
35  ].
36definition is_inl : ∀A,B.A + B → bool ≝ λA,B,x.match x with
37  [ inl _ ⇒ true
38  | inr _ ⇒ false
39  ].
40
41definition skip_block ≝ λp,globals,A.
42  (list (block_step p globals)) × A.
43
44definition seq_block ≝ λp : stmt_params.λglobals,A.
45  (list (joint_seq p globals)) × A.
46
47definition seq_to_skip_block :
48  ∀p,g,A.seq_block p g A → skip_block p g A
49 ≝ λp,g,A,b.〈\fst b, \snd b〉.
50
51coercion skip_from_seq_block :
52  ∀p,g,A.∀b : seq_block p g A.skip_block p g A ≝
53  seq_to_skip_block on _b : seq_block ??? to skip_block ???.
54
55definition bind_seq_block ≝ λp : stmt_params.λglobals,A.
56  bind_new (localsT p) (seq_block p globals A).
57unification hint 0 ≔ p : stmt_params, g, X;
58R ≟ localsT p,
59P ≟ seq_block p g X
60(*---------------------------------------*)⊢
61bind_seq_block p g X ≡ bind_new R P.
62
63definition bind_seq_list ≝ λp : stmt_params.λglobals.
64  bind_new (localsT p) (list (joint_seq p globals)).
65unification hint 0 ≔ p : stmt_params, g;
66R ≟ localsT p,
67S ≟ joint_seq p g,
68L ≟ list S
69(*---------------------------------------*)⊢
70bind_seq_list p g ≡ bind_new R L.
71
72definition bind_skip_block ≝ λp : stmt_params.λglobals,A.
73  bind_new (localsT p) (skip_block p globals A).
74unification hint 0 ≔ p : stmt_params, g, A;
75B ≟ skip_block p g A, R ≟ localsT p
76(*---------------------------------------*)⊢
77bind_skip_block p g A ≡ bind_new R B.
78
79definition bind_seq_to_skip_block :
80  ∀p,g,A.bind_seq_block p g A → bind_skip_block p g A ≝
81  λp,g,A.m_map ? (seq_block p g A) (skip_block p g A)
82    (λx.x).
83
84coercion bind_skip_from_seq_block :
85  ∀p,g,A.∀b:bind_seq_block p g A.bind_skip_block p g A ≝
86  bind_seq_to_skip_block on _b : bind_seq_block ??? to bind_skip_block ???.
87(*
88definition block_classifier ≝
89  λp,g.λb : other_block p g.
90  seq_or_fin_step_classifier ?? (\snd b).
91*)
92
93let rec split_on_last A (dflt : A) (l : list A) on l : (list A) × A ≝
94match l with
95[ nil ⇒ 〈[ ], dflt〉
96| cons hd tl ⇒
97  match tl with
98  [ nil ⇒ 〈[ ], hd〉
99  | _ ⇒
100    let 〈pref, post〉 ≝ split_on_last A dflt tl in
101    〈hd :: pref, post〉
102  ]
103].
104
105lemma split_on_last_ok :
106  ∀A,dflt,l.
107  match l with
108  [ nil ⇒ True
109  | _ ⇒ l = (let 〈pre, post〉 ≝ split_on_last A dflt l in pre @ [post])
110  ].
111#A #dflt #l elim l normalize nodelta
112[ %
113| #hd * [ #_ %]
114  #hd' #tl #IH whd in match (split_on_last ???); >IH in ⊢ (??%?);
115  elim (split_on_last ???) #a #b %
116]
117qed.
118
119definition seq_block_from_seq_list :
120∀p : stmt_params.∀g.list (joint_seq p g) → seq_block p g (joint_step p g) ≝
121λp,g,l.let 〈pre,post〉 ≝ split_on_last … (NOOP ??) l in 〈pre, (post : joint_step ??)〉.
122
123definition bind_seq_block_from_bind_seq_list :
124  ∀p : stmt_params.∀g.bind_new (localsT p) (list (joint_seq p g)) →
125    bind_seq_block p g (joint_step p g) ≝ λp.λg.m_map … (seq_block_from_seq_list …).
126
127definition bind_seq_block_step :
128  ∀p,g.bind_seq_block p g (joint_step p g) →
129    bind_seq_block p g (joint_step p g) + bind_seq_block p g (joint_fin_step p) ≝
130  λp,g.inl ….
131coercion bind_seq_block_from_step :
132  ∀p,g.∀b:bind_seq_block p g (joint_step p g).
133    bind_seq_block p g (joint_step p g) + bind_seq_block p g (joint_fin_step p) ≝
134  bind_seq_block_step on _b : bind_seq_block ?? (joint_step ??) to
135    bind_seq_block ?? (joint_step ??) + bind_seq_block ?? (joint_fin_step ?).
136
137definition bind_seq_block_fin_step :
138  ∀p,g.bind_seq_block p g (joint_fin_step p) →
139    bind_seq_block p g (joint_step p g) + bind_seq_block p g (joint_fin_step p) ≝
140  λp,g.inr ….
141coercion bind_seq_block_from_fin_step :
142  ∀p,g.∀b:bind_seq_block p g (joint_fin_step p).
143    bind_seq_block p g (joint_step p g) + bind_seq_block p g (joint_fin_step p) ≝
144  bind_seq_block_fin_step on _b : bind_seq_block ?? (joint_fin_step ?) to
145    bind_seq_block ?? (joint_step ??) + bind_seq_block ?? (joint_fin_step ?).
146
147definition seq_block_bind_seq_block :
148  ∀p : stmt_params.∀g,A.seq_block p g A → bind_seq_block p g A ≝ λp,g,A.bret ….
149coercion seq_block_to_bind_seq_block :
150  ∀p : stmt_params.∀g,A.∀b:seq_block p g A.bind_seq_block p g A ≝
151  seq_block_bind_seq_block
152  on _b : seq_block ??? to bind_seq_block ???.
153
154definition joint_step_seq_block : ∀p : stmt_params.∀g.joint_step p g → seq_block p g (joint_step p g) ≝
155  λp,g,x.〈[ ], x〉.
156coercion joint_step_to_seq_block : ∀p : stmt_params.∀g.∀b : joint_step p g.seq_block p g (joint_step p g) ≝
157  joint_step_seq_block on _b : joint_step ?? to seq_block ?? (joint_step ??).
158
159definition joint_fin_step_seq_block : ∀p : stmt_params.∀g.joint_fin_step p → seq_block p g (joint_fin_step p) ≝
160  λp,g,x.〈[ ], x〉.
161coercion joint_fin_step_to_seq_block : ∀p : stmt_params.∀g.∀b : joint_fin_step p.seq_block p g (joint_fin_step p) ≝
162  joint_fin_step_seq_block on _b : joint_fin_step ? to seq_block ?? (joint_fin_step ?).
163
164definition seq_list_seq_block :
165  ∀p:stmt_params.∀g.list (joint_seq p g) → seq_block p g (joint_step p g) ≝
166  λp,g,l.let pr ≝ split_on_last … (NOOP ??) l in 〈\fst pr, \snd pr〉.
167coercion seq_list_to_seq_block :
168  ∀p:stmt_params.∀g.∀l:list (joint_seq p g).seq_block p g (joint_step p g) ≝
169  seq_list_seq_block on _l : list (joint_seq ??) to seq_block ?? (joint_step ??).
170
171definition bind_seq_list_bind_seq_block :
172  ∀p:stmt_params.∀g.bind_new (localsT p) (list (joint_seq p g)) → bind_seq_block p g (joint_step p g) ≝
173  λp,g.m_map ??? (λx : list (joint_seq ??).(x : seq_block ???)).
174
175coercion bind_seq_list_to_bind_seq_block :
176  ∀p:stmt_params.∀g.∀l:bind_new (localsT p) (list (joint_seq p g)).bind_seq_block p g (joint_step p g) ≝
177  bind_seq_list_bind_seq_block on _l : bind_new ? (list (joint_seq ??)) to bind_seq_block ?? (joint_step ??).
178
179(*
180
181definition seq_block_append :
182  ∀p,g.
183  ∀b1 : Σb.is_safe_block p g b.
184  ∀b2 : seq_block p g.
185  seq_block p g ≝ λp,g,b1,b2.
186  〈match b1 with
187  [ mk_Sig instr prf ⇒
188    match \snd instr return λx.bool_to_Prop (is_inl … x) ∧ seq_or_fin_step_classifier … x = ? → ? with
189    [ inl i ⇒ λprf.\fst b1 @ i :: \fst b2
190    | inr _ ⇒ λprf.⊥
191    ] prf
192  ],\snd b2〉.
193  cases prf #H1 #H2 assumption
194  qed.
195
196definition other_block_append :
197  ∀p,g.
198  (Σb.block_classifier ?? b = cl_other) →
199  other_block p g →
200  other_block p g ≝ λp,g,b1,b2.
201  〈\fst b1 @ «\snd b1, pi2 … b1» :: \fst b2, \snd b2〉.
202
203definition seq_block_cons : ∀p : stmt_params.∀g.(Σs.step_classifier p g s = cl_other) →
204  seq_block p g → seq_block p g ≝
205  λp,g,x,b.〈x :: \fst b,\snd b〉.
206definition other_block_cons : ∀p,g.
207  (Σs.seq_or_fin_step_classifier p g s = cl_other) → other_block p g →
208  other_block p g ≝
209  λp,g,x,b.〈x :: \fst b,\snd b〉.
210
211interpretation "seq block cons" 'cons x b = (seq_block_cons ?? x b).
212interpretation "other block cons" 'vcons x b = (other_block_cons ?? x b).
213interpretation "seq block append" 'append b1 b2 = (seq_block_append ?? b1 b2).
214interpretation "other block append" 'vappend b1 b2 = (other_block_append ?? b1 b2).
215
216definition step_to_block : ∀p,g.
217  seq_or_fin_step p g → seq_block p g ≝ λp,g,s.〈[ ], s〉.
218
219coercion block_from_step : ∀p,g.∀s : seq_or_fin_step p g.
220  seq_block p g ≝ step_to_block on _s : seq_or_fin_step ?? to seq_block ??.
221
222definition bind_seq_block_cons :
223  ∀p : stmt_params.∀g,is_seq.
224  (Σs.step_classifier p g s = cl_other) → bind_seq_block p g is_seq →
225  bind_seq_block p g is_seq ≝
226  λp,g,is_seq,x.m_map ??? (λb.〈x::\fst b,\snd b〉).
227
228definition bind_other_block_cons :
229  ∀p,g.(Σs.seq_or_fin_step_classifier p g s = cl_other) → bind_other_block p g → bind_other_block p g ≝
230  λp,g,x.m_map … (other_block_cons … x).
231
232let rec bind_pred_aux B X (P : X → Prop) (c : bind_new B X) on c : Prop ≝
233  match c with
234  [ bret x ⇒ P x
235  | bnew f ⇒ ∀b.bind_pred_aux B X P (f b)
236  ].
237
238let rec bind_pred_inj_aux B X (P : X → Prop) (c : bind_new B X) on c :
239  bind_pred_aux B X P c → bind_new B (Σx.P x) ≝
240  match c return λx.bind_pred_aux B X P x → bind_new B (Σx.P x) with
241  [ bret x ⇒ λprf.return «x, prf»
242  | bnew f ⇒ λprf.bnew … (λx.bind_pred_inj_aux B X P (f x) (prf x))
243  ].
244
245definition bind_pred ≝ λB.
246  mk_InjMonadPred (BindNew B)
247    (mk_MonadPred ?
248      (bind_pred_aux B)
249      ???)
250    (λX,P,c_sig.bind_pred_inj_aux B X P c_sig (pi2 … c_sig))
251    ?.
252[ #X #P #Q #H #y elim y [ #x @H | #f #IH #G #b @IH @G]
253| #X #Y #Pin #Pout #m elim m [#x | #f #IH] #H #g #G [ @G @H | #b @(IH … G) @H]
254| #X #P #x #Px @Px
255| #X #P * #m elim m [#x | #f #IH] #H [ % | @bnew_proper #b @IH]
256]
257qed.
258
259definition bind_seq_block_append :
260  ∀p,g,is_seq.(Σb : bind_seq_block p g true.bind_pred ? (λb.step_classifier p g (\snd b) = cl_other) b) →
261  bind_seq_block p g is_seq → bind_seq_block p g is_seq ≝
262  λp,g,is_seq,b1,b2.
263    !«p, prf» ← mp_inject … b1;
264    !〈post, last〉 ← b2;
265    return 〈\fst p @ «\snd p, prf» :: post, last〉.
266
267definition bind_other_block_append :
268  ∀p,g.(Σb : bind_other_block p g.bind_pred ?
269    (λx.block_classifier ?? x = cl_other) b) →
270  bind_other_block p g → bind_other_block p g ≝
271  λp,g,b1.m_bin_op … (other_block_append ??) (mp_inject … b1).
272
273interpretation "bind seq block cons" 'cons x b = (bind_seq_block_cons ??? x b).
274interpretation "bind other block cons" 'vcons x b = (bind_other_block_cons ?? x b).
275interpretation "bind seq block append" 'append b1 b2 = (bind_seq_block_append ??? b1 b2).
276interpretation "bind other block append" 'vappend b1 b2 = (bind_other_block_append ?? b1 b2).
277
278let rec instantiates_to B X
279  (b : bind_new B X) (l : list B) (x : X) on b : Prop ≝
280  match b with
281  [ bret B ⇒
282    match l with
283    [ nil ⇒ x = B
284    | _ ⇒ False
285    ]
286  | bnew f ⇒
287    match l with
288    [ nil ⇒ False
289    | cons r l' ⇒
290      instantiates_to B X (f r) l' x
291    ]
292  ].
293
294lemma instantiates_to_bind_pred :
295  ∀B,X,P,b,l,x.instantiates_to B X b l x → bind_pred B P b → P x.
296#B #X #P #b elim b
297[ #x * [ #y #EQ >EQ normalize // | #hd #tl #y *]
298| #f #IH * [ #y * | #hd #tl normalize #b #H #G @(IH … H) @G ]
299]
300qed.
301
302lemma seq_block_append_proof_irr :
303  ∀p,g,b1,b1',b2.pi1 ?? b1 = pi1 ?? b1' →
304    seq_block_append p g b1 b2 = seq_block_append p g b1' b2.
305#p #g * #b1 #b1prf * #b1' #b1prf' #b2 #EQ destruct(EQ) %
306qed.
307
308lemma other_block_append_proof_irr :
309  ∀p,g,b1,b1',b2.pi1 ?? b1 = pi1 ?? b1' →
310  other_block_append p g b1 b2 = other_block_append p g b1' b2.
311#p #g * #b1 #b1prf * #b1' #b1prf' #b2 #EQ destruct(EQ) %
312qed.
313
314(*
315lemma is_seq_block_instance_append : ∀p,g,is_seq.
316  ∀B1.
317  ∀B2 : bind_seq_block p g is_seq.
318  ∀l1,l2.
319  ∀b1 : Σb.is_safe_block p g b.
320  ∀b2 : seq_block p g.
321  instantiates_to ? (seq_block p g) B1 l1 (pi1 … b1) →
322  instantiates_to ? (seq_block p g) B2 l2 b2 →
323  instantiates_to ? (seq_block p g) (B1 @ B2) (l1 @ l2) (b1 @ b2).
324#p #g * #B1 elim B1 -B1
325[ #B1 | #f1 #IH1 ]
326#B1prf whd in B1prf;
327#B2 * [2,4: #r1 #l1' ] #l2 #b1 #b2 [1,4: *]
328whd in ⊢ (%→?);
329[ @IH1
330| #EQ destruct(EQ) lapply b2 -b2 lapply l2 -l2 elim B2 -B2
331  [ #B2 | #f2 #IH2] * [2,4: #r2 #l2'] #b2 [1,4: *]
332  whd in ⊢ (%→?);
333  [ @IH2
334  | #EQ' whd destruct @seq_block_append_proof_irr %
335  ]
336]
337qed.
338
339lemma is_other_block_instance_append : ∀p,g.
340  ∀B1 : Σb.bind_pred ? (λx.block_classifier p g x = cl_other) b.
341  ∀B2 : bind_other_block p g.
342  ∀l1,l2.
343  ∀b1 : Σb.block_classifier p g b = cl_other.
344  ∀b2 : other_block p g.
345  instantiates_to ? (other_block p g) B1 l1 (pi1 … b1) →
346  instantiates_to ? (other_block p g) B2 l2 b2 →
347  instantiates_to ? (other_block p g) (B1 @@ B2) (l1 @ l2) (b1 @@ b2).
348#p #g * #B1 elim B1 -B1
349[ #B1 | #f1 #IH1 ]
350#B1prf whd in B1prf;
351#B2 * [2,4: #r1 #l1' ] #l2 #b1 #b2 [1,4: *]
352whd in ⊢ (%→?);
353[ @IH1
354| #EQ destruct(EQ) lapply b2 -b2 lapply l2 -l2 elim B2 -B2
355  [ #B2 | #f2 #IH2] * [2,4: #r2 #l2'] #b2 [1,4: *]
356  whd in ⊢ (%→?);
357  [ @IH2
358  | #EQ' whd destruct @other_block_append_proof_irr %
359  ]
360]
361qed.
362
363lemma other_fin_step_has_one_label :
364  ∀p,g.∀s:(Σs.fin_step_classifier p g s = cl_other).
365  match fin_step_labels ?? s with
366  [ nil ⇒ False
367  | cons _ tl ⇒
368    match tl with
369    [ nil ⇒ True
370    | _ ⇒ False
371    ]
372  ].
373#p #g ** [#lbl || #ext]
374normalize
375[3: cases (ext_fin_step_flows p ext)
376  [* [2: #lbl' * [2: #lbl'' #tl']]] normalize nodelta ]
377#EQ destruct %
378qed.
379
380definition label_of_other_fin_step : ∀p,g.
381  (Σs.fin_step_classifier p g s = cl_other) → label ≝
382λp,g,s.
383match fin_step_labels p ? s return λx.match x with [ nil ⇒ ? | cons _ tl ⇒ ?] → ? with
384[ nil ⇒ Ⓧ
385| cons lbl tl ⇒ λ_.lbl
386] (other_fin_step_has_one_label p g s).
387
388(*
389definition point_seq_transition : ∀p,g.codeT p g →
390  code_point p → code_point p → Prop ≝
391  λp,g,c,src,dst.
392  match stmt_at … c src with
393  [ Some stmt ⇒ match stmt with
394    [ sequential sq nxt ⇒
395      point_of_succ … src nxt = dst
396    | final fn ⇒
397      match fin_step_labels … fn with
398      [ nil ⇒ False
399      | cons lbl tl ⇒
400        match tl with
401        [ nil ⇒ point_of_label … c lbl = Some ? dst
402        | _ ⇒ False
403        ]
404      ]
405    ]
406  | None ⇒ False
407  ].
408
409lemma point_seq_transition_label_of_other_fin_step :
410  ∀p,c,src.∀s : (Σs.fin_step_classifier p s = cl_other).∀dst.
411  stmt_at ?? c src = Some ? s →
412  point_seq_transition p c src dst →
413  point_of_label … c (label_of_other_fin_step p s) = Some ? dst.
414#p #c #src ** [#lbl || #ext] #EQ1
415#dst #EQ2
416whd in match point_seq_transition; normalize nodelta
417>EQ2 normalize nodelta whd in ⊢ (?→??(????%)?);
418[#H @H | * ]
419lapply (other_fin_step_has_one_label ? «ext,?»)
420cases (fin_step_labels p ? ext) normalize nodelta [*]
421#hd * normalize nodelta [2: #_ #_ *] *
422#H @H
423qed.
424
425lemma point_seq_transition_succ :
426  ∀p,c,src.∀s,nxt.∀dst.
427  stmt_at ?? c src = Some ? (sequential ?? s nxt) →
428  point_seq_transition p c src dst →
429  point_of_succ … src nxt = dst.
430#p #c #src #s #nxt #dst #EQ
431whd in match point_seq_transition; normalize nodelta
432>EQ normalize nodelta #H @H
433qed.
434*)
435
436definition if_other : ∀p,g.∀A : Type[2].seq_or_fin_step p g → A → A → A ≝
437  λp,g,A,c.match seq_or_fin_step_classifier p g c with
438  [ cl_other ⇒ λx,y.x
439  | _ ⇒ λx,y.y
440  ].
441
442definition other_step_in_code ≝
443  λp,g.
444  λc : codeT p g.
445  λsrc : code_point p.
446  λs : seq_or_fin_step p g.
447  match s return λx.if_other p g ? x (code_point p) unit → Prop with
448  [ inl s'' ⇒ λdst.∃n.stmt_at … c src = Some ? (sequential … s'' n) ∧ ?
449  | inr s'' ⇒ λdst.stmt_at … c src = Some ? (final … s'') ∧ ?
450  ].
451  [ whd in dst; cases (seq_or_fin_step_classifier ???) in dst;
452    normalize nodelta [1,2,3: #_ @True |*: #dst
453      @(point_of_succ … src n = dst)]
454  | whd in dst;
455    lapply dst -dst
456    lapply (refl … (seq_or_fin_step_classifier ?? (inr … s'')))
457    cases (seq_or_fin_step_classifier ?? (inr … s'')) in ⊢ (???%→%);
458    normalize nodelta
459    [1,2,3: #_ #_ @True
460    |*: #EQ #dst
461      @(point_of_label … c (label_of_other_fin_step p g «s'', EQ») = Some ? dst)
462    ]
463  ]
464qed.
465
466definition if_other_sig :
467  ∀p,g.∀B,C : Type[0].∀s : Σs.seq_or_fin_step_classifier p g s = cl_other.
468  if_other p g ? s B C → B ≝
469  λp,g,B,C.?.
470  ** #s whd in match (if_other ??????);
471  cases (seq_or_fin_step_classifier ???) normalize nodelta #EQ destruct(EQ)
472  #x @x
473qed.
474
475definition if_other_block_sig :
476  ∀p,g.∀B,C : Type[0].∀b : Σb.block_classifier p g b = cl_other.
477  if_other p g ? (\snd b) B C → B ≝
478  λp,g,B,C.?.
479  ** #l #s
480  #prf #x @(if_other_sig ???? «s, prf» x)
481qed.
482
483coercion other_sig_to_if nocomposites:
484  ∀p,g.∀B,C : Type[0].∀s : Σs.seq_or_fin_step_classifier p g s = cl_other.
485  ∀x : if_other p g ? s B C.B ≝ if_other_sig
486  on _x : if_other ?? Type[0] ??? to ?.
487
488coercion other_block_sig_to_if nocomposites:
489  ∀p,g.∀B,C : Type[0].∀s : Σs.block_classifier p g s = cl_other.
490  ∀x : if_other p g ? (\snd s) B C.B ≝ if_other_block_sig
491  on _x : if_other ?? Type[0] (\snd ?) ?? to ?.
492
493let rec other_list_in_code p g (c : codeT p g)
494  src
495  (b : list (Σs.seq_or_fin_step_classifier p g s = cl_other))
496  dst on b : Prop ≝
497  match b with
498  [ nil ⇒ src = dst
499  | cons hd tl ⇒ ∃mid.
500    other_step_in_code p g c src hd mid ∧ other_list_in_code p g c mid tl dst
501  ].
502
503notation > "x ~❨ B ❩~> y 'in' c" with precedence 56 for
504  @{'block_in_code $c $x $B $y}.
505 
506notation < "hvbox(x ~❨ B ❩~> y \nbsp 'in' \nbsp break c)" with precedence 56 for
507  @{'block_in_code $c $x $B $y}.
508
509interpretation "list in code" 'block_in_code c x B y =
510  (other_list_in_code ?? c x B y).
511
512definition other_block_in_code : ∀p,g.codeT p g →
513  code_point p → ∀b : other_block p g.
514    if_other … (\snd b) (code_point p) unit → Prop ≝
515  λp,g,c,src,b,dst.
516  ∃mid.src ~❨\fst b❩~> mid in c ∧
517  other_step_in_code p g c mid (\snd b) dst.
518
519interpretation "block in code" 'block_in_code c x B y =
520  (other_block_in_code ?? c x B y).
521
522lemma other_list_in_code_append : ∀p,g.∀c : codeT p g.
523  ∀x.∀b1 : list ?.
524  ∀y.∀b2 : list ?.∀z.
525  x ~❨b1❩~> y in c→ y ~❨b2❩~> z in c → x ~❨b1@b2❩~> z in c.
526#p#g#c#x#b1 lapply x -x
527elim b1 [2: ** #hd #hd_prf #tl #IH] #x #y #b2 #z
528[3: #EQ normalize in EQ; destruct #H @H]
529* #mid * normalize nodelta [ *#n ] #H1 #H2 #H3
530whd normalize nodelta %{mid}
531%{(IH … H2 H3)}
532[ %{n} ] @H1
533qed.
534
535lemma other_block_in_code_append : ∀p,g.∀c : codeT p g.∀x.
536  ∀B1 : Σb.block_classifier p g b = cl_other.
537  ∀y.
538  ∀B2 : other_block p g.
539  ∀z.
540  x ~❨B1❩~> y in c → y ~❨B2❩~> z in c →
541  x ~❨B1@@B2❩~> z in c.
542#p#g#c #x ** #hd1 *#tl1 #tl1prf
543#y * #hd2 #tl2 #z
544* #mid1 * #H1 #H2
545* #mid2 * #G1 #G2
546%{mid2} %{G2}
547whd in match (\fst ?);
548@(other_list_in_code_append … H1)
549%{y} %{H2 G1}
550qed.
551
552(*
553definition instr_block_in_function :
554  ∀p : evaluation_params.∀fn : joint_internal_function (globals p) p.
555    code_point p →
556    ∀b : bind_other_block p.
557    ? → Prop ≝
558 λp,fn,src,B,dst.
559 ∃vars,B'.
560  All ? (In ? (joint_if_locals … fn)) vars ∧
561  instantiates_to … B vars B' ∧
562  src ~❨B'❩~> dst in joint_if_code … fn.
563
564interpretation "bind block in function" 'block_in_code fn x B y =
565  (instr_block_in_function ? fn x B y).
566
567lemma instr_block_in_function_trans :
568  ∀p,fn,src.
569  ∀B1 : ΣB.bind_pred ? (λb.block_classifier p b = cl_other) B.
570  ∀mid.
571  ∀B2 : bind_other_block p.
572  ∀dst.
573  src ~❨B1❩~> Some ? mid in fn →
574  mid ~❨B2❩~> dst in fn →
575  src ~❨B1@@B2❩~> dst in fn.
576#p#fn#src*#B1#B1prf#mid#B2#dst
577* #vars1 * #b1 ** #vars1_ok #b1B1 #b1_in
578* #vars2 * #b2 ** #vars2_ok #b2B2 #b2_in
579%{(vars1@vars2)} %{(«b1,instantiates_to_bind_pred … b1B1 B1prf» @@ b2)}
580/4 by All_append, conj, is_other_block_instance_append, other_block_in_code_append/
581qed.
582*)
583*)
584*)
Note: See TracBrowser for help on using the repository browser.