source: src/ASM/AssemblyProofSplit.ma @ 2018

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

CJNE case a complete mess.

File size: 78.7 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  [30: (* CJNE *)
863  (* XXX: work on the right hand side *)
864  cases addr1 -addr1 #addr1 normalize nodelta
865  cases addr1 -addr1 #addr1_l #addr1_r normalize nodelta
866  (* XXX: switch to the left hand side *)
867  >EQP -P normalize nodelta
868  #sigma_increment_commutation #maps_assm #fetch_many_assm
869
870  whd in match (expand_pseudo_instruction ??????) in fetch_many_assm;
871  whd in match (expand_relative_jump ????);
872  <EQppc in fetch_many_assm;
873  @pair_elim #result #flags #sub16_refl
874  @pair_elim #upper #lower #split_refl
875  inversion (eq_bv ???) #upper_split_refl normalize nodelta
876  [1,3:
877    >EQppc in ⊢ (% → ?); #fetch_many_assm %{1}
878    whd in ⊢ (??%?);
879    <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
880    inversion (¬ (eq_bv ???)) in ⊢ (???%); #eq_bv_refl normalize nodelta
881    lapply (refl_to_jmrefl ??? eq_bv_refl) -eq_bv_refl #eq_bv_refl
882    @(if_then_else_replace ???????? eq_bv_refl)
883    [1,3,5,7:
884      cases daemon
885    |2,4,6,8:
886      (* XXX: switch to the right hand side *)
887      normalize nodelta >EQs -s >EQticks -ticks
888      whd in ⊢ (??%%);
889      (* XXX: finally, prove the equality using sigma commutation *)
890      @split_eq_status try %
891      [3,7,11,15:
892        whd in ⊢ (??%?);
893        [1,3:
894          cases daemon
895        |2,4:
896          cases daemon
897        ]
898      ]
899      cases daemon (* XXX *)
900    ]
901  |2,4:
902    >EQppc
903    * @(pose … (add 16 ??)) #intermediate_pc #EQintermediate_pc #fetch_refl
904    * @(pose … (add 16 ??)) #intermediate_pc' #EQintermediate_pc' #fetch_refl'
905    * @(pose … (add 16 ??)) #intermediate_pc'' #EQintermediate_pc'' #fetch_refl''
906    #fetch_many_assm whd in fetch_many_assm; %{2}
907    change with (execute_1 ?? = ?)
908    @(pose … (execute_1 ? (status_of_pseudo_status …)))
909    #status_after_1 #EQstatus_after_1
910    <(?: ? = status_after_1)
911    [3,6:
912      >EQstatus_after_1 in ⊢ (???%);
913      whd in ⊢ (???%);
914      [1: <fetch_refl in ⊢ (???%);
915      |2: <fetch_refl in ⊢ (???%);
916      ]
917      whd in ⊢ (???%);
918      inversion (¬ (eq_bv ???)) in ⊢ (???%); #eq_bv_refl normalize nodelta
919      whd in ⊢ (???%);
920      whd in match (addr_of_relative ????);
921      change with (add ???) in match (\snd (half_add ???));
922      >set_clock_set_program_counter in ⊢ (???%);
923      >program_counter_set_program_counter in ⊢ (???%);
924      >(?: add ? intermediate_pc (sign_extension (bitvector_of_nat ? 2)) = intermediate_pc')
925      [2,4,6,8:
926        >bitvector_of_nat_sign_extension_equivalence
927        [1,3,5,7:
928          >EQintermediate_pc' %
929        |*:
930          repeat @le_S_S @le_O_n
931        ]
932      ]
933      [1,3: % ]
934    ]
935  ]
936  |17,19,21,23,25,27,29,16,18,20,22,24,26,28: (* JC, JNC, JB, JNB, JBC, JZ, JNZ (true cases last) *)
937  (* XXX: work on the right hand side *)
938  >p normalize nodelta
939  (* XXX: switch to the left hand side *)
940  -instr_refl >EQP -P normalize nodelta
941  #sigma_increment_commutation #maps_assm #fetch_many_assm
942 
943  whd in match (expand_pseudo_instruction ??????) in fetch_many_assm;
944  whd in match (expand_relative_jump ????);
945  <EQppc in fetch_many_assm;
946  @pair_elim #result #flags #sub16_refl
947  @pair_elim #upper #lower #split_refl
948  cases (eq_bv ???) normalize nodelta
949  [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
950    >EQppc in ⊢ (% → ?); #fetch_many_assm %{1}
951    whd in ⊢ (??%?);
952    <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
953    (* XXX: work on the left hand side *)
954    @(if_then_else_replace ???????? p) normalize nodelta
955    [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
956      cases daemon
957    ]
958    (* XXX: switch to the right hand side *)
959    normalize nodelta >EQs -s >EQticks -ticks
960    whd in ⊢ (??%%);
961    (* XXX: finally, prove the equality using sigma commutation *)
962    @split_eq_status try %
963    cases daemon
964  |2,4,6,8,10,12,14,16,18,20,22,24,26,28:
965    >EQppc
966    * @(pose … (add 16 ??)) #intermediate_pc #EQintermediate_pc #fetch_refl
967    * @(pose … (add 16 ??)) #intermediate_pc' #EQintermediate_pc' #fetch_refl'
968    * @(pose … (add 16 ??)) #intermediate_pc'' #EQintermediate_pc'' #fetch_refl''
969    #fetch_many_assm whd in fetch_many_assm; %{2}
970    change with (execute_1 ?? = ?)
971    @(pose … (execute_1 ? (status_of_pseudo_status …)))
972    #status_after_1 #EQstatus_after_1
973    <(?: ? = status_after_1)
974    [3,6,9,12,15,18,21,24,27,30,33,36,39,42:
975      >EQstatus_after_1 in ⊢ (???%);
976      whd in ⊢ (???%);
977      [1: <fetch_refl in ⊢ (???%);
978      |2: <fetch_refl in ⊢ (???%);
979      |3: <fetch_refl in ⊢ (???%);
980      |4: <fetch_refl in ⊢ (???%);
981      |5: <fetch_refl in ⊢ (???%);
982      |6: <fetch_refl in ⊢ (???%);
983      |7: <fetch_refl in ⊢ (???%);
984      |8: <fetch_refl in ⊢ (???%);
985      |9: <fetch_refl in ⊢ (???%);
986      |10: <fetch_refl in ⊢ (???%);
987      |11: <fetch_refl in ⊢ (???%);
988      |12: <fetch_refl in ⊢ (???%);
989      |13: <fetch_refl in ⊢ (???%);
990      |14: <fetch_refl in ⊢ (???%);
991      ]
992      whd in ⊢ (???%);
993      @(if_then_else_replace ???????? p)
994      [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
995        cases daemon
996      |2,4,6,8,10,12,14,16,18,20,22,24,26,28:
997        normalize nodelta
998        whd in match (addr_of_relative ????);
999        >set_clock_mk_Status_commutation
1000        [9,10:
1001          (* XXX: demodulation not working in this case *)
1002          >program_counter_set_arg_1 in ⊢ (???%);
1003          >program_counter_set_program_counter in ⊢ (???%);
1004        |*:
1005          /demod/
1006        ]
1007        whd in ⊢ (???%);
1008        change with (add ???) in match (\snd (half_add ???));
1009        >(?: add ? intermediate_pc (sign_extension (bitvector_of_nat ? 2)) = intermediate_pc')
1010        [2,4,6,8,10,12,14,16,18,20,22,24,26,28:
1011          >bitvector_of_nat_sign_extension_equivalence
1012          [1,3,5,7,9,11,13,15,17,19,21,23,25,27:
1013            >EQintermediate_pc' %
1014          |*:
1015            repeat @le_S_S @le_O_n
1016          ]
1017        ]
1018        %
1019      ]
1020    |1,4,7,10,13,16,19,22,25,28,31,34,37,40:
1021      skip
1022    ]
1023    -status_after_1
1024    @(pose … (execute_1 ? (mk_PreStatus …)))
1025    #status_after_1 #EQstatus_after_1
1026    <(?: ? = status_after_1)
1027    [3,6,9,12,15,18,21,24,27,30,33,36,39,42:
1028      >EQstatus_after_1 in ⊢ (???%);
1029      whd in ⊢ (???%);
1030      (* XXX: matita bug with patterns across multiple goals *)
1031      [1: <fetch_refl'' in ⊢ (???%);
1032      |2: <fetch_refl' in ⊢ (???%);
1033      |3: <fetch_refl'' in ⊢ (???%);
1034      |4: <fetch_refl' in ⊢ (???%);
1035      |5: <fetch_refl'' in ⊢ (???%);
1036      |6: <fetch_refl' in ⊢ (???%);
1037      |7: <fetch_refl'' in ⊢ (???%);
1038      |8: <fetch_refl' in ⊢ (???%);
1039      |9: <fetch_refl'' in ⊢ (???%);
1040      |10: <fetch_refl' in ⊢ (???%);
1041      |11: <fetch_refl'' in ⊢ (???%);
1042      |12: <fetch_refl' in ⊢ (???%);
1043      |13: <fetch_refl'' in ⊢ (???%);
1044      |14: <fetch_refl' in ⊢ (???%);
1045      ]
1046      whd in ⊢ (???%);
1047      [9,10:
1048      |*:
1049        /demod/
1050      ] %
1051    |1,4,7,10,13,16,19,22,25,28,31,34,37,40:
1052      skip
1053    ]
1054    -status_after_1 whd in ⊢ (??%?);
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    @split_eq_status try %
1060    [3,11,19,27,36,53,61:
1061      >program_counter_set_program_counter >set_clock_mk_Status_commutation
1062      [5: >program_counter_set_program_counter ]
1063      >EQaddr_of normalize nodelta
1064      whd in ⊢ (??%?); >EQlookup_labels normalize nodelta
1065      >EQcm %
1066    |7,15,23,31,45,57,65:
1067      >set_clock_mk_Status_commutation >program_counter_set_program_counter
1068      whd in ⊢ (??%?); normalize nodelta
1069      >EQppc in fetch_many_assm; #fetch_many_assm
1070      [5:
1071        >program_counter_set_arg_1 >program_counter_set_program_counter
1072      ]
1073      <(eq_bv_eq … fetch_many_assm) >EQintermediate_pc''
1074      <bitvector_of_nat_sign_extension_equivalence
1075      [1,3,5,7,9,11,13:
1076        whd in ⊢ (???%); cases (half_add ???) normalize //
1077      |2,4,6,8,10,12,14:
1078        @assembly1_lt_128
1079        @le_S_S @le_O_n
1080      ]
1081    |*:
1082      cases daemon
1083    ]
1084  ]
1085  |4,5,6,7,8,36,37,38,39,40,41,50: (* INC, CLR, CPL, PUSH *)
1086  (* XXX: work on the right hand side *)
1087  lapply (subaddressing_modein ???)
1088  <EQaddr normalize nodelta #irrelevant
1089  try (>p normalize nodelta)
1090  try (>p1 normalize nodelta)
1091  (* XXX: switch to the left hand side *)
1092  >EQP -P normalize nodelta
1093  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1094  whd in ⊢ (??%?);
1095  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1096  (* XXX: work on the left hand side *)
1097  [1,2,3,4,5:
1098    generalize in ⊢ (??(???(?%))?);
1099  |6,7,8,9,10,11:
1100    generalize in ⊢ (??(???(?%))?);
1101  |12:
1102    generalize in ⊢ (??(???(?%))?);
1103  ]
1104  <EQaddr normalize nodelta #irrelevant
1105  try @(jmpair_as_replace ?????????? p)
1106  [10: normalize nodelta try @(jmpair_as_replace ?????????? p1) ]
1107  (* XXX: switch to the right hand side *)
1108  normalize nodelta >EQs -s >EQticks -ticks
1109  whd in ⊢ (??%%);
1110  (* XXX: finally, prove the equality using sigma commutation *)
1111  try @split_eq_status try % whd in ⊢ (??%%);
1112  [1:
1113    >low_internal_ram_set_8051_sfr >low_internal_ram_set_clock
1114    >low_internal_ram_set_program_counter @eq_f2 try %
1115    whd in maps_assm:(??%?); destruct %
1116  |2:
1117    >high_internal_ram_set_8051_sfr >high_internal_ram_set_clock
1118    >high_internal_ram_set_program_counter @eq_f2 try %
1119    whd in maps_assm:(??%?); destruct %
1120  |3:
1121    >clock_set_program_counter >clock_set_program_counter <instr_refl %
1122  |4,6:
1123    >set_clock_set_program_counter >get_arg_8_set_program_counter
1124    >clock_set_program_counter >set_clock_mk_Status_commutation
1125    >set_clock_mk_Status_commutation >clock_set_program_counter <instr_refl
1126  |8:
1127    cases daemon
1128  ]
1129  |1,2,3,9,46,51,53,54,55: (* ADD, ADDC, SUBB, DEC, SWAP, POP, XCHD, RET, RETI  *)
1130  (* XXX: work on the right hand side *)
1131  >p normalize nodelta
1132  try (>p1 normalize nodelta)
1133  (* XXX: switch to the left hand side *)
1134  -instr_refl >EQP -P normalize nodelta
1135  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1136  whd in ⊢ (??%?);
1137  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1138  (* XXX: work on the left hand side *)
1139  @(pair_replace ?????????? p)
1140  [1,3,5,7,9,11,13,15,17:
1141    >set_clock_set_program_counter >set_clock_mk_Status_commutation
1142    >set_program_counter_mk_Status_commutation >clock_set_program_counter
1143    cases daemon
1144  |14,16,18:
1145    normalize nodelta
1146    @(pair_replace ?????????? p1)
1147    [1,3,5:
1148      >set_clock_mk_Status_commutation
1149      cases daemon
1150    ]
1151  ]
1152  (* XXX: switch to the right hand side *)
1153  normalize nodelta >EQs -s >EQticks -ticks
1154  whd in ⊢ (??%%);
1155  (* XXX: finally, prove the equality using sigma commutation *)
1156  try @split_eq_status try %
1157  >set_clock_mk_Status_commutation
1158  cases daemon (*
1159       @split_eq_status try %
1160       [*: whd in ⊢ (??%%); >set_clock_mk_Status_commutation
1161           whd in match (set_flags ??????);
1162           (* CSC: TO BE COMPLETED *)
1163       ] *)
1164  |10,42,43,44,45,49,52,56: (* MUL *)
1165  (* XXX: work on the right hand side *)
1166  (* XXX: switch to the left hand side *)
1167  -instr_refl >EQP -P normalize nodelta
1168  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1169  whd in ⊢ (??%?);
1170  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1171  (* XXX: work on the left hand side *)
1172  (* XXX: switch to the right hand side *)
1173  normalize nodelta >EQs -s >EQticks -ticks
1174  whd in ⊢ (??%%);
1175  (* XXX: finally, prove the equality using sigma commutation *)
1176  cases daemon
1177  |11,12: (* DIV *)
1178  (* XXX: work on the right hand side *)
1179  normalize nodelta in p;
1180  >p normalize nodelta
1181  (* XXX: switch to the left hand side *)
1182  -instr_refl >EQP -P normalize nodelta
1183  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1184  whd in ⊢ (??%?);
1185  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1186  @(pose … (nat_of_bitvector 8 ?)) #pose_assm #pose_refl
1187  >(?: pose_assm = 0) normalize nodelta
1188  [2,4:
1189    <p >pose_refl
1190    cases daemon
1191  |1,3:
1192    (* XXX: switch to the right hand side *)
1193    >EQs -s >EQticks -ticks
1194    whd in ⊢ (??%%);
1195    (* XXX: finally, prove the equality using sigma commutation *)
1196    @split_eq_status try %
1197    cases daemon
1198  ]
1199  |13,14,15: (* DA *)
1200  (* XXX: work on the right hand side *)
1201  >p normalize nodelta
1202  >p1 normalize nodelta
1203  try (>p2 normalize nodelta
1204  try (>p3 normalize nodelta
1205  try (>p4 normalize nodelta
1206  try (>p5 normalize nodelta))))
1207  (* XXX: switch to the left hand side *)
1208  -instr_refl >EQP -P normalize nodelta
1209  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1210  whd in ⊢ (??%?);
1211  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1212  (* XXX: work on the left hand side *)
1213  @(pair_replace ?????????? p)
1214  [1,3,5:
1215    /demod/
1216    cases daemon
1217  |2,4,6:
1218    @(if_then_else_replace ???????? p1)
1219    [1,3,5:
1220      cases daemon
1221    |2,4:
1222      normalize nodelta
1223      @(pair_replace ?????????? p2)
1224      [1,3:
1225        cases daemon
1226      |2,4:
1227        normalize nodelta >p3 normalize nodelta
1228        >p4 normalize nodelta try >p5
1229      ]
1230    ]
1231  (* XXX: switch to the right hand side *)
1232  normalize nodelta >EQs -s >EQticks -ticks
1233  whd in ⊢ (??%%);
1234  (* XXX: finally, prove the equality using sigma commutation *)
1235  @split_eq_status try %
1236  cases daemon
1237  ]
1238  |33,34,35,48: (* ANL, ORL, XRL, MOVX *)
1239  (* XXX: work on the right hand side *)
1240  cases addr #addr' normalize nodelta
1241  [1,3:
1242    cases addr' #addr'' normalize nodelta
1243  ]
1244  @pair_elim #lft #rgt #lft_rgt_refl >lft_rgt_refl normalize nodelta
1245  (* XXX: switch to the left hand side *)
1246  -instr_refl >EQP -P normalize nodelta
1247  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1248  whd in ⊢ (??%?);
1249  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1250  (* XXX: work on the left hand side *)
1251  (* XXX: switch to the right hand side *)
1252  normalize nodelta >EQs -s >EQticks -ticks
1253  whd in ⊢ (??%%);
1254  (* XXX: finally, prove the equality using sigma commutation *)
1255  cases daemon
1256  |47: (* MOV *)
1257  (* XXX: work on the right hand side *)
1258  cases addr -addr #addr normalize nodelta
1259  [1:
1260    cases addr #addr normalize nodelta
1261    [1:
1262      cases addr #addr normalize nodelta
1263      [1:
1264        cases addr #addr normalize nodelta
1265        [1:
1266          cases addr #addr normalize nodelta
1267        ]
1268      ]
1269    ]
1270  ]
1271  cases addr #lft #rgt normalize nodelta
1272  (* XXX: switch to the left hand side *)
1273  >EQP -P normalize nodelta
1274  #sigma_increment_commutation #maps_assm #fetch_many_assm %{1}
1275  whd in ⊢ (??%?);
1276  <(fetch_many_singleton … fetch_many_assm) -fetch_many_assm whd in ⊢ (??%?);
1277  (* XXX: work on the left hand side *)
1278  (* XXX: switch to the right hand side *)
1279  normalize nodelta >EQs -s >EQticks -ticks
1280  whd in ⊢ (??%%);
1281  (* XXX: finally, prove the equality using sigma commutation *)
1282  cases daemon
1283  ]
1284]
1285cases daemon (* XXX: CJNE and DJNZ cases *)
1286qed.
1287(*   
1288   
1289
1290    @list_addressing_mode_tags_elim_prop try % whd
1291    @list_addressing_mode_tags_elim_prop try % whd #arg
1292    (* XXX: we first work on sigma_increment_commutation *)
1293    #sigma_increment_commutation
1294    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1295    (* XXX: we work on the maps *)
1296    whd in ⊢ (??%? → ?);
1297    try (change with (if ? then ? else ? = ? → ?)
1298         cases (addressing_mode_ok ????? ∧ addressing_mode_ok ?????) normalize nodelta)
1299    #H try @(None_Some_elim ??? H) @(Some_Some_elim ????? H) #map_refl_assm <map_refl_assm
1300    (* XXX: we assume the fetch_many hypothesis *)
1301    #fetch_many_assm
1302    (* XXX: we give the existential *)
1303    %{1}
1304    whd in match (execute_1_pseudo_instruction0 ?????);
1305    (* XXX: work on the left hand side of the equality *)
1306    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1307    (* XXX: execute fetches some more *)
1308    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1309    whd in fetch_many_assm;
1310    >EQassembled in fetch_many_assm;
1311    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1312    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1313    #fetch_many_assm whd in fetch_many_assm;
1314    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1315    >(eq_instruction_to_eq … eq_instr) -instr
1316    [ @(pose … (pi1 … (execute_1_preinstruction' …))) #lhs #EQlhs
1317      @(pose …
1318        (λlhs. status_of_pseudo_status M 〈preamble,instr_list〉 lhs sigma policy))
1319      #Pl #EQPl
1320      cut (∀A,B:Type[0].∀f,f':A → B.∀x. f=f' → f x = f' x) [2: #eq_f_g_to_eq
1321      lapply (λy.eq_f_g_to_eq ???? y EQPl) #XX <(XX lhs) -XX >EQlhs -lhs
1322      whd in ⊢ (??%?); whd in ⊢ (??(???%)(?(???%)));
1323      @pair_elim
1324      >tech_pi1_let_as_commute
1325
1326*) 
1327
1328
1329theorem main_thm:
1330  ∀M.
1331  ∀M'.
1332  ∀program: pseudo_assembly_program.
1333  ∀sigma: Word → Word.
1334  ∀policy: Word → bool.
1335  ∀sigma_policy_specification_witness: sigma_policy_specification program sigma policy.
1336  ∀ps: PseudoStatus program.
1337    next_internal_pseudo_address_map M program ps = Some … M' →
1338      ∃n. execute n … (status_of_pseudo_status M … ps sigma policy) =
1339        status_of_pseudo_status M' …
1340          (execute_1_pseudo_instruction (ticks_of program sigma policy) program ps) sigma policy.
1341  #M #M' * #preamble #instr_list #sigma #policy #sigma_policy_witness #ps
1342  change with (next_internal_pseudo_address_map0 ????? = ? → ?)
1343  @(pose … (program_counter ?? ps)) #ppc #EQppc
1344  generalize in match (fetch_assembly_pseudo2 〈preamble,instr_list〉 sigma policy sigma_policy_witness ppc) in ⊢ ?;
1345  @pair_elim #labels #costs #create_label_cost_refl normalize nodelta
1346  @pair_elim #assembled #costs' #assembly_refl normalize nodelta
1347  lapply (pair_destruct_1 ????? (sym_eq ??? assembly_refl)) #EQassembled
1348  @pair_elim #pi #newppc #fetch_pseudo_refl normalize nodelta
1349  @(pose … (λx. sigma (address_of_word_labels_code_mem instr_list x))) #lookup_labels #EQlookup_labels
1350  @(pose … (λx. lookup_def … (construct_datalabels preamble) x (zero 16))) #lookup_datalabels #EQlookup_datalabels
1351  whd in match execute_1_pseudo_instruction; normalize nodelta
1352  whd in match ticks_of; normalize nodelta <EQppc >fetch_pseudo_refl normalize nodelta
1353  lapply (snd_fetch_pseudo_instruction instr_list ppc) >fetch_pseudo_refl #EQnewppc >EQnewppc
1354  lapply (snd_assembly_1_pseudoinstruction_ok 〈preamble,instr_list〉 … sigma policy sigma_policy_witness … ppc pi … EQlookup_labels EQlookup_datalabels ?)
1355  [1: >fetch_pseudo_refl % ]
1356  #assm1 #assm2 #assm3 generalize in match assm2; generalize in match assm3;
1357  generalize in match assm1; -assm1 -assm2 -assm3
1358  normalize nodelta
1359  cases pi
1360  [2,3:
1361    #arg
1362    (* XXX: we first work on sigma_increment_commutation *)
1363    #sigma_increment_commutation
1364    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1365    (* XXX: we work on the maps *)
1366    whd in ⊢ (??%? → ?); @Some_Some_elim #map_refl_assm <map_refl_assm
1367    (* XXX: we assume the fetch_many hypothesis *)
1368    #fetch_many_assm
1369    (* XXX: we give the existential *)
1370    %{0}
1371    whd in match (execute_1_pseudo_instruction0 ?????);
1372    (* XXX: work on the left hand side of the equality *)
1373    whd in ⊢ (??%?);
1374    @split_eq_status //
1375    [1,2: /demod/ >EQnewppc >sigma_increment_commutation <add_zero % (*CSC: auto not working, why? *) ]
1376  |6: (* Mov *)
1377    #arg1 #arg2
1378    (* XXX: we first work on sigma_increment_commutation *)
1379    #sigma_increment_commutation
1380    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1381    (* XXX: we work on the maps *)
1382    whd in ⊢ (??%? → ?); @Some_Some_elim #map_refl_assm <map_refl_assm
1383    (* XXX: we assume the fetch_many hypothesis *)
1384    #fetch_many_assm
1385    (* XXX: we give the existential *)
1386    %{1}
1387    whd in match (execute_1_pseudo_instruction0 ?????);
1388    (* XXX: work on the left hand side of the equality *)
1389    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1390    (* XXX: execute fetches some more *)
1391    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1392    whd in fetch_many_assm;
1393    >EQassembled in fetch_many_assm;
1394    cases (fetch ??) * #instr #newpc #ticks normalize nodelta *
1395    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1396    #fetch_many_assm whd in fetch_many_assm;
1397    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1398    >(eq_instruction_to_eq … eq_instr) -instr whd in ⊢ (??%?);
1399    (* XXX: now we start to work on the mk_PreStatus equality *)
1400    (* XXX: lhs *)
1401    change with (set_arg_16 ????? = ?)
1402    >set_program_counter_mk_Status_commutation
1403    >set_clock_mk_Status_commutation
1404    >set_arg_16_mk_Status_commutation
1405    (* XXX: rhs *)
1406    change with (? = status_of_pseudo_status ?? (set_arg_16 ?????) ??)
1407    >set_program_counter_mk_Status_commutation
1408    >set_clock_mk_Status_commutation
1409    >set_arg_16_mk_Status_commutation in ⊢ (???%);
1410    (* here we are *)
1411    @split_eq_status //
1412    [1:
1413      assumption
1414    |2:
1415      @special_function_registers_8051_set_arg_16
1416      [2: >EQlookup_datalabels %
1417      |1: //
1418      ]
1419    ]
1420  |1: (* Instruction *) -pi; #instr
1421    @(main_lemma_preinstruction M M' preamble instr_list … (refl …) … sigma_policy_witness
1422      … EQppc … create_label_cost_refl … assembly_refl EQassembled … EQlookup_labels …
1423      EQlookup_datalabels EQnewppc instr … (refl …) … (refl …) … (refl …) … (refl …))
1424  |4,5: cases daemon
1425  ]
1426qed.
1427(* 
1428    *
1429    [1,2,3: (* ADD, ADDC, SUBB *)
1430    @list_addressing_mode_tags_elim_prop try % whd
1431    @list_addressing_mode_tags_elim_prop try % whd #arg
1432    (* XXX: we first work on sigma_increment_commutation *)
1433    #sigma_increment_commutation
1434    normalize in match (assembly_1_pseudoinstruction ??????) in sigma_increment_commutation;
1435    (* XXX: we work on the maps *)
1436    whd in ⊢ (??%? → ?);
1437    try (change with (if ? then ? else ? = ? → ?)
1438         cases (addressing_mode_ok ????? ∧ addressing_mode_ok ?????) normalize nodelta)
1439    #H try @(None_Some_elim ??? H) @(Some_Some_elim ????? H) #map_refl_assm <map_refl_assm
1440    (* XXX: we assume the fetch_many hypothesis *)
1441    #fetch_many_assm
1442    (* XXX: we give the existential *)
1443    %{1}
1444    whd in match (execute_1_pseudo_instruction0 ?????);
1445    (* XXX: work on the left hand side of the equality *)
1446    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1447    (* XXX: execute fetches some more *)
1448    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1449    whd in fetch_many_assm;
1450    >EQassembled in fetch_many_assm;
1451    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1452    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1453    #fetch_many_assm whd in fetch_many_assm;
1454    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1455    >(eq_instruction_to_eq … eq_instr) -instr
1456    [ @(pose … (pi1 … (execute_1_preinstruction' …))) #lhs #EQlhs
1457      @(pose …
1458        (λlhs. status_of_pseudo_status M 〈preamble,instr_list〉 lhs sigma policy))
1459      #Pl #EQPl
1460      cut (∀A,B:Type[0].∀f,f':A → B.∀x. f=f' → f x = f' x) [2: #eq_f_g_to_eq
1461      lapply (λy.eq_f_g_to_eq ???? y EQPl) #XX <(XX lhs) -XX >EQlhs -lhs
1462      whd in ⊢ (??%?); whd in ⊢ (??(???%)(?(???%)));
1463      @pair_elim
1464      >tech_pi1_let_as_commute
1465   
1466   
1467    whd in ⊢ (??%?);
1468    [ @(pose … (execute_1_preinstruction' ???????))
1469      #lhs whd in ⊢ (???% → ?); #EQlhs
1470      @(pose … (execute_1_preinstruction' ???????))
1471      #rhs whd in ⊢ (???% → ?); #EQrhs
1472
1473
1474      CSC: delirium
1475     
1476      >EQlhs -EQlhs >EQrhs -EQrhs
1477      cases (add_8_with_carry ???) #bits1 #bits2 whd in ⊢ (??%%);
1478     
1479     lapply (refl ? (execute_1_preinstruction' ???????));
1480    [ whd in match (execute_1_preinstruction' ???????);
1481
1482    whd in ⊢ (??%?);
1483    [ whd in ⊢ (??(???%)%);
1484      whd in match (execute_1_preinstruction' ???????);
1485      cases (add_8_with_carry ???) #bits1 #bits2 whd in ⊢ (??%?);
1486      @pair_elim #result #flags #Heq1
1487    whd in match execute_1_preinstruction'; normalize nodelta
1488    (* XXX: now we start to work on the mk_PreStatus equality *)
1489    whd in ⊢ (??%?);
1490 
1491 
1492 
1493    [1,2,3: (* ADD, ADDC, SUBB *) #arg1 #arg2
1494    (* XXX: we take up the hypotheses *)
1495    #sigma_increment_commutation #next_map_assm #fetch_many_assm
1496    (* XXX: we give the existential *)
1497    %{1}
1498    whd in match (execute_1_pseudo_instruction0 ?????);
1499    whd in ⊢ (??%?); whd in match (program_counter ???); <EQppc
1500    whd in match code_memory_of_pseudo_assembly_program; normalize nodelta
1501    (* XXX: fetching of the instruction *)
1502    whd in fetch_many_assm;
1503    >EQassembled in fetch_many_assm;
1504    cases (fetch ??) * #instr #newpc #ticks normalize nodelta * *
1505    #eq_instr #EQticks whd in EQticks:(???%); >EQticks
1506    #fetch_many_assm whd in fetch_many_assm;
1507    lapply (eq_bv_eq … fetch_many_assm) -fetch_many_assm #EQnewpc
1508    >(eq_instruction_to_eq … eq_instr) -instr
1509    (* XXX: now we start to work on the mk_PreStatus equality *)
1510    whd in ⊢ (??%?);
1511    check execute_1_preinstruction
1512   
1513   
1514     #MAP #H1 #H2 #EQ %[1,3,5:@1]
1515       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1516       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1517       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1518       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1519       >H2b >(eq_instruction_to_eq … H2a)
1520       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); generalize in match MAP; -MAP;
1521       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1;
1522       @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2
1523       normalize nodelta; #MAP;
1524       [1: change in ⊢ (? → %) with
1525        ((let 〈result,flags〉 ≝
1526          add_8_with_carry
1527           (get_arg_8 ? ps false ACC_A)
1528           (get_arg_8 ?
1529             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1530             false (DIRECT ARG2))
1531           ? in ?) = ?)
1532        [2,3: %]
1533        change in ⊢ (???% → ?) with
1534         (let 〈result,flags〉 ≝ add_8_with_carry ?(*(get_arg_8 ? ps false ACC_A)*) ?? in ?)
1535        >get_arg_8_set_clock
1536       [1,2: cases (addressing_mode_ok ???? ∧ addressing_mode_ok ????) in MAP ⊢ ?
1537         [2,4: #abs @⊥ normalize in abs; destruct (abs)
1538         |*:whd in ⊢ (??%? → ?) #H <(option_destruct_Some ??? H)]
1539       [ change in ⊢ (? → %) with
1540        ((let 〈result,flags〉 ≝
1541          add_8_with_carry
1542           (get_arg_8 ? ps false ACC_A)
1543           (get_arg_8 ?
1544             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1545             false (DIRECT ARG2))
1546           ? in ?) = ?)
1547          >get_arg_8_set_low_internal_ram
1548       
1549        cases (add_8_with_carry ???)
1550         
1551        [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)]
1552       #result #flags
1553       #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) %
1554
1555
1556  |4: (* Jmp *) #label whd in ⊢ (??%? → ???% → ?);
1557   @Some_Some_elim #MAP cases (pol ?) normalize nodelta
1558       [3: (* long *) #EQ3 @(Some_Some_elim ????? EQ3) #EQ3'
1559         whd in match eject normalize nodelta >EQ3' in ⊢ (% → ?) whd in ⊢ (% → ?)
1560         @pair_elim' * #instr #newppc' #ticks #EQ4       
1561         * * #H2a #H2b whd in ⊢ (% → ?) #H2
1562         >H2b >(eq_instruction_to_eq … H2a)
1563         #EQ %[@1]
1564         <MAP >(eq_bv_eq … H2) >EQ
1565         whd in ⊢ (??%?) >EQ4 whd in ⊢ (??%?)
1566         cases ps in EQ4; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXX >XXX %
1567         whd in ⊢ (??%?)
1568         whd in ⊢ (??(match ?%? with [_ ⇒ ?])?)
1569         cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX %
1570  |5: (* Call *) #label #MAP
1571      generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP <MAP -MAP;
1572      whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta;
1573       [ (* short *) #abs @⊥ destruct (abs)
1574       |3: (* long *) #H1 #H2 #EQ %[@1]
1575           (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1576           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1577           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1578           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1579           >H2b >(eq_instruction_to_eq … H2a)
1580           generalize in match EQ; -EQ;
1581           whd in ⊢ (???% → ??%?);
1582           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;
1583           >(eq_bv_eq … H2c)
1584           change with
1585            ((?=let 〈ppc_bu,ppc_bl〉 ≝ split bool 8 8 newppc in ?) →
1586                (let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?)
1587           generalize in match (refl … (split … 8 8 newppc)) cases (split bool 8 8 newppc) in ⊢ (??%? → %) #ppc_bu #ppc_bl #EQppc
1588           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;
1589           >get_8051_sfr_write_at_stack_pointer >get_8051_sfr_write_at_stack_pointer
1590           >get_8051_sfr_set_8051_sfr >get_8051_sfr_set_8051_sfr
1591           generalize in match (refl … (half_add ? new_sp (bitvector_of_nat ? 1))) cases (half_add ???) in ⊢ (??%? → %) #carry' #new_sp' #EQ2 normalize nodelta;
1592           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1593           @split_eq_status;
1594            [ >code_memory_write_at_stack_pointer whd in ⊢ (??%?)
1595              >code_memory_write_at_stack_pointer %
1596            | >set_program_counter_set_low_internal_ram
1597              >set_clock_set_low_internal_ram
1598              @low_internal_ram_write_at_stack_pointer
1599               [ >EQ0 @pol | % | %
1600               | @(  … EQ1)
1601               | @(pair_destruct_2 … EQ2)
1602               | >(pair_destruct_1 ????? EQpc)
1603                 >(pair_destruct_2 ????? EQpc)
1604                 @split_elim #x #y #H <H -x y H;
1605                 >(pair_destruct_1 ????? EQppc)
1606                 >(pair_destruct_2 ????? EQppc)
1607                 @split_elim #x #y #H <H -x y H;
1608                 >EQ0 % ]
1609            | >set_low_internal_ram_set_high_internal_ram
1610              >set_program_counter_set_high_internal_ram
1611              >set_clock_set_high_internal_ram
1612              @high_internal_ram_write_at_stack_pointer
1613               [ >EQ0 @pol | % | %
1614               | @(pair_destruct_2 … EQ1)
1615               | @(pair_destruct_2 … EQ2)
1616               | >(pair_destruct_1 ????? EQpc)
1617                 >(pair_destruct_2 ????? EQpc)
1618                 @split_elim #x #y #H <H -x y H;
1619                 >(pair_destruct_1 ????? EQppc)
1620                 >(pair_destruct_2 ????? EQppc)
1621                 @split_elim #x #y #H <H -x y H;
1622                 >EQ0 % ]           
1623            | >external_ram_write_at_stack_pointer whd in ⊢ (??%?)
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 %
1627            | change with (? = sigma ?? (address_of_word_labels_code_mem (\snd (code_memory ? ps)) ?))
1628              >EQ0 %
1629            | >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (??%?)
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 %
1633            | >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (??%?)
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 %
1637            | >p1_latch_write_at_stack_pointer whd in ⊢ (??%?)
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 %
1641            | >p3_latch_write_at_stack_pointer whd in ⊢ (??%?)
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 %
1645            | >clock_write_at_stack_pointer whd in ⊢ (??%?)
1646              >clock_write_at_stack_pointer whd in ⊢ (???%)
1647              >clock_write_at_stack_pointer whd in ⊢ (???%)
1648              >clock_write_at_stack_pointer %]
1649       (*| (* medium *)  #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1650         @pair_elim' #fst_5_addr #rest_addr #EQ1
1651         @pair_elim' #fst_5_pc #rest_pc #EQ2
1652         generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc))
1653         cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)]
1654         generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?)
1655         change in ⊢ (? →??%?) with (execute_1_0 ??)
1656         @pair_elim' * #instr #newppc' #ticks #EQn
1657          * * #H2a #H2b whd in ⊢ (% → ?) #H2c >H2b >(eq_instruction_to_eq … H2a) whd in ⊢ (??%?)
1658          generalize in match EQ; -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1659          @pair_elim' #carry #new_sp change with (half_add ? (get_8051_sfr ? ps ?) ? = ? → ?) #EQ4
1660          @split_elim' #pc_bu #pc_bl >program_counter_set_8051_sfr XXX change with (newppc = ?) #EQ5
1661          @pair_elim' #carry' #new_sp' #EQ6 normalize nodelta; #EQx >EQx -EQx;
1662          change in ⊢ (??(match ????% with [_ ⇒ ?])?) with (sigma … newppc)
1663          @split_elim' #pc_bu' #pc_bl' #EQ7 change with (newppc' = ? → ?)
1664          >get_8051_sfr_set_8051_sfr
1665         
1666          whd in EQ:(???%) ⊢ ? >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?)
1667           change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 newppc) in ?)=?)
1668           generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 newppc)))
1669           cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4
1670           generalize in match (refl … (split bool 4 4 pc_bu))
1671           cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5
1672           generalize in match (refl … (split bool 3 8 rest_addr))
1673           cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6
1674           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?)
1675           generalize in match
1676            (refl …
1677             (half_add 16 (sigma 〈preamble,instr_list〉 newppc)
1678             ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2)))
1679           cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7
1680           @split_eq_status try %
1681            [ change with (? = sigma ? (address_of_word_labels ps label))
1682              (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1683            | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?)
1684              @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]] *)]
1685  |4: (* Jmp *) #label #MAP
1686      generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP >MAP -MAP;
1687      whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta;
1688       [3: (* long *) #H1 #H2 #EQ %[@1]
1689           (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1690           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1691           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1692           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1693           >H2b >(eq_instruction_to_eq … H2a)
1694           generalize in match EQ; -EQ;
1695           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1696           cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX %
1697       |1: (* short *) #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1698           generalize in match
1699            (refl ?
1700             (sub_16_with_carry
1701              (sigma 〈preamble,instr_list〉 pol (program_counter … ps))
1702              (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label))
1703              false))
1704           cases (sub_16_with_carry ???) in ⊢ (??%? → %); #results #flags normalize nodelta;
1705           generalize in match (refl … (split … 8 8 results)) cases (split ????) in ⊢ (??%? → %) #upper #lower normalize nodelta;
1706           generalize in match (refl … (eq_bv … upper (zero 8))) cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta;
1707           #EQ1 #EQ2 #EQ3 #H1 [2: @⊥ destruct (H1)]
1708           generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1709           change in ⊢ (? → ??%?) with (execute_1_0 ??)
1710           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1711           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1712           >H2b >(eq_instruction_to_eq … H2a)
1713           generalize in match EQ; -EQ;
1714           whd in ⊢ (???% → ?);
1715           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c)
1716           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma ???) ? in ?) = ?)
1717           generalize in match (refl … (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc) (sign_extension lower)))
1718           cases (half_add ???) in ⊢ (??%? → %) #carry #newpc normalize nodelta #EQ4
1719           @split_eq_status try % change with (newpc = sigma ?? (address_of_word_labels ps label))
1720           (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1721       | (* medium *)  #H1 #H2 #EQ %[@1] generalize in match H1; -H1;
1722         generalize in match
1723          (refl …
1724            (split … 5 11 (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label))))
1725         cases (split ????) in ⊢ (??%? → %) #fst_5_addr #rest_addr normalize nodelta; #EQ1
1726         generalize in match
1727          (refl …
1728            (split … 5 11 (sigma 〈preamble,instr_list〉 pol (program_counter … ps))))
1729         cases (split ????) in ⊢ (??%? → %) #fst_5_pc #rest_pc normalize nodelta; #EQ2
1730         generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc))
1731         cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)]
1732         generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?)
1733         change in ⊢ (? →??%?) with (execute_1_0 ??)
1734           cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1735           * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1736           >H2b >(eq_instruction_to_eq … H2a)
1737           generalize in match EQ; -EQ;
1738           whd in ⊢ (???% → ?);
1739           #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?)
1740           change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?)
1741           generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc)))
1742           cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4
1743           generalize in match (refl … (split bool 4 4 pc_bu))
1744           cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5
1745           generalize in match (refl … (split bool 3 8 rest_addr))
1746           cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6
1747           change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?)
1748           generalize in match
1749            (refl …
1750             (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc)
1751             ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2)))
1752           cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7   
1753           @split_eq_status try %
1754            [ change with (? = sigma ?? (address_of_word_labels ps label))
1755              (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *)
1756            | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?)
1757              @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]]
1758  | (* Instruction *) -pi;  whd in ⊢ (? → ??%? → ?) *; normalize nodelta;
1759    [1,2,3: (* ADD, ADDC, SUBB *) #arg1 #arg2 #MAP #H1 #H2 #EQ %[1,3,5:@1]
1760       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1761       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1762       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1763       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1764       >H2b >(eq_instruction_to_eq … H2a)
1765       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); generalize in match MAP; -MAP;
1766       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1;
1767       @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2
1768       normalize nodelta; #MAP;
1769       [1: change in ⊢ (? → %) with
1770        ((let 〈result,flags〉 ≝
1771          add_8_with_carry
1772           (get_arg_8 ? ps false ACC_A)
1773           (get_arg_8 ?
1774             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1775             false (DIRECT ARG2))
1776           ? in ?) = ?)
1777        [2,3: %]
1778        change in ⊢ (???% → ?) with
1779         (let 〈result,flags〉 ≝ add_8_with_carry ?(*(get_arg_8 ? ps false ACC_A)*) ?? in ?)
1780        >get_arg_8_set_clock
1781       [1,2: cases (addressing_mode_ok ???? ∧ addressing_mode_ok ????) in MAP ⊢ ?
1782         [2,4: #abs @⊥ normalize in abs; destruct (abs)
1783         |*:whd in ⊢ (??%? → ?) #H <(option_destruct_Some ??? H)]
1784       [ change in ⊢ (? → %) with
1785        ((let 〈result,flags〉 ≝
1786          add_8_with_carry
1787           (get_arg_8 ? ps false ACC_A)
1788           (get_arg_8 ?
1789             (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps)))
1790             false (DIRECT ARG2))
1791           ? in ?) = ?)
1792          >get_arg_8_set_low_internal_ram
1793       
1794        cases (add_8_with_carry ???)
1795         
1796        [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)]
1797       #result #flags
1798       #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) %
1799    | (* INC *) #arg1 #H1 #H2 #EQ %[@1]
1800       normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?)
1801       change in ⊢ (? → ??%?) with (execute_1_0 ??)
1802       cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta;
1803       * * #H2a #H2b whd in ⊢ (% → ?) #H2c
1804       >H2b >(eq_instruction_to_eq … H2a)
1805       generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?);
1806       @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1; normalize nodelta; [1,2,3: #ARG]
1807       [1,2,3,4: cases (half_add ???) #carry #result
1808       | cases (half_add ???) #carry #bl normalize nodelta;
1809         cases (full_add ????) #carry' #bu normalize nodelta ]
1810        #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) -newppc';
1811        [5: %
1812        |1: <(set_arg_8_set_code_memory 0 [[direct]] ? ? ? (set_clock pseudo_assembly_program
1813      (set_program_counter pseudo_assembly_program ps newppc)
1814      (\fst  (ticks_of0 〈preamble,instr_list〉
1815                   (program_counter pseudo_assembly_program ps)
1816                   (Instruction (INC Identifier (DIRECT ARG))))
1817       +clock pseudo_assembly_program
1818        (set_program_counter pseudo_assembly_program ps newppc))) (load_code_memory assembled) result (DIRECT ARG))
1819        [2,3: // ]
1820            <(set_arg_8_set_program_counter 0 [[direct]] ? ? ? ? ?) [2://]
1821            whd in ⊢ (??%%)
1822            cases (split bool 4 4 ARG)
1823            #nu' #nl'
1824            normalize nodelta
1825            cases (split bool 1 3 nu')
1826            #bit_1' #ignore'
1827            normalize nodelta
1828            cases (get_index_v bool 4 nu' ? ?)
1829            [ normalize nodelta (* HERE *) whd in ⊢ (??%%) %
1830            |
1831            ]
1832cases daemon (* EASY CASES TO BE COMPLETED *)
1833qed.
1834*)
Note: See TracBrowser for help on using the repository browser.