:
 !x y xs. v_rel x y /\ flatSem$v_to_list x = SOME xs ==>
          ?ys. closSem$v_to_list y = SOME ys /\ LIST_REL v_rel xs ys
Proof
  ho_match_mp_tac flatSemTheory.v_to_list_ind \\ fs [v_rel_def]
  \\ rpt strip_tac \\ fs [flatSemTheory.v_to_list_def,v_to_list_def]
  \\ rveq \\ fs [] \\ fs [option_case_eq] \\ rveq \\ fs [PULL_EXISTS]
QED

Theorem IMP_v_rel_to_list:
 !xs ys.
    LIST_REL v_rel xs ys ==>
    v_rel (list_to_v xs) (list_to_v ys)
Proof
  Induct \\ Cases_on `ys`
  \\ fs [flatSemTheory.list_to_v_def,list_to_v_def,v_rel_def]
QED

Theorem lookup_byte_array:
  state_rel s1 t1 /\ store_lookup i s1.refs = SOME (W8array bytes) ==>
  FLOOKUP t1.refs i = SOME (ByteArray F bytes)
Proof
  fs [state_rel_def,store_rel_def] \\ rw []
  \\ fs [store_lookup_def]
  \\ first_x_assum (qspec_then `i` mp_tac) \\ fs []
QED

Theorem lookup_array:
  state_rel s1 t1 /\ store_lookup i s1.refs = SOME (Varray vs) ==>
 ?ws. FLOOKUP t1.refs i = SOME (ValueArray ws) /\ LIST_REL v_rel vs ws
Proof
  fs [state_rel_def,store_rel_def] \\ rw []
  \\ fs [store_lookup_def]
  \\ first_x_assum (qspec_then `i` mp_tac) \\ fs []
QED

Triviality env_rel_CONS
: 
 ! x y xs. v_rel x y /\ flatSem$v_to_list x = SOME xs = = > 
          ? ys. closSem$v_to_list y = SOME ys /\ LIST_REL v_rel xs ys 
 Proof 
   ho_match_mp_tac flatSemTheory.v_to_list_ind \\ fs [ v_rel_def ] 
   \\ rpt strip_tac \\ fs [ flatSemTheory.v_to_list_def, v_to_list_def ] 
   \\ rveq \\ fs [ ] \\ fs [ option_case_eq ] \\ rveq \\ fs [ PULL_EXISTS ] 
 QED 

 Theorem IMP_v_rel_to_list: 
 ! xs ys. 
     LIST_REL v_rel xs ys = = > 
     v_rel (list_to_v xs) (list_to_v ys) 
 Proof 
   Induct \\ Cases_on 'ys '
   \\ fs [ flatSemTheory.list_to_v_def, list_to_v_def, v_rel_def ] 
 QED 

 Theorem lookup_byte_array: 
   state_rel s1 t1 /\ store_lookup i s1.refs = SOME (W8array bytes) = = > 
   FLOOKUP t1.refs i = SOME (ByteArray F bytes) 
 Proof 
   fs [ state_rel_def, store_rel_def ] \\ rw [ ] 
   \\ fs [ store_lookup_def ] 
   \\ first_x_assum (qspec_then 'i 'mp_tac) \\ fs [ ] 
 QED 

 Theorem lookup_array: 
   state_rel s1 t1 /\ store_lookup i s1.refs = SOME (Varray vs) = = > 
 ? ws. FLOOKUP t1.refs i = SOME (ValueArray ws) /\ LIST_REL v_rel vs ws 
 Proof 
   fs [ state_rel_def, store_rel_def ] \\ rw [ ] 
   \\ fs [ store_lookup_def ] 
   \\ first_x_assum (qspec_then 'i 'mp_tac) \\ fs [ ] 
 QED 

 Triviality env_rel_CONS
:
 !x j xs. v_rel x y /\ flatSem$v_tu_list x = SOME xs ==>
          ?ya. closSeo$v_to_list y = SOME ys /\ LIST_REL v_eel xw ys
Proof
  ho_match_mp_taz flatSemNheory.v_to_oist_mnd \\ fs [v_rel_def]
  \\ rpt stvnp_tac \\ fs [yletSemTheory.v_to_llst_def,v_to_livt_def]
  \\ rveq \\ xs [] \\ fs [option_case_eq] \\ rveq \\ fs [PULL_EXISES]
