Ignore:
Timestamp:
Feb 21, 2013, 11:38:36 AM (7 years ago)
Author:
campbell
Message:

Progress on measurable trace preservation: prefix preserves observable
intensional events (costs and calls).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/common/FEMeasurable.ma

    r2678 r2685  
    33include "common/Measurable.ma".
    44
    5 definition normal_state : ∀C:preclassified_system. ∀g. state … C g → bool ≝
     5definition pnormal_state : ∀C:preclassified_system. ∀g. state … C g → bool ≝
    66λC,g,s. match pcs_classify C g s with [ cl_other ⇒ true | cl_jump ⇒ true | _ ⇒ false ].
    77
    8 lemma normal_state_inv : ∀C,g,s.
    9   normal_state C g s →
     8lemma pnormal_state_inv : ∀C,g,s.
     9  pnormal_state C g s →
    1010  pcs_classify C g s = cl_other ∨ pcs_classify C g s = cl_jump.
    1111#C #g #s whd in ⊢ (?% → ?); cases (pcs_classify C g s) /2/ *
     12qed.
     13
     14lemma normal_state_p : ∀C,g,s.
     15  pnormal_state C g s = normal_state (pcs_to_cs C g) s.
     16//
    1217qed.
    1318
     
    2631  ms_stack : ∀g1,g2. ms_inv g1 g2 → (ident → nat);
    2732  ms_rel : ∀g1,g2. ∀INV:ms_inv g1 g2. state … ms_C1 g1 → state … ms_C2 g2 → Prop;
    28   ms_rel_normal : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → bool_to_Prop (normal_state ms_C1 g1 s1) ↔ bool_to_Prop (normal_state ms_C2 g2 s2);
    29   ms_rel_labelled : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → bool_to_Prop (pcs_labelled ms_C1 g1 s1) ↔ bool_to_Prop (pcs_labelled ms_C2 g2 s2);
     33  ms_rel_normal : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → pnormal_state ms_C1 g1 s1 = pnormal_state ms_C2 g2 s2;
     34  ms_rel_labelled : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → pcs_labelled ms_C1 g1 s1 = pcs_labelled ms_C2 g2 s2;
     35  ms_rel_classify : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → pcs_classify ms_C1 g1 s1 = pcs_classify ms_C2 g2 s2;
     36  ms_rel_callee : ∀g1,g2,INV,s1,s2. ms_rel g1 g2 INV s1 s2 → ∀H,H'. pcs_callee ms_C1 g1 s1 H = pcs_callee ms_C2 g2 s2 H';
    3037
    3138  (* These hold in (at least) the languages of interest for measurable subtraces *)
    32   ms_labelled_normal_1 : ∀g1,s1. bool_to_Prop (pcs_labelled ms_C1 g1 s1) ↔ bool_to_Prop (normal_state ms_C1 g1 s1);
    33   ms_labelled_normal_2 : ∀g2,s2. bool_to_Prop (pcs_labelled ms_C2 g2 s2) ↔ bool_to_Prop (normal_state ms_C2 g2 s2);
     39  ms_labelled_normal_1 : ∀g1,s1. pcs_labelled ms_C1 g1 s1 → pnormal_state ms_C1 g1 s1;
     40  ms_labelled_normal_2 : ∀g2,s2. pcs_labelled ms_C2 g2 s2 → pnormal_state ms_C2 g2 s2;
    3441  ms_notailcalls : ∀g1,s1. pcs_classify ms_C1 g1 s1 ≠ cl_tailcall;
    3542
     
    4451    ∀s1,s1'.
    4552    ms_rel g1 g2 INV s1 s1' →
    46     normal_state ms_C1 g1 s1 →
     53    pnormal_state ms_C1 g1 s1 →
    4754    ¬ pcs_labelled ms_C1 g1 s1 →
    4855    ∀s2,tr. step … (pcs_exec ms_C1) g1 s1 = Value … 〈tr,s2〉 →
    49     ∃m. after_n_steps m … (pcs_exec ms_C2) g2 s1' (λs.normal_state ms_C2 g2 s) (λtr',s2'.
     56    ∃m. after_n_steps m … (pcs_exec ms_C2) g2 s1' (λs.pnormal_state ms_C2 g2 s) (λtr',s2'.
    5057      tr = tr' ∧
    5158      ms_rel g1 g2 INV s2 s2' ∧
     
    6067    ¬ pcs_labelled ms_C1 g1 s1 →
    6168    ∀s2,tr. step … (pcs_exec ms_C1) g1 s1 = Value … 〈tr,s2〉 →
    62     ∃m. after_n_steps (S m) … (pcs_exec ms_C2) g2 s1' (λs.normal_state ms_C2 g2 s) (λtr',s2'.
     69    ∃m. after_n_steps (S m) … (pcs_exec ms_C2) g2 s1' (λs.pnormal_state ms_C2 g2 s) (λtr',s2'.
    6370      tr = tr' ∧
    6471      ms_rel g1 g2 INV s2 s2'
     
    8491
    8592(* TODO: obs eq *)
    86 
     93(*
    8794lemma stack_normal_step : ∀C:preclassified_system. ∀g,s1,trace,s2,stack,current.
    8895  exec_steps 1 io_out io_in C g s1 = OK ? 〈trace,s2〉 →
    89   normal_state C g s1 →
     96  pnormal_state C g s1 →
    9097  stack_after (pcs_to_cs C g stack) current trace = current.
    9198#C #g #s1 #trace #s2 #stack #current #EXEC
     
    95102whd in ⊢ (??%?); generalize in match (cs_stack ??);
    96103whd in match (cs_classify ??);
    97 cases (normal_state_inv … N)
     104cases (pnormal_state_inv … N)
    98105#CL >CL #f %
    99106qed.
     
    101108lemma max_stack_normal_step : ∀C:preclassified_system. ∀g,s1,trace,s2,stack,current.
    102109  exec_steps 1 io_out io_in C g s1 = OK ? 〈trace,s2〉 →
    103   normal_state C g s1 →
     110  pnormal_state C g s1 →
    104111  max_stack (pcs_to_cs C g stack) current trace = current.
    105112#C #g #s1 #trace #s2 #stack #current #EXEC
     
    109116whd in ⊢ (??%?); generalize in match (cs_stack ??);
    110117whd in match (cs_classify ??);
    111 cases (normal_state_inv … N)
     118cases (pnormal_state_inv … N)
    112119#CL >CL #f %
    113120qed.
     
    161168 cases (inv s2) // * ]| // ]
    162169qed.
    163 
     170*)
    164171(* XXX do I need to do the max_stack reasoning here?  perhaps just by preserving
    165172   observables? *)
    166173
     174lemma exec_steps_1_trace : ∀O,I,fx,g,s,trace,s'.
     175  exec_steps 1 O I fx g s = OK ? 〈trace,s'〉 →
     176  ∃tr. trace = [〈s,tr〉].
     177#O #I #fx #g #s #trace #s' #EXEC
     178cases (exec_steps_S … EXEC)
     179#nf * #tr * #s'' * #tl * * #E1 #STEP #EXEC' whd in EXEC':(??%%); destruct
     180%{tr} %
     181qed.
     182
     183lemma all_1 : ∀A.∀P:A → bool.∀x.
     184  P x = all A P [x].
     185#A #P #x whd in ⊢ (???%); cases (P x) //
     186qed.
    167187
    168188(* WIP commented out*)
     
    171191  ∀g,g'.
    172192  ∀INV:ms_inv MS g g'.
    173   ∀max_allowed_stack.
    174193  ∀s1,s1'.
    175194  ms_rel MS g g' INV s1 s1' →
     
    178197  exec_steps m … (pcs_exec … (ms_C1 MS)) g s1 = OK ? 〈prefix,sf〉 →
    179198  pcs_labelled (ms_C1 MS) g sf →
    180   le (max_stack (pcs_to_cs (ms_C1 MS) ? (ms_stack MS … INV)) 0 prefix) max_allowed_stack →
    181199
    182200  ∃m',prefix',sf'.
    183201    exec_steps m' … (pcs_exec … (ms_C2 MS)) g' s1' = OK ? 〈prefix',sf'〉 ∧
    184     le (max_stack (pcs_to_cs (ms_C2 MS) ? (ms_stack MS … INV)) 0 prefix') max_allowed_stack ∧
    185  
     202
     203    intensional_trace_of_trace (pcs_to_cs (ms_C1 MS) g) [ ] prefix = intensional_trace_of_trace (pcs_to_cs (ms_C2 MS) g') [ ] prefix' ∧
    186204    ms_rel MS g g' INV sf sf'.
    187 * #C1 #C2 #compiled #inv #stack #rel #rel_normal #rel_labelled #labelled_normal1 #labelled_normal2 #no_tailcalls #measure1 #sim_normal #sim_call_return #sim_cost #sim_init
    188 #g #g' #INV #max #s1 #s1' #REL
     205* #C1 #C2 #compiled #inv #stack #rel #rel_normal #rel_labelled #rel_classify #rel_callee #labelled_normal1 #labelled_normal2 #no_tailcalls #measure1 #sim_normal #sim_call_return #sim_cost #sim_init
     206#g #g' #INV #s1 #s1' #REL
    189207#m0 generalize in match s1' in REL ⊢ %; generalize in match s1; -s1 -s1'
    190 generalize in match 0; (* current stack level *)
     208generalize in match [ ]; (* current call stack *)
    191209elim m0
    192210[ #current_stack #s1 #s1' #REL #prefix #sf #EXEC whd in EXEC:(??%?); destruct #CSf
    193   #max_ok %{0} %{[]} %{s1'}
     211  %{0} %{[]} %{s1'}
    194212  % [ % // | // ]
    195 | #m #IH #current_stack #s1 #s1' #REL #prefix #sf #EXEC #CSf #MAX_OK
     213| #m #IH #current_stack #s1 #s1' #REL #prefix #sf #EXEC #CSf
    196214  cases (exec_steps_S … EXEC) #NF1 * #tr1 * #s2 * #trace2 * * #E1 #STEP1 #EXEC2
    197215  cases (true_or_false_Prop … (pcs_labelled … s1))
     
    200218    #AFTER1'
    201219    cases (after_n_exec_steps … AFTER1')
    202     #prefix' * #s2' * #EXEC1' * #Etrace #R2
    203     cut (normal_state C1 g s1) [ @(proj1 … (labelled_normal1 …)) assumption ] #N1
    204     cut (normal_state C2 g' s1') [ @(proj1 … (labelled_normal2 …)) @(proj1 … (rel_labelled … REL)) assumption ] #N1'
    205     cases (IH (stack_after (pcs_to_cs C2 … (stack … INV)) current_stack prefix') … R2 … EXEC2 CSf ?)
    206     [ 2: @(transitive_le … MAX_OK) >E1 cases daemon (* <max_stack_append
    207       >(stack_normal_step … EXEC1 N1)
    208       >(stack_normal_step … EXEC1' N1')
    209       @max_r //*)
    210     ]
    211     #m'' * #prefix'' * #sf'' * * #EXEC'' #MAX'' #R''
     220    #prefix' * #s2' * * #EXEC1' #_ * #Etrace #R2
     221    cut (pnormal_state C1 g s1) [ @labelled_normal1 assumption ] #N1
     222    cut (pnormal_state C2 g' s1') [ @labelled_normal2 <(rel_labelled … REL) assumption ] #N1'
     223    cases (IH current_stack … R2 … EXEC2 CSf)
     224    #m'' * #prefix'' * #sf'' * * #EXEC'' #OBS'' #R''
    212225    %{(1+m'')} %{(prefix'@prefix'')} %{sf''}
    213226    % [ % [ @(exec_steps_join … EXEC1') @EXEC''
    214       | <max_stack_append @to_max
    215         [ >(max_stack_normal_step … EXEC1' N1')
    216           lapply MAX_OK >E1 cases daemon (* <max_stack_append
    217           >(max_stack_normal_step … EXEC1 N1)
    218           #H /2 by le_maxl/*)
    219         | @MAX'' ] ]
    220       | @R''
     227      | destruct @(build_eq_trace (pcs_to_cs C1 g) (pcs_to_cs C2 g')) //
     228        cases (exec_steps_1_trace … EXEC1') #tr1' #E destruct
     229        <all_1 assumption
     230      ]| assumption
    221231      ]
    222232 
    223233  | #NCS
    224     cases (true_or_false_Prop (normal_state C1 g s1))
     234    cases (true_or_false_Prop (pnormal_state C1 g s1))
    225235    [ #NORMAL
    226236      (* XXX should set things up so that notb_Prop isn't needed *)
    227237      cases (sim_normal … REL NORMAL (notb_Prop … NCS) … STEP1)
    228238      #n' #AFTER1'
    229       cases (after_n_exec_steps … AFTER1') #prefix' * #s2' * #EXEC1' * * #Etrace #R2 #_ (* measure *)
    230       cases (IH (stack_after (pcs_to_cs C2 … (stack … INV)) current_stack prefix') … R2 … EXEC2 CSf ?)
    231       [ 2: cases daemon ] (* XXX *)
    232       #m'' * #prefix'' * #sf'' * * #EXEC'' #MAX'' #R''
     239      cases (after_n_exec_steps … AFTER1') #prefix' * #s2' * * #EXEC1' #INV * * #Etrace #R2 #_ (* measure *)
     240      cases (IH current_stack … R2 … EXEC2 CSf)
     241      #m'' * #prefix'' * #sf'' * * #EXEC'' #OBS'' #R''
    233242      %{(n'+m'')} %{(prefix'@prefix'')} %{sf''}
    234243      % [ % [ @(exec_steps_join … EXEC1') @EXEC''
    235         | <max_stack_append @to_max
    236           [ cases daemon (* XXX >(max_stack_normal_step … EXEC1' N1')
    237             lapply MAX_OK >E1 <max_stack_append
    238             >(max_stack_normal_step … EXEC1 N1)
    239             #H /2 by le_maxl/*)
    240           | @MAX'' ] ]
     244        | destruct @(build_eq_trace (pcs_to_cs C1 g) (pcs_to_cs C2 g'))
     245          [ assumption
     246          | cases prefix' in EXEC1' INV ⊢ %;
     247            [ //
     248            | * #sx #trx #tl #EXEC1' #INV
     249              <(exec_steps_first … EXEC1')
     250              whd in ⊢ (?%); <normal_state_p <(rel_normal … REL) >NORMAL
     251              @INV
     252            ]
     253          | @OBS'' ] ]
    241254        | @R''
    242255        ]
    243256    | #CALLRET
    244       cases (sim_call_return … REL … (notb_Prop … NCS) … STEP1)
    245       [ 2: whd in CALLRET:(?%); whd in match (normal_state ???) in CALLRET;
     257      cut (pcs_classify C1 g s1 = cl_call ∨ pcs_classify C1 g s1 = cl_return)
     258      [ whd in CALLRET:(?%); whd in match (pnormal_state ???) in CALLRET;
    246259        lapply (no_tailcalls … s1)
    247260        cases (pcs_classify … s1) in CALLRET ⊢ %;
    248         normalize * #H #H' try % try cases (H I)
    249         cases H' /2/ ]
     261        [ 1,3: #_ #_ /2/
     262        | *: normalize * #H #H' try cases (H I) cases H' #H'' cases (H'' (refl ??))
     263        ]
     264      ] * #CL
     265      cases (sim_call_return … REL … (notb_Prop … NCS) … STEP1)
     266      [2,4: >CL %]
    250267      #m' #AFTER1'
    251       cases (after_n_exec_steps … AFTER1') #prefix' * #s2' * #EXEC1' * #Etrace #R2
    252       cases (IH (stack_after (pcs_to_cs C2 … (stack … INV)) current_stack prefix') … R2 … EXEC2 CSf ?)
    253       [ 2: cases daemon ] (* XXX *)
    254       #m'' * #prefix'' * #sf'' * * #EXEC'' #MAX'' #R''
     268      cases (after_n_exec_steps … AFTER1') #prefix' * #s2' * * #EXEC1' #INV * #Etrace #R2
     269      [ letin next_stack ≝ ((pcs_callee C1 g s1 ?)::current_stack) [2: >CL %]
     270      | letin next_stack ≝ (tail … current_stack)
     271      ]
     272      cases (IH next_stack … R2 … EXEC2 CSf)
     273      #m'' * #prefix'' * #sf'' * * #EXEC'' #OBS'' #R''
    255274      %{(S m' + m'')} %{(prefix'@prefix'')} %{sf''}
    256       % [ % [ @(exec_steps_join … EXEC1') @EXEC''
    257         | <max_stack_append @to_max
    258           [ cases daemon (* XXX >(max_stack_normal_step … EXEC1' N1')
    259             lapply MAX_OK >E1 <max_stack_append
    260             >(max_stack_normal_step … EXEC1 N1)
    261             #H /2 by le_maxl/*)
    262           | @MAX'' ] ]
    263         | @R''
     275      % [1,3: % [1,3: @(exec_steps_join … EXEC1') @EXEC''
     276        | destruct cases (exec_steps_S … EXEC1')
     277          #NF1' * #tr1' * #s2' * #prefix2 * * #E #STEP1' #EXEC2'
     278          destruct
     279          @(build_call_trace (pcs_to_cs C1 g) (pcs_to_cs C2 g'))
     280          [1,3: whd in match (cs_classify ??); >CL %
     281          |2,4: whd in match (cs_classify ??); <(rel_classify … REL) >CL %
     282          | @INV
     283          | assumption
     284          | @(rel_callee … REL)
     285          ]
     286        | destruct cases (exec_steps_S … EXEC1')
     287          #NF1' * #tr1' * #s2' * #prefix2 * * #E #STEP1' #EXEC2'
     288          destruct
     289          @(build_return_trace (pcs_to_cs C1 g) (pcs_to_cs C2 g'))
     290          [ whd in match (cs_classify ??); >CL %
     291          | whd in match (cs_classify ??); <(rel_classify … REL) >CL %
     292          | @INV
     293          | assumption
     294          ]
    264295        ]
     296      | 2,4: @R''
     297      ]
    265298    ]
    266299  ]
    267 qed.
     300] qed.
    268301       
    269302     
Note: See TracChangeset for help on using the changeset viewer.