Changeset 1649 for src/ASM/Assembly.ma


Ignore:
Timestamp:
Jan 18, 2012, 6:17:37 PM (8 years ago)
Author:
boender
Message:
  • changes to Assembly for integration with Policy and easier use of _safe functions (with CSC)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ASM/Assembly.ma

    r1615 r1649  
    1414  | medium_jump: jump_length
    1515  | long_jump: jump_length.
    16 
    17 definition policy_type ≝ Word → jump_length.
    1816
    1917definition assembly_preinstruction ≝
     
    420418qed.
    421419
    422 definition expand_relative_jump_internal:
    423  (Identifier → Word) → jump_length → Identifier → Word → ([[relative]] → preinstruction [[relative]]) →
     420definition expand_relative_jump_internal_safe:
     421 Word → jump_length → Word → ([[relative]] → preinstruction [[relative]]) →
    424422 option (list instruction)
    425423 ≝
    426   λlookup_labels,jmp_len.λjmp:Identifier.λpc,i.
     424  λlookup_address,jmp_len.λpc,i.
    427425  match jmp_len with
    428426  [ short_jump ⇒
    429      let lookup_address ≝ lookup_labels jmp in
    430427     let 〈result, flags〉 ≝ sub_16_with_carry pc lookup_address false in
    431428     let 〈upper, lower〉 ≝ split ? 8 8 result in
     
    440437    [ RealInstruction (i (RELATIVE (bitvector_of_nat ? 2)));
    441438      SJMP (RELATIVE (bitvector_of_nat ? 3)); (* LJMP size? *)
    442       LJMP (ADDR16 (lookup_labels jmp))
     439      LJMP (ADDR16 lookup_address)
    443440    ]
    444441  ].
     
    446443qed.
    447444
    448 definition expand_relative_jump: (Identifier → Word) → jump_length → Word → preinstruction Identifier → option (list instruction) ≝
     445definition 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
     452lemma eject_rel_jump_length: ∀x,y. rel_jump_length_ok x y → jump_length.
     453 #x #y #p @(pi1 … p)
     454qed.
     455
     456coercion 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
     460definition 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/
     471qed.
     472
     473definition expand_relative_jump_safe: ∀lookup_labels:Identifier → Word.Word → jump_length → preinstruction Identifier → option (list instruction) ≝
    449474  λlookup_labels.
     475  λpc: Word.
    450476  λjmp_len: jump_length.
    451   λpc.
    452477  λi: preinstruction Identifier.
    453478  let rel_jmp ≝ RELATIVE (bitvector_of_nat ? 2) in
    454479  match i with
    455   [ JC jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JC ?)
    456   | JNC jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JNC ?)
    457   | JB baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JB ? baddr)
    458   | JZ jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JZ ?)
    459   | JNZ jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JNZ ?)
    460   | JBC baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JBC ? baddr)
    461   | JNB baddr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (JNB ? baddr)
    462   | CJNE addr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (CJNE ? addr)
    463   | DJNZ addr jmp ⇒ expand_relative_jump_internal lookup_labels jmp_len jmp pc (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 ?) ]
    492517  ].
    493518
    494 
    495 definition expand_pseudo_instruction_safe: ? → ? → Word → jump_length → pseudo_instruction → option (list instruction) ≝
     519definition expand_pseudo_instruction_safe:
     520 ∀lookup_labels,pc. jump_length → ? → pseudo_instruction → option (list instruction) ≝
    496521  λlookup_labels.
    497   λlookup_datalabels.
    498522  λpc.
    499523  λjmp_len.
     524  λlookup_datalabels.
    500525  λi.
    501526  match i with
     
    520545    let address ≝ DATA16 (lookup_datalabels trgt) in
    521546      Some ? [ RealInstruction (MOV ? (inl ? ? (inl ? ? (inr ? ? 〈DPTR, address〉))))]
    522   | Instruction instr ⇒ expand_relative_jump lookup_labels jmp_len pc instr
     547  | Instruction instr ⇒ expand_relative_jump_safe lookup_labels pc jmp_len instr
    523548  | Jmp jmp ⇒
    524549    match jmp_len with
    525550    [ 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
    528552      let 〈upper, lower〉 ≝ split ? 8 8 result in
    529553      if eq_bv ? upper (zero 8) then
     
    533557        None ?
    534558    | 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
    537560      let 〈fst_5_pc, rest_pc〉 ≝ split ? 5 11 pc in
    538561      if eq_bv ? fst_5_addr fst_5_pc then
     
    542565        None ?
    543566    | long_jump ⇒
    544       let address ≝ ADDR16 (lookup_labels jmp) in
     567        let address ≝ ADDR16 (lookup_labels jmp) in
    545568        Some ? [ LJMP address ]
    546569    ]
     
    549572qed.
    550573
    551 
    552 definition assembly_1_pseudoinstruction_safe ≝
    553   λprogram: pseudo_assembly_program.
    554   λjump_expansion: policy_type.
    555   λppc: Word.
     574definition 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
     581lemma eject_jump_length: ∀x,y. jump_length_ok x y → jump_length.
     582 #x #y #p @(pi1 … p)
     583qed.
     584
     585coercion 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
     589definition 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/
     599qed.
     600
     601definition policy_type ≝
     602 λlookup_labels:Identifier → Word.
     603 ∀pc:Word. jump_length_ok lookup_labels pc.
     604
     605definition policy_type2 ≝
     606 ∀lookup_labels.policy_type lookup_labels.
     607 
     608definition assembly_1_pseudoinstruction ≝
     609  λlookup_labels.
     610  λjump_expansion: policy_type lookup_labels.
     611  (*λppc: Word.*)
    556612  λpc: Word.
    557   λlookup_labels.
    558613  λlookup_datalabels.
    559614  λ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〉.
    569621 
    570 definition construct_costs_safe
    571   λprogram.
    572   λjump_expansion: policy_type.
     622definition construct_costs
     623  λprogram_counter: nat.
     624  λjump_expansion: policy_type (λx.bitvector_of_nat ? program_counter).
    573625  λpseudo_program_counter: nat.
    574   λprogram_counter: nat.
    575626  λcosts: BitVectorTrie costlabel 16.
    576627  λi.
     
    578629  [ Cost cost ⇒
    579630    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)〉
    581632  | _ ⇒
    582633    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*)
    585635    let lookup_datalabels ≝ λx.zero ? in
    586636    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〉
    596641  ].
    597642
     
    599644   program counters. It is at the heart of the proof. *)
    600645(*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?*)
     649definition sigma00: policy_type2 → list ? → ? → (nat × (nat × (BitVectorTrie Word 16))) ≝
     650 λjump_expansion: policy_type2.
    604651 λl:list labelled_instruction.
    605652 λacc.
    606653  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
     662definition sigma0: pseudo_assembly_program → policy_type2 → (nat × (nat × (BitVectorTrie Word 16))) ≝
    622663  λprog.
    623664  λ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
     667definition tech_pc_sigma00: pseudo_assembly_program → policy_type2 →
     668 list labelled_instruction → (nat × nat) ≝
    627669 λ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
     674definition sigma_safe: pseudo_assembly_program → policy_type2 →
     675 option (Word → Word) ≝
    636676 λ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 …)).
    646683
    647684(* stuff about policy *)
     
    649686definition policy_ok ≝ λjump_expansion,p. sigma_safe p jump_expansion ≠ None ….
    650687
    651 definition policy ≝ λp. Σjump_expansion:policy_type. policy_ok jump_expansion p.
    652 
    653 lemma eject_policy: ∀p. policy p → policy_type.
     688definition policy ≝ λp. Σjump_expansion:policy_type2. policy_ok jump_expansion p.
     689
     690lemma eject_policy: ∀p. policy p → policy_type2.
    654691 #p #pol @(pi1 … pol)
    655692qed.
    656693
    657 coercion eject_policy nocomposites: ∀p.∀pol:policy p. policy_type ≝ eject_policy on _pol:(policy ?) to policy_type.
     694coercion eject_policy nocomposites: ∀p.∀pol:policy p. policy_type2 ≝ eject_policy on _pol:(policy ?) to policy_type2.
    658695
    659696definition sigma: ∀p:pseudo_assembly_program. policy p → Word → Word ≝
     
    675712
    676713lemma sigma00_append:
    677  ∀instr_list,jump_expansion,l1,l2,acc.
    678   sigma00 instr_list jump_expansion (l1@l2) acc =
    679    sigma00 instr_list jump_expansion
    680     l2 (sigma00 instr_list jump_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).
    681718 whd in match sigma00; normalize nodelta;
    682  #instr_list #jump_expansion #l1 #l2 #acc @foldl_append
    683 qed.
    684 
    685 lemma sigma00_strict:
    686  ∀instr_list,jump_expansion,l,acc. acc = None ? →
    687   sigma00 instr_list jump_expansion l acc = None ….
    688  #instr_list #jump_expansion #l elim l
     719 #jump_expansion #l1 #l2 #acc @foldl_append
     720qed.
     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
    689726  [ #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 % ]
    691728qed.
    692729
     
    702739  [2: #x #_ % #abs destruct(abs)
    703740  | * #abs @⊥ @abs >sigma00_strict % ]
    704 qed.
     741qed. 
    705742
    706743lemma policy_ok_prefix_hd_ok:
     
    720757 cases (construct_costs_safe ??????) normalize
    721758  [* #abs @⊥ @abs % | #X #_ % #abs destruct(abs)]
    722 qed.
    723 
     759qed. *)
     760
     761(* JPB,CSC: this definition is now replaced by the expand_pseudo_instruction higher up
    724762definition expand_pseudo_instruction:
    725763 ∀program:pseudo_assembly_program.∀pol: policy program.
     
    729767  let pi ≝ \fst (fetch_pseudo_instruction (\snd program) ppc) in
    730768  pc = sigma program pol ppc →
    731   Σres:list instruction. Some … res = expand_pseudo_instruction_safe lookup_labels lookup_datalabels pc (pol ppc) pi
     769  Σres:list instruction. Some … res = expand_pseudo_instruction_safe pc (lookup_labels pi) lookup_datalabels (pol ppc) pi
    732770≝ λprogram,pol,ppc,lookup_labels,lookup_datalabels,pc,prf1,prf2,prf3.
    733771   match expand_pseudo_instruction_safe lookup_labels lookup_datalabels pc (pol ppc) (\fst (fetch_pseudo_instruction (\snd program) ppc)) with
     
    753791   per concludere construct_costs_safe ≠ None *)
    754792 | >p %]
    755 qed.
     793qed. *)
    756794
    757795(* MAIN AXIOM HERE, HIDDEN USING cases daemon *)
    758 definition assembly_1_pseudoinstruction':
     796(* definition assembly_1_pseudoinstruction':
    759797 ∀program:pseudo_assembly_program.∀pol: policy program.
    760798  ∀ppc:Word.∀lookup_labels,lookup_datalabels,pi.
     
    763801  \fst (fetch_pseudo_instruction (\snd program) ppc) = pi →
    764802  Σres:(nat × (list Byte)).
    765    Some … res = assembly_1_pseudoinstruction_safe program 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 ∧
    766804   let 〈len,code〉 ≝ res in
    767805    sigma program pol (\snd (half_add ? ppc (bitvector_of_nat ? 1))) =
     
    774812  λpi.
    775813  λ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.
    779815 [ @⊥ elim pi in p; [*]
    780816   try (#ARG1 #ARG2 #ARG3 #abs) try (#ARG1 #ARG2 #abs) try (#ARG1 #abs) try #abs
     
    787823   (* THIS SHOULD BE TRUE INSTEAD *)
    788824   cases daemon]
    789 qed.
     825qed. 
    790826
    791827definition assembly_1_pseudoinstruction:
     
    811847 cases (pi2 … (assembly_1_pseudoinstruction' program pol ppc lookup_labels lookup_datalabels pi prf1 prf2 prf3))
    812848 #H1 #_ @H1
    813 qed.
     849qed. *)
    814850
    815851(* MAIN AXIOM HERE, HIDDEN USING cases daemon *)
    816 definition construct_costs':
     852(* definition construct_costs':
    817853 ∀program. ∀pol:policy program. ∀ppc,pc,costs,i.
    818854  Σres:(nat × (BitVectorTrie costlabel 16)). Some … res = construct_costs_safe program pol ppc pc costs i
     
    827863
    828864definition 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). *)
    830866
    831867(*
     
    902938*)
    903939
    904 axiom construct_costs_sigma:
     940(* axiom construct_costs_sigma:
    905941 ∀p.∀pol:policy p.∀ppc,pc,costs,i.
    906942  bitvector_of_nat ? pc = sigma p pol (bitvector_of_nat ? ppc) →
     
    910946 ∀program.∀pol:policy program.∀prefix,costs,label,i,ppc,pc.
    911947  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)〉. *)
    913949
    914950axiom eq_identifier_eq:
     
    941977              And (bitvector_of_nat ? pc' = sigma pseudo_program pol (bitvector_of_nat ? ppc')) (*∧*)
    942978                (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'〉)) (*∧*)
    944980                (∀id. occurs_exactly_once id pre →
    945981                  lookup_def … labels id (zero …) = sigma pseudo_program pol (address_of_word_labels_code_mem pre id)))
     
    958994            ]
    959995          in
    960             let construct ≝ construct_costs pseudo_program pol ppc pc costs i' in
     996            let construct ≝ construct_costs pc (pol (λx.bitvector_of_nat ? pc)) ppc costs i' in
    961997              〈labels, 〈S ppc,construct〉〉) 〈empty_map …, 〈0, 〈0, Stub ? ?〉〉〉
    962998    in
     
    9651001      let 〈pc, costs〉 ≝ pc_costs in
    9661002        〈labels, costs〉.
    967  [2: whd generalize in match (pi2 … t); >p >p1 >p2 >p3 * * * #IHn1 #IH0 #IH1 #IH2
     1003(* [2: whd generalize in match (pi2 … t); >p >p1 >p2 >p3 * * * #IHn1 #IH0 #IH1 #IH2
    9681004   generalize in match (refl … construct); cases construct in ⊢ (???% → %); #PC #CODE #JMEQ % [% [%]]
    9691005   [ <(construct_costs_sigma … costs i1 IHn1) change with (? = ?(\fst construct)) >JMEQ %
     
    9831019 | generalize in match (pi2 … result) in ⊢ ?;
    9841020   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
    9861023qed.
    9871024
     
    10031040          let 〈pi,newppc〉 ≝ fetch_pseudo_instruction instr_list ppc' in
    10041041          let 〈len,assembledi〉 ≝
    1005            assembly_1_pseudoinstruction 〈preamble,instr_list〉 pol ppc' lookup_labels lookup_datalabels pi ??? in
     1042           assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc' lookup_datalabels pi in
    10061043           True)
    10071044      instr_list
     
    10091046        let 〈pc, ppc_code〉 ≝ pc_ppc_code in
    10101047        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) ??? in
     1048        let 〈pc_delta, program〉 ≝ assembly_1_pseudoinstruction lookup_labels (pol lookup_labels) ppc lookup_datalabels (\snd hd) in
    10121049        let 〈new_pc, flags〉 ≝ add_16_with_carry pc (bitvector_of_nat ? pc_delta) false in
    10131050        let new_ppc ≝ \snd (half_add ? ppc (bitvector_of_nat ? 1)) in
     
    10161053    in
    10171054     〈\snd (\snd result), costs〉.
    1018  [2,5: %
    1019  |*: cases daemon ]
     1055 cases daemon
    10201056qed.
    10211057
Note: See TracChangeset for help on using the changeset viewer.