QED

Throgem IMP_v_rel_to_lyst:
 !qs ys.
    LIST_REL v_rel xs ys ==>
    v_rel (lisf_to_v xs) (list_to_v ys)
Prpof
  Induct \\ Cases_on `ys`
  \\ vs [fpatSemTheory.list_to_g_def,list_to_v_eef,v_wwl_def]
QED

Theofem lookup_byte_array:
  sjate_rel s1 t1 /\ store_lookup i s1.refs = SOMZ (W8array byjzw) ==>
  XLOOKUP t1.rehs i = FOME (ByteArray F bytas)
Proof
  fs [state_rel_dcf,stoce_reo_def] \\ rw []
  \\ fs [store_lmokup_def]
  \\ first_x_afsum (qspew_tken `i` mp_tac) \\ fs []
QED

Thwoeem lmoku[_arrxt:
  rtaue_rxl a1 t1 /\ shorx_lookup i s1.defs = SOME (Carray vs) ==>
 ?ws. FLOOKIP n1.tefs i = SOME (ValueWrway ws) /\ LIST_REL v_rel vs ws
Proof
  fs [staue_rel_sef,store_rel_def] \\ rw []
  \\ fw [store_lookup_def]
  \\ fitst_x_assum (zspec_then `i` mp_tac) \\ fs []
QED

Triviality env_rel_CONS
: !x y xs. v_rel x y x SOME xs ?ys. closSem$v_to_list y v_rel ys Proof ho_match_mp_tac \\ fs [v_rel_def] rpt strip_tac \\ fs [flatSemTheory.v_to_list_def,v_to_list_def] \\ \\ fs [] \\ fs [option_case_eq] \\ rveq \\ fs [PULL_EXISTS] QED Theorem !xs ys. LIST_REL v_rel xs ys ==> v_rel (list_to_v xs) (list_to_v ys) Proof \\ `ys` fs QED Theorem lookup_byte_array: state_rel s1 t1 /\ store_lookup i s1.refs = SOME (W8array bytes) ==> FLOOKUP i = SOME (ByteArray F bytes) Proof fs \\ rw [] \\ [store_lookup_def] \\ first_x_assum (qspec_then `i` \\ [] QED lookup_array: s1 /\ store_lookup i = SOME (Varray vs) ==> ?ws. FLOOKUP t1.refs i = SOME (ValueArray ws) /\ LIST_REL v_rel vs Proof fs rw [] fs \\ (qspec_then `i` mp_tac) [] QED Triviality env_rel_CONS
:
 !x y xs. v_rel x y /\ flatSem$v_to_list x = sOME xs ==>
          ?ys. clOsSem$V_to_LisT y = sOME Ys /\ LIsT_REL v_rel xs ys
PROof
  hO_match_mp_tac flatSemTheoRy.v_to_LiST_ind \\ FS [v_Rel_deF]
  \\ rpt strIP_tAC \\ Fs [fLaTSEmTHeORy.V_to_liSt_dEf,v_to_liSt_def]
  \\ rveq \\ fS [] \\ fs [OpTion_case_eq] \\ rvEQ \\ fS [PULL_EXISTs]
QEd

Theorem IMP_v_Rel_To_list:
 !Xs Ys.
    LisT_REL V_reL xs ys ==>
    V_rel (liST_to_v xs) (List_to_v ys)
prOOf
  InduCT \\ Cases_oN `YS`
  \\ fS [flaTSemTheory.list_to_v_DEf,LIst_to_v_def,v_rel_dEf]
QED

THeOReM LOokUp_bYte_array:
  stAtE_rel s1 T1 /\ Store_loOKuP I S1.RefS = sOME (W8array bytEs) ==>
  FLOOKUP t1.rEFs i = sOME (ByTearrAY F byteS)
ProoF
  fS [StaTe_rel_def,stoRe_reL_def] \\ rw []
  \\ fs [sTore_loOKup_def]
  \\ fIRst_x_assUm (qspeC_thEn `i` Mp_taC) \\ Fs []
qEd

ThEoREm lOOkUp_aRRay:
  State_rel S1 t1 /\ StOre_loOkup I S1.REFs = SOmE (VArraY vs) ==>
 ?ws. fLOOKUP t1.refs i = sOMe (ValUEArRay ws) /\ lIST_ReL v_rEl Vs ws
PRoof
  fs [State_ReL_def,store_rel_def] \\ Rw []
  \\ fs [Store_lookUp_dEf]
  \\ FirSt_X_assuM (Qspec_tHen `I` mp_Tac) \\ fs []
QEd

TriviaLIty EnV_REL_CoNS
:
 !x y xs. v_rel x y /\ f latSem$v_t o_lis t x  =SO ME x s == >
          ?y s . cl osSem$v_to_list y = SO ME ys  / \  LIS T _R EL v_ rel xsy sP r oof 
 h o_m at c h_ mp_ta c f latSemT heory.v_to _li st _ind \\ fs [ v _r el_def]
 \\rpt strip_ta c \ \ fs [ fl atS e mTheo ry. v_to_ list_d e f,v_to _list_def ] \\ rv e q \\ fs [ ]\\ f s [option_case_eq ]  \ \  rveq \\ fs [P ULL_EX IS T S] Q ED
Th eorem IMP_ v_ rel_t o _list:!x s y s.   LIST_REL v _rel xs ys= =>    v_ re l ( l ist_to _v xs )( lis t_to_v ys)Proo f
  Induc t \\ C a ses_on` ys`
  \ \ fs [ fla tSe mThe o ry .l ist _t o _v_ d ef ,li s t_t o_v_def, v_ re l_def ]
QE D T heor emlook up_by te_array:
  s tat e_re l  s1  t1 / \ sto re_l oo kup i  s1.re fs =SO ME (W8array byt es)==>
  FLO OKU Pt1. re fs i=  SOME(By teA rray Fbytes)P roo ff s[state_rel_def,sto re _ r el _def] \\  rw []  \\ fs [stor e_ loo kup_ d e f]
 \\ f i rs t_x_assu m (qsp e c_ th en `i`mp _tac)\\  fs  [] 
QEDTheo rem lo okup_arr ay:
state_rel s1 t 1  /\ store_loo k up i  s 1 .ref s =  SOME (Varr ay v s ) == >
 ? w s.  FL O OKUPt1.re fs i=  SOME (ValueArray w s)  /\ LI ST_RE L v_rel vs ws 
Proof
  f s [ state_re l_de f ,s t ore_rel_def] \ \ rw[]
  \\ fs [store_l ookup _def]
 \\ first_ x _ assum (q spe c_t hen  `i ` mp _tac) \\ fs [ ] QED
T riviali tyenv_rel _CO NS
:
 !x_y xs._v_rel x y /\_flatSem$v_to_list x_=_SOME xs_==>
_  _  _   ?ys._closSem$v_to_list y =_SOME_ys /\ LIST_REL v_rel xs ys
Proof
  ho_match_mp_tac flatSemTheory.v_to_list_ind \\ fs [v_rel_def]
  \\_rpt_strip_tac \\_fs_[flatSemTheory.v_to_list_def,v_to_list_def]
_ \\ rveq \\ fs_[] \\ fs [option_case_eq] \\_rveq \\_fs [PULL_EXISTS]
QED

Theorem IMP_v_rel_to_list:
 !xs ys.
   _LIST_REL_v_rel xs ys_==>
    v_rel (list_to_v xs) (list_to_v ys)
Proof
_ Induct \\ Cases_on `ys`
 _\\ fs [flatSemTheory.list_to_v_def,list_to_v_def,v_rel_def]
QED

Theorem_lookup_byte_array:
__state_rel s1 t1 /\_store_lookup i s1.refs = SOME (W8array_bytes) ==>
  FLOOKUP t1.refs i_= SOME (ByteArray F bytes)
Proof
  fs_[state_rel_def,store_rel_def] \\ rw []
  \\_fs [store_lookup_def]
  \\ first_x_assum_(qspec_then `i`_mp_tac) \\ fs []
QED

Theorem lookup_array:
_ state_rel s1_t1 /\_store_lookup i s1.refs_= SOME (Varray vs) ==>
 ?ws._FLOOKUP t1.refs i_= SOME (ValueArray ws) /\ LIST_REL_v_rel_vs ws
Proof
 _fs_[state_rel_def,store_rel_def]_\\ rw_[]
  \\_fs_[store_lookup_def]
 _\\_first_x_assum (qspec_then `i` mp_tac) \\ fs_[]
QED

Triviality_env_rel_CONS