| 1 | include "ASM/AssemblyProof.ma". |
|---|
| 2 | include alias "arithmetics/nat.ma". |
|---|
| 3 | include alias "basics/logic.ma". |
|---|
| 4 | |
|---|
| 5 | theorem main_thm: |
|---|
| 6 | ∀M. |
|---|
| 7 | ∀M'. |
|---|
| 8 | ∀cm. |
|---|
| 9 | ∀ps. |
|---|
| 10 | ∀sigma. |
|---|
| 11 | ∀policy. |
|---|
| 12 | next_internal_pseudo_address_map M cm ps = Some … M' → |
|---|
| 13 | ∃n. execute n … (status_of_pseudo_status M … ps sigma policy) = |
|---|
| 14 | status_of_pseudo_status M' … |
|---|
| 15 | (execute_1_pseudo_instruction (ticks_of cm sigma policy) cm ps) sigma policy. |
|---|
| 16 | #M #M' * #preamble #instr_list #ps #sigma #policy |
|---|
| 17 | change with (next_internal_pseudo_address_map0 ????? = ? → ?) |
|---|
| 18 | @(pose … (program_counter ?? ps)) #ppc #EQppc |
|---|
| 19 | generalize in match (fetch_assembly_pseudo2 〈preamble,instr_list〉 sigma policy ppc) in ⊢ ?; |
|---|
| 20 | @pair_elim #labels #costs #H0 normalize nodelta |
|---|
| 21 | @pair_elim #assembled #costs' #EQ1 normalize nodelta |
|---|
| 22 | @pair_elim #pi #newppc #EQ2 normalize nodelta |
|---|
| 23 | @(pose … (λx. sigma (address_of_word_labels_code_mem instr_list x))) #lookup_labels #EQlookup_labels |
|---|
| 24 | @(pose … (λx. lookup_def … (construct_datalabels preamble) x (zero 16))) #lookup_datalabels #EQlookup_datalabels |
|---|
| 25 | whd in match execute_1_pseudo_instruction; normalize nodelta |
|---|
| 26 | whd in match ticks_of; normalize nodelta <EQppc #H2 >EQ2 normalize nodelta |
|---|
| 27 | lapply (snd_fetch_pseudo_instruction instr_list ppc) >EQ2 #EQnewppc >EQnewppc |
|---|
| 28 | lapply (snd_assembly_1_pseudoinstruction_ok 〈preamble,instr_list〉 … policy … ppc pi … EQlookup_labels EQlookup_datalabels ?) |
|---|
| 29 | [>EQ2 %] |
|---|
| 30 | inversion pi |
|---|
| 31 | [2,3: (* Comment, Cost *) |
|---|
| 32 | #ARG #EQ |
|---|
| 33 | #H3 normalize nodelta in H3; normalize in match (assembly_1_pseudoinstruction ??????) in H3; |
|---|
| 34 | whd in ⊢ (??%? → ?); @Some_Some_elim #MAP <MAP |
|---|
| 35 | whd in match (execute_1_pseudo_instruction0 ?????); |
|---|
| 36 | %{0} @split_eq_statusCSC: this works :-) (lapply H3 -H3 letin sixteen ≝ 16 #H3 // /demod/) |
|---|
| 37 | CSC: STOP HERE, was // but requires -H3 because of 16! |
|---|
| 38 | ⇒ CHANGE TO AVOID \fst and \pi1! (* |
|---|
| 39 | try (<H3 -H0 -H3 //) |
|---|
| 40 | [ <add_zero in H3; #H3 >H3 -H0 -H3 // |
|---|
| 41 | | -H0 -H3 /demod/*) |
|---|
| 42 | |4: (* Jmp *) #label whd in ⊢ (??%? → ???% → ?) |
|---|
| 43 | @Some_Some_elim #MAP cases (pol ?) normalize nodelta |
|---|
| 44 | [3: (* long *) #EQ3 @(Some_Some_elim ????? EQ3) #EQ3' |
|---|
| 45 | whd in match eject normalize nodelta >EQ3' in ⊢ (% → ?) whd in ⊢ (% → ?) |
|---|
| 46 | @pair_elim' * #instr #newppc' #ticks #EQ4 |
|---|
| 47 | * * #H2a #H2b whd in ⊢ (% → ?) #H2 |
|---|
| 48 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 49 | #EQ %[@1] |
|---|
| 50 | <MAP >(eq_bv_eq … H2) >EQ |
|---|
| 51 | whd in ⊢ (??%?) >EQ4 whd in ⊢ (??%?) |
|---|
| 52 | cases ps in EQ4; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXX >XXX % |
|---|
| 53 | whd in ⊢ (??%?) |
|---|
| 54 | whd in ⊢ (??(match ?%? with [_ ⇒ ?])?) |
|---|
| 55 | cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX % |
|---|
| 56 | |6: (* Mov *) #arg1 #arg2 |
|---|
| 57 | #H1 #H2 #EQ %[@1] |
|---|
| 58 | normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 59 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 60 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 61 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 62 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 63 | generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); |
|---|
| 64 | @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1; whd in ⊢ (???% → ??%?) |
|---|
| 65 | @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2 |
|---|
| 66 | normalize nodelta; |
|---|
| 67 | [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)] |
|---|
| 68 | #result #flags |
|---|
| 69 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) % |
|---|
| 70 | |5: (* Call *) #label #MAP |
|---|
| 71 | generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP <MAP -MAP; |
|---|
| 72 | whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta; |
|---|
| 73 | [ (* short *) #abs @⊥ destruct (abs) |
|---|
| 74 | |3: (* long *) #H1 #H2 #EQ %[@1] |
|---|
| 75 | (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 76 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 77 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 78 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 79 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 80 | generalize in match EQ; -EQ; |
|---|
| 81 | whd in ⊢ (???% → ??%?); |
|---|
| 82 | 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; |
|---|
| 83 | >(eq_bv_eq … H2c) |
|---|
| 84 | change with |
|---|
| 85 | ((?=let 〈ppc_bu,ppc_bl〉 ≝ split bool 8 8 newppc in ?) → |
|---|
| 86 | (let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?) |
|---|
| 87 | generalize in match (refl … (split … 8 8 newppc)) cases (split bool 8 8 newppc) in ⊢ (??%? → %) #ppc_bu #ppc_bl #EQppc |
|---|
| 88 | 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; |
|---|
| 89 | >get_8051_sfr_write_at_stack_pointer >get_8051_sfr_write_at_stack_pointer |
|---|
| 90 | >get_8051_sfr_set_8051_sfr >get_8051_sfr_set_8051_sfr |
|---|
| 91 | generalize in match (refl … (half_add ? new_sp (bitvector_of_nat ? 1))) cases (half_add ???) in ⊢ (??%? → %) #carry' #new_sp' #EQ2 normalize nodelta; |
|---|
| 92 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) |
|---|
| 93 | @split_eq_status; |
|---|
| 94 | [ >code_memory_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 95 | >code_memory_write_at_stack_pointer % |
|---|
| 96 | | >set_program_counter_set_low_internal_ram |
|---|
| 97 | >set_clock_set_low_internal_ram |
|---|
| 98 | @low_internal_ram_write_at_stack_pointer |
|---|
| 99 | [ >EQ0 @pol | % | % |
|---|
| 100 | | @(pair_destruct_2 … EQ1) |
|---|
| 101 | | @(pair_destruct_2 … EQ2) |
|---|
| 102 | | >(pair_destruct_1 ????? EQpc) |
|---|
| 103 | >(pair_destruct_2 ????? EQpc) |
|---|
| 104 | @split_elim #x #y #H <H -x y H; |
|---|
| 105 | >(pair_destruct_1 ????? EQppc) |
|---|
| 106 | >(pair_destruct_2 ????? EQppc) |
|---|
| 107 | @split_elim #x #y #H <H -x y H; |
|---|
| 108 | >EQ0 % ] |
|---|
| 109 | | >set_low_internal_ram_set_high_internal_ram |
|---|
| 110 | >set_program_counter_set_high_internal_ram |
|---|
| 111 | >set_clock_set_high_internal_ram |
|---|
| 112 | @high_internal_ram_write_at_stack_pointer |
|---|
| 113 | [ >EQ0 @pol | % | % |
|---|
| 114 | | @(pair_destruct_2 … EQ1) |
|---|
| 115 | | @(pair_destruct_2 … EQ2) |
|---|
| 116 | | >(pair_destruct_1 ????? EQpc) |
|---|
| 117 | >(pair_destruct_2 ????? EQpc) |
|---|
| 118 | @split_elim #x #y #H <H -x y H; |
|---|
| 119 | >(pair_destruct_1 ????? EQppc) |
|---|
| 120 | >(pair_destruct_2 ????? EQppc) |
|---|
| 121 | @split_elim #x #y #H <H -x y H; |
|---|
| 122 | >EQ0 % ] |
|---|
| 123 | | >external_ram_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 124 | >external_ram_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 125 | >external_ram_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 126 | >external_ram_write_at_stack_pointer % |
|---|
| 127 | | change with (? = sigma ?? (address_of_word_labels_code_mem (\snd (code_memory ? ps)) ?)) |
|---|
| 128 | >EQ0 % |
|---|
| 129 | | >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 130 | >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 131 | >special_function_registers_8051_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 132 | >special_function_registers_8051_write_at_stack_pointer % |
|---|
| 133 | | >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 134 | >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 135 | >special_function_registers_8052_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 136 | >special_function_registers_8052_write_at_stack_pointer % |
|---|
| 137 | | >p1_latch_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 138 | >p1_latch_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 139 | >p1_latch_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 140 | >p1_latch_write_at_stack_pointer % |
|---|
| 141 | | >p3_latch_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 142 | >p3_latch_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 143 | >p3_latch_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 144 | >p3_latch_write_at_stack_pointer % |
|---|
| 145 | | >clock_write_at_stack_pointer whd in ⊢ (??%?) |
|---|
| 146 | >clock_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 147 | >clock_write_at_stack_pointer whd in ⊢ (???%) |
|---|
| 148 | >clock_write_at_stack_pointer %] |
|---|
| 149 | (*| (* medium *) #H1 #H2 #EQ %[@1] generalize in match H1; -H1; |
|---|
| 150 | @pair_elim' #fst_5_addr #rest_addr #EQ1 |
|---|
| 151 | @pair_elim' #fst_5_pc #rest_pc #EQ2 |
|---|
| 152 | generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc)) |
|---|
| 153 | cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)] |
|---|
| 154 | generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 155 | change in ⊢ (? →??%?) with (execute_1_0 ??) |
|---|
| 156 | @pair_elim' * #instr #newppc' #ticks #EQn |
|---|
| 157 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c >H2b >(eq_instruction_to_eq … H2a) whd in ⊢ (??%?) |
|---|
| 158 | generalize in match EQ; -EQ; normalize nodelta; >(eq_bv_eq … H2c) |
|---|
| 159 | @pair_elim' #carry #new_sp change with (half_add ? (get_8051_sfr ? ps ?) ? = ? → ?) #EQ4 |
|---|
| 160 | @split_elim' #pc_bu #pc_bl >program_counter_set_8051_sfr XXX change with (newppc = ?) #EQ5 |
|---|
| 161 | @pair_elim' #carry' #new_sp' #EQ6 normalize nodelta; #EQx >EQx -EQx; |
|---|
| 162 | change in ⊢ (??(match ????% with [_ ⇒ ?])?) with (sigma … newppc) |
|---|
| 163 | @split_elim' #pc_bu' #pc_bl' #EQ7 change with (newppc' = ? → ?) |
|---|
| 164 | >get_8051_sfr_set_8051_sfr |
|---|
| 165 | |
|---|
| 166 | whd in EQ:(???%) ⊢ ? >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?) |
|---|
| 167 | change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 newppc) in ?)=?) |
|---|
| 168 | generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 newppc))) |
|---|
| 169 | cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4 |
|---|
| 170 | generalize in match (refl … (split bool 4 4 pc_bu)) |
|---|
| 171 | cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5 |
|---|
| 172 | generalize in match (refl … (split bool 3 8 rest_addr)) |
|---|
| 173 | cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6 |
|---|
| 174 | change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?) |
|---|
| 175 | generalize in match |
|---|
| 176 | (refl … |
|---|
| 177 | (half_add 16 (sigma 〈preamble,instr_list〉 newppc) |
|---|
| 178 | ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2))) |
|---|
| 179 | cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7 |
|---|
| 180 | @split_eq_status try % |
|---|
| 181 | [ change with (? = sigma ? (address_of_word_labels ps label)) |
|---|
| 182 | (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *) |
|---|
| 183 | | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?) |
|---|
| 184 | @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]] *)] |
|---|
| 185 | |4: (* Jmp *) #label #MAP |
|---|
| 186 | generalize in match (option_destruct_Some ??? MAP) -MAP; #MAP >MAP -MAP; |
|---|
| 187 | whd in ⊢ (???% → ?) cases (pol ?) normalize nodelta; |
|---|
| 188 | [3: (* long *) #H1 #H2 #EQ %[@1] |
|---|
| 189 | (* normalize in H1; !!!*) generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 190 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 191 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 192 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 193 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 194 | generalize in match EQ; -EQ; |
|---|
| 195 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) |
|---|
| 196 | cases ps in EQ0 ⊢ %; #A1 #A2 #A3 #A4 #A5 #A6 #A7 #A8 #A9 #A10 #XXXX >XXXX % |
|---|
| 197 | |1: (* short *) #H1 #H2 #EQ %[@1] generalize in match H1; -H1; |
|---|
| 198 | generalize in match |
|---|
| 199 | (refl ? |
|---|
| 200 | (sub_16_with_carry |
|---|
| 201 | (sigma 〈preamble,instr_list〉 pol (program_counter … ps)) |
|---|
| 202 | (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label)) |
|---|
| 203 | false)) |
|---|
| 204 | cases (sub_16_with_carry ???) in ⊢ (??%? → %); #results #flags normalize nodelta; |
|---|
| 205 | generalize in match (refl … (split … 8 8 results)) cases (split ????) in ⊢ (??%? → %) #upper #lower normalize nodelta; |
|---|
| 206 | generalize in match (refl … (eq_bv … upper (zero 8))) cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; |
|---|
| 207 | #EQ1 #EQ2 #EQ3 #H1 [2: @⊥ destruct (H1)] |
|---|
| 208 | generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 209 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 210 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 211 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 212 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 213 | generalize in match EQ; -EQ; |
|---|
| 214 | whd in ⊢ (???% → ?); |
|---|
| 215 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) |
|---|
| 216 | change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma ???) ? in ?) = ?) |
|---|
| 217 | generalize in match (refl … (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc) (sign_extension lower))) |
|---|
| 218 | cases (half_add ???) in ⊢ (??%? → %) #carry #newpc normalize nodelta #EQ4 |
|---|
| 219 | @split_eq_status try % change with (newpc = sigma ?? (address_of_word_labels ps label)) |
|---|
| 220 | (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *) |
|---|
| 221 | | (* medium *) #H1 #H2 #EQ %[@1] generalize in match H1; -H1; |
|---|
| 222 | generalize in match |
|---|
| 223 | (refl … |
|---|
| 224 | (split … 5 11 (sigma 〈preamble,instr_list〉 pol (address_of_word_labels_code_mem instr_list label)))) |
|---|
| 225 | cases (split ????) in ⊢ (??%? → %) #fst_5_addr #rest_addr normalize nodelta; #EQ1 |
|---|
| 226 | generalize in match |
|---|
| 227 | (refl … |
|---|
| 228 | (split … 5 11 (sigma 〈preamble,instr_list〉 pol (program_counter … ps)))) |
|---|
| 229 | cases (split ????) in ⊢ (??%? → %) #fst_5_pc #rest_pc normalize nodelta; #EQ2 |
|---|
| 230 | generalize in match (refl … (eq_bv … fst_5_addr fst_5_pc)) |
|---|
| 231 | cases (eq_bv ???) in ⊢ (??%? → %) normalize nodelta; #EQ3 #TEQ [2: destruct (TEQ)] |
|---|
| 232 | generalize in match (option_destruct_Some ??? TEQ) -TEQ; #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 233 | change in ⊢ (? →??%?) with (execute_1_0 ??) |
|---|
| 234 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 235 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 236 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 237 | generalize in match EQ; -EQ; |
|---|
| 238 | whd in ⊢ (???% → ?); |
|---|
| 239 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) whd in ⊢ (??%?) |
|---|
| 240 | change with ((let 〈pc_bu,pc_bl〉 ≝ split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc) in ?)=?) |
|---|
| 241 | generalize in match (refl … (split bool 8 8 (sigma 〈preamble,instr_list〉 pol newppc))) |
|---|
| 242 | cases (split ????) in ⊢ (??%? → %) #pc_bu #pc_bl normalize nodelta; #EQ4 |
|---|
| 243 | generalize in match (refl … (split bool 4 4 pc_bu)) |
|---|
| 244 | cases (split ????) in ⊢ (??%? → %) #nu #nl normalize nodelta; #EQ5 |
|---|
| 245 | generalize in match (refl … (split bool 3 8 rest_addr)) |
|---|
| 246 | cases (split ????) in ⊢ (??%? → %) #relevant1 #relevant2 normalize nodelta; #EQ6 |
|---|
| 247 | change with ((let 〈carry,new_pc〉 ≝ half_add ? (sigma … newppc) ? in ?) = ?) |
|---|
| 248 | generalize in match |
|---|
| 249 | (refl … |
|---|
| 250 | (half_add 16 (sigma 〈preamble,instr_list〉 pol newppc) |
|---|
| 251 | ((nu@@get_index' bool 0 3 nl:::relevant1)@@relevant2))) |
|---|
| 252 | cases (half_add ???) in ⊢ (??%? → %) #carry #new_pc normalize nodelta; #EQ7 |
|---|
| 253 | @split_eq_status try % |
|---|
| 254 | [ change with (? = sigma ?? (address_of_word_labels ps label)) |
|---|
| 255 | (* ARITHMETICS, BUT THE GOAL SEEMS FALSE *) |
|---|
| 256 | | whd in ⊢ (??%%) whd in ⊢ (??(?%?)?) whd in ⊢ (??(?(match ?(?%)? with [_ ⇒ ?])?)?) |
|---|
| 257 | @(bitvector_3_elim_prop … (\fst (split bool 3 8 rest_addr))) %]] |
|---|
| 258 | | (* Instruction *) -pi; whd in ⊢ (? → ??%? → ?) *; normalize nodelta; |
|---|
| 259 | [1,2,3: (* ADD, ADDC, SUBB *) #arg1 #arg2 #MAP #H1 #H2 #EQ %[1,3,5:@1] |
|---|
| 260 | normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 261 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 262 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 pol (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 263 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 264 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 265 | generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); generalize in match MAP; -MAP; |
|---|
| 266 | @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1; |
|---|
| 267 | @(list_addressing_mode_tags_elim_prop … arg2) whd try % -arg2; #ARG2 |
|---|
| 268 | normalize nodelta; #MAP; |
|---|
| 269 | [1: change in ⊢ (? → %) with |
|---|
| 270 | ((let 〈result,flags〉 ≝ |
|---|
| 271 | add_8_with_carry |
|---|
| 272 | (get_arg_8 ? ps false ACC_A) |
|---|
| 273 | (get_arg_8 ? |
|---|
| 274 | (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps))) |
|---|
| 275 | false (DIRECT ARG2)) |
|---|
| 276 | ? in ?) = ?) |
|---|
| 277 | [2,3: %] |
|---|
| 278 | change in ⊢ (???% → ?) with |
|---|
| 279 | (let 〈result,flags〉 ≝ add_8_with_carry ?(*(get_arg_8 ? ps false ACC_A)*) ?? in ?) |
|---|
| 280 | >get_arg_8_set_clock |
|---|
| 281 | [1,2: cases (addressing_mode_ok ???? ∧ addressing_mode_ok ????) in MAP ⊢ ? |
|---|
| 282 | [2,4: #abs @⊥ normalize in abs; destruct (abs) |
|---|
| 283 | |*:whd in ⊢ (??%? → ?) #H <(option_destruct_Some ??? H)] |
|---|
| 284 | [ change in ⊢ (? → %) with |
|---|
| 285 | ((let 〈result,flags〉 ≝ |
|---|
| 286 | add_8_with_carry |
|---|
| 287 | (get_arg_8 ? ps false ACC_A) |
|---|
| 288 | (get_arg_8 ? |
|---|
| 289 | (set_low_internal_ram ? ps (low_internal_ram_of_pseudo_low_internal_ram M (low_internal_ram … ps))) |
|---|
| 290 | false (DIRECT ARG2)) |
|---|
| 291 | ? in ?) = ?) |
|---|
| 292 | >get_arg_8_set_low_internal_ram |
|---|
| 293 | |
|---|
| 294 | cases (add_8_with_carry ???) |
|---|
| 295 | |
|---|
| 296 | [1,2,3,4,5,6,7,8: cases (add_8_with_carry ???) |*: cases (sub_8_with_carry ???)] |
|---|
| 297 | #result #flags |
|---|
| 298 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) % |
|---|
| 299 | | (* INC *) #arg1 #H1 #H2 #EQ %[@1] |
|---|
| 300 | normalize in H1; generalize in match (option_destruct_Some ??? H1) #K1 >K1 in H2; whd in ⊢ (% → ?) |
|---|
| 301 | change in ⊢ (? → ??%?) with (execute_1_0 ??) |
|---|
| 302 | cases (fetch (load_code_memory assembled) (sigma 〈preamble,instr_list〉 (program_counter … ps))) * #instr #newppc' #ticks normalize nodelta; |
|---|
| 303 | * * #H2a #H2b whd in ⊢ (% → ?) #H2c |
|---|
| 304 | >H2b >(eq_instruction_to_eq … H2a) |
|---|
| 305 | generalize in match EQ; -EQ; whd in ⊢ (???% → ??%?); |
|---|
| 306 | @(list_addressing_mode_tags_elim_prop … arg1) whd try % -arg1; normalize nodelta; [1,2,3: #ARG] |
|---|
| 307 | [1,2,3,4: cases (half_add ???) #carry #result |
|---|
| 308 | | cases (half_add ???) #carry #bl normalize nodelta; |
|---|
| 309 | cases (full_add ????) #carry' #bu normalize nodelta ] |
|---|
| 310 | #EQ >EQ -EQ; normalize nodelta; >(eq_bv_eq … H2c) -newppc'; |
|---|
| 311 | [5: % |
|---|
| 312 | |1: <(set_arg_8_set_code_memory 0 [[direct]] ? ? ? (set_clock pseudo_assembly_program |
|---|
| 313 | (set_program_counter pseudo_assembly_program ps newppc) |
|---|
| 314 | (\fst (ticks_of0 〈preamble,instr_list〉 |
|---|
| 315 | (program_counter pseudo_assembly_program ps) |
|---|
| 316 | (Instruction (INC Identifier (DIRECT ARG)))) |
|---|
| 317 | +clock pseudo_assembly_program |
|---|
| 318 | (set_program_counter pseudo_assembly_program ps newppc))) (load_code_memory assembled) result (DIRECT ARG)) |
|---|
| 319 | [2,3: // ] |
|---|
| 320 | <(set_arg_8_set_program_counter 0 [[direct]] ? ? ? ? ?) [2://] |
|---|
| 321 | whd in ⊢ (??%%) |
|---|
| 322 | cases (split bool 4 4 ARG) |
|---|
| 323 | #nu' #nl' |
|---|
| 324 | normalize nodelta |
|---|
| 325 | cases (split bool 1 3 nu') |
|---|
| 326 | #bit_1' #ignore' |
|---|
| 327 | normalize nodelta |
|---|
| 328 | cases (get_index_v bool 4 nu' ? ?) |
|---|
| 329 | [ normalize nodelta (* HERE *) whd in ⊢ (??%%) % |
|---|
| 330 | | |
|---|
| 331 | ] |
|---|
| 332 | cases daemon (* EASY CASES TO BE COMPLETED *) |
|---|
| 333 | qed. |
|---|