Changeset 1649 for src/ASM/Assembly.ma
 Timestamp:
 Jan 18, 2012, 6:17:37 PM (8 years ago)
 File:

 1 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
Note: See TracChangeset
for help on using the changeset viewer.