source: src/ASM/AssemblyProofSplit.ma @ 2017

Last change on this file since 2017 was 2017, checked in by mulligan, 8 years ago

Large swathes of proof of main lemma added.

File size: 78.8 KB
Line 
1include "ASM/AssemblyProof.ma".
2include alias "arithmetics/nat.ma".
3include alias "basics/logic.ma".
4
5lemma set_arg_16_mk_Status_commutation:
6  ∀M: Type[0].
7  ∀cm: M.
8  ∀s: PreStatus M cm.
9  ∀w: Word.
10  ∀d: [[dptr]].
11    set_arg_16 M cm s w d =
12      mk_PreStatus M cm
13        (low_internal_ram … s)
14        (high_internal_ram … s)
15        (external_ram … s)
16        (program_counter … s)
17        (special_function_registers_8051 … (set_arg_16 M cm s w d))
18        (special_function_registers_8052 … s)
19        (p1_latch … s)
20        (p3_latch … s)
21        (clock … s).
22  #M #cm #s #w #d
23  whd in match set_arg_16; normalize nodelta
24  whd in match set_arg_16'; normalize nodelta
25  @(subaddressing_mode_elim … [[dptr]] … [[dptr]]) [1: // ]
26  cases (split bool 8 8 w) #bu #bl normalize nodelta
27  whd in match set_8051_sfr; normalize nodelta %
28qed.
29
30lemma set_program_counter_mk_Status_commutation:
31  ∀M: Type[0].
32  ∀cm: M.
33  ∀s: PreStatus M cm.
34  ∀w: Word.
35    set_program_counter M cm s w =
36      mk_PreStatus M cm
37        (low_internal_ram … s)
38        (high_internal_ram … s)
39        (external_ram … s)
40        w
41        (special_function_registers_8051 … s)
42        (special_function_registers_8052 … s)
43        (p1_latch … s)
44        (p3_latch … s)
45        (clock … s).
46  //
47qed.
48
49lemma set_clock_mk_Status_commutation:
50  ∀M: Type[0].
51  ∀cm: M.
52  ∀s: PreStatus M cm.
53  ∀c: nat.
54    set_clock M cm s c =
55      mk_PreStatus M cm
56        (low_internal_ram … s)
57        (high_internal_ram … s)
58        (external_ram … s)
59        (program_counter … s)
60        (special_function_registers_8051 … s)
61        (special_function_registers_8052 … s)
62        (p1_latch … s)
63        (p3_latch … s)
64        c.
65  //
66qed.
67
68lemma get_8051_sfr_set_clock:
69  ∀M: Type[0].
70  ∀cm: M.
71  ∀s: PreStatus M cm.
72  ∀sfr: SFR8051.
73  ∀t: Time.
74    get_8051_sfr M cm (set_clock M cm s t) sfr =
75      get_8051_sfr M cm s sfr.
76  #M #cm #s #sfr #t %
77qed.
78
79lemma get_8051_sfr_set_program_counter:
80  ∀M: Type[0].
81  ∀cm: M.
82  ∀s: PreStatus M cm.
83  ∀sfr: SFR8051.
84  ∀pc: Word.
85    get_8051_sfr M cm (set_program_counter M cm s pc) =
86      get_8051_sfr M cm s.
87  #M #cm #s #sfr #pc %
88qed.
89
90lemma special_function_registers_8051_set_arg_16:
91  ∀M, M': Type[0].
92  ∀cm: M.
93  ∀cm': M'.
94  ∀s: PreStatus M cm.
95  ∀s': PreStatus M' cm'.
96  ∀w, w': Word.
97  ∀d, d': [[dptr]].
98   special_function_registers_8051 ?? s = special_function_registers_8051 … s' →
99    w = w' →
100      special_function_registers_8051 ?? (set_arg_16 … s w d) =
101        special_function_registers_8051 ?? (set_arg_16 M' cm' s' w' d').
102  #M #M' #cm #cm' #s #s' #w #w'
103  @list_addressing_mode_tags_elim_prop try %
104  @list_addressing_mode_tags_elim_prop try %
105  #EQ1 #EQ2 <EQ2 normalize cases (split bool 8 8 w) #b1 #b2 normalize <EQ1 %
106qed.
107
108lemma program_counter_set_arg_1:
109  ∀M: Type[0].
110  ∀cm: M.
111  ∀s: PreStatus M cm.
112  ∀addr: [[bit_addr; carry]].
113  ∀b: Bit.
114    program_counter M cm (set_arg_1 M cm s addr b) = program_counter M cm s.
115  #M #cm #s whd in match set_arg_1; whd in match set_arg_1'; normalize nodelta
116  #addr #b
117  @(subaddressing_mode_elim … [[bit_addr; carry]] … [[bit_addr; carry]]) [1: // ]
118  [1:
119    #byte cases (split ????) #nu #nl normalize nodelta
120    cases (split ????) #ignore #three_bits normalize nodelta
121    cases (get_index_v bool ????) normalize nodelta
122    [1:
123      @program_counter_set_bit_addressable_sfr
124    |2:
125      @program_counter_set_low_internal_ram
126    ]
127  |2:
128    cases (split ????) //
129  ]
130qed.
131
132lemma get_ov_flag_set_program_counter:
133  ∀M: Type[0].
134  ∀cm: M.
135  ∀s: PreStatus M cm.
136  ∀pc: Word.
137    get_ov_flag M cm (set_program_counter M cm s pc) =
138      get_ov_flag M cm s.
139  #M #cm #s #pc %
140qed.
141
142lemma external_ram_set_program_counter:
143  ∀M: Type[0].
144  ∀cm: M.
145  ∀s: PreStatus M cm.
146  ∀pc: Word.
147    external_ram M cm (set_program_counter M cm s pc) =
148      external_ram M cm s.
149  #M #cm #s #pc %
150qed.
151
152lemma low_internal_ram_set_program_counter:
153  ∀M: Type[0].
154  ∀cm: M.
155  ∀s: PreStatus M cm.
156  ∀pc: Word.
157    low_internal_ram M cm (set_program_counter M cm s pc) =
158      low_internal_ram M cm s.
159  #M #cm #s #pc %
160qed.
161
162lemma high_internal_ram_set_program_counter:
163  ∀M: Type[0].
164  ∀cm: M.
165  ∀s: PreStatus M cm.
166  ∀pc: Word.
167    high_internal_ram M cm (set_program_counter M cm s pc) =
168      high_internal_ram M cm s.
169  #M #cm #s #pc %
170qed.
171
172lemma get_arg_8_set_program_counter:
173  ∀M: Type[0].
174  ∀cm: M.
175  ∀s: PreStatus M cm.
176  ∀flag: bool.
177  ∀addr.
178  ∀pc: Word.
179    get_arg_8 M cm (set_program_counter M cm s pc) flag addr =
180      get_arg_8 M cm s flag addr.
181  #M #cm #s #flag #addr #pc
182  whd in match get_arg_8; normalize nodelta
183  cases addr *
184  try (#addr1 #addr2 #absurd normalize in absurd; cases absurd @I)
185  try (#addr1 #absurd normalize in absurd; cases absurd @I)
186  try (#absurd normalize in absurd; cases absurd @I)
187  try (#addr1 #addr2) try #addr1
188  normalize nodelta try %
189  >external_ram_set_program_counter
190  >program_counter_set_program_counter
191  cases daemon (* XXX: rewrite not working but provable *)
192qed.
193
194lemma external_ram_set_flags:
195  ∀M: Type[0].
196  ∀cm: M.
197  ∀s: PreStatus M cm.
198  ∀opt: option Bit.
199  ∀bit1, bit2: Bit.
200    external_ram M cm (set_flags M cm s bit1 opt bit2) =
201      external_ram M cm s.
202  #M #cm #s #opt #bit1 #bit2 %
203qed.
204
205lemma low_internal_ram_set_flags:
206  ∀M: Type[0].
207  ∀cm: M.
208  ∀s: PreStatus M cm.
209  ∀opt: option Bit.
210  ∀bit1, bit2: Bit.
211    low_internal_ram M cm (set_flags M cm s bit1 opt bit2) =
212      low_internal_ram M cm s.
213  #M #cm #s #opt #bit1 #bit2 %
214qed.
215
216lemma high_internal_ram_set_flags:
217  ∀M: Type[0].
218  ∀cm: M.
219  ∀s: PreStatus M cm.
220  ∀opt: option Bit.
221  ∀bit1, bit2: Bit.
222    high_internal_ram M cm (set_flags M cm s bit1 opt bit2) =
223      high_internal_ram M cm s.
224  #M #cm #s #opt #bit1 #bit2 %
225qed.
226
227lemma low_internal_ram_set_clock:
228  ∀M: Type[0].
229  ∀cm: M.
230  ∀s: PreStatus M cm.
231  ∀t: Time.
232    low_internal_ram M cm (set_clock M cm s t) =
233      low_internal_ram M cm s.
234  #M #cm #s #t %
235qed.
236
237lemma high_internal_ram_set_clock:
238  ∀M: Type[0].
239  ∀cm: M.
240  ∀s: PreStatus M cm.
241  ∀t: Time.
242    high_internal_ram M cm (set_clock M cm s t) =
243      high_internal_ram M cm s.
244  #M #cm #s #t %
245qed.
246
247lemma external_ram_set_clock:
248  ∀M: Type[0].
249  ∀cm: M.
250  ∀s: PreStatus M cm.
251  ∀t: Time.
252    external_ram M cm (set_clock M cm s t) =
253      external_ram M cm s.
254  #M #cm #s #t %
255qed.
256
257lemma set_8051_sfr_set_program_counter:
258  ∀M: Type[0].
259  ∀cm: M.
260  ∀s: PreStatus M cm.
261  ∀pc: Word.
262  ∀sfr: SFR8051.
263  ∀v: Byte.
264    set_8051_sfr M cm (set_program_counter M cm s pc) sfr v =
265      set_program_counter M cm (set_8051_sfr M cm s sfr v) pc.
266  #M #cm #s #pc #sfr #v %
267qed.
268
269lemma low_internal_ram_set_8051_sfr:
270  ∀M: Type[0].
271  ∀cm: M.
272  ∀s: PreStatus M cm.
273  ∀sfr: SFR8051.
274  ∀v: Byte.
275    low_internal_ram M cm (set_8051_sfr M cm s sfr v) =
276      low_internal_ram M cm s.
277  #M #cm #s #sfr #v %
278qed.
279
280lemma high_internal_ram_set_8051_sfr:
281  ∀M: Type[0].
282  ∀cm: M.
283  ∀s: PreStatus M cm.
284  ∀sfr: SFR8051.
285  ∀v: Byte.
286    high_internal_ram M cm (set_8051_sfr M cm s sfr v) =
287      high_internal_ram M cm s.
288  #M #cm #s #sfr #v %
289qed.
290
291lemma external_ram_set_8051_sfr:
292  ∀M: Type[0].
293  ∀cm: M.
294  ∀s: PreStatus M cm.
295  ∀sfr: SFR8051.
296  ∀v: Byte.
297    external_ram M cm (set_8051_sfr M cm s sfr v) =
298      external_ram M cm s.
299  #M #cm #s #sfr #v %
300qed.
301
302lemma get_arg_8_set_clock:
303  ∀M: Type[0].
304  ∀cm: M.
305  ∀s: PreStatus M cm.
306  ∀addr.
307  ∀t: Time.
308    get_arg_8 M cm (set_clock M cm s t) addr =
309      get_arg_8 M cm s addr.
310  #M #cm #s #addr #t %
311qed.
312
313lemma None_Some_elim: ∀P:Prop. ∀A,a. None A = Some A a → P.
314 #P #A #a #abs destruct
315qed.
316
317(*
318lemma pi1_let_commute:
319 ∀A,B,C,P. ∀c:A × B. ∀t: Σc:C.P c.
320 pi1 … (let 〈x1,y1〉 ≝ c in t) = (let 〈x1,y1〉 ≝ c in pi1 … t).
321 #A #B #C #P * #a #b * //
322qed.
323
324lemma pi1_let_as_commute:
325 ∀A,B,C,P. ∀c:A × B. ∀t: Σc:C.P c.
326 pi1 … (let 〈x1,y1〉 as H ≝ c in t) =
327  (let 〈x1,y1〉 as H ≝ c in pi1 … t).
328 #A #B #C #P * #a #b * //
329qed.
330
331lemma tech_pi1_let_as_commute:
332 ∀A,B,C,P. ∀f. ∀c,c':A × B.
333 ∀t: ∀a,b. 〈a,b〉=c → Σc:C.P c.
334 ∀t': ∀a,b. 〈a,b〉=c' → Σc:C.P c.
335  c=c' → (∀x,y,H,H'.t x y H = f (pi1 … (t' x y H'))) →
336  pi1 … (let 〈x1,y1〉 as H ≝ c in t x1 y1 H) =
337   f (pi1 … (let 〈x1,y1〉 as H ≝ c' in t' x1 y1 H)).
338 #A #B #C #P #f * #a #b * #a' #b' #t #t' #EQ1 destruct normalize /2/
339qed.
340*)
341
342include alias "arithmetics/nat.ma".
343include alias "basics/logic.ma".
344include alias "ASM/BitVectorTrie.ma".
345
346lemma pair_replace:
347 ∀A,B,T:Type[0].∀P:T → Prop. ∀t. ∀a,b.∀c,c': A × B. c'=c → c ≃ 〈a,b〉 →
348  P (t a b) → P (let 〈a',b'〉 ≝ c' in t a' b').
349 #A #B #T #P #t #a #b * #x #y * #x' #y' #H1 #H2 destruct //
350qed.
351
352lemma jmpair_as_replace:
353 ∀A,B,T:Type[0].∀P:T → Prop. ∀a:A. ∀b:B.∀c,c': A × B. ∀t: ∀a,b. c' ≃ 〈a, b〉 → T. ∀EQc: c'= c.
354  ∀EQ:c ≃ 〈a,b〉.
355  P (t a b ?) → P ((let 〈a',b'〉 (*as H*) ≝ c' in λH. t a' b' H) (refl_jmeq ? c')).
356  [2:
357    >EQc @EQ
358  |1:
359    #A #B #T #P #a #b
360    #c #c' #t #EQc >EQc in t; -c' normalize #f #EQ
361    letin eta ≝ (? : ∀ab:A × B.∀P:A × B → Type[0]. P ab → P 〈\fst ab,\snd ab〉) [2: * // ]
362    change with (eta 〈a,b〉 (λab.c ≃ ab) EQ) in match EQ;
363    @(jmeq_elim ?? (λab.λH.P (f (\fst ab) (\snd ab) ?) → ?) ?? EQ) normalize -eta
364    -EQ cases c in f; normalize //
365  ]
366qed.
367
368lemma if_then_else_replace:
369  ∀T: Type[0].
370  ∀P: T → Prop.
371  ∀t1, t2: T.
372  ∀c, c', c'': bool.
373    c' = c → c ≃ c'' → P (if c'' then t1 else t2) → P (if c' then t1 else t2).
374  #T #P #t1 #t2 #c #c' #c'' #c_refl #c_refl' destruct #assm
375  assumption
376qed.
377
378lemma fetch_many_singleton:
379  ∀code_memory: BitVectorTrie Byte 16.
380  ∀final_pc, start_pc: Word.
381  ∀i: instruction.
382    fetch_many code_memory final_pc start_pc [i] →
383      〈i, final_pc, ticks_of_instruction i〉 = fetch code_memory start_pc.
384  #code_memory #final_pc #start_pc #i * #new_pc
385  #fetch_many_assm whd in fetch_many_assm;
386  cases (eq_bv_eq … fetch_many_assm) assumption
387qed.
388
389lemma refl_to_jmrefl:
390  ∀a: Type[0].
391  ∀l, r: a.
392    l = r → l ≃ r.
393  #a #l #r #refl destruct %
394qed.
395
396include alias "ASM/Vector.ma".
397
398lemma main_lemma_preinstruction:
399 ∀M,M': internal_pseudo_address_map.
400 ∀preamble : preamble. ∀instr_list : list labelled_instruction.
401 ∀cm: pseudo_assembly_program.
402 ∀EQcm: cm = 〈preamble,instr_list〉.
403 ∀sigma : Word→Word. ∀policy : Word→bool.
404 ∀sigma_policy_witness : sigma_policy_specification cm sigma policy.
405 ∀ps : PseudoStatus cm.
406 ∀ppc : Word.
407 ∀EQppc : ppc=program_counter pseudo_assembly_program cm ps.
408 ∀labels : label_map.
409 ∀costs : BitVectorTrie costlabel 16.
410 ∀create_label_cost_refl : create_label_cost_map instr_list=〈labels,costs〉.
411 ∀newppc : Word.
412 ∀lookup_labels : Identifier→Word.
413 ∀EQlookup_labels : lookup_labels = (λx:Identifier. address_of_word_labels_code_mem instr_list x).
414 ∀lookup_datalabels : identifier ASMTag→Word.
415 ∀EQlookup_datalabels : lookup_datalabels = (λx.lookup_def ASMTag Word (construct_datalabels preamble) x (zero 16)).
416 ∀EQnewppc : newppc=add 16 ppc (bitvector_of_nat 16 1).
417 ∀instr: preinstruction Identifier.
418 ∀ticks.
419 ∀EQticks: ticks = ticks_of0 〈preamble,instr_list〉 sigma policy ppc (Instruction instr).
420 ∀addr_of.
421 ∀EQaddr_of: addr_of = (λx:Identifier
422         .λy:PreStatus pseudo_assembly_program cm
423          .address_of_word_labels cm x).
424 ∀s.
425 ∀EQs: s = (set_program_counter pseudo_assembly_program cm ps
426         (add 16 ppc (bitvector_of_nat 16 1))).
427 ∀P.
428 ∀EQP: P = (λinstr, s.
429  sigma (add 16 ppc (bitvector_of_nat 16 1))
430   =add 16 (sigma ppc)
431    (bitvector_of_nat 16
432     (\fst  (assembly_1_pseudoinstruction lookup_labels sigma policy ppc
433                  lookup_datalabels (Instruction instr))))
434   →next_internal_pseudo_address_map0 pseudo_assembly_program (Instruction instr)
435    M cm ps
436    =Some internal_pseudo_address_map M'
437    →fetch_many (load_code_memory (\fst  (assembly cm sigma policy)))
438     (sigma (add 16 ppc (bitvector_of_nat 16 1))) (sigma (program_counter pseudo_assembly_program cm ps))
439     (expand_pseudo_instruction lookup_labels sigma policy (program_counter pseudo_assembly_program cm ps) lookup_datalabels
440      (Instruction instr))
441     → ∃n. execute n
442       (code_memory_of_pseudo_assembly_program cm sigma
443        policy)
444       (status_of_pseudo_status M cm ps sigma policy)
445      =status_of_pseudo_status M' cm s sigma policy).
446     P instr (execute_1_preinstruction ticks Identifier pseudo_assembly_program cm
447         addr_of instr s).
448 #M #M' #preamble #instr_list #cm #EQcm #sigma #policy #sigma_policy_witness #ps #ppc #EQppc #labels
449 #costs #create_label_cost_refl #newppc
450 #lookup_labels #EQlookup_labels #lookup_datalabels #EQlookup_datalabels #EQnewppc #instr
451 #ticks #EQticks #addr_of #EQaddr_of #s #EQs #P #EQP
452 (*#sigma_increment_commutation #maps_assm #fetch_many_assm *)
453 letin a ≝ Identifier letin m ≝ pseudo_assembly_program
454 cut (Σxxx:PseudoStatus cm. P instr (execute_1_preinstruction ticks a m cm addr_of instr s))
455 [2: * // ]
456 @(
457  let add_ticks1 ≝ λs: PreStatus m cm. set_clock ?? s (\fst ticks + clock ?? s) in
458  let add_ticks2 ≝ λs: PreStatus m cm. set_clock ?? s (\snd ticks + clock ?? s) in
459  match instr in preinstruction return λx. x = instr → Σs'.? with
460        [ ADD addr1 addr2 ⇒ λinstr_refl.
461            let s ≝ add_ticks1 s in
462            let 〈result, flags〉 ≝ add_8_with_carry (get_arg_8 … s false addr1)
463                                                   (get_arg_8 … s false addr2) false in
464            let cy_flag ≝ get_index' ? O  ? flags in
465            let ac_flag ≝ get_index' ? 1 ? flags in
466            let ov_flag ≝ get_index' ? 2 ? flags in
467            let s ≝ set_arg_8 … s ACC_A result in
468              set_flags … s cy_flag (Some Bit ac_flag) ov_flag
469        | ADDC addr1 addr2 ⇒ λinstr_refl.
470            let s ≝ add_ticks1 s in
471            let old_cy_flag ≝ get_cy_flag ?? s in
472            let 〈result, flags〉 ≝ add_8_with_carry (get_arg_8 … s false addr1)
473                                                   (get_arg_8 … s false addr2) old_cy_flag in
474            let cy_flag ≝ get_index' ? O ? flags in
475            let ac_flag ≝ get_index' ? 1 ? flags in
476            let ov_flag ≝ get_index' ? 2 ? flags in
477            let s ≝ set_arg_8 … s ACC_A result in
478              set_flags … s cy_flag (Some Bit ac_flag) ov_flag
479        | SUBB addr1 addr2 ⇒ λinstr_refl.
480            let s ≝ add_ticks1 s in
481            let old_cy_flag ≝ get_cy_flag ?? s in
482            let 〈result, flags〉 ≝ sub_8_with_carry (get_arg_8 … s false addr1)
483                                                   (get_arg_8 … s false addr2) old_cy_flag in
484            let cy_flag ≝ get_index' ? O ? flags in
485            let ac_flag ≝ get_index' ? 1 ? flags in
486            let ov_flag ≝ get_index' ? 2 ? flags in
487            let s ≝ set_arg_8 … s ACC_A result in
488              set_flags … s cy_flag (Some Bit ac_flag) ov_flag
489        | ANL addr ⇒ λinstr_refl.
490          let s ≝ add_ticks1 s in
491          match addr with
492            [ inl l ⇒
493              match l with
494                [ inl l' ⇒
495                  let 〈addr1, addr2〉 ≝ l' in
496                  let and_val ≝ conjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
497                    set_arg_8 … s addr1 and_val
498                | inr r ⇒
499                  let 〈addr1, addr2〉 ≝ r in
500                  let and_val ≝ conjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
501                    set_arg_8 … s addr1 and_val
502                ]
503            | inr r ⇒
504              let 〈addr1, addr2〉 ≝ r in
505              let and_val ≝ andb (get_cy_flag … s) (get_arg_1 … s addr2 true) in
506               set_flags … s and_val (None ?) (get_ov_flag ?? s)
507            ]
508        | ORL addr ⇒ λinstr_refl.
509          let s ≝ add_ticks1 s in
510          match addr with
511            [ inl l ⇒
512              match l with
513                [ inl l' ⇒
514                  let 〈addr1, addr2〉 ≝ l' in
515                  let or_val ≝ inclusive_disjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
516                    set_arg_8 … s addr1 or_val
517                | inr r ⇒
518                  let 〈addr1, addr2〉 ≝ r in
519                  let or_val ≝ inclusive_disjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
520                    set_arg_8 … s addr1 or_val
521                ]
522            | inr r ⇒
523              let 〈addr1, addr2〉 ≝ r in
524              let or_val ≝ (get_cy_flag … s) ∨ (get_arg_1 … s addr2 true) in
525               set_flags … s or_val (None ?) (get_ov_flag … s)
526            ]
527        | XRL addr ⇒ λinstr_refl.
528          let s ≝ add_ticks1 s in
529          match addr with
530            [ inl l' ⇒
531              let 〈addr1, addr2〉 ≝ l' in
532              let xor_val ≝ exclusive_disjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
533                set_arg_8 … s addr1 xor_val
534            | inr r ⇒
535              let 〈addr1, addr2〉 ≝ r in
536              let xor_val ≝ exclusive_disjunction_bv ? (get_arg_8 … s true addr1) (get_arg_8 … s true addr2) in
537                set_arg_8 … s addr1 xor_val
538            ]
539        | INC addr ⇒ λinstr_refl.
540            match addr return λx. bool_to_Prop (is_in … [[ acc_a;registr;direct;indirect;dptr ]] x) → x = addr → Σs': PreStatus m cm. ? with
541              [ ACC_A ⇒ λacc_a: True. λEQaddr.
542                let s' ≝ add_ticks1 s in
543                let 〈 carry, result 〉 ≝ half_add ? (get_arg_8 … s' true ACC_A) (bitvector_of_nat 8 1) in
544                 set_arg_8 … s' ACC_A result
545              | REGISTER r ⇒ λregister: True. λEQaddr.
546                let s' ≝ add_ticks1 s in
547                let 〈 carry, result 〉 ≝ half_add ? (get_arg_8 … s' true (REGISTER r)) (bitvector_of_nat 8 1) in
548                 set_arg_8 … s' (REGISTER r) result
549              | DIRECT d ⇒ λdirect: True. λEQaddr.
550                let s' ≝ add_ticks1 s in
551                let 〈 carry, result 〉 ≝ half_add ? (get_arg_8 … s' true (DIRECT d)) (bitvector_of_nat 8 1) in
552                 set_arg_8 … s' (DIRECT d) result
553              | INDIRECT i ⇒ λindirect: True. λEQaddr.
554                let s' ≝ add_ticks1 s in
555                let 〈 carry, result 〉 ≝ half_add ? (get_arg_8 … s' true (INDIRECT i)) (bitvector_of_nat 8 1) in
556                 set_arg_8 … s' (INDIRECT i) result
557              | DPTR ⇒ λdptr: True. λEQaddr.
558                let s' ≝ add_ticks1 s in
559                let 〈 carry, bl 〉 ≝ half_add ? (get_8051_sfr … s' SFR_DPL) (bitvector_of_nat 8 1) in
560                let 〈 carry, bu 〉 ≝ full_add ? (get_8051_sfr … s' SFR_DPH) (zero 8) carry in
561                let s ≝ set_8051_sfr … s' SFR_DPL bl in
562                 set_8051_sfr … s' SFR_DPH bu
563              | _ ⇒ λother: False. ⊥
564              ] (subaddressing_modein … addr) (refl … (subaddressing_modeel … addr))
565        | NOP ⇒ λinstr_refl.
566           let s ≝ add_ticks2 s in
567            s
568        | DEC addr ⇒ λinstr_refl.
569           let s ≝ add_ticks1 s in
570           let 〈 result, flags 〉 ≝ sub_8_with_carry (get_arg_8 … s true addr) (bitvector_of_nat 8 1) false in
571             set_arg_8 … s addr result
572        | MUL addr1 addr2 ⇒ λinstr_refl.
573           let s ≝ add_ticks1 s in
574           let acc_a_nat ≝ nat_of_bitvector 8 (get_8051_sfr … s SFR_ACC_A) in
575           let acc_b_nat ≝ nat_of_bitvector 8 (get_8051_sfr … s SFR_ACC_B) in
576           let product ≝ acc_a_nat * acc_b_nat in
577           let ov_flag ≝ product ≥ 256 in
578           let low ≝ bitvector_of_nat 8 (product mod 256) in
579           let high ≝ bitvector_of_nat 8 (product ÷ 256) in
580           let s ≝ set_8051_sfr … s SFR_ACC_A low in
581             set_8051_sfr … s SFR_ACC_B high
582        | DIV addr1 addr2 ⇒ λinstr_refl.
583           let s ≝ add_ticks1 s in
584           let acc_a_nat ≝ nat_of_bitvector 8 (get_8051_sfr … s SFR_ACC_A) in
585           let acc_b_nat ≝ nat_of_bitvector 8 (get_8051_sfr … s SFR_ACC_B) in
586             match acc_b_nat with
587               [ O ⇒ set_flags … s false (None Bit) true
588               | S o ⇒
589                 let q ≝ bitvector_of_nat 8 (acc_a_nat ÷ (S o)) in
590                 let r ≝ bitvector_of_nat 8 (acc_a_nat mod 256) in
591                 let s ≝ set_8051_sfr … s SFR_ACC_A q in
592                 let s ≝ set_8051_sfr … s SFR_ACC_B r in
593                   set_flags … s false (None Bit) false
594               ]
595        | DA addr ⇒ λinstr_refl.
596            let s ≝ add_ticks1 s in
597            let 〈acc_nu, acc_nl〉 ≝ split ? 4 4 (get_8051_sfr … s SFR_ACC_A) in
598              if (gtb (nat_of_bitvector ? acc_nl) 9) ∨ (get_ac_flag … s) then
599                let 〈result, flags〉 ≝ add_8_with_carry (get_8051_sfr … s SFR_ACC_A) (bitvector_of_nat 8 6) false in
600                let cy_flag ≝ get_index' ? O ? flags in
601                let 〈acc_nu', acc_nl'〉 ≝ split ? 4 4 result in
602                  if (gtb (nat_of_bitvector ? acc_nu') 9) ∨ cy_flag then
603                    let 〈 carry, nu 〉 ≝ half_add ? acc_nu' (bitvector_of_nat 4 6) in
604                    let new_acc ≝ nu @@ acc_nl' in
605                    let s ≝ set_8051_sfr … s SFR_ACC_A new_acc in
606                      set_flags … s cy_flag (Some ? (get_ac_flag … s)) (get_ov_flag … s)
607                  else
608                    s
609              else
610                s
611        | CLR addr ⇒ λinstr_refl.
612          match addr return λx. bool_to_Prop (is_in … [[ acc_a; carry; bit_addr ]] x) → x = addr → Σs': PreStatus m cm. ? with
613            [ ACC_A ⇒ λacc_a: True.  λEQaddr.
614              let s ≝ add_ticks1 s in
615               set_arg_8 … s ACC_A (zero 8)
616            | CARRY ⇒ λcarry: True.  λEQaddr.
617              let s ≝ add_ticks1 s in
618               set_arg_1 … s CARRY false
619            | BIT_ADDR b ⇒ λbit_addr: True.  λEQaddr.
620              let s ≝ add_ticks1 s in
621               set_arg_1 … s (BIT_ADDR b) false
622            | _ ⇒ λother: False. ⊥
623            ] (subaddressing_modein … addr) (refl … (subaddressing_modeel … addr))
624        | CPL addr ⇒ λinstr_refl.
625          match addr return λx. bool_to_Prop (is_in … [[ acc_a; carry; bit_addr ]] x) → x = addr → Σs': PreStatus m cm. ? with
626            [ ACC_A ⇒ λacc_a: True.  λEQaddr.
627                let s ≝ add_ticks1 s in
628                let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
629                let new_acc ≝ negation_bv ? old_acc in
630                 set_8051_sfr … s SFR_ACC_A new_acc
631            | CARRY ⇒ λcarry: True. λEQaddr.
632                let s ≝ add_ticks1 s in
633                let old_cy_flag ≝ get_arg_1 … s CARRY true in
634                let new_cy_flag ≝ ¬old_cy_flag in
635                 set_arg_1 … s CARRY new_cy_flag
636            | BIT_ADDR b ⇒ λbit_addr: True. λEQaddr.
637                let s ≝ add_ticks1 s in
638                let old_bit ≝ get_arg_1 … s (BIT_ADDR b) true in
639                let new_bit ≝ ¬old_bit in
640                 set_arg_1 … s (BIT_ADDR b) new_bit
641            | _ ⇒ λother: False. ?
642            ] (subaddressing_modein … addr) (refl … (subaddressing_modeel … addr))
643        | SETB b ⇒ λinstr_refl.
644            let s ≝ add_ticks1 s in
645            set_arg_1 … s b false
646        | RL _ ⇒ λinstr_refl. (* DPM: always ACC_A *)
647            let s ≝ add_ticks1 s in
648            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
649            let new_acc ≝ rotate_left … 1 old_acc in
650              set_8051_sfr … s SFR_ACC_A new_acc
651        | RR _ ⇒ λinstr_refl. (* DPM: always ACC_A *)
652            let s ≝ add_ticks1 s in
653            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
654            let new_acc ≝ rotate_right … 1 old_acc in
655              set_8051_sfr … s SFR_ACC_A new_acc
656        | RLC _ ⇒ λinstr_refl. (* DPM: always ACC_A *)
657            let s ≝ add_ticks1 s in
658            let old_cy_flag ≝ get_cy_flag ?? s in
659            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
660            let new_cy_flag ≝ get_index' ? O ? old_acc in
661            let new_acc ≝ shift_left … 1 old_acc old_cy_flag in
662            let s ≝ set_arg_1 … s CARRY new_cy_flag in
663              set_8051_sfr … s SFR_ACC_A new_acc
664        | RRC _ ⇒ λinstr_refl. (* DPM: always ACC_A *)
665            let s ≝ add_ticks1 s in
666            let old_cy_flag ≝ get_cy_flag ?? s in
667            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
668            let new_cy_flag ≝ get_index' ? 7 ? old_acc in
669            let new_acc ≝ shift_right … 1 old_acc old_cy_flag in
670            let s ≝ set_arg_1 … s CARRY new_cy_flag in
671              set_8051_sfr … s SFR_ACC_A new_acc
672        | SWAP _ ⇒ λinstr_refl. (* DPM: always ACC_A *)
673            let s ≝ add_ticks1 s in
674            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
675            let 〈nu,nl〉 ≝ split ? 4 4 old_acc in
676            let new_acc ≝ nl @@ nu in
677              set_8051_sfr … s SFR_ACC_A new_acc
678        | PUSH addr ⇒ λinstr_refl.
679            match addr return λx. bool_to_Prop (is_in … [[ direct ]] x) → x = addr → Σs': PreStatus m cm. ? with
680              [ DIRECT d ⇒ λdirect: True. λEQaddr.
681                let s ≝ add_ticks1 s in
682                let 〈carry, new_sp〉 ≝ half_add ? (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) in
683                let s ≝ set_8051_sfr … s SFR_SP new_sp in
684                  write_at_stack_pointer … s d
685              | _ ⇒ λother: False. ⊥
686              ] (subaddressing_modein … addr) (refl … (subaddressing_modeel … addr))
687        | POP addr ⇒ λinstr_refl.
688            let s ≝ add_ticks1 s in
689            let contents ≝ read_at_stack_pointer ?? s in
690            let 〈new_sp, flags〉 ≝ sub_8_with_carry (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) false in
691            let s ≝ set_8051_sfr … s SFR_SP new_sp in
692              set_arg_8 … s addr contents
693        | XCH addr1 addr2 ⇒ λinstr_refl.
694            let s ≝ add_ticks1 s in
695            let old_addr ≝ get_arg_8 … s false addr2 in
696            let old_acc ≝ get_8051_sfr … s SFR_ACC_A in
697            let s ≝ set_8051_sfr … s SFR_ACC_A old_addr in
698              set_arg_8 … s addr2 old_acc
699        | XCHD addr1 addr2 ⇒ λinstr_refl.
700            let s ≝ add_ticks1 s in
701            let 〈acc_nu, acc_nl〉 ≝ split … 4 4 (get_8051_sfr … s SFR_ACC_A) in
702            let 〈arg_nu, arg_nl〉 ≝ split … 4 4 (get_arg_8 … s false addr2) in
703            let new_acc ≝ acc_nu @@ arg_nl in
704            let new_arg ≝ arg_nu @@ acc_nl in
705            let s ≝ set_8051_sfr ?? s SFR_ACC_A new_acc in
706              set_arg_8 … s addr2 new_arg
707        | RET ⇒ λinstr_refl.
708            let s ≝ add_ticks1 s in
709            let high_bits ≝ read_at_stack_pointer ?? s in
710            let 〈new_sp, flags〉 ≝ sub_8_with_carry (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) false in
711            let s ≝ set_8051_sfr … s SFR_SP new_sp in
712            let low_bits ≝ read_at_stack_pointer ?? s in
713            let 〈new_sp, flags〉 ≝ sub_8_with_carry (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) false in
714            let s ≝ set_8051_sfr … s SFR_SP new_sp in
715            let new_pc ≝ high_bits @@ low_bits in
716              set_program_counter … s new_pc
717        | RETI ⇒ λinstr_refl.
718            let s ≝ add_ticks1 s in
719            let high_bits ≝ read_at_stack_pointer ?? s in
720            let 〈new_sp, flags〉 ≝ sub_8_with_carry (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) false in
721            let s ≝ set_8051_sfr … s SFR_SP new_sp in
722            let low_bits ≝ read_at_stack_pointer ?? s in
723            let 〈new_sp, flags〉 ≝ sub_8_with_carry (get_8051_sfr … s SFR_SP) (bitvector_of_nat 8 1) false in
724            let s ≝ set_8051_sfr … s SFR_SP new_sp in
725            let new_pc ≝ high_bits @@ low_bits in
726              set_program_counter … s new_pc
727        | MOVX addr ⇒ λinstr_refl.
728          let s ≝ add_ticks1 s in
729          (* DPM: only copies --- doesn't affect I/O *)
730          match addr with
731            [ inl l ⇒
732              let 〈addr1, addr2〉 ≝ l in
733                set_arg_8 … s addr1 (get_arg_8 … s false addr2)
734            | inr r ⇒
735              let 〈addr1, addr2〉 ≝ r in
736                set_arg_8 … s addr1 (get_arg_8 … s false addr2)
737            ]
738        | MOV addr ⇒ λinstr_refl.
739          let s ≝ add_ticks1 s in
740          match addr with
741            [ inl l ⇒
742              match l with
743                [ inl l' ⇒
744                  match l' with
745                    [ inl l'' ⇒
746                      match l'' with
747                        [ inl l''' ⇒
748                          match l''' with
749                            [ inl l'''' ⇒
750                              let 〈addr1, addr2〉 ≝ l'''' in
751                                set_arg_8 … s addr1 (get_arg_8 … s false addr2)
752                            | inr r'''' ⇒
753                              let 〈addr1, addr2〉 ≝ r'''' in
754                                set_arg_8 … s addr1 (get_arg_8 … s false addr2)
755                            ]
756                        | inr r''' ⇒
757                          let 〈addr1, addr2〉 ≝ r''' in
758                            set_arg_8 … s addr1 (get_arg_8 … s false addr2)
759                        ]
760                    | inr r'' ⇒
761                      let 〈addr1, addr2〉 ≝ r'' in
762                       set_arg_16 … s (get_arg_16 … s addr2) addr1
763                    ]
764                | inr r ⇒
765                  let 〈addr1, addr2〉 ≝ r in
766                   set_arg_1 … s addr1 (get_arg_1 … s addr2 false)
767                ]
768            | inr r ⇒
769              let 〈addr1, addr2〉 ≝ r in
770               set_arg_1 … s addr1 (get_arg_1 … s addr2 false)
771            ]
772          | JC addr ⇒ λinstr_refl.
773                  if get_cy_flag ?? s then
774                    let s ≝ add_ticks1 s in
775                      set_program_counter … s (addr_of addr s)
776                  else
777                    let s ≝ add_ticks2 s in
778                      s
779            | JNC addr ⇒ λinstr_refl.
780                  if ¬(get_cy_flag ?? s) then
781                   let s ≝ add_ticks1 s in
782                     set_program_counter … s (addr_of addr s)
783                  else
784                   let s ≝ add_ticks2 s in
785                    s
786            | JB addr1 addr2 ⇒ λinstr_refl.
787                  if get_arg_1 … s addr1 false then
788                   let s ≝ add_ticks1 s in
789                    set_program_counter … s (addr_of addr2 s)
790                  else
791                   let s ≝ add_ticks2 s in
792                    s
793            | JNB addr1 addr2 ⇒ λinstr_refl.
794                  if ¬(get_arg_1 … s addr1 false) then
795                   let s ≝ add_ticks1 s in
796                    set_program_counter … s (addr_of addr2 s)
797                  else
798                   let s ≝ add_ticks2 s in
799                    s
800            | JBC addr1 addr2 ⇒ λinstr_refl.
801                  let s ≝ set_arg_1 … s addr1 false in
802                    if get_arg_1 … s addr1 false then
803                     let s ≝ add_ticks1 s in
804                      set_program_counter … s (addr_of addr2 s)
805                    else
806                     let s ≝ add_ticks2 s in
807                      s
808            | JZ addr ⇒ λinstr_refl.
809                    if eq_bv ? (get_8051_sfr … s SFR_ACC_A) (zero 8) then
810                     let s ≝ add_ticks1 s in
811                      set_program_counter … s (addr_of addr s)
812                    else
813                     let s ≝ add_ticks2 s in
814                      s
815            | JNZ addr ⇒ λinstr_refl.
816                    if ¬(eq_bv ? (get_8051_sfr … s SFR_ACC_A) (zero 8)) then
817                     let s ≝ add_ticks1 s in
818                      set_program_counter … s (addr_of addr s)
819                    else
820                     let s ≝ add_ticks2 s in
821                      s
822            | CJNE addr1 addr2 ⇒ λinstr_refl.
823                  match addr1 with
824                    [ inl l ⇒
825                        let 〈addr1, addr2'〉 ≝ l in
826                        let new_cy ≝ ltb (nat_of_bitvector ? (get_arg_8 … s false addr1))
827                                                 (nat_of_bitvector ? (get_arg_8 … s false addr2')) in
828                          if ¬(eq_bv ? (get_arg_8 … s false addr1) (get_arg_8 … s false addr2')) then
829                            let s ≝ add_ticks1 s in
830                            let s ≝ set_program_counter … s (addr_of addr2 s) in
831                              set_flags … s new_cy (None ?) (get_ov_flag ?? s)
832                          else
833                            let s ≝ add_ticks2 s in
834                              set_flags … s new_cy (None ?) (get_ov_flag ?? s)
835                    | inr r' ⇒
836                        let 〈addr1, addr2'〉 ≝ r' in
837                        let new_cy ≝ ltb (nat_of_bitvector ? (get_arg_8 … s false addr1))
838                                                 (nat_of_bitvector ? (get_arg_8 … s false addr2')) in
839                          if ¬(eq_bv ? (get_arg_8 … s false addr1) (get_arg_8 … s false addr2')) then
840                            let s ≝ add_ticks1 s in
841                            let s ≝ set_program_counter … s (addr_of addr2 s) in
842                              set_flags … s new_cy (None ?) (get_ov_flag ?? s)
843                          else
844                            let s ≝ add_ticks2 s in
845                              set_flags … s new_cy (None ?) (get_ov_flag ?? s)
846                    ]
847            | DJNZ addr1 addr2 ⇒ λinstr_refl.
848              let 〈result, flags〉 ≝ sub_8_with_carry (get_arg_8 … s true addr1) (bitvector_of_nat 8 1) false in
849              let s ≝ set_arg_8 … s addr1 result in
850                if ¬(eq_bv ? result (zero 8)) then
851                 let s ≝ add_ticks1 s in
852                  set_program_counter … s (addr_of addr2 s)
853                else
854                 let s ≝ add_ticks2 s in
855                  s
856           ] (refl … instr))
857  try (cases(other))
858  try assumption (*20s*)
859  try (% @False) (*6s*) (* Bug exploited here to implement solve :-*)
860  try (@(execute_1_technical … (subaddressing_modein …)) @I) (*66s*)
861  whd in match execute_1_preinstruction; normalize nodelta
862  [4,5,6,7,8,36,37,38,39,40,41,50: (* INC, CLR, CPL, PUSH *)
863  (* XXX: work on the right hand side *)
864  lapply (subaddressing_modein ???)
865  <EQaddr normalize nodelta #irrelevant
866  try (>p normalize nodelta)
867  try (>p1 normalize nodelta)
868  (* XXX: switch to the left hand side *)
869  >EQP -P normalize nodelta
870  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
871  whd in ⊢ (??%?);
872  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
873  (* XXX: work on the left hand side *)
874  [1,2,3,4,5:
875    generalize in ⊢ (??(???(?%))?);
876  |6,7,8,9,10,11:
877    generalize in ⊢ (??(???(?%))?);
878  |12:
879    generalize in ⊢ (??(???(?%))?);
880  ]
881  <EQaddr normalize nodelta #irrelevant
882  try @(jmpair_as_replace ?????????? p)
883  [10: normalize nodelta try @(jmpair_as_replace ?????????? p1) ]
884  (* XXX: switch to the right hand side *)
885  normalize nodelta >EQs -s >EQticks -ticks
886  whd in ⊢ (??%%);
887  (* XXX: finally, prove the equality using sigma commutation *)
888  try @split_eq_status try % whd in ⊢ (??%%);
889  [1:
890    >low_internal_ram_set_8051_sfr >low_internal_ram_set_clock
891    >low_internal_ram_set_program_counter @eq_f2 try %
892    whd in maps_assm:(??%?); destruct %
893  |2:
894    >high_internal_ram_set_8051_sfr >high_internal_ram_set_clock
895    >high_internal_ram_set_program_counter @eq_f2 try %
896    whd in maps_assm:(??%?); destruct %
897  |3:
898    >clock_set_program_counter >clock_set_program_counter <instr_refl %
899  |4,6:
900    >set_clock_set_program_counter >get_arg_8_set_program_counter
901    >clock_set_program_counter >set_clock_mk_Status_commutation
902    >set_clock_mk_Status_commutation >clock_set_program_counter <instr_refl
903  |8:
904    cases daemon
905  ]
906  |1,2,3,9,46,51,53,54,55: (* ADD, ADDC, SUBB, DEC, SWAP, POP, XCHD, RET, RETI  *)
907  (* XXX: work on the right hand side *)
908  >p normalize nodelta
909  try (>p1 normalize nodelta)
910  (* XXX: switch to the left hand side *)
911  -instr_refl >EQP -P normalize nodelta
912  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
913  whd in ⊢ (??%?);
914  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
915  (* XXX: work on the left hand side *)
916  @(pair_replace ?????????? p)
917  [1,3,5,7,9,11,13,15,17:
918    >set_clock_set_program_counter >set_clock_mk_Status_commutation
919    >set_program_counter_mk_Status_commutation >clock_set_program_counter
920    cases daemon
921  |14,16,18:
922    normalize nodelta
923    @(pair_replace ?????????? p1)
924    [1,3,5:
925      >set_clock_mk_Status_commutation
926      cases daemon
927    ]
928  ]
929  (* XXX: switch to the right hand side *)
930  normalize nodelta >EQs -s >EQticks -ticks
931  whd in ⊢ (??%%);
932  (* XXX: finally, prove the equality using sigma commutation *)
933  try @split_eq_status try %
934  >set_clock_mk_Status_commutation
935  cases daemon (*
936       @split_eq_status try %
937       [*: whd in ⊢ (??%%); >set_clock_mk_Status_commutation
938           whd in match (set_flags ??????);
939           (* CSC: TO BE COMPLETED *)
940       ] *)
941  |10,42,43,44,45,49,52,56: (* MUL *)
942  (* XXX: work on the right hand side *)
943  (* XXX: switch to the left hand side *)
944  -instr_refl >EQP -P normalize nodelta
945  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
946  whd in ⊢ (??%?);
947  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
948  (* XXX: work on the left hand side *)
949  (* XXX: switch to the right hand side *)
950  normalize nodelta >EQs -s >EQticks -ticks
951  whd in ⊢ (??%%);
952  (* XXX: finally, prove the equality using sigma commutation *)
953  cases daemon
954  |11,12: (* DIV *)
955  (* XXX: work on the right hand side *)
956  normalize nodelta in p;
957  >p normalize nodelta
958  (* XXX: switch to the left hand side *)
959  -instr_refl >EQP -P normalize nodelta
960  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
961  whd in ⊢ (??%?);
962  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
963  @(pose … (nat_of_bitvector 8 ?)) #pose_assm #pose_refl
964  >(?: pose_assm = 0) normalize nodelta
965  [2,4:
966    <p >pose_refl
967    cases daemon
968  |1,3:
969    (* XXX: switch to the right hand side *)
970    >EQs -s >EQticks -ticks
971    whd in ⊢ (??%%);
972    (* XXX: finally, prove the equality using sigma commutation *)
973    @split_eq_status try %
974    cases daemon
975  ]
976  |13,14,15: (* DA *)
977  (* XXX: work on the right hand side *)
978  >p normalize nodelta
979  >p1 normalize nodelta
980  try (>p2 normalize nodelta
981  try (>p3 normalize nodelta
982  try (>p4 normalize nodelta
983  try (>p5 normalize nodelta))))
984  (* XXX: switch to the left hand side *)
985  -instr_refl >EQP -P normalize nodelta
986  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
987  whd in ⊢ (??%?);
988  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
989  (* XXX: work on the left hand side *)
990  @(pair_replace ?????????? p)
991  [1,3,5:
992    /demod/
993    cases daemon
994  |2,4,6:
995    @(if_then_else_replace ???????? p1)
996    [1,3,5:
997      cases daemon
998    |2,4:
999      normalize nodelta
1000      @(pair_replace ?????????? p2)
1001      [1,3:
1002        cases daemon
1003      |2,4:
1004        normalize nodelta >p3 normalize nodelta
1005        >p4 normalize nodelta try >p5
1006      ]
1007    ]
1008  (* XXX: switch to the right hand side *)
1009  normalize nodelta >EQs -s >EQticks -ticks
1010  whd in ⊢ (??%%);
1011  (* XXX: finally, prove the equality using sigma commutation *)
1012  @split_eq_status try %
1013  cases daemon
1014  ]
1015  |33,34,35,48: (* ANL, ORL, XRL, MOVX *)
1016  (* XXX: work on the right hand side *)
1017  cases addr #addr' normalize nodelta
1018  [1,3:
1019    cases addr' #addr'' normalize nodelta
1020  ]
1021  @pair_elim #lft #rgt #lft_rgt_refl >lft_rgt_refl normalize nodelta
1022  (* XXX: switch to the left hand side *)
1023  -instr_refl >EQP -P normalize nodelta
1024  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1025  whd in ⊢ (??%?);
1026  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1027  (* XXX: work on the left hand side *)
1028  (* XXX: switch to the right hand side *)
1029  normalize nodelta >EQs -s >EQticks -ticks
1030  whd in ⊢ (??%%);
1031  (* XXX: finally, prove the equality using sigma commutation *)
1032  cases daemon
1033  |47: (* MOV *)
1034  (* XXX: work on the right hand side *)
1035  cases addr -addr #addr normalize nodelta
1036  [1:
1037    cases addr #addr normalize nodelta
1038    [1:
1039      cases addr #addr normalize nodelta
1040      [1:
1041        cases addr #addr normalize nodelta
1042        [1:
1043          cases addr #addr normalize nodelta
1044        ]
1045      ]
1046    ]
1047  ]
1048  cases addr #lft #rgt normalize nodelta
1049  (* XXX: switch to the left hand side *)
1050  >EQP -P normalize nodelta
1051  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1052  whd in ⊢ (??%?);
1053  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1054  (* XXX: work on the left hand side *)
1055  (* XXX: switch to the right hand side *)
1056  normalize nodelta >EQs -s >EQticks -ticks
1057  whd in ⊢ (??%%);
1058  (* XXX: finally, prove the equality using sigma commutation *)
1059  cases daemon
1060  |17,19,21,23,25,27,29,16,18,20,22,24,26,28: (* JC, JNC, JB, JNB, JBC, JZ, JNZ (true cases last) *)
1061  (* XXX: work on the right hand side *)
1062  >p normalize nodelta
1063  (* XXX: switch to the left hand side *)
1064  -instr_refl >EQP -P normalize nodelta
1065  #sigma_increment_commutation #maps_assm #fetch_many_assm
1066 
1067  whd in match (expand_pseudo_instruction ??????) in fetch_many_assm;
1068  whd in match (expand_relative_jump ????);
1069  <EQppc in fetch_many_assm;
1070  @pair_elim #result #flags #sub16_refl
1071  @pair_elim #upper #lower #split_refl
1072  cases (eq_bv ???) normalize nodelta
1073  [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1074    >EQppc in ⊢ (% → ?); #fetch_many_assm %{1}
1075    whd in ⊢ (??%?);
1076    <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1077    (* XXX: work on the left hand side *)
1078    @(if_then_else_replace ???????? p) normalize nodelta
1079    [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1080      cases daemon
1081    ]
1082    (* XXX: switch to the right hand side *)
1083    normalize nodelta >EQs -s >EQticks -ticks
1084    whd in ⊢ (??%%);
1085    (* XXX: finally, prove the equality using sigma commutation *)
1086    @split_eq_status try %
1087    cases daemon
1088  |2,4,6,8,10,12,14,16,18,20,22,24,26,28:
1089    >EQppc
1090    * @(pose … (add 16 ??)) #intermediate_pc #EQintermediate_pc #fetch_refl
1091    * @(pose … (add 16 ??)) #intermediate_pc' #EQintermediate_pc' #fetch_refl'
1092    * @(pose … (add 16 ??)) #intermediate_pc'' #EQintermediate_pc'' #fetch_refl''
1093    #fetch_many_assm whd in fetch_many_assm; %{2}
1094    change with (execute_1 ?? = ?)
1095    @(pose … (execute_1 ? (status_of_pseudo_status …)))
1096    #status_after_1 #EQstatus_after_1
1097    <(?: ? = status_after_1)
1098    [3,6,9,12,15,18,21,24,27,30,33,36,39,42:
1099      >EQstatus_after_1 in ⊢ (???%);
1100      whd in ⊢ (???%);
1101      [1: <fetch_refl in ⊢ (???%);
1102      |2: <fetch_refl in ⊢ (???%);
1103      |3: <fetch_refl in ⊢ (???%);
1104      |4: <fetch_refl in ⊢ (???%);
1105      |5: <fetch_refl in ⊢ (???%);
1106      |6: <fetch_refl in ⊢ (???%);
1107      |7: <fetch_refl in ⊢ (???%);
1108      |8: <fetch_refl in ⊢ (???%);
1109      |9: <fetch_refl in ⊢ (???%);
1110      |10: <fetch_refl in ⊢ (???%);
1111      |11: <fetch_refl in ⊢ (???%);
1112      |12: <fetch_refl in ⊢ (???%);
1113      |13: <fetch_refl in ⊢ (???%);
1114      |14: <fetch_refl in ⊢ (???%);
1115      ]
1116      whd in ⊢ (???%);
1117      @(if_then_else_replace ???????? p)
1118      [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1119        cases daemon
1120      |2,4,6,8,10,12,14,16,18,20,22,24,26,28:
1121        normalize nodelta
1122        whd in match (addr_of_relative ????);
1123        >set_clock_mk_Status_commutation
1124        [9,10:
1125          (* XXX: demodulation not working in this case *)
1126          >program_counter_set_arg_1 in ⊢ (???%);
1127          >program_counter_set_program_counter in ⊢ (???%);
1128        |*:
1129          /demod/
1130        ]
1131        whd in ⊢ (???%);
1132        change with (add ???) in match (\snd (half_add ???));
1133        >(?: add ? intermediate_pc (sign_extension (bitvector_of_nat ? 2)) = intermediate_pc')
1134        [2,4,6,8,10,12,14,16,18,20,22,24,26,28:
1135          >bitvector_of_nat_sign_extension_equivalence
1136          [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1137            >EQintermediate_pc' %
1138          |*:
1139            repeat @le_S_S @le_O_n
1140          ]
1141        ]
1142        %
1143      ]
1144    |1,4,7,10,13,16,19,22,25,28,31,34,37,40:
1145      skip
1146    ]
1147    -status_after_1
1148    @(pose … (execute_1 ? (mk_PreStatus …)))
1149    #status_after_1 #EQstatus_after_1
1150    <(?: ? = status_after_1)
1151    [3,6,9,12,15,18,21,24,27,30,33,36,39,42:
1152      >EQstatus_after_1 in ⊢ (???%);
1153      whd in ⊢ (???%);
1154      (* XXX: matita bug with patterns across multiple goals *)
1155      [1: <fetch_refl'' in ⊢ (???%);
1156      |2: <fetch_refl' in ⊢ (???%);
1157      |3: <fetch_refl'' in ⊢ (???%);
1158      |4: <fetch_refl' in ⊢ (???%);
1159      |5: <fetch_refl'' in ⊢ (???%);
1160      |6: <fetch_refl' in ⊢ (???%);
1161      |7: <fetch_refl'' in ⊢ (???%);
1162      |8: <fetch_refl' in ⊢ (???%);
1163      |9: <fetch_refl'' in ⊢ (???%);
1164      |10: <fetch_refl' in ⊢ (???%);
1165      |11: <fetch_refl'' in ⊢ (???%);
1166      |12: <fetch_refl' in ⊢ (???%);
1167      |13: <fetch_refl'' in ⊢ (???%);
1168      |14: <fetch_refl' in ⊢ (???%);
1169      ]
1170      whd in ⊢ (???%);
1171      [9,10:
1172      |*:
1173        /demod/
1174      ] %
1175    |1,4,7,10,13,16,19,22,25,28,31,34,37,40:
1176      skip
1177    ]
1178    -status_after_1 whd in ⊢ (??%?);
1179    (* XXX: switch to the right hand side *)
1180    normalize nodelta >EQs -s >EQticks -ticks
1181    whd in ⊢ (??%%);
1182    (* XXX: finally, prove the equality using sigma commutation *)
1183    @split_eq_status try %
1184    [3,11,19,27,36,53,61:
1185      >program_counter_set_program_counter >set_clock_mk_Status_commutation
1186      [5: >program_counter_set_program_counter ]
1187      >EQaddr_of normalize nodelta
1188      whd in ⊢ (??%?); >EQlookup_labels normalize nodelta
1189      >EQcm %
1190    |7,15,23,31,45,57,65:
1191      >set_clock_mk_Status_commutation >program_counter_set_program_counter
1192      whd in ⊢ (??%?); normalize nodelta
1193      >EQppc in fetch_many_assm; #fetch_many_assm
1194      [5:
1195        >program_counter_set_arg_1 >program_counter_set_program_counter
1196      ]
1197      <(eq_bv_eq … fetch_many_assm) >EQintermediate_pc''
1198      <bitvector_of_nat_sign_extension_equivalence
1199      [1,3,5,7,9,11,13:
1200        whd in ⊢ (???%); cases (half_add ???) normalize //
1201      |2,4,6,8,10,12,14:
1202        @assembly1_lt_128
1203        @le_S_S @le_O_n
1204      ]
1205    |*:
1206      cases daemon
1207    ]
1208  ]
1209  |30: (* CJNE *)
1210  cases addr1 * #addr1_l #addr1_r normalize nodelta
1211  (* XXX: work on the right hand side *)
1212  (* XXX: switch to the left hand side *)
1213  -instr_refl >EQP -P normalize nodelta
1214  #sigma_increment_commutation #maps_assm #fetch_many_assm
1215
1216  whd in match (expand_pseudo_instruction ??????) in fetch_many_assm;
1217  whd in match (expand_relative_jump ????);
1218  <EQppc in fetch_many_assm;
1219  @pair_elim #result #flags #sub16_refl
1220  @pair_elim #upper #lower #split_refl
1221  cases (eq_bv ???) normalize nodelta
1222  [1,3:
1223    >EQppc in ⊢ (% → ?); #fetch_many_assm %{1}
1224    whd in ⊢ (??%?);
1225    <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1226    (* XXX: work on the left hand side *)
1227    inversion (¬ (eq_bv ???)) in ⊢ (???%); #eq_bv_refl normalize nodelta
1228    lapply (refl_to_jmrefl ??? eq_bv_refl) -eq_bv_refl #eq_bv_refl
1229    @(if_then_else_replace ???????? eq_bv_refl)
1230    [1,3,5,7:
1231      cases daemon
1232    |*:
1233      (* XXX: switch to the right hand side *)
1234      normalize nodelta >EQs -s >EQticks -ticks
1235      whd in ⊢ (??%%);
1236      (* XXX: finally, prove the equality using sigma commutation *)
1237      @split_eq_status try %
1238      cases daemon
1239    ]
1240  |2,4:
1241    >EQppc
1242    * @(pose … (add 16 ??)) #intermediate_pc #EQintermediate_pc #fetch_refl
1243    * @(pose … (add 16 ??)) #intermediate_pc' #EQintermediate_pc' #fetch_refl'
1244    * @(pose … (add 16 ??)) #intermediate_pc'' #EQintermediate_pc'' #fetch_refl''
1245    #fetch_many_assm whd in fetch_many_assm; %{2}
1246    change with (execute_1 ?? = ?)
1247    @(pose … (execute_1 ? (status_of_pseudo_status …)))
1248    #status_after_1 #EQstatus_after_1
1249    <(?: ? = status_after_1)
1250    [3,6:
1251      >EQstatus_after_1 in ⊢ (???%);
1252      whd in ⊢ (???%);
1253      [1:
1254        <fetch_refl in ⊢ (???%);
1255      |2:
1256        <fetch_refl in ⊢ (???%);
1257      ]
1258      whd in ⊢ (???%);
1259      cases (¬ eq_bv ???) normalize nodelta
1260      whd in match (addr_of_relative ????);
1261      >set_clock_mk_Status_commutation
1262      whd in ⊢ (???%);
1263        [9,10:
1264          (* XXX: demodulation not working in this case *)
1265          >program_counter_set_arg_1 in ⊢ (???%);
1266          >program_counter_set_program_counter in ⊢ (???%);
1267        |*:
1268          /demod/
1269        ]
1270        whd in ⊢ (???%);
1271        change with (add ???) in match (\snd (half_add ???));
1272        >(?: add ? intermediate_pc (sign_extension (bitvector_of_nat ? 2)) = intermediate_pc')
1273        [2,4,6,8,10,12,14,16,18,20,22,24,26,28:
1274          >bitvector_of_nat_sign_extension_equivalence
1275          [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1276            >EQintermediate_pc' %
1277          |*:
1278            repeat @le_S_S @le_O_n
1279          ]
1280        ]
1281        %
1282    ]
1283     
1284  ]
1285]
1286cases daemon (* XXX: CJNE and DJNZ cases *)
1287qed.
1288(*   
1289   
1290
1291    @list_addressing_mode_tags_elim_prop try % whd
1292    @list_addressing_mode_tags_elim_prop try % whd #arg
1293    (* XXX: we first work on sigma_increment_commutation *)
1294    #sigma_increment_commutation
1295    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1296    (* XXX: we work on the maps *)
1297    whd in ⊢ (??%? → ?);
1298    try (change with (if ? then ? else ? = ? → ?)
1299         cases (addressing_mode_ok ????? ∧ addressing_mode_ok ?????) normalize nodelta)
1300    #H try @(None_Some_elim ??? H) @(Some_Some_elim ????? H) #map_refl_assm <map_refl_assm
1301    (* XXX: we assume the fetch_many hypothesis *)
1302    #fetch_many_assm
1303    (* XXX: we give the existential *)
1304    %{1}
1305    whd in match (execute_1_pseudo_instruction0 ?????);
1306    (* XXX: work on the left hand side of the equality *)
1307    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1308    (* XXX: execute fetches some more *)
1309    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1310    whd in fetch_many_assm;
1311    >EQassembled in fetch_many_assm;
1312    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1313    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1314    #fetch_many_assm whd in fetch_many_assm;
1315    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1316    >(eq_instruction_to_eq … eq_instr) -instr
1317    [ @(pose … (pi1 … (execute_1_preinstruction' …))) #lhs #EQlhs
1318      @(pose …
1319        (λlhs. status_of_pseudo_status M 〈preamble,instr_list〉 lhs sigma policy))
1320      #Pl #EQPl
1321      cut (∀A,B:Type[0].∀f,f':A → B.∀x. f=f' → f x = f' x) [2: #eq_f_g_to_eq
1322      lapply (λy.eq_f_g_to_eq ???? y EQPl) #XX <(XX lhs) -XX >EQlhs -lhs
1323      whd in ⊢ (??%?); whd in ⊢ (??(???%)(?(???%)));
1324      @pair_elim
1325      >tech_pi1_let_as_commute
1326
1327*) 
1328
1329
1330theorem main_thm:
1331  ∀M.
1332  ∀M'.
1333  ∀program: pseudo_assembly_program.
1334  ∀sigma: Word → Word.
1335  ∀policy: Word → bool.
1336  ∀sigma_policy_specification_witness: sigma_policy_specification program sigma policy.
1337  ∀ps: PseudoStatus program.
1338    next_internal_pseudo_address_map M program ps = Some … M' →
1339      ∃n. execute n … (status_of_pseudo_status M … ps sigma policy) =
1340        status_of_pseudo_status M' …
1341          (execute_1_pseudo_instruction (ticks_of program sigma policy) program ps) sigma policy.
1342  #M #M' * #preamble #instr_list #sigma #policy #sigma_policy_witness #ps
1343  change with (next_internal_pseudo_address_map0 ????? = ? → ?)
1344  @(pose … (program_counter ?? ps)) #ppc #EQppc
1345  generalize in match (fetch_assembly_pseudo2 〈preamble,instr_list〉 sigma policy sigma_policy_witness ppc) in ⊢ ?;
1346  @pair_elim #labels #costs #create_label_cost_refl normalize nodelta
1347  @pair_elim #assembled #costs' #assembly_refl normalize nodelta
1348  lapply (pair_destruct_1 ????? (sym_eq ??? assembly_refl)) #EQassembled
1349  @pair_elim #pi #newppc #fetch_pseudo_refl normalize nodelta
1350  @(pose … (λx. sigma (address_of_word_labels_code_mem instr_list x))) #lookup_labels #EQlookup_labels
1351  @(pose … (λx. lookup_def … (construct_datalabels preamble) x (zero 16))) #lookup_datalabels #EQlookup_datalabels
1352  whd in match execute_1_pseudo_instruction; normalize nodelta
1353  whd in match ticks_of; normalize nodelta <EQppc >fetch_pseudo_refl normalize nodelta
1354  lapply (snd_fetch_pseudo_instruction instr_list ppc) >fetch_pseudo_refl #EQnewppc >EQnewppc
1355  lapply (snd_assembly_1_pseudoinstruction_ok 〈preamble,instr_list〉 … sigma policy sigma_policy_witness … ppc pi … EQlookup_labels EQlookup_datalabels ?)
1356  [1: >fetch_pseudo_refl % ]
1357  #assm1 #assm2 #assm3 generalize in match assm2; generalize in match assm3;
1358  generalize in match assm1; -assm1 -assm2 -assm3
1359  normalize nodelta
1360  cases pi
1361  [2,3:
1362    #arg
1363    (* XXX: we first work on sigma_increment_commutation *)
1364    #sigma_increment_commutation
1365    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1366    (* XXX: we work on the maps *)
1367    whd in ⊢ (??%? → ?); @Some_Some_elim #map_refl_assm <map_refl_assm
1368    (* XXX: we assume the fetch_many hypothesis *)
1369    #fetch_many_assm
1370    (* XXX: we give the existential *)
1371    %{0}
1372    whd in match (execute_1_pseudo_instruction0 ?????);
1373    (* XXX: work on the left hand side of the equality *)
1374    whd in ⊢ (??%?);
1375    @split_eq_status //
1376    [1,2: /demod/ >EQnewppc >sigma_increment_commutation <add_zero % (*CSC: auto not working, why? *) ]
1377  |6: (* Mov *)
1378    #arg1 #arg2
1379    (* XXX: we first work on sigma_increment_commutation *)
1380    #sigma_increment_commutation
1381    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1382    (* XXX: we work on the maps *)
1383    whd in ⊢ (??%? → ?); @Some_Some_elim #map_refl_assm <map_refl_assm
1384    (* XXX: we assume the fetch_many hypothesis *)
1385    #fetch_many_assm
1386    (* XXX: we give the existential *)
1387    %{1}
1388    whd in match (execute_1_pseudo_instruction0 ?????);
1389    (* XXX: work on the left hand side of the equality *)
1390    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1391    (* XXX: execute fetches some more *)
1392    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1393    whd in fetch_many_assm;
1394    >EQassembled in fetch_many_assm;
1395    cases (fetch ??) * #instr #newpc #ticks normalize nodelta *
1396    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1397    #fetch_many_assm whd in fetch_many_assm;
1398    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1399    >(eq_instruction_to_eq … eq_instr) -instr whd in ⊢ (??%?);
1400    (* XXX: now we start to work on the mk_PreStatus equality *)
1401    (* XXX: lhs *)
1402    change with (set_arg_16 ????? = ?)
1403    >set_program_counter_mk_Status_commutation
1404    >set_clock_mk_Status_commutation
1405    >set_arg_16_mk_Status_commutation
1406    (* XXX: rhs *)
1407    change with (? = status_of_pseudo_status ?? (set_arg_16 ?????) ??)
1408    >set_program_counter_mk_Status_commutation
1409    >set_clock_mk_Status_commutation
1410    >set_arg_16_mk_Status_commutation in ⊢ (???%);
1411    (* here we are *)
1412    @split_eq_status //
1413    [1:
1414      assumption
1415    |2:
1416      @special_function_registers_8051_set_arg_16
1417      [2: >EQlookup_datalabels %
1418      |1: //
1419      ]
1420    ]
1421  |1: (* Instruction *) -pi; #instr
1422    @(main_lemma_preinstruction M M' preamble instr_list … (refl …) … sigma_policy_witness
1423      … EQppc … create_label_cost_refl … assembly_refl EQassembled … EQlookup_labels …
1424      EQlookup_datalabels EQnewppc instr … (refl …) … (refl …) … (refl …) … (refl …))
1425  |4,5: cases daemon
1426  ]
1427qed.
1428(* 
1429    *
1430    [1,2,3: (* ADD, ADDC, SUBB *)
1431    @list_addressing_mode_tags_elim_prop try % whd
1432    @list_addressing_mode_tags_elim_prop try % whd #arg
1433    (* XXX: we first work on sigma_increment_commutation *)
1434    #sigma_increment_commutation
1435    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1436    (* XXX: we work on the maps *)
1437    whd in ⊢ (??%? → ?);
1438    try (change with (if ? then ? else ? = ? → ?)
1439         cases (addressing_mode_ok ????? ∧ addressing_mode_ok ?????) normalize nodelta)
1440    #H try @(None_Some_elim ??? H) @(Some_Some_elim ????? H) #map_refl_assm <map_refl_assm
1441    (* XXX: we assume the fetch_many hypothesis *)
1442    #fetch_many_assm
1443    (* XXX: we give the existential *)
1444    %{1}
1445    whd in match (execute_1_pseudo_instruction0 ?????);
1446    (* XXX: work on the left hand side of the equality *)
1447    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1448    (* XXX: execute fetches some more *)
1449    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1450    whd in fetch_many_assm;
1451    >EQassembled in fetch_many_assm;
1452    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1453    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1454    #fetch_many_assm whd in fetch_many_assm;
1455    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1456    >(eq_instruction_to_eq … eq_instr) -instr
1457    [ @(pose … (pi1 … (execute_1_preinstruction' …))) #lhs #EQlhs
1458      @(pose …
1459        (λlhs. status_of_pseudo_status M 〈preamble,instr_list〉 lhs sigma policy))
1460      #Pl #EQPl
1461      cut (∀A,B:Type[0].∀f,f':A → B.∀x. f=f' → f x = f' x) [2: #eq_f_g_to_eq
1462      lapply (λy.eq_f_g_to_eq ???? y EQPl) #XX <(XX lhs) -XX >EQlhs -lhs
1463      whd in ⊢ (??%?); whd in ⊢ (??(???%)(?(???%)));
1464      @pair_elim
1465      >tech_pi1_let_as_commute
1466   
1467   
1468    whd in ⊢ (??%?);
1469    [ @(pose … (execute_1_preinstruction' ???????))
1470      #lhs whd in ⊢ (???% → ?); #EQlhs
1471      @(pose … (execute_1_preinstruction' ???????))
1472      #rhs whd in ⊢ (???% → ?); #EQrhs
1473
1474
1475      CSC: delirium
1476     
1477      >EQlhs -EQlhs >EQrhs -EQrhs
1478      cases (add_8_with_carry ???) #bits1 #bits2 whd in ⊢ (??%%);
1479     
1480     lapply (refl ? (execute_1_preinstruction' ???????));
1481    [ whd in match (execute_1_preinstruction' ???????);
1482
1483    whd in ⊢ (??%?);
1484    [ whd in ⊢ (??(???%)%);
1485      whd in match (execute_1_preinstruction' ???????);
1486      cases (add_8_with_carry ???) #bits1 #bits2 whd in ⊢ (??%?);
1487      @pair_elim #result #flags #Heq1
1488    whd in match execute_1_preinstruction'; normalize nodelta
1489    (* XXX: now we start to work on the mk_PreStatus equality *)
1490    whd in ⊢ (??%?);
1491 
1492 
1493 
1494    [1,2,3: (* ADD, ADDC, SUBB *) #arg1 #arg2
1495    (* XXX: we take up the hypotheses *)
1496    #sigma_increment_commutation #next_map_assm #fetch_many_assm
1497    (* XXX: we give the existential *)
1498    %{1}
1499    whd in match (execute_1_pseudo_instruction0 ?????);
1500    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1501    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1502    (* XXX: fetching of the instruction *)
1503    whd in fetch_many_assm;
1504    >EQassembled in fetch_many_assm;
1505    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1506    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1507    #fetch_many_assm whd in fetch_many_assm;
1508    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1509    >(eq_instruction_to_eq … eq_instr) -instr
1510    (* XXX: now we start to work on the mk_PreStatus equality *)
1511    whd in ⊢ (??%?);
1512    check execute_1_preinstruction
1513   
1514   
1515     #MAP #H1 #H2 #EQ %[1,3,5:@1]
1516       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1517       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1518       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1519       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1520       >H2b >(eq_instruction_to_eq … H2a)
1521       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); generalize in match MAP; -MAP;
1522       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1;
1523       @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2
1524       normalize nodelta; #MAP;
1525       [1: change in ⊢ (? → %) with
1526        ((let 〈result,flags〉 ≝
1527          add_8_with_carry
1528           (get_arg_8 ? ps false ACC_A)
1529           (get_arg_8 ?
1530             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1531             false (DIRECT ARG2))
1532           ? in ?) = ?)
1533        [2,3: %]
1534        change in ⊢ (???% → ?) with
1535         (let 〈result,flags〉 ≝ add_8_with_carry ?(*(get_arg_8 ? ps false ACC_A)*) ?? in ?)
1536        >get_arg_8_set_clock
1537       [1,2: cases (addressing_mode_ok ???? ∧ addressing_mode_ok ????) in MAP ⊢ ?
1538         [2,4: #abs @⊥ normalize in abs; destruct (abs)
1539         |*:whd in ⊢ (??%? → ?) #H <(option_destruct_Some ??? H)]
1540       [ change in ⊢ (? → %) with
1541        ((let 〈result,flags〉 ≝
1542          add_8_with_carry
1543           (get_arg_8 ? ps false ACC_A)
1544           (get_arg_8 ?
1545             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1546             false (DIRECT ARG2))
1547           ? in ?) = ?)
1548          >get_arg_8_set_low_internal_ram
1549       
1550        cases (add_8_with_carry ???)
1551         
1552        [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)]
1553       #result #flags
1554       #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) %
1555
1556
1557  |4: (* Jmp *) #label whd in ⊢ (??%? → ???% → ?);
1558   @Some_Some_elim #MAP cases (pol ?) normalize nodelta
1559       [3: (* long *) #EQ3 @(Some_Some_elim ????? EQ3) #EQ3'
1560         whd in match eject normalize nodelta >EQ3' in ⊢ (% → ?) whd in ⊢ (% → ?)
1561         @pair_elim' * #instr #newppc' #ticks #EQ4       
1562         * * #H2a #H2b whd in ⊢ (% → ?) #H2
1563         >H2b >(eq_instruction_to_eq … H2a)
1564         #EQ %[@1]
1565         <MAP >(eq_bv_eq … H2) >EQ
1566         whd in ⊢ (??%?) >EQ4 whd in ⊢ (??%?)
1567         cases ps in EQ4; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXX >XXX %
1568         whd in ⊢ (??%?)
1569         whd in ⊢ (??(match ?%? with [_ ⇒ ?])?)
1570         cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX %
1571  |5: (* Call *) #label #MAP
1572      generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP <MAP -MAP;
1573      whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta;
1574       [ (* short *) #abs @⊥ destruct (abs)
1575       |3: (* long *) #H1 #H2 #EQ %[@1]
1576           (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1577           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1578           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1579           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1580           >H2b >(eq_instruction_to_eq … H2a)
1581           generalize in match EQ; -EQ;
1582           whd in ⊢ (???% → ??%?);
1583           generalize in match (refl … (half_add 8 (get_8051_sfr ? ps SFR_SP) (bitvector_of_nat ? 1))) cases (half_add ???) in ⊢ (??%? → %) #carry #new_sp #EQ1 normalize nodelta;
1584           >(eq_bv_eq … H2c)
1585           change with
1586            ((?=let 〈ppc_bu,ppc_bl〉 ≝ split bool 8 8 newppc in ?) →
1587                (let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?)
1588           generalize in match (refl … (split … 8 8 newppc)) cases (split bool 8 8 newppc) in ⊢ (??%? → %) #ppc_bu #ppc_bl #EQppc
1589           generalize in match (refl … (split … 8 8 (sigma 〈preamble,instr_list〉 pol newppc))) cases (split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc)) in ⊢ (??%? → %) #pc_bu #pc_bl #EQpc normalize nodelta;
1590           >get_8051_sfr_write_at_stack_pointer >get_8051_sfr_write_at_stack_pointer
1591           >get_8051_sfr_set_8051_sfr >get_8051_sfr_set_8051_sfr
1592           generalize in match (refl … (half_add ? new_sp (bitvector_of_nat ? 1))) cases (half_add ???) in ⊢ (??%? → %) #carry' #new_sp' #EQ2 normalize nodelta;
1593           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1594           @split_eq_status;
1595            [ >code_memory_write_at_stack_pointer whd in ⊢ (??%?)
1596              >code_memory_write_at_stack_pointer %
1597            | >set_program_counter_set_low_internal_ram
1598              >set_clock_set_low_internal_ram
1599              @low_internal_ram_write_at_stack_pointer
1600               [ >EQ0 @pol | % | %
1601               | @(  … EQ1)
1602               | @(pair_destruct_2 … EQ2)
1603               | >(pair_destruct_1 ????? EQpc)
1604                 >(pair_destruct_2 ????? EQpc)
1605                 @split_elim #x #y #H <H -x y H;
1606                 >(pair_destruct_1 ????? EQppc)
1607                 >(pair_destruct_2 ????? EQppc)
1608                 @split_elim #x #y #H <H -x y H;
1609                 >EQ0 % ]
1610            | >set_low_internal_ram_set_high_internal_ram
1611              >set_program_counter_set_high_internal_ram
1612              >set_clock_set_high_internal_ram
1613              @high_internal_ram_write_at_stack_pointer
1614               [ >EQ0 @pol | % | %
1615               | @(pair_destruct_2 … EQ1)
1616               | @(pair_destruct_2 … EQ2)
1617               | >(pair_destruct_1 ????? EQpc)
1618                 >(pair_destruct_2 ????? EQpc)
1619                 @split_elim #x #y #H <H -x y H;
1620                 >(pair_destruct_1 ????? EQppc)
1621                 >(pair_destruct_2 ????? EQppc)
1622                 @split_elim #x #y #H <H -x y H;
1623                 >EQ0 % ]           
1624            | >external_ram_write_at_stack_pointer whd in ⊢ (??%?)
1625              >external_ram_write_at_stack_pointer whd in ⊢ (???%)
1626              >external_ram_write_at_stack_pointer whd in ⊢ (???%)
1627              >external_ram_write_at_stack_pointer %
1628            | change with (? = sigma ?? (address_of_word_labels_code_mem (\snd (code_memory ? ps)) ?))
1629              >EQ0 %
1630            | >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (??%?)
1631              >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (???%)
1632              >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (???%)
1633              >special_function_registers_8051_write_at_stack_pointer %
1634            | >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (??%?)
1635              >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (???%)
1636              >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (???%)
1637              >special_function_registers_8052_write_at_stack_pointer %
1638            | >p1_latch_write_at_stack_pointer whd in ⊢ (??%?)
1639              >p1_latch_write_at_stack_pointer whd in ⊢ (???%)
1640              >p1_latch_write_at_stack_pointer whd in ⊢ (???%)
1641              >p1_latch_write_at_stack_pointer %
1642            | >p3_latch_write_at_stack_pointer whd in ⊢ (??%?)
1643              >p3_latch_write_at_stack_pointer whd in ⊢ (???%)
1644              >p3_latch_write_at_stack_pointer whd in ⊢ (???%)
1645              >p3_latch_write_at_stack_pointer %
1646            | >clock_write_at_stack_pointer whd in ⊢ (??%?)
1647              >clock_write_at_stack_pointer whd in ⊢ (???%)
1648              >clock_write_at_stack_pointer whd in ⊢ (???%)
1649              >clock_write_at_stack_pointer %]
1650       (*| (* medium *)  #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1651         @pair_elim' #fst_5_addr #rest_addr #EQ1
1652         @pair_elim' #fst_5_pc #rest_pc #EQ2
1653         generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc))
1654         cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)]
1655         generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?)
1656         change in ⊢ (? →??%?) with (execute_1_0 ??)
1657         @pair_elim' * #instr #newppc' #ticks #EQn
1658          * * #H2a #H2b whd in ⊢ (% → ?) #H2c >H2b >(eq_instruction_to_eq … H2a) whd in ⊢ (??%?)
1659          generalize in match EQ; -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1660          @pair_elim' #carry #new_sp change with (half_add ? (get_8051_sfr ? ps ?) ? = ? → ?) #EQ4
1661          @split_elim' #pc_bu #pc_bl >program_counter_set_8051_sfr XXX change with (newppc = ?) #EQ5
1662          @pair_elim' #carry' #new_sp' #EQ6 normalize nodelta; #EQx >EQx -EQx;
1663          change in ⊢ (??(match ????% with [_ ⇒ ?])?) with (sigma … newppc)
1664          @split_elim' #pc_bu' #pc_bl' #EQ7 change with (newppc' = ? → ?)
1665          >get_8051_sfr_set_8051_sfr
1666         
1667          whd in EQ:(???%) ⊢ ? >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?)
1668           change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 newppc) in ?)=?)
1669           generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 newppc)))
1670           cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4
1671           generalize in match (refl … (split bool 4 4 pc_bu))
1672           cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5
1673           generalize in match (refl … (split bool 3 8 rest_addr))
1674           cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6
1675           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?)
1676           generalize in match
1677            (refl …
1678             (half_add 16 (sigma 〈preamble,instr_list〉 newppc)
1679             ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2)))
1680           cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7
1681           @split_eq_status try %
1682            [ change with (? = sigma ? (address_of_word_labels ps label))
1683              (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1684            | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?)
1685              @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]] *)]
1686  |4: (* Jmp *) #label #MAP
1687      generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP >MAP -MAP;
1688      whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta;
1689       [3: (* long *) #H1 #H2 #EQ %[@1]
1690           (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1691           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1692           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1693           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1694           >H2b >(eq_instruction_to_eq … H2a)
1695           generalize in match EQ; -EQ;
1696           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1697           cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX %
1698       |1: (* short *) #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1699           generalize in match
1700            (refl ?
1701             (sub_16_with_carry
1702              (sigma 〈preamble,instr_list〉 pol (program_counter … ps))
1703              (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label))
1704              false))
1705           cases (sub_16_with_carry ???) in ⊢ (??%? → %); #results #flags normalize nodelta;
1706           generalize in match (refl … (split … 8 8 results)) cases (split ????) in ⊢ (??%? → %) #upper #lower normalize nodelta;
1707           generalize in match (refl … (eq_bv … upper (zero 8))) cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta;
1708           #EQ1 #EQ2 #EQ3 #H1 [2: @⊥ destruct (H1)]
1709           generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1710           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1711           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1712           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1713           >H2b >(eq_instruction_to_eq … H2a)
1714           generalize in match EQ; -EQ;
1715           whd in ⊢ (???% → ?);
1716           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1717           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma ???) ? in ?) = ?)
1718           generalize in match (refl … (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc) (sign_extension lower)))
1719           cases (half_add ???) in ⊢ (??%? → %) #carry #newpc normalize nodelta #EQ4
1720           @split_eq_status try % change with (newpc = sigma ?? (address_of_word_labels ps label))
1721           (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1722       | (* medium *)  #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1723         generalize in match
1724          (refl …
1725            (split … 5 11 (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label))))
1726         cases (split ????) in ⊢ (??%? → %) #fst_5_addr #rest_addr normalize nodelta; #EQ1
1727         generalize in match
1728          (refl …
1729            (split … 5 11 (sigma 〈preamble,instr_list〉 pol (program_counter … ps))))
1730         cases (split ????) in ⊢ (??%? → %) #fst_5_pc #rest_pc normalize nodelta; #EQ2
1731         generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc))
1732         cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)]
1733         generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?)
1734         change in ⊢ (? →??%?) with (execute_1_0 ??)
1735           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1736           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1737           >H2b >(eq_instruction_to_eq … H2a)
1738           generalize in match EQ; -EQ;
1739           whd in ⊢ (???% → ?);
1740           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?)
1741           change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?)
1742           generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc)))
1743           cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4
1744           generalize in match (refl … (split bool 4 4 pc_bu))
1745           cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5
1746           generalize in match (refl … (split bool 3 8 rest_addr))
1747           cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6
1748           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?)
1749           generalize in match
1750            (refl …
1751             (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc)
1752             ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2)))
1753           cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7   
1754           @split_eq_status try %
1755            [ change with (? = sigma ?? (address_of_word_labels ps label))
1756              (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1757            | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?)
1758              @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]]
1759  | (* Instruction *) -pi;  whd in ⊢ (? → ??%? → ?) *; normalize nodelta;
1760    [1,2,3: (* ADD, ADDC, SUBB *) #arg1 #arg2 #MAP #H1 #H2 #EQ %[1,3,5:@1]
1761       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1762       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1763       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1764       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1765       >H2b >(eq_instruction_to_eq … H2a)
1766       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); generalize in match MAP; -MAP;
1767       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1;
1768       @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2
1769       normalize nodelta; #MAP;
1770       [1: change in ⊢ (? → %) with
1771        ((let 〈result,flags〉 ≝
1772          add_8_with_carry
1773           (get_arg_8 ? ps false ACC_A)
1774           (get_arg_8 ?
1775             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1776             false (DIRECT ARG2))
1777           ? in ?) = ?)
1778        [2,3: %]
1779        change in ⊢ (???% → ?) with
1780         (let 〈result,flags〉 ≝ add_8_with_carry ?(*(get_arg_8 ? ps false ACC_A)*) ?? in ?)
1781        >get_arg_8_set_clock
1782       [1,2: cases (addressing_mode_ok ???? ∧ addressing_mode_ok ????) in MAP ⊢ ?
1783         [2,4: #abs @⊥ normalize in abs; destruct (abs)
1784         |*:whd in ⊢ (??%? → ?) #H <(option_destruct_Some ??? H)]
1785       [ change in ⊢ (? → %) with
1786        ((let 〈result,flags〉 ≝
1787          add_8_with_carry
1788           (get_arg_8 ? ps false ACC_A)
1789           (get_arg_8 ?
1790             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1791             false (DIRECT ARG2))
1792           ? in ?) = ?)
1793          >get_arg_8_set_low_internal_ram
1794       
1795        cases (add_8_with_carry ???)
1796         
1797        [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)]
1798       #result #flags
1799       #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) %
1800    | (* INC *) #arg1 #H1 #H2 #EQ %[@1]
1801       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1802       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1803       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1804       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1805       >H2b >(eq_instruction_to_eq … H2a)
1806       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?);
1807       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1; normalize nodelta; [1,2,3: #ARG]
1808       [1,2,3,4: cases (half_add ???) #carry #result
1809       | cases (half_add ???) #carry #bl normalize nodelta;
1810         cases (full_add ????) #carry' #bu normalize nodelta ]
1811        #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) -newppc';
1812        [5: %
1813        |1: <(set_arg_8_set_code_memory 0 [[direct]] ? ? ? (set_clock pseudo_assembly_program
1814      (set_program_counter pseudo_assembly_program ps newppc)
1815      (\fst  (ticks_of0 〈preamble,instr_list〉
1816                   (program_counter pseudo_assembly_program ps)
1817                   (Instruction (INC Identifier (DIRECT ARG))))
1818       +clock pseudo_assembly_program
1819        (set_program_counter pseudo_assembly_program ps newppc))) (load_code_memory assembled) result (DIRECT ARG))
1820        [2,3: // ]
1821            <(set_arg_8_set_program_counter 0 [[direct]] ? ? ? ? ?) [2://]
1822            whd in ⊢ (??%%)
1823            cases (split bool 4 4 ARG)
1824            #nu' #nl'
1825            normalize nodelta
1826            cases (split bool 1 3 nu')
1827            #bit_1' #ignore'
1828            normalize nodelta
1829            cases (get_index_v bool 4 nu' ? ?)
1830            [ normalize nodelta (* HERE *) whd in ⊢ (??%%) %
1831            |
1832            ]
1833cases daemon (* EASY CASES TO BE COMPLETED *)
1834qed.
1835*)
Note: See TracBrowser for help on using the repository browser.