Changeset 1649
 Timestamp:
 Jan 18, 2012, 6:17:37 PM (10 years ago)
 Location:
 src/ASM
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/ASM/Assembly.ma
r1615 r1649 14 14  medium_jump: jump_length 15 15  long_jump: jump_length. 16 17 definition policy_type ≝ Word → jump_length.18 16 19 17 definition assembly_preinstruction ≝ … … 420 418 qed. 421 419 422 definition expand_relative_jump_internal :423 (Identifier → Word) → jump_length → Identifier→ Word → ([[relative]] → preinstruction [[relative]]) →420 definition expand_relative_jump_internal_safe: 421 Word → jump_length → Word → ([[relative]] → preinstruction [[relative]]) → 424 422 option (list instruction) 425 423 ≝ 426 λlookup_ labels,jmp_len.λjmp:Identifier.λpc,i.424 λlookup_address,jmp_len.λpc,i. 427 425 match jmp_len with 428 426 [ short_jump ⇒ 429 let lookup_address ≝ lookup_labels jmp in430 427 let 〈result, flags〉 ≝ sub_16_with_carry pc lookup_address false in 431 428 let 〈upper, lower〉 ≝ split ? 8 8 result in … … 440 437 [ RealInstruction (i (RELATIVE (bitvector_of_nat ? 2))); 441 438 SJMP (RELATIVE (bitvector_of_nat ? 3)); (* LJMP size? *) 442 LJMP (ADDR16 (lookup_labels jmp))439 LJMP (ADDR16 lookup_address) 443 440 ] 444 441 ]. … … 446 443 qed. 447 444 448 definition expand_relative_jump: (Identifier → Word) → jump_length → Word → preinstruction Identifier → option (list instruction) ≝ 445 definition rel_jump_length_ok ≝ 446 λlookup_address:Word. 447 λpc:Word. 448 Σjump_len:jump_length. 449 (* CSC,JPB: Cheating here, use Jaap's better definition select_reljump_length *) 450 ∀(*x,*)y. expand_relative_jump_internal_safe lookup_address jump_len (*x*) pc y ≠ None ?. 451 452 lemma eject_rel_jump_length: ∀x,y. rel_jump_length_ok x y → jump_length. 453 #x #y #p @(pi1 … p) 454 qed. 455 456 coercion eject_rel_jump_length nocomposites: 457 ∀x,y.∀pol:rel_jump_length_ok x y. jump_length ≝ 458 eject_rel_jump_length on _pol:(rel_jump_length_ok ??) to jump_length. 459 460 definition expand_relative_jump_internal: 461 ∀lookup_address:Word. ∀pc:Word. rel_jump_length_ok lookup_address pc → 462 ([[relative]] → preinstruction [[relative]]) → 463 list instruction 464 ≝ λlookup_address,pc,jump_len,i. 465 match expand_relative_jump_internal_safe lookup_address jump_len pc i 466 return λres. res ≠ None ? → ? 467 with 468 [ None ⇒ λabs.⊥ 469  Some res ⇒ λ_.res ] (pi2 … jump_len i). 470 cases abs /2/ 471 qed. 472 473 definition expand_relative_jump_safe: ∀lookup_labels:Identifier → Word.Word → jump_length → preinstruction Identifier → option (list instruction) ≝ 449 474 λlookup_labels. 475 λpc: Word. 450 476 λjmp_len: jump_length. 451 λpc.452 477 λi: preinstruction Identifier. 453 478 let rel_jmp ≝ RELATIVE (bitvector_of_nat ? 2) in 454 479 match i with 455 [ JC jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JC ?)456  JNC jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JNC ?)457  JB baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JB ? baddr)458  JZ jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JZ ?)459  JNZ jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JNZ ?)460  JBC baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JBC ? baddr)461  JNB baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (JNB ? baddr)462  CJNE addr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (CJNE ? addr)463  DJNZ addr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmppc (DJNZ ? addr)464  ADD arg1 arg2 ⇒ Some ?[ ADD ? arg1 arg2 ]465  ADDC arg1 arg2 ⇒ Some ?[ ADDC ? arg1 arg2 ]466  SUBB arg1 arg2 ⇒ Some ?[ SUBB ? arg1 arg2 ]467  INC arg ⇒ Some ?[ INC ? arg ]468  DEC arg ⇒ Some ?[ DEC ? arg ]469  MUL arg1 arg2 ⇒ Some ?[ MUL ? arg1 arg2 ]470  DIV arg1 arg2 ⇒ Some ?[ DIV ? arg1 arg2 ]471  DA arg ⇒ Some ?[ DA ? arg ]472  ANL arg ⇒ Some ?[ ANL ? arg ]473  ORL arg ⇒ Some ?[ ORL ? arg ]474  XRL arg ⇒ Some ?[ XRL ? arg ]475  CLR arg ⇒ Some ?[ CLR ? arg ]476  CPL arg ⇒ Some ?[ CPL ? arg ]477  RL arg ⇒ Some ?[ RL ? arg ]478  RR arg ⇒ Some ?[ RR ? arg ]479  RLC arg ⇒ Some ?[ RLC ? arg ]480  RRC arg ⇒ Some ?[ RRC ? arg ]481  SWAP arg ⇒ Some ?[ SWAP ? arg ]482  MOV arg ⇒ Some ?[ MOV ? arg ]483  MOVX arg ⇒ Some ?[ MOVX ? arg ]484  SETB arg ⇒ Some ?[ SETB ? arg ]485  PUSH arg ⇒ Some ?[ PUSH ? arg ]486  POP arg ⇒ Some ?[ POP ? arg ]487  XCH arg1 arg2 ⇒ Some ?[ XCH ? arg1 arg2 ]488  XCHD arg1 arg2 ⇒ Some ?[ XCHD ? arg1 arg2 ]489  RET ⇒ Some ?[ RET ? ]490  RETI ⇒ Some ?[ RETI ? ]491  NOP ⇒ Some ?[ RealInstruction (NOP ?) ]480 [ JC jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JC ?) 481  JNC jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JNC ?) 482  JB baddr jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JB ? baddr) 483  JZ jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JZ ?) 484  JNZ jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JNZ ?) 485  JBC baddr jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JBC ? baddr) 486  JNB baddr jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (JNB ? baddr) 487  CJNE addr jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (CJNE ? addr) 488  DJNZ addr jmp ⇒ expand_relative_jump_internal_safe (lookup_labels jmp) jmp_len pc (DJNZ ? addr) 489  ADD arg1 arg2 ⇒ Some … [ ADD ? arg1 arg2 ] 490  ADDC arg1 arg2 ⇒ Some … [ ADDC ? arg1 arg2 ] 491  SUBB arg1 arg2 ⇒ Some … [ SUBB ? arg1 arg2 ] 492  INC arg ⇒ Some … [ INC ? arg ] 493  DEC arg ⇒ Some … [ DEC ? arg ] 494  MUL arg1 arg2 ⇒ Some … [ MUL ? arg1 arg2 ] 495  DIV arg1 arg2 ⇒ Some … [ DIV ? arg1 arg2 ] 496  DA arg ⇒ Some … [ DA ? arg ] 497  ANL arg ⇒ Some … [ ANL ? arg ] 498  ORL arg ⇒ Some … [ ORL ? arg ] 499  XRL arg ⇒ Some … [ XRL ? arg ] 500  CLR arg ⇒ Some … [ CLR ? arg ] 501  CPL arg ⇒ Some … [ CPL ? arg ] 502  RL arg ⇒ Some … [ RL ? arg ] 503  RR arg ⇒ Some … [ RR ? arg ] 504  RLC arg ⇒ Some … [ RLC ? arg ] 505  RRC arg ⇒ Some … [ RRC ? arg ] 506  SWAP arg ⇒ Some … [ SWAP ? arg ] 507  MOV arg ⇒ Some … [ MOV ? arg ] 508  MOVX arg ⇒ Some … [ MOVX ? arg ] 509  SETB arg ⇒ Some … [ SETB ? arg ] 510  PUSH arg ⇒ Some … [ PUSH ? arg ] 511  POP arg ⇒ Some … [ POP ? arg ] 512  XCH arg1 arg2 ⇒ Some … [ XCH ? arg1 arg2 ] 513  XCHD arg1 arg2 ⇒ Some … [ XCHD ? arg1 arg2 ] 514  RET ⇒ Some … [ RET ? ] 515  RETI ⇒ Some … [ RETI ? ] 516  NOP ⇒ Some … [ RealInstruction (NOP ?) ] 492 517 ]. 493 518 494 495 definition expand_pseudo_instruction_safe: ? → ? → Word → jump_length→ pseudo_instruction → option (list instruction) ≝519 definition expand_pseudo_instruction_safe: 520 ∀lookup_labels,pc. jump_length → ? → pseudo_instruction → option (list instruction) ≝ 496 521 λlookup_labels. 497 λlookup_datalabels.498 522 λpc. 499 523 λjmp_len. 524 λlookup_datalabels. 500 525 λi. 501 526 match i with … … 520 545 let address ≝ DATA16 (lookup_datalabels trgt) in 521 546 Some ? [ RealInstruction (MOV ? (inl ? ? (inl ? ? (inr ? ? 〈DPTR, address〉))))] 522  Instruction instr ⇒ expand_relative_jump lookup_labels jmp_len pcinstr547  Instruction instr ⇒ expand_relative_jump_safe lookup_labels pc jmp_len instr 523 548  Jmp jmp ⇒ 524 549 match jmp_len with 525 550 [ short_jump ⇒ 526 let lookup_address ≝ lookup_labels jmp in 527 let 〈result, flags〉 ≝ sub_16_with_carry pc lookup_address false in 551 let 〈result, flags〉 ≝ sub_16_with_carry pc (lookup_labels jmp) false in 528 552 let 〈upper, lower〉 ≝ split ? 8 8 result in 529 553 if eq_bv ? upper (zero 8) then … … 533 557 None ? 534 558  medium_jump ⇒ 535 let address ≝ lookup_labels jmp in 536 let 〈fst_5_addr, rest_addr〉 ≝ split ? 5 11 address in 559 let 〈fst_5_addr, rest_addr〉 ≝ split ? 5 11 (lookup_labels jmp) in 537 560 let 〈fst_5_pc, rest_pc〉 ≝ split ? 5 11 pc in 538 561 if eq_bv ? fst_5_addr fst_5_pc then … … 542 565 None ? 543 566  long_jump ⇒ 544 let address ≝ ADDR16 (lookup_labels jmp) in567 let address ≝ ADDR16 (lookup_labels jmp) in 545 568 Some ? [ LJMP address ] 546 569 ] … … 549 572 qed. 550 573 551 552 definition assembly_1_pseudoinstruction_safe ≝ 553 λprogram: pseudo_assembly_program. 554 λjump_expansion: policy_type. 555 λppc: Word. 574 definition jump_length_ok ≝ 575 λlookup_labels:Identifier → Word. 576 λpc:Word. 577 Σjump_len:jump_length. 578 (* CSC,JPB: Cheating here, use Jaap's better definition select_reljump_length *) 579 ∀x,y.expand_pseudo_instruction_safe lookup_labels pc jump_len x y ≠ None ?. 580 581 lemma eject_jump_length: ∀x,y. jump_length_ok x y → jump_length. 582 #x #y #p @(pi1 … p) 583 qed. 584 585 coercion eject_jump_length nocomposites: 586 ∀x,y.∀pol:jump_length_ok x y. jump_length ≝ 587 eject_jump_length on _pol:(jump_length_ok ??) to jump_length. 588 589 definition expand_pseudo_instruction: 590 ∀lookup_labels:Identifier → Word. ∀pc:Word. jump_length_ok lookup_labels pc → 591 ? → pseudo_instruction → list instruction ≝ 592 λlookup_labels,pc,jump_len,lookup_datalabels,i. 593 match expand_pseudo_instruction_safe lookup_labels pc jump_len lookup_datalabels i 594 return λres. res ≠ None ? → ? 595 with 596 [ None ⇒ λabs.⊥ 597  Some res ⇒ λ_.res ] (pi2 … jump_len lookup_datalabels i). 598 cases abs /2/ 599 qed. 600 601 definition policy_type ≝ 602 λlookup_labels:Identifier → Word. 603 ∀pc:Word. jump_length_ok lookup_labels pc. 604 605 definition policy_type2 ≝ 606 ∀lookup_labels.policy_type lookup_labels. 607 608 definition assembly_1_pseudoinstruction ≝ 609 λlookup_labels. 610 λjump_expansion: policy_type lookup_labels. 611 (*λppc: Word.*) 556 612 λpc: Word. 557 λlookup_labels.558 613 λlookup_datalabels. 559 614 λi. 560 let expansion ≝ jump_expansion ppc in 561 match expand_pseudo_instruction_safe lookup_labels lookup_datalabels pc expansion i with 562 [ None ⇒ None ? 563  Some pseudos ⇒ 564 let mapped ≝ map ? ? assembly1 pseudos in 565 let flattened ≝ flatten ? mapped in 566 let pc_len ≝ length ? flattened in 567 Some ? (〈pc_len, flattened〉) 568 ]. 615 let expansion ≝ jump_expansion pc in 616 let pseudos ≝ expand_pseudo_instruction lookup_labels pc expansion lookup_datalabels i in 617 let mapped ≝ map ? ? assembly1 pseudos in 618 let flattened ≝ flatten ? mapped in 619 let pc_len ≝ length ? flattened in 620 〈pc_len, flattened〉. 569 621 570 definition construct_costs _safe≝571 λprogram .572 λjump_expansion: policy_type .622 definition construct_costs ≝ 623 λprogram_counter: nat. 624 λjump_expansion: policy_type (λx.bitvector_of_nat ? program_counter). 573 625 λpseudo_program_counter: nat. 574 λprogram_counter: nat.575 626 λcosts: BitVectorTrie costlabel 16. 576 627 λi. … … 578 629 [ Cost cost ⇒ 579 630 let program_counter_bv ≝ bitvector_of_nat ? program_counter in 580 Some ?〈program_counter, (insert … program_counter_bv cost costs)〉631 〈program_counter, (insert … program_counter_bv cost costs)〉 581 632  _ ⇒ 582 633 let pc_bv ≝ bitvector_of_nat ? program_counter in 583 let ppc_bv ≝ bitvector_of_nat ? pseudo_program_counter in 584 let lookup_labels ≝ λx.pc_bv in 634 (*let ppc_bv ≝ bitvector_of_nat ? pseudo_program_counter in*) 585 635 let lookup_datalabels ≝ λx.zero ? in 586 636 let pc_delta_assembled ≝ 587 assembly_1_pseudoinstruction_safe program jump_expansion ppc_bv pc_bv 588 lookup_labels lookup_datalabels i 589 in 590 match pc_delta_assembled with 591 [ None ⇒ None ? 592  Some pc_delta_assembled ⇒ 593 let 〈pc_delta, assembled〉 ≝ pc_delta_assembled in 594 Some ? 〈pc_delta + program_counter, costs〉 595 ] 637 assembly_1_pseudoinstruction (λx.bitvector_of_nat ? program_counter) 638 jump_expansion (*ppc_bv*) pc_bv lookup_datalabels i in 639 let 〈pc_delta, assembled〉 ≝ pc_delta_assembled in 640 〈pc_delta + program_counter, costs〉 596 641 ]. 597 642 … … 599 644 program counters. It is at the heart of the proof. *) 600 645 (*CSC: code taken from build_maps *) 601 definition sigma00: pseudo_assembly_program → policy_type → list ? → ? → option (nat × (nat × (BitVectorTrie Word 16))) ≝ 602 λinstr_list. 603 λjump_expansion: policy_type. 646 (*JPB: Here it gets strange because we need a program counter for the jump 647 *expansion, but we can't give it to the type because we don't have it yet. Argh. 648 *add a forall type?*) 649 definition sigma00: policy_type2 → list ? → ? → (nat × (nat × (BitVectorTrie Word 16))) ≝ 650 λjump_expansion: policy_type2. 604 651 λl:list labelled_instruction. 605 652 λacc. 606 653 foldl … 607 (λt,i. 608 match t with 609 [ None ⇒ None … 610  Some ppc_pc_map ⇒ 611 let 〈ppc,pc_map〉 ≝ ppc_pc_map in 612 let 〈program_counter, sigma_map〉 ≝ pc_map in 613 let 〈label, i〉 ≝ i in 614 match construct_costs_safe instr_list jump_expansion ppc program_counter (Stub …) i with 615 [ None ⇒ None ? 616  Some pc_ignore ⇒ 617 let 〈pc,ignore〉 ≝ pc_ignore in 618 Some … 〈S ppc, 〈pc, insert ?? (bitvector_of_nat 16 ppc) (bitvector_of_nat 16 pc) sigma_map〉〉 ] 619 ]) acc l. 620 621 definition sigma0: pseudo_assembly_program → policy_type → option (nat × (nat × (BitVectorTrie Word 16))) ≝ 654 (λppc_pc_map,i. 655 let 〈ppc,pc_map〉 ≝ ppc_pc_map in 656 let 〈program_counter, sigma_map〉 ≝ pc_map in 657 let 〈label, i〉 ≝ i in 658 let 〈pc,ignore〉 ≝ construct_costs program_counter (jump_expansion (λx.bitvector_of_nat ? program_counter)) ppc (Stub …) i in 659 〈S ppc, 〈pc, insert ?? (bitvector_of_nat 16 ppc) (bitvector_of_nat 16 pc) sigma_map〉〉 660 ) acc l. 661 662 definition sigma0: pseudo_assembly_program → policy_type2 → (nat × (nat × (BitVectorTrie Word 16))) ≝ 622 663 λprog. 623 664 λjump_expansion. 624 sigma00 prog jump_expansion (\snd prog) (Some ? 〈0, 〈0, Stub …〉〉). 625 626 definition tech_pc_sigma00: pseudo_assembly_program → policy_type → list labelled_instruction → option (nat × nat) ≝ 665 sigma00 jump_expansion (\snd prog) 〈0, 〈0, Stub …〉〉. 666 667 definition tech_pc_sigma00: pseudo_assembly_program → policy_type2 → 668 list labelled_instruction → (nat × nat) ≝ 627 669 λprogram,jump_expansion,instr_list. 628 match sigma00 program jump_expansion instr_list (Some ? 〈0, 〈0, (Stub ? ?)〉〉) (* acc copied from sigma0 *) with 629 [ None ⇒ None … 630  Some result ⇒ 631 let 〈ppc,pc_sigma_map〉 ≝ result in 632 let 〈pc,map〉 ≝ pc_sigma_map in 633 Some … 〈ppc,pc〉 ]. 634 635 definition sigma_safe: pseudo_assembly_program → policy_type → option (Word → Word) ≝ 670 let 〈ppc,pc_sigma_map〉 ≝ sigma00 jump_expansion instr_list 〈0, 〈0, (Stub ? ?)〉〉 in (* acc copied from sigma0 *) 671 let 〈pc,map〉 ≝ pc_sigma_map in 672 〈ppc,pc〉. 673 674 definition sigma_safe: pseudo_assembly_program → policy_type2 → 675 option (Word → Word) ≝ 636 676 λinstr_list,jump_expansion. 637 match sigma0 instr_list jump_expansion with 638 [ None ⇒ None ? 639  Some result ⇒ 640 let 〈ppc,pc_sigma_map〉 ≝ result in 641 let 〈pc, sigma_map〉 ≝ pc_sigma_map in 642 if gtb pc (2^16) then 643 None ? 644 else 645 Some ? (λx. lookup … x sigma_map (zero …)) ]. 677 let 〈ppc,pc_sigma_map〉 ≝ sigma0 instr_list jump_expansion in 678 let 〈pc, sigma_map〉 ≝ pc_sigma_map in 679 if gtb pc (2^16) then 680 None ? 681 else 682 Some ? (λx. lookup … x sigma_map (zero …)). 646 683 647 684 (* stuff about policy *) … … 649 686 definition policy_ok ≝ λjump_expansion,p. sigma_safe p jump_expansion ≠ None …. 650 687 651 definition policy ≝ λp. Σjump_expansion:policy_type . policy_ok jump_expansion p.652 653 lemma eject_policy: ∀p. policy p → policy_type .688 definition policy ≝ λp. Σjump_expansion:policy_type2. policy_ok jump_expansion p. 689 690 lemma eject_policy: ∀p. policy p → policy_type2. 654 691 #p #pol @(pi1 … pol) 655 692 qed. 656 693 657 coercion eject_policy nocomposites: ∀p.∀pol:policy p. policy_type ≝ eject_policy on _pol:(policy ?) to policy_type.694 coercion eject_policy nocomposites: ∀p.∀pol:policy p. policy_type2 ≝ eject_policy on _pol:(policy ?) to policy_type2. 658 695 659 696 definition sigma: ∀p:pseudo_assembly_program. policy p → Word → Word ≝ … … 675 712 676 713 lemma sigma00_append: 677 ∀ instr_list,jump_expansion,l1,l2,acc.678 sigma00 instr_listjump_expansion (l1@l2) acc =679 sigma00 instr_listjump_expansion680 l2 (sigma00 instr_listjump_expansion l1 acc).714 ∀jump_expansion,l1,l2,acc. 715 sigma00 jump_expansion (l1@l2) acc = 716 sigma00 jump_expansion 717 l2 (sigma00 jump_expansion l1 acc). 681 718 whd in match sigma00; normalize nodelta; 682 # instr_list #jump_expansion #l1 #l2 #acc @foldl_append683 qed. 684 685 lemma sigma00_strict:686 ∀ instr_list,jump_expansion,l,acc. acc = None ? →687 sigma00 instr_listjump_expansion l acc = None ….688 # instr_list #jump_expansion #l elim l719 #jump_expansion #l1 #l2 #acc @foldl_append 720 qed. 721 722 (* lemma sigma00_strict: 723 ∀jump_expansion,l,acc. acc = None ? → 724 sigma00 jump_expansion l acc = None …. 725 #jump_expansion #l elim l 689 726 [ #acc #H >H % 690  #hd #tl #IH #acc #H >H change with (sigma00 ? ?tl ? = ?) @IH % ]727  #hd #tl #IH #acc #H >H change with (sigma00 ? tl ? = ?) @IH % ] 691 728 qed. 692 729 … … 702 739 [2: #x #_ % #abs destruct(abs) 703 740  * #abs @⊥ @abs >sigma00_strict % ] 704 qed. 741 qed. 705 742 706 743 lemma policy_ok_prefix_hd_ok: … … 720 757 cases (construct_costs_safe ??????) normalize 721 758 [* #abs @⊥ @abs %  #X #_ % #abs destruct(abs)] 722 qed. 723 759 qed. *) 760 761 (* JPB,CSC: this definition is now replaced by the expand_pseudo_instruction higher up 724 762 definition expand_pseudo_instruction: 725 763 ∀program:pseudo_assembly_program.∀pol: policy program. … … 729 767 let pi ≝ \fst (fetch_pseudo_instruction (\snd program) ppc) in 730 768 pc = sigma program pol ppc → 731 Σres:list instruction. Some … res = expand_pseudo_instruction_safe lookup_labels lookup_datalabels pc(pol ppc) pi769 Σres:list instruction. Some … res = expand_pseudo_instruction_safe pc (lookup_labels pi) lookup_datalabels (pol ppc) pi 732 770 ≝ λprogram,pol,ppc,lookup_labels,lookup_datalabels,pc,prf1,prf2,prf3. 733 771 match expand_pseudo_instruction_safe lookup_labels lookup_datalabels pc (pol ppc) (\fst (fetch_pseudo_instruction (\snd program) ppc)) with … … 753 791 per concludere construct_costs_safe ≠ None *) 754 792  >p %] 755 qed. 793 qed. *) 756 794 757 795 (* MAIN AXIOM HERE, HIDDEN USING cases daemon *) 758 definition assembly_1_pseudoinstruction':796 (* definition assembly_1_pseudoinstruction': 759 797 ∀program:pseudo_assembly_program.∀pol: policy program. 760 798 ∀ppc:Word.∀lookup_labels,lookup_datalabels,pi. … … 763 801 \fst (fetch_pseudo_instruction (\snd program) ppc) = pi → 764 802 Σres:(nat × (list Byte)). 765 Some … res = assembly_1_pseudoinstruction_safeprogram pol ppc (sigma program pol ppc) lookup_labels lookup_datalabels pi ∧803 res = assembly_1_pseudoinstruction program pol ppc (sigma program pol ppc) lookup_labels lookup_datalabels pi ∧ 766 804 let 〈len,code〉 ≝ res in 767 805 sigma program pol (\snd (half_add ? ppc (bitvector_of_nat ? 1))) = … … 774 812 λpi. 775 813 λprf1,prf2,prf3. 776 match assembly_1_pseudoinstruction_safe program pol ppc (sigma program pol ppc) lookup_labels lookup_datalabels pi with 777 [ None ⇒ let dummy ≝ 〈0,[ ]〉 in dummy 778  Some res ⇒ res ]. 814 assembly_1_pseudoinstruction program pol ppc (sigma program pol ppc) lookup_labels lookup_datalabels pi. 779 815 [ @⊥ elim pi in p; [*] 780 816 try (#ARG1 #ARG2 #ARG3 #abs) try (#ARG1 #ARG2 #abs) try (#ARG1 #abs) try #abs … … 787 823 (* THIS SHOULD BE TRUE INSTEAD *) 788 824 cases daemon] 789 qed. 825 qed. 790 826 791 827 definition assembly_1_pseudoinstruction: … … 811 847 cases (pi2 … (assembly_1_pseudoinstruction' program pol ppc lookup_labels lookup_datalabels pi prf1 prf2 prf3)) 812 848 #H1 #_ @H1 813 qed. 849 qed. *) 814 850 815 851 (* MAIN AXIOM HERE, HIDDEN USING cases daemon *) 816 definition construct_costs':852 (* definition construct_costs': 817 853 ∀program. ∀pol:policy program. ∀ppc,pc,costs,i. 818 854 Σres:(nat × (BitVectorTrie costlabel 16)). Some … res = construct_costs_safe program pol ppc pc costs i … … 827 863 828 864 definition construct_costs ≝ 829 λprogram,pol,ppc,pc,costs,i. pi1 … (construct_costs' program pol ppc pc costs i). 865 λprogram,pol,ppc,pc,costs,i. pi1 … (construct_costs' program pol ppc pc costs i). *) 830 866 831 867 (* … … 902 938 *) 903 939 904 axiom construct_costs_sigma:940 (* axiom construct_costs_sigma: 905 941 ∀p.∀pol:policy p.∀ppc,pc,costs,i. 906 942 bitvector_of_nat ? pc = sigma p pol (bitvector_of_nat ? ppc) → … … 910 946 ∀program.∀pol:policy program.∀prefix,costs,label,i,ppc,pc. 911 947 tech_pc_sigma00 program pol prefix = Some … 〈ppc,pc〉 → 912 tech_pc_sigma00 program pol (prefix@[〈label,i〉]) = Some … 〈S ppc,\fst (construct_costs program pol … ppc pc costs i)〉. 948 tech_pc_sigma00 program pol (prefix@[〈label,i〉]) = Some … 〈S ppc,\fst (construct_costs program pol … ppc pc costs i)〉. *) 913 949 914 950 axiom eq_identifier_eq: … … 941 977 And (bitvector_of_nat ? pc' = sigma pseudo_program pol (bitvector_of_nat ? ppc')) (*∧*) 942 978 (ppc' = length … pre)) (*∧ *) 943 (tech_pc_sigma00 pseudo_program (pi1 … pol) pre = Some ?〈ppc',pc'〉)) (*∧*)979 (tech_pc_sigma00 pseudo_program (pi1 … pol) pre = 〈ppc',pc'〉)) (*∧*) 944 980 (∀id. occurs_exactly_once id pre → 945 981 lookup_def … labels id (zero …) = sigma pseudo_program pol (address_of_word_labels_code_mem pre id))) … … 958 994 ] 959 995 in 960 let construct ≝ construct_costs p seudo_program pol ppcpc costs i' in996 let construct ≝ construct_costs pc (pol (λx.bitvector_of_nat ? pc)) ppc costs i' in 961 997 〈labels, 〈S ppc,construct〉〉) 〈empty_map …, 〈0, 〈0, Stub ? ?〉〉〉 962 998 in … … 965 1001 let 〈pc, costs〉 ≝ pc_costs in 966 1002 〈labels, costs〉. 967 [2: whd generalize in match (pi2 … t); >p >p1 >p2 >p3 * * * #IHn1 #IH0 #IH1 #IH21003 (* [2: whd generalize in match (pi2 … t); >p >p1 >p2 >p3 * * * #IHn1 #IH0 #IH1 #IH2 968 1004 generalize in match (refl … construct); cases construct in ⊢ (???% → %); #PC #CODE #JMEQ % [% [%]] 969 1005 [ <(construct_costs_sigma … costs i1 IHn1) change with (? = ?(\fst construct)) >JMEQ % … … 983 1019  generalize in match (pi2 … result) in ⊢ ?; 984 1020 normalize nodelta in p ⊢ %; result; >p in ⊢ (match % with [_ ⇒ ?] → ?); 985 normalize nodelta; >p1 normalize nodelta; >p2; normalize nodelta; * #_; #H @H] 1021 normalize nodelta; >p1 normalize nodelta; >p2; normalize nodelta; * #_; #H @H] *) 1022 cases daemon 986 1023 qed. 987 1024 … … 1003 1040 let 〈pi,newppc〉 ≝ fetch_pseudo_instruction instr_list ppc' in 1004 1041 let 〈len,assembledi〉 ≝ 1005 assembly_1_pseudoinstruction 〈preamble,instr_list〉 pol ppc' lookup_labels lookup_datalabels pi ???in1042 assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc' lookup_datalabels pi in 1006 1043 True) 1007 1044 instr_list … … 1009 1046 let 〈pc, ppc_code〉 ≝ pc_ppc_code in 1010 1047 let 〈ppc, code〉 ≝ ppc_code in 1011 let 〈pc_delta, program〉 ≝ assembly_1_pseudoinstruction 〈preamble,instr_list〉 pol ppc lookup_labels lookup_datalabels (\snd hd) ???in1048 let 〈pc_delta, program〉 ≝ assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc lookup_datalabels (\snd hd) in 1012 1049 let 〈new_pc, flags〉 ≝ add_16_with_carry pc (bitvector_of_nat ? pc_delta) false in 1013 1050 let new_ppc ≝ \snd (half_add ? ppc (bitvector_of_nat ? 1)) in … … 1016 1053 in 1017 1054 〈\snd (\snd result), costs〉. 1018 [2,5: % 1019 *: cases daemon ] 1055 cases daemon 1020 1056 qed. 1021 1057 
src/ASM/AssemblyProof.ma
r1616 r1649 1288 1288 #H >H * #H1 try (whd in ⊢ (% → ?); * #H2) 1289 1289 try (whd in ⊢ (% → ?); * #H3) whd in ⊢ (% → ?); #H4 1290 [ whd in match fetch; normalize nodelta <H1 (*XXX 1290 [ whd in match fetch; normalize nodelta <H1 ] cases daemon 1291 (*XXX 1291 1292 1292 1293 whd in ⊢ (let fetched ≝ ??% in ?) <H1 whd in ⊢ (let fetched ≝ % in ?) … … 1317 1318 1318 1319 lemma fetch_assembly_pseudo': 1319 ∀ program.∀pol:policy program.∀ppc,lookup_labels,lookup_datalabels.1320 ∀lookup_labels.∀pol:policy_type lookup_labels.∀ppc,lookup_datalabels. 1320 1321 ∀pi,code_memory,len,assembled,instructions,pc. 1321 1322 let expansion ≝ pol ppc in 1322 Some ? instructions = expand_pseudo_instruction_safe lookup_labels lookup_datalabels (bitvector_of_nat ? pc) expansionpi →1323 Some … 〈len,assembled〉 = assembly_1_pseudoinstruction_safe program pol ppc (bitvector_of_nat ? pc) lookup_labelslookup_datalabels pi →1323 instructions = expand_pseudo_instruction lookup_labels ppc expansion lookup_datalabels pi → 1324 〈len,assembled〉 = assembly_1_pseudoinstruction lookup_labels pol ppc lookup_datalabels pi → 1324 1325 encoding_check code_memory (bitvector_of_nat … pc) (bitvector_of_nat … (pc + len)) assembled → 1325 1326 fetch_many code_memory (bitvector_of_nat … (pc + len)) (bitvector_of_nat … pc) instructions. 1326 # program #pol #ppc #lookup_labels#lookup_datalabels #pi #code_memory #len #assembled #instructions #pc1327 #EQ1 whd in ⊢ (???% → ?) <EQ1 whd in ⊢ (???% → ?)#EQ21328 cases (pair_destruct ?????? (option_destruct_Some … EQ2)) EQ2; #EQ2a #EQ2b1329 >EQ2a >EQ2b EQ2a EQ2b;1327 #lookup_labels #pol #ppc #lookup_datalabels #pi #code_memory #len #assembled #instructions #pc 1328 #EQ1 whd in ⊢ (???% → ?); <EQ1 whd in ⊢ (???% → ?); #EQ2 1329 cases (pair_destruct ?????? EQ2) EQ2; #EQ2a #EQ2b 1330 >EQ2a >EQ2b EQ2a EQ2b; 1330 1331 generalize in match (pc + flatten … (map … assembly1 instructions)); #final_pc 1331 generalize in match pc elim instructions1332 [ #pc whd in ⊢ (% → %) #H >H @eq_bv_refl1332 generalize in match pc; elim instructions 1333 [ #pc whd in ⊢ (% → %); #H >H @eq_bv_refl 1333 1334  #i #tl #IH #pc #H whd cases (encoding_check_append … H); H; #H1 #H2 whd 1334 generalize in match (fetch_assembly pc i code_memory … (refl …) H1) 1335 cases (fetch code_memory (bitvector_of_nat … pc)) #newi_pc #ticks whd in ⊢ (% → %) 1336 cases newi_pc #newi #newpc whd in ⊢ (% → %) #K cases (conjunction_true … K) K; #K11335 generalize in match (fetch_assembly pc i code_memory … (refl …) H1); 1336 cases (fetch code_memory (bitvector_of_nat … pc)) #newi_pc #ticks whd in ⊢ (% → %); 1337 cases newi_pc #newi #newpc whd in ⊢ (% → %); #K cases (conjunction_true … K) K; #K1 1337 1338 cases (conjunction_true … K1) K1; #K1 #K2 #K3 % try % 1338 1339 [ @K1  @eqb_true_to_eq <(eq_instruction_to_eq … K1) @K2  >(eq_bv_eq … K3) @IH @H2 ] … … 1345 1346 (* CSC: soo long next one; can we merge with previous one now? *) 1346 1347 lemma fetch_assembly_pseudo: 1347 ∀program.∀pol:policy program.∀ppc. 1348 ∀code_memory. 1349 let lookup_labels ≝ ? in 1350 let lookup_datalabels ≝ ? in 1351 let pc ≝ ? in 1352 let pi ≝ \fst (fetch_pseudo_instruction (\snd program) ppc) in 1353 let instructions ≝ expand_pseudo_instruction program pol ppc lookup_labels lookup_datalabels pc (refl …) (refl …) (refl …) in 1354 let 〈len,assembled〉 ≝ assembly_1_pseudoinstruction program pol ppc lookup_labels lookup_datalabels pi (refl …) (refl …) (refl …) in 1355 encoding_check code_memory pc (bitvector_of_nat … (nat_of_bitvector ? pc + len)) assembled → 1356 fetch_many code_memory (bitvector_of_nat … (nat_of_bitvector ? pc + len)) pc instructions. 1357 #program #pol #ppc #code_memory 1358 letin lookup_labels ≝ (λx:Identifier 1359 .sigma program pol (address_of_word_labels_code_mem (\snd program) x)) 1360 letin lookup_datalabels ≝ 1361 (λx:BitVector 16 1362 .lookup Identifier 16 x (construct_datalabels (\fst program)) (zero 16)) 1363 letin pc ≝ (sigma program pol ppc) 1364 letin pi ≝ (\fst (fetch_pseudo_instruction (\snd program) ppc)) 1365 letin instructions ≝ (expand_pseudo_instruction program pol ppc lookup_labels lookup_datalabels pc (refl …) (refl …) (refl …)) 1366 @pair_elim' #len #assembled #EQ1 #H 1348 ∀program:pseudo_assembly_program. 1349 let lookup_labels ≝ λx:Identifier.(address_of_word_labels_code_mem (\snd program) x) in 1350 ∀pol:(policy program).∀ppc.∀code_memory. 1351 let lookup_datalabels ≝ λx:Identifier.lookup_def … (construct_datalabels (\fst program)) x (zero 16) in 1352 let pc ≝ sigma program pol ppc in 1353 let pi ≝ \fst (fetch_pseudo_instruction (\snd program) ppc) in 1354 let instructions ≝ expand_pseudo_instruction lookup_labels ppc (pol lookup_labels ppc) lookup_datalabels pi in 1355 let 〈len,assembled〉 ≝ assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc lookup_datalabels pi in 1356 encoding_check code_memory pc (bitvector_of_nat … (nat_of_bitvector ? pc + len)) assembled → 1357 fetch_many code_memory (bitvector_of_nat … (nat_of_bitvector ? pc + len)) pc instructions. 1358 #program letin lookup_labels ≝ (λx.?) #pol #ppc #code_memory 1359 letin lookup_datalabels ≝ (λx.?) 1360 letin pc ≝ (sigma ???) letin pi ≝ (fst ???) 1361 letin instructions ≝ (expand_pseudo_instruction ?????) 1362 @pair_elim #len #assembled #EQ1 #H 1367 1363 generalize in match 1368 (fetch_assembly_pseudo' program pol ppc lookup_labels lookup_datalabels pi 1369 code_memory len assembled instructions (nat_of_bitvector ? pc) ???) in ⊢ ?; 1370 [ >bitvector_of_nat_nat_of_bitvector // 1371  >bitvector_of_nat_nat_of_bitvector normalize nodelta >(sig2 ?? (expand_pseudo_instruction …)) % 1372  >bitvector_of_nat_nat_of_bitvector <EQ1 @assembly_1_pseudoinstruction_ok1 1373  //] 1364 (fetch_assembly_pseudo' lookup_labels ((pi1 ?? pol) lookup_labels) ppc lookup_datalabels pi code_memory len 1365 assembled instructions (nat_of_bitvector ? pc)) in ⊢ ?; 1366 >bitvector_of_nat_nat_of_bitvector >EQ1 normalize nodelta 1367 #X @X // 1374 1368 qed. 1375 1369 … … 1386 1380 let preamble ≝ \fst program in 1387 1381 let datalabels ≝ construct_datalabels preamble in 1388 let lookup_labels ≝ λx. sigma program pol (address_of_word_labels_code_mem (\snd program) x)in1389 let lookup_datalabels ≝ λx. lookup ?? x datalabels(zero ?) in1382 let lookup_labels ≝ λx. address_of_word_labels_code_mem (\snd program) x in 1383 let lookup_datalabels ≝ λx. lookup_def ?? datalabels x (zero ?) in 1390 1384 ∀ppc. 1391 1385 let pi_newppc ≝ fetch_pseudo_instruction (\snd program) ppc in 1392 1386 ∀len,assembledi. 1393 〈len,assembledi〉 = assembly_1_pseudoinstruction program pol ppc lookup_labels lookup_datalabels (\fst pi_newppc) (refl …) (refl …) (refl …) →1387 〈len,assembledi〉 = assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc lookup_datalabels (\fst pi_newppc) → 1394 1388 encoding_check code_memory (sigma program pol ppc) (bitvector_of_nat … (nat_of_bitvector … (sigma program pol ppc) + len)) assembledi ∧ 1395 1389 sigma program pol (\snd pi_newppc) = bitvector_of_nat … (nat_of_bitvector … (sigma program pol ppc) + len). … … 1401 1395 let code_memory ≝ load_code_memory assembled in 1402 1396 let data_labels ≝ construct_datalabels (\fst program) in 1403 let lookup_labels ≝ λx. sigma program pol (address_of_word_labels_code_mem (\snd program) x)in1404 let lookup_datalabels ≝ λx. lookup ? ? x data_labels(zero ?) in1397 let lookup_labels ≝ λx.address_of_word_labels_code_mem (\snd program) x in 1398 let lookup_datalabels ≝ λx. lookup_def ? ? data_labels x (zero ?) in 1405 1399 let 〈pi,newppc〉 ≝ fetch_pseudo_instruction (\snd program) ppc in 1406 let instructions ≝ expand_pseudo_instruction program pol ppc lookup_labels lookup_datalabels (sigma program pol ppc) (refl …) (refl …) (refl …)in1400 let instructions ≝ expand_pseudo_instruction lookup_labels ppc (pol lookup_labels ppc) lookup_datalabels pi in 1407 1401 fetch_many code_memory (sigma program pol newppc) (sigma program pol ppc) instructions. 1408 1402 * #preamble #instr_list #pol #ppc … … 1410 1404 letin code_memory ≝ (load_code_memory assembled) 1411 1405 letin data_labels ≝ (construct_datalabels preamble) 1412 letin lookup_labels ≝ (λx. sigma … pol (address_of_word_labels_code_mem instr_list x))1413 letin lookup_datalabels ≝ (λx. lookup ? ? x data_labels(zero ?))1414 @pair_elim ' #pi #newppc #EQ1 change in EQ1 with (fetch_pseudo_instruction instr_list ? = ?)1415 generalize in match (assembly_ok ? pol assembled (\snd (assembly 〈preamble,instr_list〉 pol))) 1416 @pair_elim '#labels #costs #EQ2 <eq_pair_fst_snd1406 letin lookup_labels ≝ (λx. address_of_word_labels_code_mem instr_list x) 1407 letin lookup_datalabels ≝ (λx. lookup_def ? ? data_labels x (zero ?)) 1408 @pair_elim #pi #newppc #EQ1 change with (fetch_pseudo_instruction instr_list ? = ?) in EQ1; 1409 generalize in match (assembly_ok ? pol assembled (\snd (assembly 〈preamble,instr_list〉 pol))); 1410 @pair_elim #labels #costs #EQ2 <eq_pair_fst_snd 1417 1411 #H cases (H (refl \ldots)) H; #EQ3 1418 generalize in match (refl … (assembly_1_pseudoinstruction … pol ppc lookup_labels lookup_datalabels ? (refl …) (refl …) (refl …))) 1419 cases (assembly_1_pseudoinstruction ?????????) in ⊢ (???% → ?) #len #assembledi #EQ4 1420 #H cases (H ppc len assembledi ?) [2: <EQ4 %] H; #H1 #H2 1421 generalize in match (fetch_assembly_pseudo … pol ppc (load_code_memory assembled)) in ⊢ ? 1422 >EQ4 #H generalize in match (H H1) in ⊢ ? H; >(pair_destruct_2 ????? (sym_eq … EQ1)) 1423 >H2 #K @K 1412 generalize in match (refl … (assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc lookup_datalabels ?)); 1413 [ cases (assembly_1_pseudoinstruction ?????) in ⊢ (???% → ?); #len #assembledi #EQ4 1414 #H cases (H ppc len assembledi ?) [2: <EQ4 %] H; #H1 #H2 1415 (* XXX JPB: attention to lookup_labels *) 1416 generalize in match (fetch_assembly_pseudo 〈preamble,instr_list〉 pol ppc (load_code_memory assembled)) in ⊢ ?; 1417 >EQ4; #H generalize in match (H H1) in ⊢ ?; H >(pair_destruct_2 ????? (sym_eq … EQ1)) 1418 >H2 >EQ1 #K @K 1424 1419 qed. 1425 1420 … … 1707 1702 *) 1708 1703 1709 definition ticks_of0: ∀p:pseudo_assembly_program. policy p → Word → ? → nat × nat ≝1710 λprogram: pseudo_assembly_program.λpol. 1704 definition ticks_of0: ∀p:pseudo_assembly_program. policy p → (Identifier→Word) → Word → ? → nat × nat ≝ 1705 λprogram: pseudo_assembly_program.λpol.λlookup_labels. 1711 1706 λppc: Word. 1712 1707 λfetched. … … 1715 1710 match instr with 1716 1711 [ JC lbl ⇒ 1717 match pol ppc with1712 match pol lookup_labels ppc with 1718 1713 [ short_jump ⇒ 〈2, 2〉 1719 1714  medium_jump ⇒ ? … … 1721 1716 ] 1722 1717  JNC lbl ⇒ 1723 match pol ppc with1718 match pol lookup_labels ppc with 1724 1719 [ short_jump ⇒ 〈2, 2〉 1725 1720  medium_jump ⇒ ? … … 1727 1722 ] 1728 1723  JB bit lbl ⇒ 1729 match pol ppc with1724 match pol lookup_labels ppc with 1730 1725 [ short_jump ⇒ 〈2, 2〉 1731 1726  medium_jump ⇒ ? … … 1733 1728 ] 1734 1729  JNB bit lbl ⇒ 1735 match pol ppc with1730 match pol lookup_labels ppc with 1736 1731 [ short_jump ⇒ 〈2, 2〉 1737 1732  medium_jump ⇒ ? … … 1739 1734 ] 1740 1735  JBC bit lbl ⇒ 1741 match pol ppc with1736 match pol lookup_labels ppc with 1742 1737 [ short_jump ⇒ 〈2, 2〉 1743 1738  medium_jump ⇒ ? … … 1745 1740 ] 1746 1741  JZ lbl ⇒ 1747 match pol ppc with1742 match pol lookup_labels ppc with 1748 1743 [ short_jump ⇒ 〈2, 2〉 1749 1744  medium_jump ⇒ ? … … 1751 1746 ] 1752 1747  JNZ lbl ⇒ 1753 match pol ppc with1748 match pol lookup_labels ppc with 1754 1749 [ short_jump ⇒ 〈2, 2〉 1755 1750  medium_jump ⇒ ? … … 1757 1752 ] 1758 1753  CJNE arg lbl ⇒ 1759 match pol ppc with1754 match pol lookup_labels ppc with 1760 1755 [ short_jump ⇒ 〈2, 2〉 1761 1756  medium_jump ⇒ ? … … 1763 1758 ] 1764 1759  DJNZ arg lbl ⇒ 1765 match pol ppc with1760 match pol lookup_labels ppc with 1766 1761 [ short_jump ⇒ 〈2, 2〉 1767 1762  medium_jump ⇒ ? … … 1862 1857 qed. 1863 1858 1864 definition ticks_of: ∀p:pseudo_assembly_program. policy p → Word → nat × nat ≝1865 λprogram: pseudo_assembly_program.λpol. 1859 definition ticks_of: ∀p:pseudo_assembly_program. policy p → (Identifier→Word) → Word → nat × nat ≝ 1860 λprogram: pseudo_assembly_program.λpol.λlookup_labels. 1866 1861 λppc: Word. 1867 1862 let 〈preamble, pseudo〉 ≝ program in 1868 1863 let 〈fetched, new_ppc〉 ≝ fetch_pseudo_instruction pseudo ppc in 1869 ticks_of0 program pol ppc fetched.1864 ticks_of0 program pol lookup_labels ppc fetched. 1870 1865 1871 1866 lemma eq_rect_Type1_r: … … 1874 1869 ∀P: ∀x:A. eq ? x a → Type[1]. P a (refl A a) → ∀x: A.∀p:eq ? x a. P x p. 1875 1870 #A #a #P #H #x #p 1876 generalize in match H 1877 generalize in match P 1871 generalize in match H; 1872 generalize in match P; 1878 1873 cases p 1879 1874 // … … 2034 2029 2035 2030 theorem main_thm: 2036 ∀M,M',ps,pol .2031 ∀M,M',ps,pol,lookup_labels. 2037 2032 next_internal_pseudo_address_map M ps = Some … M' → 2038 2033 ∃n. 2039 2034 execute n (status_of_pseudo_status M ps pol) 2040 = status_of_pseudo_status M' (execute_1_pseudo_instruction (ticks_of (code_memory … ps) pol ) ps) ?.2035 = status_of_pseudo_status M' (execute_1_pseudo_instruction (ticks_of (code_memory … ps) pol lookup_labels) ps) ?. 2041 2036 [2: >execute_1_pseudo_instruction_preserves_code_memory @pol] 2042 #M #M' #ps #pol # SAFE2037 #M #M' #ps #pol #lookup_labels #SAFE 2043 2038 cut 2044 2039 (∀ps'. 2045 ∀prf:ps'=execute_1_pseudo_instruction (ticks_of (code_memory … ps) pol ) ps.2040 ∀prf:ps'=execute_1_pseudo_instruction (ticks_of (code_memory … ps) pol lookup_labels) ps. 2046 2041 ∃n. execute n (status_of_pseudo_status M ps pol) = status_of_pseudo_status M' ps' ?) 2047 2042 [ >prf >execute_1_pseudo_instruction_preserves_code_memory @pol 3: #K @(K ? (refl …))] 2048 2043 #ps' #EQ 2049 whd in ⊢ (??(λ_.??(??%)?)) 2044 whd in ⊢ (??(λ_.??(??%)?)); 2050 2045 change with 2051 2046 (∃n. … … 2062 2057 (set_program_counter ? 2063 2058 (set_code_memory ?? ? (load_code_memory ?)) 2064 (sigma ???)) ?) ?) 2065 >EQ whd in match eq_rect_Type0_r normalize nodelta2059 (sigma ???)) ?) ?); 2060 >EQ whd in match eq_rect_Type0_r; normalize nodelta 2066 2061 >execute_1_pseudo_instruction_preserves_code_memory normalize nodelta 2067 generalize in match EQ EQ;2068 generalize in match (refl … (code_memory pseudo_assembly_program ps)) 2069 generalize in match pol pol; generalize in ⊢ (∀_.??%? → ?)2070 * #preamble #instr_list #pol #EQ1 generalize in match pol pol <EQ1 #pol #EQps' <EQps'2062 generalize in match EQ; EQ; 2063 generalize in match (refl … (code_memory pseudo_assembly_program ps)); 2064 generalize in match pol; pol; generalize in ⊢ (∀_.??%? → ?); 2065 * #preamble #instr_list #pol #EQ1 generalize in match pol; pol <EQ1 #pol #EQps' <EQps' 2071 2066 (* Dependent types madness ends here *) 2072 2067 letin ppc ≝ (program_counter … ps) 2073 generalize in match (fetch_assembly_pseudo2 ? pol ppc) in ⊢ ? 2068 generalize in match (fetch_assembly_pseudo2 ? pol ppc) in ⊢ ?; 2074 2069 letin assembled ≝ (\fst (assembly ? pol)) 2075 letin lookup_labels ≝ (λx. sigma ? pol(address_of_word_labels_code_mem instr_list x))2076 letin lookup_datalabels ≝ (λx. lookup … x (construct_datalabels preamble)(zero 16))2077 @pair_elim '#pi #newppc #EQ22070 letin lookup_labels ≝ (λx.(address_of_word_labels_code_mem instr_list x)) 2071 letin lookup_datalabels ≝ (λx. lookup_def … (construct_datalabels preamble) x (zero 16)) 2072 @pair_elim #pi #newppc #EQ2 2078 2073 letin instructions ≝ 2079 (expand_pseudo_instruction ? pol ppc lookup_labelslookup_datalabels2080 (sigma ? pol ppc) (refl …) (refl …) (refl …))2081 change with (fetch_many ???? → ?) #H12082 change in EQ2 with (fetch_pseudo_instruction instr_list ppc = ?)2083 change in SAFE with (next_internal_pseudo_address_map0 ???? = ?)<EQ1 in SAFE;2084 >EQ2 whd in ⊢ (??(??%??)? → ?) #SAFE2074 (expand_pseudo_instruction lookup_labels ppc ((pi1 ?? pol) lookup_labels ppc) lookup_datalabels 2075 pi) 2076 change with (fetch_many ???? → ?); #H1 2077 change with (fetch_pseudo_instruction instr_list ppc = ?) in EQ2; 2078 change with (next_internal_pseudo_address_map0 ???? = ?) in SAFE; <EQ1 in SAFE; 2079 >EQ2 whd in ⊢ (??(??%??)? → ?); #SAFE 2085 2080 whd in EQps':(???%); <EQ1 in EQps'; >EQ2 normalize nodelta 2086 generalize in match H1; H1; generalize in match instructions instructions2087 * #instructions >EQ2 change in match (\fst 〈pi,newppc〉) with pi2088 whd in match ticks_of normalize nodelta <EQ1 >EQ22089 cases pi in SAFE 2090 [2,3: (* Comment, Cost *) #ARG whd in ⊢ (??%? → ???% → ?) 2081 generalize in match H1; H1; generalize in match instructions; instructions 2082 * #instructions >EQ2 change with pi in match (\fst 〈pi,newppc〉); 2083 whd in match ticks_of; normalize nodelta <EQ1 >EQ2 2084 cases pi in SAFE; 2085 [2,3: (* Comment, Cost *) #ARG whd in ⊢ (??%? → ???% → ?); 2091 2086 @Some_Some_elim #MAP #EQ3 @(Some_Some_elim ????? EQ3) #EQ3' 2092 2087 whd in match eject normalize nodelta >EQ3' in ⊢ (% → ?) whd in ⊢ (% → ?)
Note: See TracChangeset
for help on using the changeset viewer.