Co2sobj_prop.thy
changeset 1 7d9c0ed02b56
child 3 b6ee5f35c41f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Co2sobj_prop.thy	Fri May 03 08:20:21 2013 +0100
@@ -0,0 +1,494 @@
+(*<*)
+theory Co2sobj_prop
+imports Main Flask Flask_type Static Static_type Sectxt_prop Init_prop Current_files_prop Current_sockets_prop
+begin
+(*<*)
+
+context tainting_s begin
+
+(************ simpset for cf2sfile ***************)
+
+declare get_parentfs_ctxts.simps [simp del]
+
+lemma cf2sfile_open_none:
+  "valid (Open p f flag fd None # s) \<Longrightarrow> cf2sfile (Open p f flag fd None # s) f b = cf2sfile s f b"
+apply (frule vd_cons, frule vt_grant_os)
+apply (frule noroot_events)
+by (auto split:if_splits option.splits    dest!:current_has_sec'
+          simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
+               get_parentfs_ctxts_simps)
+
+lemma cf2sfile_open_some1:
+  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); f' \<in> current_files s\<rbrakk>
+   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' = cf2sfile s f'"
+apply (frule vd_cons, frule vt_grant_os, frule noroot_events, rule ext)
+apply (induct f')
+apply (auto  split:if_splits option.splits    dest!:current_has_sec'
+          simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
+               get_parentfs_ctxts_simps)
+done
+
+lemma cf2sfile_open_some2:
+  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_file s f'\<rbrakk>
+   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' True = cf2sfile s f' True"
+apply (frule vd_cons, drule is_file_in_current)
+by (simp add:cf2sfile_open_some1)
+
+lemma cf2sfile_open_some3:
+  "\<lbrakk>valid (Open p f flag fd (Some inum) # s); is_dir s f'\<rbrakk>
+   \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f' False = cf2sfile s f' False"
+apply (frule vd_cons, drule is_dir_in_current)
+by (simp add:cf2sfile_open_some1)
+
+lemma cf2sfile_open_some:
+  "valid (Open p f flag fd (Some inum) # s) \<Longrightarrow> cf2sfile (Open p f flag fd (Some inum) # s) f True = (
+     case (parent f) of
+       Some pf \<Rightarrow> (case (sectxt_of_obj (Open p f flag fd (Some inum) # s) (O_file f), sectxt_of_obj s (O_dir pf), 
+                         get_parentfs_ctxts s pf) of
+                    (Some sec, Some psec, Some asecs) \<Rightarrow> Some (Created, sec, Some psec, set asecs)
+                  | _ \<Rightarrow> None)
+     | None \<Rightarrow> None)"
+apply (frule vd_cons, frule vt_grant_os, frule noroot_events)
+apply (auto split:if_splits option.splits    dest!:current_has_sec'
+          simp:cf2sfile_def is_file_simps is_dir_simps current_files_simps sectxt_of_obj_simps 
+               get_parentfs_ctxts_simps)
+
+
+
+lemma cf2sfile_open:
+  "valid (Open p f flag fd opt # s) \<Longrightarrow> cf2sfile (Open p f flag fd opt # s) = (\<lambda> f' b. 
+     if (opt = None) then cf2sfile s f' b
+     else if (f' = f \<and> b = True) 
+     then (case (parent f) of
+             Some pf \<Rightarrow> (case (sectxt_of_obj s (O_file f), sectxt_of_obj s (O_dir pf), 
+                 get_parentfs_ctxts s pf) of
+                          (Some sec, Some psec, Some asecs) \<Rightarrow>
+                              Some (if (\<not> deleted (O_file f) s \<and> f \<in> init_files) 
+                                    then Init f else Created, sec, Some psec, set asecs)
+                        | _ \<Rightarrow> None)
+           | None \<Rightarrow> None)
+     else cf2sfile s f' b)"
+apply (frule vd_cons, frule vt_grant_os, rule ext, rule ext)
+apply (auto split:if_splits option.splits 
+             simp:sectxt_of_obj_simps)
+
+
+
+
+
+
+
+
+
+
+
+
+lemma cf2sfile_keep_path: "\<lbrakk>f \<preceq> f'; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'"
+apply (induct f', simp add:no_junior_def)
+apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
+apply (drule no_junior_noteq, simp, simp add:cf2sfile.simps)
+done
+
+lemma ckp'_aux: "\<not> f \<preceq> a # f' \<Longrightarrow> \<not> f \<preceq> f'"
+by (auto simp:no_junior_def)
+
+lemma cf2sfile_keep_path': "\<lbrakk>\<not> f \<preceq> f'; \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; f' \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> \<not> cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'"
+apply (induct f', simp add:no_junior_def cf2sfile.simps, rule notI, drule cf2sfile_root_file, simp)
+apply (case_tac "f = a # f'", simp add:cf2sfile.simps)
+apply (rule notI)
+apply (frule ckp'_aux, simp, frule parentf_in_current', simp+)
+apply (case_tac "cf2sfile \<tau> f = cf2sfile \<tau> (a # f')", drule cf2sfile_inj, simp+)
+apply (simp add:cf2sfile.simps)
+by (drule no_junior_noteq, simp+)
+
+lemma cf2sfile_keep_path'': "\<lbrakk>cf2sfile \<tau> f \<preceq> cf2sfile \<tau> f'; \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; f' \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> f \<preceq> f'"
+using cf2sfile_keep_path'
+by (auto)
+
+lemma cf2sfile_open_some': "\<lbrakk>f \<in> current_files \<tau>; Open p f' flags fd (Some inum) # \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> cf2sfile (Open p f' flags fd (Some inum) # \<tau>) f = cf2sfile \<tau> f"
+apply (frule vt_cons')
+apply (drule vt_grant_os)
+apply (induct f)
+apply (simp add:cf2sfile.simps)+
+apply (frule parentf_in_current', simp)
+apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
+done
+
+lemma cf2sfile_open_some: "\<lbrakk>Open p f flags fd (Some inum) # \<tau> \<in> vt rc_cs; parent f = Some pf\<rbrakk> 
+                           \<Longrightarrow> cf2sfile (Open p f flags fd (Some inum) # \<tau>) f = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))"
+apply (case_tac f, simp)
+apply (frule vt_grant_os)
+apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_open_some')
+done
+
+lemma cf2sfile_open_none: "cf2sfile (Open p f flags fd None # \<tau>) f' = cf2sfile \<tau> f'"
+apply (induct f')
+by (simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)+
+
+lemma cf2sfile_open: "\<lbrakk>Open p f flags fd opt # \<tau> \<in> vt rc_cs; f' \<in> current_files (Open p f flags fd opt # \<tau>)\<rbrakk> \<Longrightarrow> 
+                       cf2sfile (Open p f flags fd opt # \<tau>) f' = (
+                         if (opt = None) then cf2sfile \<tau> f'
+                         else if (f' = f) then (case (parent f) of
+                                                  Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
+                                                | _       \<Rightarrow> [])
+                              else cf2sfile \<tau> f'                                                          )"
+apply (frule vt_grant_os)
+by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_open_none cf2sfile_open_some cf2sfile_open_some' split:if_splits option.splits)
+
+lemma cf2sfile_mkdir_some': "\<lbrakk>Mkdir p f' inum # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> cf2sfile (Mkdir p f' inum # \<tau>) f = cf2sfile \<tau> f"
+apply (frule vt_cons', drule vt_grant_os)
+apply (induct f, (simp add:cf2sfile.simps)+)
+apply (frule parentf_in_current', simp)
+apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
+done
+
+lemma cf2sfile_mkdir_some: "\<lbrakk>Mkdir p f inum # \<tau> \<in> vt rc_cs; parent f = Some pf\<rbrakk>
+                             \<Longrightarrow> cf2sfile (Mkdir p f inum # \<tau>) f = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))"
+apply (case_tac f, simp)
+apply (frule vt_grant_os)
+apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_mkdir_some')
+done
+
+lemma cf2sfile_mkdir: "\<lbrakk>Mkdir p f inum # \<tau> \<in> vt rc_cs; f' \<in> current_files (Mkdir p f inum # \<tau>)\<rbrakk> \<Longrightarrow>
+                        cf2sfile (Mkdir p f inum # \<tau>) f' = (
+                          if (f' = f) then (case (parent f) of
+                                              Some pf \<Rightarrow> (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf))
+                                            | _       \<Rightarrow> [])
+                          else cf2sfile \<tau> f'               ) "
+apply (frule vt_grant_os)
+by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_mkdir_some cf2sfile_mkdir_some' split:if_splits option.splits)
+
+lemma cf2sfile_linkhard_none: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = cf2sfile \<tau> f"
+apply (frule vt_cons')
+apply (drule vt_grant_os)
+apply (induct f)
+apply (simp add:cf2sfile.simps)+
+apply (frule parentf_in_current', simp)
+apply (auto simp:os_grant.simps index_of_file.simps split:option.splits)
+done
+
+lemma cf2sfile_linkhard_some: 
+  "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; parent f\<^isub>2 = Some pf\<^isub>2\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f\<^isub>2 = (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>2))"
+apply (case_tac f\<^isub>2, simp)
+apply (frule vt_grant_os)
+apply (simp add:cf2sfile.simps os_grant.simps current_files_simps index_of_file.simps cf2sfile_linkhard_none)
+done
+
+lemma cf2sfile_linkhard: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; f \<in> current_files (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>)\<rbrakk> \<Longrightarrow>
+                           cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = (
+                             if (f = f\<^isub>2) then (case (parent f\<^isub>2) of
+                                                 Some pf\<^isub>2 \<Rightarrow> SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>2)
+                                               | _        \<Rightarrow> [])
+                             else cf2sfile \<tau> f                 )"
+apply (frule vt_grant_os)
+by (auto simp:os_grant.simps current_files_simps intro:cf2sfile_linkhard_none cf2sfile_linkhard_some split:if_splits option.splits)
+
+
+lemma no_junior_aux: "\<not> f\<^isub>2 \<preceq> a # f \<Longrightarrow> \<not> f\<^isub>2 \<preceq> f"
+by (auto simp:no_junior_def)
+
+lemma cf2sfile_rename_aux: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>\<rbrakk> \<Longrightarrow> f \<noteq> f\<^isub>3 \<and> \<not> f\<^isub>3 \<preceq> f"
+apply (frule vt_grant_os, simp add:os_grant.simps, (erule exE|erule conjE)+)
+apply (rule conjI, rule notI, simp)
+apply (rule notI, drule vt_cons', simp add:ancenf_in_current)
+done
+
+lemma cf2sfile_rename'1: 
+  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; \<not> (f\<^isub>2 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
+apply (frule vt_cons',frule vt_grant_os,  induct f)
+apply (simp add:cf2sfile.simps)
+apply (frule parentf_in_current', simp, simp)
+apply (frule no_junior_aux, simp)
+apply (simp add:os_grant.simps, (erule exE|erule conjE)+)
+apply (drule cf2sfile_rename_aux, simp, erule conjE)
+apply (auto simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
+done
+
+lemma cf2sfile_rename'2: 
+  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; \<not> (f\<^isub>3 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
+apply (frule vt_cons', induct f)
+by (auto simp add:index_of_file.simps cf2sfile.simps no_junior_def split:option.splits nat.splits)
+
+lemma cf2sfile_rename1:
+  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f\<^isub>3 = SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)"
+apply (case_tac f\<^isub>3, simp add:cf2sfile.simps)
+apply (auto dest!:cf2sfile_rename'2 simp add:no_junior_def cf2sfile.simps index_of_file.simps split:option.splits)
+done
+
+lemma index_of_file_rename1: "\<lbrakk>f\<^isub>2 \<preceq> f; f \<noteq> f\<^isub>2\<rbrakk> \<Longrightarrow> index_of_file (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = index_of_file \<tau> f"
+apply (clarsimp simp add:index_of_file.simps split:option.splits)
+by (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop3, simp, erule conjE, simp add:file_renaming_prop5)
+
+lemma cf2sfile_rename2: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; (file_before_rename f\<^isub>2 f\<^isub>3 f) \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>3 \<preceq> f\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))"
+apply (induct f, simp add:no_junior_def)
+apply (case_tac "a # f = f\<^isub>3", simp)
+apply (drule cf2sfile_rename1, simp, simp add:file_renaming_prop0' file_renaming_prop0)
+
+apply (frule no_junior_noteq, simp, simp)
+apply (frule_tac file_renaming_prop1')
+apply (frule_tac f = f\<^isub>2 and \<tau> = \<tau> in cf2sfile_keep_path, simp add:vt_cons')
+apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop8')
+apply (frule_tac f\<^isub>2 = f\<^isub>2 and a = a in file_renaming_prop6')
+apply (frule_tac f = "file_before_rename f\<^isub>2 f\<^isub>3 (a # f)" and \<tau> = \<tau> and f\<^isub>2 = f\<^isub>2 and f\<^isub>3 = f\<^isub>3 and p = p in index_of_file_rename1, simp add:file_before_rename_def)
+apply (drule_tac f\<^isub>3 = f\<^isub>3 and f\<^isub>1 = f and a = a and f\<^isub>2 = f\<^isub>2 in file_renaming_prop9', simp)
+apply (drule parentf_in_current', simp add:vt_cons')
+apply (simp add:cf2sfile.simps)
+apply (erule file_renaming_prop6[THEN sym])
+done
+
+lemma cf2sfile_rename2': "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>2 \<preceq> f\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
+apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop5)
+apply (frule_tac f\<^isub>3 = f\<^isub>3 in file_renaming_prop1)
+apply (drule_tac f = "file_after_rename f\<^isub>2 f\<^isub>3 f" in cf2sfile_rename2, simp+)
+done
+
+lemma cf2sfile_rename3: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files \<tau>; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
+apply (case_tac "f\<^isub>2 \<preceq> f")
+apply (rule cf2sfile_rename2', simp+)
+apply (frule vt_grant_os)
+apply (frule_tac \<tau> = \<tau> in cf2sfile_keep_path', simp add:vt_cons', simp add:os_grant.simps, simp)
+apply (simp add:file_after_rename_def)
+by (rule cf2sfile_rename'1, simp+)
+
+lemma cf2sfile_rename: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; f \<in> current_files (Rename p f\<^isub>2 f\<^isub>3 # \<tau>)\<rbrakk> \<Longrightarrow>
+                         cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = (
+                           if (f\<^isub>3 \<preceq> f) then (case (parent f\<^isub>3) of 
+                                               Some pf\<^isub>3 \<Rightarrow> file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))
+                                             | _        \<Rightarrow> [])
+                           else cf2sfile \<tau> f               )"
+apply (frule vt_grant_os)
+apply (case_tac "f = f\<^isub>3", clarsimp simp:os_grant.simps, drule cf2sfile_rename1, simp+, simp add:file_renaming_prop0' file_renaming_prop0)
+
+apply (auto simp:os_grant.simps current_files_simps intro:cf2sfile_rename'2 cf2sfile_rename1 split:if_splits option.splits) 
+apply (rule cf2sfile_rename2, simp, drule rename_renaming_decom, simp+)
+apply (drule_tac f\<^isub>2 = f\<^isub>2 and f\<^isub>1 = f\<^isub>1 and f\<^isub>3 = f\<^isub>3 in file_renaming_prop5, simp+)
+done
+
+lemma cf2sfile_other: "\<lbrakk>
+                        \<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
+                        \<forall> p f im. e \<noteq> Mkdir p f im;
+                        \<forall> p f\<^isub>1 f\<^isub>2. e \<noteq> LinkHard p f\<^isub>1 f\<^isub>2;
+                        \<forall> p f\<^isub>2 f\<^isub>3. e \<noteq> Rename p f\<^isub>2 f\<^isub>3\<rbrakk> \<Longrightarrow> cf2sfile (e # \<tau>) f' = cf2sfile \<tau> f'"
+apply (induct f', simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
+apply (case_tac e, auto simp add:cf2sfile.simps index_of_file.simps split:option.splits nat.splits)
+done
+
+lemmas cf2sfile_nil = init_cf2sfile
+
+lemma cf2sfile_nil': "f \<in> current_files [] \<Longrightarrow> cf2sfile [] f = map SInit f"
+by (simp add:cf2sfile_nil current_files_simps)
+
+lemmas cf2sfile_simps = cf2sfile_nil cf2sfile_nil' cf2sfile_open cf2sfile_mkdir cf2sfile_linkhard cf2sfile_rename cf2sfile_other
+
+lemmas cf2sfile_simpss = cf2sfile_nil cf2sfile_nil' cf2sfile_open_some' cf2sfile_open_some cf2sfile_open_none cf2sfile_open cf2sfile_mkdir_some' cf2sfile_mkdir_some
+                         cf2sfile_mkdir cf2sfile_linkhard_none cf2sfile_linkhard_some cf2sfile_linkhard cf2sfile_rename'1 cf2sfile_rename'2 cf2sfile_rename1
+                         cf2sfile_rename2 cf2sfile_rename2' cf2sfile_rename3 cf2sfile_rename cf2sfile_other
+
+lemma cf2sfile_open_some'_inum: "\<lbrakk>Open p f' flags fd (Some inum) # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (Open p f' flags fd (Some inum) # \<tau>) f = cf2sfile \<tau> f"
+by (simp add:cf2sfile_open_some' current_files_def)
+
+lemma cf2sfile_mkdir_some'_inum: "\<lbrakk>Mkdir p f' inum # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (Mkdir p f' inum # \<tau>) f = cf2sfile \<tau> f"
+by (simp add:cf2sfile_mkdir_some' current_files_def)
+
+lemma cf2sfile_linkhard_none_inum: "\<lbrakk>LinkHard p f\<^isub>1 f\<^isub>2 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im\<rbrakk> \<Longrightarrow> cf2sfile (LinkHard p f\<^isub>1 f\<^isub>2 # \<tau>) f = cf2sfile \<tau> f"
+by (simp add:cf2sfile_linkhard_none current_files_def)
+
+lemma cf2sfile_rename'1_inum: 
+  "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im ; \<not> (f\<^isub>2 \<preceq> f)\<rbrakk> \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = cf2sfile \<tau> f"
+by (simp add:cf2sfile_rename'1 current_files_def)
+
+lemma cf2sfile_rename2_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f) = Some im; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>3 \<preceq> f\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) f = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> (file_before_rename f\<^isub>2 f\<^isub>3 f))"
+by (simp add:cf2sfile_rename2 current_files_def)
+
+lemma cf2sfile_rename2'_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im; parent f\<^isub>3 = Some pf\<^isub>3; f\<^isub>2 \<preceq> f\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
+by (simp add:cf2sfile_rename2' current_files_def)
+
+lemma cf2sfile_rename3_inum: "\<lbrakk>Rename p f\<^isub>2 f\<^isub>3 # \<tau> \<in> vt rc_cs; inum_of_file \<tau> f = Some im; parent f\<^isub>3 = Some pf\<^isub>3\<rbrakk> 
+   \<Longrightarrow> cf2sfile (Rename p f\<^isub>2 f\<^isub>3 # \<tau>) (file_after_rename f\<^isub>2 f\<^isub>3 f) = file_after_rename (cf2sfile \<tau> f\<^isub>2) (SCrea (Suc (length \<tau>)) # (cf2sfile \<tau> pf\<^isub>3)) (cf2sfile \<tau> f)"
+by (simp add:cf2sfile_rename3 current_files_def)
+
+lemma cf2sfile_nil'_inum: "inum_of_file [] f = Some im \<Longrightarrow> cf2sfile [] f = map SInit f"
+by (simp add:cf2sfile_nil' current_files_def)
+
+lemmas cf2sfile_simps_inum = cf2sfile_nil cf2sfile_nil'_inum cf2sfile_open_some'_inum cf2sfile_open_some cf2sfile_open_none cf2sfile_open cf2sfile_mkdir_some'_inum cf2sfile_mkdir_some
+                         cf2sfile_mkdir cf2sfile_linkhard_none_inum cf2sfile_linkhard_some cf2sfile_linkhard cf2sfile_rename'1_inum cf2sfile_rename'2 cf2sfile_rename1
+                         cf2sfile_rename2_inum cf2sfile_rename2'_inum cf2sfile_rename3_inum cf2sfile_rename cf2sfile_other
+
+(*************** cp2sproc simpset *********************)
+
+lemma cp2sproc_nil: "p \<in> init_processes \<Longrightarrow> cp2sproc [] p = SInit p"
+by (simp add:cp2sproc_def index_of_proc.simps)
+
+lemma cp2sproc_nil': "p \<in> current_procs [] \<Longrightarrow> cp2sproc [] p = SInit p"
+by (simp add:cp2sproc_nil current_procs.simps)
+
+lemma cp2sproc_clone: "cp2sproc (Clone p p' # \<tau>) p'' = (
+                         if (p'' = p') then SCrea (Suc (length \<tau>))
+                         else cp2sproc \<tau> p''           )"
+by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
+
+lemma cp2sproc_other: "\<forall> p p'. e \<noteq> Clone p p' \<Longrightarrow> cp2sproc (e # \<tau>) p'' = cp2sproc \<tau> p''"
+apply (case_tac e)
+by (auto simp:cp2sproc_def index_of_proc.simps d2s_aux.simps)
+
+lemmas cp2sproc_simps = cp2sproc_nil cp2sproc_nil' cp2sproc_clone cp2sproc_other
+
+(******************** ch2sshm simpset **************************)
+
+lemma ch2sshm_nil: "h \<in> init_shms \<Longrightarrow> ch2sshm [] h = SInit h"
+by (simp add:ch2sshm_def index_of_shm.simps)
+
+lemma ch2sshm_nil': "h \<in> current_shms [] \<Longrightarrow> ch2sshm [] h = SInit h"
+by (simp add:ch2sshm_nil current_shms.simps)
+
+lemma ch2sshm_createshm: "ch2sshm (CreateShM p h # \<tau>) h' = (if (h' = h) then SCrea (Suc (length \<tau>)) else ch2sshm \<tau> h')"
+by (simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
+
+lemma ch2sshm_other: "\<forall> p h. e \<noteq> CreateShM p h \<Longrightarrow> ch2sshm (e # \<tau>) h' = ch2sshm \<tau> h'"
+apply (case_tac e)
+by (auto simp add:ch2sshm_def index_of_shm.simps d2s_aux.simps) 
+
+lemmas ch2sshm_simps = ch2sshm_nil ch2sshm_nil' ch2sshm_createshm ch2sshm_other
+
+(********************* cm2smsg simpset ***********************)
+
+lemma cm2smsg_nil: "m \<in> init_msgs \<Longrightarrow> cm2smsg [] m = SInit m"
+by (simp add:cm2smsg_def index_of_msg.simps)
+
+lemma cm2smsg_nil': "m \<in> current_msgs [] \<Longrightarrow> cm2smsg [] m = SInit m"
+by (simp add:cm2smsg_nil current_msgs.simps)
+
+lemma cm2smsg_createmsg: "cm2smsg (CreateMsg p m # \<tau>) m' = (if (m' = m) then SCrea (Suc (length \<tau>)) else cm2smsg \<tau> m')"
+by (simp add:cm2smsg_def index_of_msg.simps d2s_aux.simps)
+
+lemma cm2smsg_other: "\<forall> p m. e \<noteq> CreateMsg p m \<Longrightarrow> cm2smsg (e # \<tau>) m' = cm2smsg \<tau> m'"
+apply (case_tac e)
+by (auto simp:cm2smsg_def index_of_msg.simps d2s_aux.simps)
+
+lemmas cm2smsg_simps = cm2smsg_nil cm2smsg_nil' cm2smsg_createmsg cm2smsg_other
+
+(********************** cfd2fd_s simpset ******************************)
+
+lemma cfd2fd_s_nil: "fd \<in> init_fds_of_proc p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
+by (simp add:cfd2fd_s_def index_of_fd.simps)
+
+lemma cfd2fd_s_nil': "fd \<in> current_proc_fds [] p \<Longrightarrow> cfd2fd_s [] p fd = SInit fd"
+by (simp add:cfd2fd_s_nil current_proc_fds.simps)
+
+lemma cfd2fd_s_open: "cfd2fd_s (Open p f flags fd opt # \<tau>) p' fd' = (
+                        if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
+                                          else cfd2fd_s \<tau> p' fd')
+                        else cfd2fd_s \<tau> p' fd'                      )"
+by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
+
+lemma cfd2fd_s_createsock: "cfd2fd_s (CreateSock p af st fd im # \<tau>) p' fd' = (
+                              if (p = p') then (if (fd = fd') then SCrea (Suc (length \<tau>)) 
+                                          else cfd2fd_s \<tau> p' fd')
+                              else cfd2fd_s \<tau> p' fd'                         )"
+by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
+
+lemma cfd2fd_s_accept: "cfd2fd_s (Accept p fd addr port fd' im # \<tau>) p' fd'' = (
+                          if (p' = p) then (if (fd'' = fd') then SCrea (Suc (length \<tau>))
+                                            else cfd2fd_s \<tau> p' fd'')
+                          else cfd2fd_s \<tau> p' fd''                             )"
+by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
+
+lemma cfd2fd_s_clone: "cfd2fd_s (Clone p p' # \<tau>) p'' fd = (if (p'' = p') then cfd2fd_s \<tau> p fd else cfd2fd_s \<tau> p'' fd)"
+by (simp add:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
+
+lemma cfd2fd_s_other: "\<lbrakk>\<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
+                        \<forall> p af st fd im. e \<noteq> CreateSock p af st fd im;
+                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im;
+                        \<forall> p p'. e \<noteq> Clone p p'\<rbrakk> \<Longrightarrow> cfd2fd_s (e # \<tau>) p'' fd'' = cfd2fd_s \<tau> p'' fd''"
+by (case_tac e, auto simp:cfd2fd_s_def index_of_fd.simps d2s_aux.simps)
+
+lemmas cfd2fd_s_simps = cfd2fd_s_nil cfd2fd_s_nil' cfd2fd_s_open cfd2fd_s_createsock cfd2fd_s_accept cfd2fd_s_clone cfd2fd_s_other
+
+(************* cim2im_s simpset **************************)
+
+(* no such lemma
+lemma cim2im_s_nil: "init_itag_of_inum im = Some tag \<Longrightarrow> cim2im_s [] im = SInit im"
+by (simp add:cim2im_s_def)
+*)
+
+lemma cim2im_s_open: "cim2im_s (Open p f flags fd (Some im) # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
+by (simp add:cim2im_s_def)
+
+lemma cim2im_s_open': "cim2im_s (Open p f flags fd None # \<tau>) im = cim2im_s \<tau> im"
+by (simp add:cim2im_s_def)
+
+lemma cim2im_s_mkdir: "cim2im_s (Mkdir p f im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
+by (simp add:cim2im_s_def)
+
+lemma cim2im_s_createsock: "cim2im_s (CreateSock p sf st fd im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
+by (simp add:cim2im_s_def)
+
+lemma cim2im_s_accept: "cim2im_s (Accept p fd addr port fd' im # \<tau>) im' = (if (im' = im) then SCrea (Suc (length \<tau>)) else cim2im_s \<tau> im')"
+by (simp add:cim2im_s_def)
+
+lemma cim2im_s_other: "\<lbrakk>\<forall> p f flags fd opt. e \<noteq> Open p f flags fd opt;
+                        \<forall> p f im. e \<noteq> Mkdir p f im;
+                        \<forall> p sf st fd im. e \<noteq> CreateSock p sf st fd im;
+                        \<forall> p fd addr port fd' im. e \<noteq> Accept p fd addr port fd' im\<rbrakk> \<Longrightarrow> cim2im_s (e # \<tau>) im = cim2im_s \<tau> im"
+by (case_tac e, auto simp:cim2im_s_def)
+
+lemmas cim2im_s_simps = cim2im_s_open cim2im_s_open' cim2im_s_mkdir cim2im_s_createsock cim2im_s_accept cim2im_s_other
+
+
+lemma cig2ig_s_simp: "cig2ig_s (e # \<tau>) tag = cig2ig_s \<tau> tag"
+apply (case_tac tag)
+by auto
+
+(******************* cobj2sobj no Suc (length \<tau>) ***********************)
+
+lemma cf2sfile_le_len: "\<lbrakk>cf2sfile \<tau> f = SCrea (Suc (length \<tau>)) # spf; f \<in> current_files \<tau>; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> False"
+apply (case_tac f, (simp add:cf2sfile.simps d2s_aux.simps)+)
+apply (case_tac "index_of_file \<tau> (a # list)", (simp add:d2s_aux.simps)+)
+by (drule index_of_file_le_length', simp+)
+
+lemma cf2sfile_le_len': "\<lbrakk>SCrea (Suc (length \<tau>)) # spf \<preceq> cf2sfile \<tau> f; f \<in> current_files \<tau>; \<tau> \<in> vt rc_cs\<rbrakk> \<Longrightarrow> False"
+apply (induct f)
+apply (simp add:no_junior_def cf2sfile.simps d2s_aux.simps)
+apply (case_tac "cf2sfile \<tau> (a # f) = SCrea (Suc (length \<tau>)) # spf") 
+apply (drule_tac f = "a # f" in cf2sfile_le_len, simp+)
+apply (simp only:cf2sfile.simps d2s_aux.simps)
+apply (drule_tac no_junior_noteq, simp+)
+apply (rule impI, erule impE, simp+)
+apply (drule parentf_in_current', simp+)
+done
+
+lemma cp2sproc_le_len: "cp2sproc \<tau> p = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
+apply (simp add:cp2sproc_def, case_tac "index_of_proc \<tau> p")
+apply (simp add:d2s_aux.simps)+
+by (drule index_of_proc_le_length', simp)
+
+lemma ch2sshm_le_len: "ch2sshm \<tau> h = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
+apply (simp add:ch2sshm_def, case_tac "index_of_shm \<tau> h")
+apply (simp add:d2s_aux.simps)+
+by (drule index_of_shm_le_length', simp)
+
+lemma cm2smsg_le_len: "cm2smsg \<tau> m = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
+apply (simp add:cm2smsg_def, case_tac "index_of_msg \<tau> m")
+apply (simp add:d2s_aux.simps)+
+by (drule index_of_msg_le_length', simp)
+
+lemma cim2im_s_le_len: "cim2im_s \<tau> im = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
+apply (simp add:cim2im_s_def, case_tac "inum2ind \<tau> im")
+apply (simp add:d2s_aux.simps)+
+by (drule inum2ind_le_length', simp)
+
+lemma cfd2fd_s_le_len: "cfd2fd_s \<tau> p fd = SCrea (Suc (length \<tau>)) \<Longrightarrow> False"
+apply (simp add:cfd2fd_s_def, case_tac "index_of_fd \<tau> p fd")
+apply (simp add:d2s_aux.simps)+
+by (drule index_of_fd_le_length', simp)
+
+end
+
+(*<*)
+end
+(*>*)
\ No newline at end of file