no_shm_selinux/Static.thy
author chunhan
Thu, 16 Jan 2014 11:04:04 +0800
changeset 95 b7fd75d104bf
parent 94 042e1e7fd505
permissions -rwxr-xr-x
update
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
chunhan
parents:
diff changeset
     1
theory Static
chunhan
parents:
diff changeset
     2
imports Static_type OS_type_def Flask_type Flask
chunhan
parents:
diff changeset
     3
begin
chunhan
parents:
diff changeset
     4
chunhan
parents:
diff changeset
     5
locale tainting_s = tainting 
chunhan
parents:
diff changeset
     6
chunhan
parents:
diff changeset
     7
begin
chunhan
parents:
diff changeset
     8
chunhan
parents:
diff changeset
     9
(*
chunhan
parents:
diff changeset
    10
definition init_sectxt_of_file:: "t_file \<Rightarrow> security_context_t option"
chunhan
parents:
diff changeset
    11
where
chunhan
parents:
diff changeset
    12
  "init_sectxt_of_file f \<equiv> 
chunhan
parents:
diff changeset
    13
     if (is_init_file f) then init_sectxt_of_obj (O_file f)
chunhan
parents:
diff changeset
    14
     else if (is_init_dir f) then init_sectxt_of_obj (O_dir f)
chunhan
parents:
diff changeset
    15
     else None"
chunhan
parents:
diff changeset
    16
*)
chunhan
parents:
diff changeset
    17
chunhan
parents:
diff changeset
    18
definition sroot :: "t_sfile"
chunhan
parents:
diff changeset
    19
where
chunhan
parents:
diff changeset
    20
  "sroot \<equiv> (Init [], sec_of_root, None, {})"
chunhan
parents:
diff changeset
    21
chunhan
parents:
diff changeset
    22
definition init_cf2sfile :: "t_file \<Rightarrow> t_sfile option"
chunhan
parents:
diff changeset
    23
where
chunhan
parents:
diff changeset
    24
  "init_cf2sfile f \<equiv> 
chunhan
parents:
diff changeset
    25
     case (parent f) of 
chunhan
parents:
diff changeset
    26
       None \<Rightarrow> Some sroot
chunhan
parents:
diff changeset
    27
     | Some pf \<Rightarrow> if (is_init_file f) then 
chunhan
parents:
diff changeset
    28
 (case (init_sectxt_of_obj (O_file f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of
chunhan
parents:
diff changeset
    29
    (Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist)
chunhan
parents:
diff changeset
    30
  | _ \<Rightarrow> None)    else 
chunhan
parents:
diff changeset
    31
 (case (init_sectxt_of_obj (O_dir f), init_sectxt_of_obj (O_dir pf), get_parentfs_ctxts [] pf) of
chunhan
parents:
diff changeset
    32
    (Some sec, Some psec, Some aseclist) \<Rightarrow> Some (Init f, sec, Some psec, set aseclist)
chunhan
parents:
diff changeset
    33
  | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
    34
chunhan
parents:
diff changeset
    35
definition init_cf2sfiles :: "t_file \<Rightarrow> t_sfile set"
chunhan
parents:
diff changeset
    36
where
chunhan
parents:
diff changeset
    37
  "init_cf2sfiles f \<equiv> {sf. \<exists>f' \<in> init_same_inode_files f. init_cf2sfile f' = Some sf}"
chunhan
parents:
diff changeset
    38
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
    39
fun remove_create_flag :: "t_open_flags \<Rightarrow> t_open_flags"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
    40
where
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
    41
  "remove_create_flag (mflag, oflags) = (mflag, oflags - {OF_CREAT})"
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
    42
77
chunhan
parents:
diff changeset
    43
definition init_cfd2sfd :: "t_process \<Rightarrow> t_fd \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) option"
chunhan
parents:
diff changeset
    44
where
chunhan
parents:
diff changeset
    45
  "init_cfd2sfd p fd = 
chunhan
parents:
diff changeset
    46
     (case (init_file_of_proc_fd p fd, init_oflags_of_proc_fd p fd, init_sectxt_of_obj (O_fd p fd)) of
chunhan
parents:
diff changeset
    47
        (Some f, Some flags, Some sec) \<Rightarrow> (case (init_cf2sfile f) of 
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
    48
                                             Some sf \<Rightarrow> Some (sec, remove_create_flag flags, sf)
77
chunhan
parents:
diff changeset
    49
                                           | _ \<Rightarrow> None)
chunhan
parents:
diff changeset
    50
      | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
    51
chunhan
parents:
diff changeset
    52
definition init_cfds2sfds :: "t_process \<Rightarrow> (security_context_t \<times> t_open_flags \<times> t_sfile) set"
chunhan
parents:
diff changeset
    53
where
chunhan
parents:
diff changeset
    54
  "init_cfds2sfds p \<equiv> { sfd. \<exists> fd \<in> init_proc_file_fds p. init_cfd2sfd p fd = Some sfd}"
chunhan
parents:
diff changeset
    55
chunhan
parents:
diff changeset
    56
(*
chunhan
parents:
diff changeset
    57
definition init_ch2sshm :: "t_shm \<Rightarrow> t_sshm option"
chunhan
parents:
diff changeset
    58
where
chunhan
parents:
diff changeset
    59
  "init_ch2sshm h \<equiv> (case (init_sectxt_of_obj (O_shm h)) of
chunhan
parents:
diff changeset
    60
                       Some sec \<Rightarrow> Some (Init h, sec)
chunhan
parents:
diff changeset
    61
                     | _        \<Rightarrow> None)"
chunhan
parents:
diff changeset
    62
chunhan
parents:
diff changeset
    63
definition init_cph2spshs 
chunhan
parents:
diff changeset
    64
  :: "t_process \<Rightarrow> (t_sshm \<times> t_shm_attach_flag) set"
chunhan
parents:
diff changeset
    65
where
chunhan
parents:
diff changeset
    66
  "init_cph2spshs p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> init_procs_of_shm h \<and> 
chunhan
parents:
diff changeset
    67
                                             init_ch2sshm h = Some sh}"
chunhan
parents:
diff changeset
    68
*)
chunhan
parents:
diff changeset
    69
definition init_cp2sproc :: "t_process \<Rightarrow> t_sproc option"
chunhan
parents:
diff changeset
    70
where
chunhan
parents:
diff changeset
    71
  "init_cp2sproc p \<equiv> (case (init_sectxt_of_obj (O_proc p)) of 
chunhan
parents:
diff changeset
    72
       Some sec \<Rightarrow> Some (Init p, sec, (init_cfds2sfds p))
chunhan
parents:
diff changeset
    73
     | None     \<Rightarrow> None)"
chunhan
parents:
diff changeset
    74
chunhan
parents:
diff changeset
    75
(* acient files of init-file 
chunhan
parents:
diff changeset
    76
definition init_o2s_afs :: "t_file \<Rightarrow> security_context_t set"
chunhan
parents:
diff changeset
    77
where
chunhan
parents:
diff changeset
    78
  "init_o2s_afs f \<equiv> {sec. \<exists> f'. f' \<preceq> f \<and> init_sectxt_of_obj (O_dir f') = Some sec}" *)
chunhan
parents:
diff changeset
    79
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
    80
(*
77
chunhan
parents:
diff changeset
    81
definition init_cm2smsg :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option"
chunhan
parents:
diff changeset
    82
where
chunhan
parents:
diff changeset
    83
  "init_cm2smsg q m \<equiv> (case (init_sectxt_of_obj (O_msg q m)) of 
chunhan
parents:
diff changeset
    84
                         Some sec \<Rightarrow> Some (Init m, sec, (O_msg q m) \<in> seeds)
chunhan
parents:
diff changeset
    85
                       | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
    86
chunhan
parents:
diff changeset
    87
fun init_cqm2sms :: "t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option"
chunhan
parents:
diff changeset
    88
where
chunhan
parents:
diff changeset
    89
  "init_cqm2sms q []     = Some []"
chunhan
parents:
diff changeset
    90
| "init_cqm2sms q (m#ms) = 
chunhan
parents:
diff changeset
    91
     (case (init_cqm2sms q ms, init_cm2smsg q m) of 
chunhan
parents:
diff changeset
    92
        (Some sms, Some sm) \<Rightarrow> Some (sm # sms)
chunhan
parents:
diff changeset
    93
      | _        \<Rightarrow> None)"
chunhan
parents:
diff changeset
    94
chunhan
parents:
diff changeset
    95
definition init_cq2smsgq :: "t_msgq \<Rightarrow> t_smsgq option"
chunhan
parents:
diff changeset
    96
where
chunhan
parents:
diff changeset
    97
  "init_cq2smsgq q \<equiv> (case (init_sectxt_of_obj (O_msgq q), init_cqm2sms q (init_msgs_of_queue q)) of 
chunhan
parents:
diff changeset
    98
       (Some sec, Some sms) \<Rightarrow> Some (Init q, sec, sms)
chunhan
parents:
diff changeset
    99
     | _ \<Rightarrow> None)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   100
*)
77
chunhan
parents:
diff changeset
   101
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   102
fun init_obj2sobj :: "t_dobject \<Rightarrow> t_sobject option"
77
chunhan
parents:
diff changeset
   103
where
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   104
  "init_obj2sobj (D_proc p) = 
77
chunhan
parents:
diff changeset
   105
     (case (init_cp2sproc p) of 
chunhan
parents:
diff changeset
   106
       Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> seeds))
chunhan
parents:
diff changeset
   107
     | _ \<Rightarrow> None)"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   108
| "init_obj2sobj (D_file f) = 
77
chunhan
parents:
diff changeset
   109
     Some (S_file (init_cf2sfiles f) 
chunhan
parents:
diff changeset
   110
                  (\<exists> f'. f' \<in> (init_same_inode_files f) \<and> O_file f \<in> seeds))"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   111
| "init_obj2sobj (D_dir f) = 
77
chunhan
parents:
diff changeset
   112
     (case (init_cf2sfile f) of
chunhan
parents:
diff changeset
   113
           Some sf \<Rightarrow> Some (S_dir sf) 
chunhan
parents:
diff changeset
   114
         | _ \<Rightarrow> None)"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   115
| "init_obj2sobj (D_msgq q) = None"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   116
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   117
fun init_dalive :: "t_dobject \<Rightarrow> bool"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   118
where
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   119
  "init_dalive (D_proc p) = (p \<in> init_procs)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   120
| "init_dalive (D_file f) = (is_init_file f)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   121
| "init_dalive (D_dir  f) = (is_init_dir  f)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   122
| "init_dalive (D_msgq q) = False"
77
chunhan
parents:
diff changeset
   123
chunhan
parents:
diff changeset
   124
definition  
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   125
  "init_static_state \<equiv> {sobj. \<exists> obj. init_dalive obj \<and> init_obj2sobj obj = Some sobj}"
77
chunhan
parents:
diff changeset
   126
chunhan
parents:
diff changeset
   127
(**************** translation from dynamic to static *******************)
chunhan
parents:
diff changeset
   128
chunhan
parents:
diff changeset
   129
definition cf2sfile :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile option"
chunhan
parents:
diff changeset
   130
where
chunhan
parents:
diff changeset
   131
  "cf2sfile s f \<equiv>
chunhan
parents:
diff changeset
   132
     case (parent f) of 
chunhan
parents:
diff changeset
   133
       None \<Rightarrow> Some sroot
chunhan
parents:
diff changeset
   134
     | Some pf \<Rightarrow> if (is_file s f) 
chunhan
parents:
diff changeset
   135
     then (case (sectxt_of_obj s (O_file f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   136
            (Some sec, Some psec, Some asecs) \<Rightarrow>
chunhan
parents:
diff changeset
   137
 Some (if (\<not> died (O_file f) s \<and> is_init_file f) then Init f else Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   138
          | _ \<Rightarrow> None) 
chunhan
parents:
diff changeset
   139
     else (case (sectxt_of_obj s (O_dir f), sectxt_of_obj s (O_dir pf), get_parentfs_ctxts s pf) of
chunhan
parents:
diff changeset
   140
            (Some sec, Some psec, Some asecs) \<Rightarrow>
chunhan
parents:
diff changeset
   141
 Some (if (\<not> died (O_dir f) s \<and> is_init_dir f) then Init f else Created, sec, Some psec, set asecs)
chunhan
parents:
diff changeset
   142
          | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   143
chunhan
parents:
diff changeset
   144
definition cf2sfiles :: "t_state \<Rightarrow> t_file \<Rightarrow> t_sfile set"
chunhan
parents:
diff changeset
   145
where
chunhan
parents:
diff changeset
   146
  "cf2sfiles s f \<equiv> {sf. \<exists> f' \<in> (same_inode_files s f). cf2sfile s f' = Some sf}"
chunhan
parents:
diff changeset
   147
chunhan
parents:
diff changeset
   148
(* here cf2sfile is passed with True, because, process' fds are only for files not dirs *)
chunhan
parents:
diff changeset
   149
definition cfd2sfd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd \<Rightarrow> t_sfd option" 
chunhan
parents:
diff changeset
   150
where
chunhan
parents:
diff changeset
   151
  "cfd2sfd s p fd \<equiv> 
chunhan
parents:
diff changeset
   152
    (case (file_of_proc_fd s p fd, flags_of_proc_fd s p fd, sectxt_of_obj s (O_fd p fd)) of
chunhan
parents:
diff changeset
   153
      (Some f, Some flags, Some sec) \<Rightarrow> (case (cf2sfile s f) of 
85
1d1aa5bdd37d add remove_create_flag to sfd
chunhan
parents: 77
diff changeset
   154
                                          Some sf \<Rightarrow> Some (sec, remove_create_flag flags, sf)
77
chunhan
parents:
diff changeset
   155
                                        | _       \<Rightarrow> None)
chunhan
parents:
diff changeset
   156
    | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   157
chunhan
parents:
diff changeset
   158
chunhan
parents:
diff changeset
   159
definition cpfd2sfds :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sfd set"
chunhan
parents:
diff changeset
   160
where
chunhan
parents:
diff changeset
   161
  "cpfd2sfds s p \<equiv> {sfd. \<exists> fd \<in> proc_file_fds s p. cfd2sfd s p fd = Some sfd}"
chunhan
parents:
diff changeset
   162
chunhan
parents:
diff changeset
   163
(*
chunhan
parents:
diff changeset
   164
definition ch2sshm :: "t_state \<Rightarrow> t_shm \<Rightarrow> t_sshm option"
chunhan
parents:
diff changeset
   165
where
chunhan
parents:
diff changeset
   166
  "ch2sshm s h \<equiv> (case (sectxt_of_obj s (O_shm h)) of
chunhan
parents:
diff changeset
   167
                    Some sec \<Rightarrow> 
chunhan
parents:
diff changeset
   168
 Some (if (\<not> died (O_shm h) s \<and> h \<in> init_shms) then Init h else Created, sec)
chunhan
parents:
diff changeset
   169
                  | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   170
chunhan
parents:
diff changeset
   171
definition cph2spshs :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc_sshm set"
chunhan
parents:
diff changeset
   172
where
chunhan
parents:
diff changeset
   173
  "cph2spshs s p \<equiv> {(sh, flag)| sh flag h. (p, flag) \<in> procs_of_shm s h \<and> ch2sshm s h = Some sh}"
chunhan
parents:
diff changeset
   174
*)
chunhan
parents:
diff changeset
   175
definition cp2sproc :: "t_state \<Rightarrow> t_process \<Rightarrow> t_sproc option"
chunhan
parents:
diff changeset
   176
where
chunhan
parents:
diff changeset
   177
  "cp2sproc s p \<equiv> (case (sectxt_of_obj s (O_proc p)) of 
chunhan
parents:
diff changeset
   178
                     Some sec \<Rightarrow> 
chunhan
parents:
diff changeset
   179
 Some (if (\<not> died (O_proc p) s \<and> p \<in> init_procs) then Init p else Created, sec, 
chunhan
parents:
diff changeset
   180
       cpfd2sfds s p)
chunhan
parents:
diff changeset
   181
                   | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   182
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   183
(*
77
chunhan
parents:
diff changeset
   184
definition cm2smsg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option"
chunhan
parents:
diff changeset
   185
where
chunhan
parents:
diff changeset
   186
  "cm2smsg s q m \<equiv> (case (sectxt_of_obj s (O_msg q m)) of 
chunhan
parents:
diff changeset
   187
                      Some sec \<Rightarrow>
chunhan
parents:
diff changeset
   188
 Some (if (\<not> died (O_msg q m) s \<and> m \<in> set (init_msgs_of_queue q)) then Init m else Created,
chunhan
parents:
diff changeset
   189
       sec, O_msg q m \<in> tainted s)
chunhan
parents:
diff changeset
   190
                    | _ \<Rightarrow> None)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   191
*)
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   192
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   193
definition cm2smsg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsg option"
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   194
where
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   195
  "cm2smsg s q m \<equiv> (case (sectxt_of_obj s (O_msg q m)) of 
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   196
                      Some sec \<Rightarrow> Some (Created, sec, O_msg q m \<in> tainted s)
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   197
                    | _ \<Rightarrow> None)"
77
chunhan
parents:
diff changeset
   198
chunhan
parents:
diff changeset
   199
fun cqm2sms:: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_msg list \<Rightarrow> (t_smsg list) option"
chunhan
parents:
diff changeset
   200
where 
chunhan
parents:
diff changeset
   201
  "cqm2sms s q [] = Some []"
chunhan
parents:
diff changeset
   202
| "cqm2sms s q (m#ms) = 
chunhan
parents:
diff changeset
   203
     (case (cqm2sms s q ms, cm2smsg s q m) of 
chunhan
parents:
diff changeset
   204
       (Some sms, Some sm) \<Rightarrow> Some (sm#sms) 
chunhan
parents:
diff changeset
   205
     | _ \<Rightarrow> None)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   206
(*
77
chunhan
parents:
diff changeset
   207
definition cq2smsgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_smsgq option"
chunhan
parents:
diff changeset
   208
where
chunhan
parents:
diff changeset
   209
  "cq2smsgq s q \<equiv> (case (sectxt_of_obj s (O_msgq q), cqm2sms s q (msgs_of_queue s q)) of 
chunhan
parents:
diff changeset
   210
                     (Some sec, Some sms) \<Rightarrow> 
chunhan
parents:
diff changeset
   211
 Some (if (\<not> died (O_msgq q) s \<and> q \<in> init_msgqs) then Init q else Created,
chunhan
parents:
diff changeset
   212
       sec, sms)
chunhan
parents:
diff changeset
   213
                   | _ \<Rightarrow> None)"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   214
*)
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   215
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   216
definition cq2smsgq :: "t_state \<Rightarrow> t_msgq \<Rightarrow> t_smsgq option"
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   217
where
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   218
  "cq2smsgq s q \<equiv> (case (sectxt_of_obj s (O_msgq q), cqm2sms s q (msgs_of_queue s q)) of 
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   219
                     (Some sec, Some sms) \<Rightarrow> Some (Created, sec, sms)
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   220
                   | _ \<Rightarrow> None)"
77
chunhan
parents:
diff changeset
   221
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   222
fun co2sobj :: "t_state \<Rightarrow> t_dobject \<Rightarrow> t_sobject option"
77
chunhan
parents:
diff changeset
   223
where
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   224
  "co2sobj s (D_proc p) = 
77
chunhan
parents:
diff changeset
   225
     (case (cp2sproc s p) of 
chunhan
parents:
diff changeset
   226
        Some sp \<Rightarrow> Some (S_proc sp (O_proc p \<in> tainted s))
chunhan
parents:
diff changeset
   227
      | _       \<Rightarrow> None)"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   228
| "co2sobj s (D_file f) = 
77
chunhan
parents:
diff changeset
   229
     Some (S_file (cf2sfiles s f) (O_file f \<in> tainted s))"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   230
| "co2sobj s (D_dir f) = 
77
chunhan
parents:
diff changeset
   231
     (case (cf2sfile s f) of
chunhan
parents:
diff changeset
   232
        Some sf  \<Rightarrow> Some (S_dir sf)
chunhan
parents:
diff changeset
   233
      | _ \<Rightarrow> None)"
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   234
| "co2sobj s (D_msgq q) = 
77
chunhan
parents:
diff changeset
   235
     (case (cq2smsgq s q) of
chunhan
parents:
diff changeset
   236
        Some sq \<Rightarrow> Some (S_msgq sq)
chunhan
parents:
diff changeset
   237
      | _ \<Rightarrow> None)"
chunhan
parents:
diff changeset
   238
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   239
fun dalive :: "t_state \<Rightarrow> t_dobject \<Rightarrow> bool"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   240
where
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   241
  "dalive s (D_proc p) = (p \<in> current_procs s)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   242
| "dalive s (D_file f) = (is_file s f)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   243
| "dalive s (D_dir  f) = (is_dir  s f)"
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   244
| "dalive s (D_msgq q) = (q \<in> current_msgqs s)"
77
chunhan
parents:
diff changeset
   245
chunhan
parents:
diff changeset
   246
definition s2ss :: "t_state \<Rightarrow> t_static_state"
chunhan
parents:
diff changeset
   247
where
92
d9dc04c3ea90 modify co2sobj/s2ss from object to dobject
chunhan
parents: 87
diff changeset
   248
  "s2ss s \<equiv> {sobj. \<exists> obj. dalive s obj \<and> co2sobj s obj = Some sobj}"
77
chunhan
parents:
diff changeset
   249
chunhan
parents:
diff changeset
   250
chunhan
parents:
diff changeset
   251
(* ******************************************************** *)
chunhan
parents:
diff changeset
   252
chunhan
parents:
diff changeset
   253
chunhan
parents:
diff changeset
   254
fun is_init_sfile :: "t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   255
where
chunhan
parents:
diff changeset
   256
  "is_init_sfile (Init _, sec, psec,asec) = True"
chunhan
parents:
diff changeset
   257
| "is_init_sfile _ = False"
chunhan
parents:
diff changeset
   258
chunhan
parents:
diff changeset
   259
fun is_many_sfile :: "t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   260
where
chunhan
parents:
diff changeset
   261
  "is_many_sfile (Created, sec, psec, asec) = True"
chunhan
parents:
diff changeset
   262
| "is_many_sfile _ = False"
chunhan
parents:
diff changeset
   263
chunhan
parents:
diff changeset
   264
fun is_init_sproc :: "t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   265
where
chunhan
parents:
diff changeset
   266
  "is_init_sproc (Init p, sec, fds) = True"
chunhan
parents:
diff changeset
   267
| "is_init_sproc _                        = False"
chunhan
parents:
diff changeset
   268
chunhan
parents:
diff changeset
   269
fun is_many_sproc :: "t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   270
where
chunhan
parents:
diff changeset
   271
  "is_many_sproc (Created, sec,fds) = True"
chunhan
parents:
diff changeset
   272
| "is_many_sproc _                       = False"
chunhan
parents:
diff changeset
   273
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   274
(*
77
chunhan
parents:
diff changeset
   275
fun is_many_smsg :: "t_smsg \<Rightarrow> bool"
chunhan
parents:
diff changeset
   276
where
chunhan
parents:
diff changeset
   277
  "is_many_smsg (Created,sec,tag) = True"
chunhan
parents:
diff changeset
   278
| "is_many_smsg _                 = False"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   279
*)
77
chunhan
parents:
diff changeset
   280
(* wrong def 
chunhan
parents:
diff changeset
   281
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool"
chunhan
parents:
diff changeset
   282
where
chunhan
parents:
diff changeset
   283
  "is_many_smsgq (Created,sec,sms) = (True \<and> (\<forall> sm \<in> (set sms). is_many_smsg sm))"
chunhan
parents:
diff changeset
   284
| "is_many_smsgq _                 = False"
chunhan
parents:
diff changeset
   285
*)
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   286
(*
77
chunhan
parents:
diff changeset
   287
fun is_many_smsgq :: "t_smsgq \<Rightarrow> bool"
chunhan
parents:
diff changeset
   288
where
chunhan
parents:
diff changeset
   289
  "is_many_smsgq (Created,sec,sms) = True"
chunhan
parents:
diff changeset
   290
| "is_many_smsgq _                 = False"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   291
*)
77
chunhan
parents:
diff changeset
   292
(*
chunhan
parents:
diff changeset
   293
fun is_many_sshm :: "t_sshm \<Rightarrow> bool"
chunhan
parents:
diff changeset
   294
where
chunhan
parents:
diff changeset
   295
  "is_many_sshm (Created, sec) = True"
chunhan
parents:
diff changeset
   296
| "is_many_sshm _              = False"
chunhan
parents:
diff changeset
   297
*)
chunhan
parents:
diff changeset
   298
fun is_many :: "t_sobject \<Rightarrow> bool"
chunhan
parents:
diff changeset
   299
where
chunhan
parents:
diff changeset
   300
  "is_many (S_proc sp   tag) = is_many_sproc sp"
chunhan
parents:
diff changeset
   301
| "is_many (S_file sfs  tag) = (\<forall> sf \<in> sfs. is_many_sfile sf)"
chunhan
parents:
diff changeset
   302
| "is_many (S_dir  sf      ) = is_many_sfile sf"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   303
| "is_many (S_msgq sq      ) = True"
77
chunhan
parents:
diff changeset
   304
(*
chunhan
parents:
diff changeset
   305
| "is_many (S_shm  sh      ) = is_many_sshm  sh"
chunhan
parents:
diff changeset
   306
*)
chunhan
parents:
diff changeset
   307
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   308
(*
77
chunhan
parents:
diff changeset
   309
fun is_init_smsgq :: "t_smsgq \<Rightarrow> bool"
chunhan
parents:
diff changeset
   310
where
chunhan
parents:
diff changeset
   311
  "is_init_smsgq (Init q,sec,sms) = True"
chunhan
parents:
diff changeset
   312
| "is_init_smsgq _                = False"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   313
*)
77
chunhan
parents:
diff changeset
   314
(*
chunhan
parents:
diff changeset
   315
fun is_init_sshm :: "t_sshm \<Rightarrow> bool"
chunhan
parents:
diff changeset
   316
where
chunhan
parents:
diff changeset
   317
  "is_init_sshm (Init h,sec) = True"
chunhan
parents:
diff changeset
   318
| "is_init_sshm _            = False"
chunhan
parents:
diff changeset
   319
*)
chunhan
parents:
diff changeset
   320
fun is_init_sobj :: "t_sobject \<Rightarrow> bool"
chunhan
parents:
diff changeset
   321
where
chunhan
parents:
diff changeset
   322
  "is_init_sobj (S_proc sp tag ) = is_init_sproc sp"
chunhan
parents:
diff changeset
   323
| "is_init_sobj (S_file sfs tag) = (\<exists> sf \<in> sfs. is_init_sfile sf)"
chunhan
parents:
diff changeset
   324
| "is_init_sobj (S_dir  sf     ) = is_init_sfile sf"
87
8d18cfc845dd remove init message queue
chunhan
parents: 85
diff changeset
   325
| "is_init_sobj (S_msgq sq     ) = False"
77
chunhan
parents:
diff changeset
   326
(*
chunhan
parents:
diff changeset
   327
| "is_init_sobj (S_shm  sh     ) = is_init_sshm sh"
chunhan
parents:
diff changeset
   328
*)
chunhan
parents:
diff changeset
   329
(*
chunhan
parents:
diff changeset
   330
fun update_ss_sp:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state"
chunhan
parents:
diff changeset
   331
where
chunhan
parents:
diff changeset
   332
  "update_ss_sp ss (S_proc sp tag) (S_proc sp' tag') = 
chunhan
parents:
diff changeset
   333
     (if (is_many_sproc sp) then ss \<union> {S_proc sp' tag'} 
chunhan
parents:
diff changeset
   334
      else (ss - {S_proc sp tag}) \<union> {S_proc sp' tag'})"
chunhan
parents:
diff changeset
   335
chunhan
parents:
diff changeset
   336
fun update_ss_sd:: "t_static_state \<Rightarrow> t_sobject \<Rightarrow> t_sobject \<Rightarrow> t_static_state"
chunhan
parents:
diff changeset
   337
where
chunhan
parents:
diff changeset
   338
  "update_ss_sd ss (S_dir sf tag) (S_dir sf' tag') = 
chunhan
parents:
diff changeset
   339
     (if (is_many_sfile sf) then ss \<union> {S_dir sf' tag'} 
chunhan
parents:
diff changeset
   340
      else (ss - {S_dir sf tag}) \<union> {S_dir sf' tag'})"
chunhan
parents:
diff changeset
   341
*)
chunhan
parents:
diff changeset
   342
chunhan
parents:
diff changeset
   343
(*
chunhan
parents:
diff changeset
   344
fun sparent :: "t_sfile \<Rightarrow> t_sfile option"
chunhan
parents:
diff changeset
   345
where
chunhan
parents:
diff changeset
   346
  "sparent (Sroot si sec) = None"
chunhan
parents:
diff changeset
   347
| "sparent (Sfile si sec spf) = Some spf"
chunhan
parents:
diff changeset
   348
chunhan
parents:
diff changeset
   349
inductive is_ancesf :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool" 
chunhan
parents:
diff changeset
   350
where
chunhan
parents:
diff changeset
   351
  "is_ancesf sf sf"
chunhan
parents:
diff changeset
   352
| "sparent sf = Some spf \<Longrightarrow> is_ancesf spf sf"
chunhan
parents:
diff changeset
   353
| "\<lbrakk>sparent sf = Some spf; is_ancesf saf spf\<rbrakk> \<Longrightarrow> is_ancesf saf sf"
chunhan
parents:
diff changeset
   354
chunhan
parents:
diff changeset
   355
definition sfile_reparent :: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile"
chunhan
parents:
diff changeset
   356
where
chunhan
parents:
diff changeset
   357
  "sfile_reparent (Sroot)"
chunhan
parents:
diff changeset
   358
*)
chunhan
parents:
diff changeset
   359
chunhan
parents:
diff changeset
   360
(*
chunhan
parents:
diff changeset
   361
(* sfds rename aux definitions *)
chunhan
parents:
diff changeset
   362
definition sfds_rename_notrelated 
chunhan
parents:
diff changeset
   363
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   364
where
chunhan
parents:
diff changeset
   365
  "sfds_rename_notrelated sfds from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   366
     (\<forall> sec flag sf. (sec,flag,sf) \<in> sfds \<and> (\<not> from \<preceq> sf) \<longrightarrow> (sec,flag,sf) \<in> sfds')"
chunhan
parents:
diff changeset
   367
chunhan
parents:
diff changeset
   368
definition sfds_rename_renamed
chunhan
parents:
diff changeset
   369
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   370
where
chunhan
parents:
diff changeset
   371
  "sfds_rename_renamed sfds sf from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   372
     (\<forall> sec flag sf'. (sec,flag,sf) \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow>
chunhan
parents:
diff changeset
   373
         (sec, flag, file_after_rename sf' from to) \<in> sfds' \<and> (sec,flag,sf) \<notin> sfds')"
chunhan
parents:
diff changeset
   374
chunhan
parents:
diff changeset
   375
definition sfds_rename_remain
chunhan
parents:
diff changeset
   376
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   377
where
chunhan
parents:
diff changeset
   378
  "sfds_rename_remain sfds sf from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   379
     (\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> 
chunhan
parents:
diff changeset
   380
         (sec, flag, sf') \<in> sfds' \<and> (sec,flag, file_after_rename sf' from to) \<notin> sfds')"
chunhan
parents:
diff changeset
   381
chunhan
parents:
diff changeset
   382
  (* for not many, choose on renamed or not *)
chunhan
parents:
diff changeset
   383
definition sfds_rename_choices
chunhan
parents:
diff changeset
   384
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   385
where
chunhan
parents:
diff changeset
   386
  "sfds_rename_choices sfds sf from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   387
     sfds_rename_remain sfds sf from to sfds' \<or> sfds_rename_renamed sfds sf from to sfds'"
chunhan
parents:
diff changeset
   388
chunhan
parents:
diff changeset
   389
(* for many, merge renamed with not renamed *)
chunhan
parents:
diff changeset
   390
definition sfds_rename_both
chunhan
parents:
diff changeset
   391
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   392
where
chunhan
parents:
diff changeset
   393
  "sfds_rename_both sfds sf from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   394
     (\<forall> sec flag sf'. (sec,flag,sf') \<in> sfds \<and> (sf \<preceq> sf') \<longrightarrow> 
chunhan
parents:
diff changeset
   395
         (sec, flag, sf') \<in> sfds' \<or> (sec,flag, file_after_rename sf' from to) \<in> sfds')"
chunhan
parents:
diff changeset
   396
  
chunhan
parents:
diff changeset
   397
(* added to the new sfds, are those only under the new sfile *)
chunhan
parents:
diff changeset
   398
definition sfds_rename_added
chunhan
parents:
diff changeset
   399
  :: "t_sfd set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   400
where
chunhan
parents:
diff changeset
   401
  "sfds_rename_added sfds from to sfds' \<equiv> 
chunhan
parents:
diff changeset
   402
     (\<forall> sec' flag' sf' sec flag. (sec',flag',sf') \<in> sfds' \<and> (sec,flag,sf') \<notin> sfds \<longrightarrow> 
chunhan
parents:
diff changeset
   403
        (\<exists> sf. (sec,flag,sf) \<in> sfds \<and> sf' = file_after_rename from to sf))"
chunhan
parents:
diff changeset
   404
chunhan
parents:
diff changeset
   405
definition sproc_sfds_renamed
chunhan
parents:
diff changeset
   406
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   407
where
chunhan
parents:
diff changeset
   408
  "sproc_sfds_renamed ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   409
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   410
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_renamed sfds sf from to sfds'))"
chunhan
parents:
diff changeset
   411
chunhan
parents:
diff changeset
   412
definition sproc_sfds_remain
chunhan
parents:
diff changeset
   413
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   414
where
chunhan
parents:
diff changeset
   415
  "sproc_sfds_remain ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   416
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   417
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_remain sfds sf from to sfds'))"
chunhan
parents:
diff changeset
   418
chunhan
parents:
diff changeset
   419
(* for not many, choose on renamed or not *)
chunhan
parents:
diff changeset
   420
definition sproc_sfds_choices
chunhan
parents:
diff changeset
   421
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   422
where
chunhan
parents:
diff changeset
   423
  "sproc_sfds_choices ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   424
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   425
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_choices sfds sf from to sfds'))"
chunhan
parents:
diff changeset
   426
  
chunhan
parents:
diff changeset
   427
(* for many, merge renamed with not renamed *)
chunhan
parents:
diff changeset
   428
definition sproc_sfds_both
chunhan
parents:
diff changeset
   429
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   430
where
chunhan
parents:
diff changeset
   431
  "sproc_sfds_both ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   432
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   433
       (\<exists> sfds'. S_proc (pi,sec,sfds',sshms) tagp \<in> ss \<and> sfds_rename_both sfds sf from to sfds'))"
chunhan
parents:
diff changeset
   434
chunhan
parents:
diff changeset
   435
(* remove (\<forall> sp tag. S_proc sp tag \<in> ss \<longrightarrow> S_proc sp tag \<in> ss'),
chunhan
parents:
diff changeset
   436
 * cause sfds contains sfs informations *)
chunhan
parents:
diff changeset
   437
definition ss_rename_notrelated 
chunhan
parents:
diff changeset
   438
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   439
where
chunhan
parents:
diff changeset
   440
  "ss_rename_notrelated ss sf sf' ss' \<equiv> 
chunhan
parents:
diff changeset
   441
     (\<forall> sq. S_msgq sq \<in> ss \<longrightarrow> S_msgq sq \<in> ss') \<and> 
chunhan
parents:
diff changeset
   442
     (\<forall> pi sec sfds sshms tagp. S_proc (pi,sec,sfds,sshms) tagp \<in> ss \<longrightarrow> (\<exists> sfds'.  
chunhan
parents:
diff changeset
   443
         S_proc (pi,sec,sfds',sshms) tagp \<in> ss'\<and> sfds_rename_notrelated sfds sf sf' sfds'))  \<and>
chunhan
parents:
diff changeset
   444
     (\<forall> sfs sf'' tag. S_file sfs tag \<in> ss \<and> sf'' \<in> sfs \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> (\<exists> sfs'. 
chunhan
parents:
diff changeset
   445
         S_file sfs tag \<in> ss' \<and> sf'' \<in> sfs')) \<and>
chunhan
parents:
diff changeset
   446
     (\<forall> sf'' tag. S_dir sf'' tag \<in> ss \<and> (\<not> sf \<preceq> sf'') \<longrightarrow> S_dir sf'' tag \<in> ss')" 
chunhan
parents:
diff changeset
   447
chunhan
parents:
diff changeset
   448
(* rename from to, from should definited renamed if not many *)
chunhan
parents:
diff changeset
   449
definition all_descendant_sf_renamed 
chunhan
parents:
diff changeset
   450
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   451
where
chunhan
parents:
diff changeset
   452
  "all_descendant_sf_renamed ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   453
     (\<forall> sfs sf' tagf. sf \<preceq> sf' \<and> S_file sfs tagf \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
chunhan
parents:
diff changeset
   454
       S_file sfs' tagf \<in> ss' \<and> file_after_rename from to sf' \<in> sfs' \<and> sf' \<notin> sfs')) \<and> 
chunhan
parents:
diff changeset
   455
     (\<forall> sf' tagf. sf \<preceq> sf' \<and> S_dir sf' tagf \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss') \<and>
chunhan
parents:
diff changeset
   456
     sproc_sfds_renamed ss sf from to ss'"
chunhan
parents:
diff changeset
   457
chunhan
parents:
diff changeset
   458
(* not renamed *)
chunhan
parents:
diff changeset
   459
definition all_descendant_sf_remain
chunhan
parents:
diff changeset
   460
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   461
where
chunhan
parents:
diff changeset
   462
  "all_descendant_sf_remain ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   463
     (\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
chunhan
parents:
diff changeset
   464
       S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<notin> sfs' \<and> sf' \<in> sfs')) \<and> 
chunhan
parents:
diff changeset
   465
     (\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> S_dir (file_after_rename from to sf') tag' \<notin> ss' \<and> S_dir sf' tag' \<in> ss') \<and>
chunhan
parents:
diff changeset
   466
     sproc_sfds_remain ss sf from to ss'"
chunhan
parents:
diff changeset
   467
chunhan
parents:
diff changeset
   468
definition all_descendant_sf_choices
chunhan
parents:
diff changeset
   469
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   470
where
chunhan
parents:
diff changeset
   471
  "all_descendant_sf_choices ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   472
     all_descendant_sf_renamed ss sf from to ss' \<or> all_descendant_sf_remain ss sf from to ss'"
chunhan
parents:
diff changeset
   473
chunhan
parents:
diff changeset
   474
definition all_descendant_sf_both
chunhan
parents:
diff changeset
   475
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   476
where
chunhan
parents:
diff changeset
   477
  "all_descendant_sf_both ss sf from to ss' \<equiv>
chunhan
parents:
diff changeset
   478
     (\<forall> sfs sf' tag'. sf \<preceq> sf' \<and> S_file sfs tag' \<in> ss \<and> sf' \<in> sfs \<longrightarrow> (\<exists> sfs'. 
chunhan
parents:
diff changeset
   479
        S_file sfs' tag' \<in> ss \<and> file_after_rename from to sf' \<in> sfs' \<or> sf' \<in> sfs')) \<and> 
chunhan
parents:
diff changeset
   480
     (\<forall> sf' tag'. sf \<preceq> sf' \<and> S_dir sf' tag' \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   481
        S_dir (file_after_rename from to sf') tag' \<in> ss' \<or> S_dir sf' tag' \<in> ss') \<and>
chunhan
parents:
diff changeset
   482
     sproc_sfds_both ss sf from to ss'"
chunhan
parents:
diff changeset
   483
chunhan
parents:
diff changeset
   484
definition ss_renamed_file 
chunhan
parents:
diff changeset
   485
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   486
where
chunhan
parents:
diff changeset
   487
  "ss_renamed_file ss sf sf' ss' \<equiv> 
chunhan
parents:
diff changeset
   488
     (if (is_many_sfile sf) 
chunhan
parents:
diff changeset
   489
        then all_descendant_sf_choices ss sf sf sf' ss'
chunhan
parents:
diff changeset
   490
        else all_descendant_sf_renamed ss sf sf sf' ss')"
chunhan
parents:
diff changeset
   491
chunhan
parents:
diff changeset
   492
(* added to the new sfs, are those only under the new sfile *)
chunhan
parents:
diff changeset
   493
definition sfs_rename_added
chunhan
parents:
diff changeset
   494
  :: "t_sfile set \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_sfile set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   495
where
chunhan
parents:
diff changeset
   496
  "sfs_rename_added sfs from to sfs' \<equiv> 
chunhan
parents:
diff changeset
   497
     (\<forall> sf'. sf' \<in> sfs' \<and> sf' \<notin> sfs \<longrightarrow> (\<exists> sf. sf \<in> sfs \<and> sf' = file_after_rename from to sf))"
chunhan
parents:
diff changeset
   498
chunhan
parents:
diff changeset
   499
(* added to the new sfile, are those only under the new sfile *)
chunhan
parents:
diff changeset
   500
definition ss_rename_added
chunhan
parents:
diff changeset
   501
  :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   502
where
chunhan
parents:
diff changeset
   503
  "ss_rename_added ss from to ss' \<equiv> 
chunhan
parents:
diff changeset
   504
     (\<forall> pi sec fds fds' shms tagp. S_proc (pi, sec, fds,shms) tagp \<in> ss \<and> 
chunhan
parents:
diff changeset
   505
        S_proc (pi,sec,fds',shms) tagp \<in> ss' \<longrightarrow> sfds_rename_added fds from to fds') \<and>
chunhan
parents:
diff changeset
   506
     (\<forall> sq. S_msgq sq \<in> ss' \<longrightarrow> S_msgq sq \<in> ss) \<and>
chunhan
parents:
diff changeset
   507
     (\<forall> sfs sfs' tagf. S_file sfs' tagf \<in> ss' \<and> S_file sfs tagf \<in> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   508
        sfs_rename_added sfs from to sfs') \<and>
chunhan
parents:
diff changeset
   509
     (\<forall> sf' tagf. S_dir sf' tagf \<in> ss' \<and> S_dir sf' tagf \<notin> ss \<longrightarrow> 
chunhan
parents:
diff changeset
   510
        (\<exists> sf. S_dir sf tagf \<in> ss \<and> sf' = file_after_rename from to sf))" 
chunhan
parents:
diff changeset
   511
chunhan
parents:
diff changeset
   512
definition sfile_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   513
where
chunhan
parents:
diff changeset
   514
  "sfile_alive ss sf \<equiv> (\<exists> sfs tagf. sf \<in> sfs \<and> S_file sfs tagf \<in> ss)"
chunhan
parents:
diff changeset
   515
chunhan
parents:
diff changeset
   516
definition sf_alive :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   517
where
chunhan
parents:
diff changeset
   518
  "sf_alive ss sf \<equiv> (\<exists> tagd. S_dir sf tagd \<in> ss) \<or> sfile_alive ss sf"
chunhan
parents:
diff changeset
   519
chunhan
parents:
diff changeset
   520
(* constrains that the new static state should satisfy *)
chunhan
parents:
diff changeset
   521
definition ss_rename:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state \<Rightarrow> bool"
chunhan
parents:
diff changeset
   522
where
chunhan
parents:
diff changeset
   523
  "ss_rename ss sf sf' ss' \<equiv> 
chunhan
parents:
diff changeset
   524
     ss_rename_notrelated ss sf sf' ss' \<and>
chunhan
parents:
diff changeset
   525
     ss_renamed_file ss sf sf' ss' \<and> ss_rename_added ss sf sf' ss' \<and>
chunhan
parents:
diff changeset
   526
     (\<forall> sf''. sf_alive ss sf'' \<and> sf \<prec> sf'' \<longrightarrow> 
chunhan
parents:
diff changeset
   527
       (if (is_many_sfile sf'') 
chunhan
parents:
diff changeset
   528
        then all_descendant_sf_choices ss sf'' sf sf' ss'
chunhan
parents:
diff changeset
   529
        else all_descendant_sf_both ss sf'' sf sf' ss'))"
chunhan
parents:
diff changeset
   530
chunhan
parents:
diff changeset
   531
(* two sfile, the last fname should not be equal *)
chunhan
parents:
diff changeset
   532
fun sfile_same_fname:: "t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   533
where
chunhan
parents:
diff changeset
   534
  "sfile_same_fname ((Init n, sec)#spf) ((Init n', sec')#spf') = (n = n')"
chunhan
parents:
diff changeset
   535
| "sfile_same_fname _                   _                      = False"
chunhan
parents:
diff changeset
   536
chunhan
parents:
diff changeset
   537
(* no same init sfile/only sfile in the target-to spf, should be in static_state addmissble check *)
chunhan
parents:
diff changeset
   538
definition ss_rename_no_same_fname:: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> bool"
chunhan
parents:
diff changeset
   539
where
chunhan
parents:
diff changeset
   540
  "ss_rename_no_same_fname ss from spf \<equiv>
chunhan
parents:
diff changeset
   541
    \<not> (\<exists> to. sfile_same_fname from to \<and> parent to = Some spf \<and> sf_alive ss to)" 
chunhan
parents:
diff changeset
   542
chunhan
parents:
diff changeset
   543
(* is not a function, is a relation (one 2 many)
chunhan
parents:
diff changeset
   544
definition update_ss_rename :: "t_static_state \<Rightarrow> t_sfile \<Rightarrow> t_sfile \<Rightarrow> t_static_state"
chunhan
parents:
diff changeset
   545
where
chunhan
parents:
diff changeset
   546
  "update_ss_rename ss sf sf' \<equiv> if (is_many_sfile sf) 
chunhan
parents:
diff changeset
   547
     then (ss \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
chunhan
parents:
diff changeset
   548
              \<union> {S_dir  (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss})
chunhan
parents:
diff changeset
   549
     else (ss - {S_file sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
chunhan
parents:
diff changeset
   550
              - {S_dir  sf'' tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss})
chunhan
parents:
diff changeset
   551
              \<union> {S_file (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_file sf'' tag \<in> ss}
chunhan
parents:
diff changeset
   552
              \<union> {S_dir  (file_after_rename sf sf' sf'') tag | sf'' tag. sf \<preceq> sf'' \<and> S_dir sf'' tag \<in> ss}" 
chunhan
parents:
diff changeset
   553
*)
chunhan
parents:
diff changeset
   554
*)
chunhan
parents:
diff changeset
   555
chunhan
parents:
diff changeset
   556
fun sectxt_of_sproc :: "t_sproc \<Rightarrow> security_context_t"
chunhan
parents:
diff changeset
   557
where
chunhan
parents:
diff changeset
   558
  "sectxt_of_sproc (pi,sec,fds) = sec"
chunhan
parents:
diff changeset
   559
chunhan
parents:
diff changeset
   560
fun sectxt_of_sfile :: "t_sfile \<Rightarrow> security_context_t"
chunhan
parents:
diff changeset
   561
where
chunhan
parents:
diff changeset
   562
  "sectxt_of_sfile (fi,sec,psec,asecs) = sec"
chunhan
parents:
diff changeset
   563
chunhan
parents:
diff changeset
   564
fun asecs_of_sfile :: "t_sfile \<Rightarrow> security_context_t set"
chunhan
parents:
diff changeset
   565
where
chunhan
parents:
diff changeset
   566
  "asecs_of_sfile (fi,sec,psec,asecs) = asecs"
chunhan
parents:
diff changeset
   567
chunhan
parents:
diff changeset
   568
definition search_check_s :: "security_context_t \<Rightarrow> t_sfile \<Rightarrow> bool \<Rightarrow> bool"
chunhan
parents:
diff changeset
   569
where
chunhan
parents:
diff changeset
   570
  "search_check_s pctxt sf if_file = 
chunhan
parents:
diff changeset
   571
    (if if_file 
chunhan
parents:
diff changeset
   572
      then search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) True
chunhan
parents:
diff changeset
   573
      else search_check_ctxt pctxt (sectxt_of_sfile sf) (asecs_of_sfile sf) False)"
chunhan
parents:
diff changeset
   574
chunhan
parents:
diff changeset
   575
definition sectxts_of_sfds :: "t_sfd set \<Rightarrow> security_context_t set"
chunhan
parents:
diff changeset
   576
where
chunhan
parents:
diff changeset
   577
  "sectxts_of_sfds sfds \<equiv> {ctxt. \<exists> flag sf. (ctxt, flag, sf) \<in> sfds}"
chunhan
parents:
diff changeset
   578
chunhan
parents:
diff changeset
   579
definition inherit_fds_check_s :: "security_context_t \<Rightarrow> t_sfd set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   580
where
chunhan
parents:
diff changeset
   581
  "inherit_fds_check_s pctxt sfds \<equiv> inherit_fds_check_ctxt pctxt (sectxts_of_sfds sfds)"
chunhan
parents:
diff changeset
   582
chunhan
parents:
diff changeset
   583
(*
chunhan
parents:
diff changeset
   584
definition sectxts_of_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> security_context_t set"
chunhan
parents:
diff changeset
   585
where
chunhan
parents:
diff changeset
   586
  "sectxts_of_sproc_sshms sshms \<equiv> {ctxt. \<exists> hi flag. ((hi, ctxt),flag) \<in> sshms}"
chunhan
parents:
diff changeset
   587
chunhan
parents:
diff changeset
   588
definition inherit_shms_check_s :: "security_context_t \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   589
where
chunhan
parents:
diff changeset
   590
  "inherit_shms_check_s pctxt sshms \<equiv> inherit_shms_check_ctxt pctxt (sectxts_of_sproc_sshms sshms)"
chunhan
parents:
diff changeset
   591
chunhan
parents:
diff changeset
   592
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   593
where
chunhan
parents:
diff changeset
   594
  "info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = 
chunhan
parents:
diff changeset
   595
     (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" 
chunhan
parents:
diff changeset
   596
chunhan
parents:
diff changeset
   597
definition info_flow_sproc_sshms :: "t_sproc_sshm set \<Rightarrow> t_sproc_sshm set \<Rightarrow> bool"
chunhan
parents:
diff changeset
   598
where
chunhan
parents:
diff changeset
   599
  "info_flow_sproc_sshms shms shms' \<equiv> (\<exists> sh flag'. (sh, SHM_RDWR) \<in> shms \<and> (sh, flag') \<in> shms')" 
chunhan
parents:
diff changeset
   600
chunhan
parents:
diff changeset
   601
chunhan
parents:
diff changeset
   602
fun info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   603
where
chunhan
parents:
diff changeset
   604
  "info_flow_sshm (pi,sec,fds,shms) (pi',sec',fds',shms') = info_flow_sproc_sshms shms shms'"
chunhan
parents:
diff changeset
   605
chunhan
parents:
diff changeset
   606
inductive info_flow_sshm :: "t_sproc \<Rightarrow> t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   607
where
chunhan
parents:
diff changeset
   608
  "info_flow_sshm sp sp"
chunhan
parents:
diff changeset
   609
| "\<lbrakk>info_flow_sshm sp (pi,sec,fds,shms); info_flow_sproc_sshms shms shms'\<rbrakk>
chunhan
parents:
diff changeset
   610
   \<Longrightarrow> info_flow_sshm sp (pi',sec',fds',shms')"
chunhan
parents:
diff changeset
   611
*)
chunhan
parents:
diff changeset
   612
chunhan
parents:
diff changeset
   613
(*
chunhan
parents:
diff changeset
   614
fun smsg_related :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool" 
chunhan
parents:
diff changeset
   615
where
chunhan
parents:
diff changeset
   616
  "smsg_related m []                   = False" 
chunhan
parents:
diff changeset
   617
| "smsg_related m ((mi, sec, tag)#sms) =  
chunhan
parents:
diff changeset
   618
    (if (mi = Init m) then True else smsg_related m sms)" 
chunhan
parents:
diff changeset
   619
chunhan
parents:
diff changeset
   620
fun smsgq_smsg_related :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool"
chunhan
parents:
diff changeset
   621
where
chunhan
parents:
diff changeset
   622
  "smsgq_smsg_related q m (qi, sec, smsgslist) = ((qi = Init q) \<and> (smsg_related m smsgslist))"
chunhan
parents:
diff changeset
   623
chunhan
parents:
diff changeset
   624
fun smsg_relatainted :: "t_msg \<Rightarrow> t_smsg list \<Rightarrow> bool"
chunhan
parents:
diff changeset
   625
where
chunhan
parents:
diff changeset
   626
  "smsg_relatainted m []                     = False"
chunhan
parents:
diff changeset
   627
| "smsg_relatainted m ((mi, sec, tag)#sms) = 
chunhan
parents:
diff changeset
   628
    (if (mi = Init m \<and> tag = True) then True else smsg_relatainted m sms)"
chunhan
parents:
diff changeset
   629
chunhan
parents:
diff changeset
   630
fun smsgq_smsg_relatainted :: "t_msgq \<Rightarrow> t_msg \<Rightarrow> t_smsgq \<Rightarrow> bool"
chunhan
parents:
diff changeset
   631
where
chunhan
parents:
diff changeset
   632
  "smsgq_smsg_relatainted q m (qi, sec, smsgslist) = 
chunhan
parents:
diff changeset
   633
     ((qi = Init q) \<and> (smsg_relatainted m smsgslist))"
chunhan
parents:
diff changeset
   634
*)
chunhan
parents:
diff changeset
   635
chunhan
parents:
diff changeset
   636
fun sfile_related :: "t_sfile \<Rightarrow> t_file \<Rightarrow> bool"
chunhan
parents:
diff changeset
   637
where
chunhan
parents:
diff changeset
   638
  "sfile_related (fi,sec,psec,asecs) f = (fi = Init f)"
chunhan
parents:
diff changeset
   639
(*
chunhan
parents:
diff changeset
   640
fun sproc_related :: "t_process \<Rightarrow> t_sproc \<Rightarrow> bool"
chunhan
parents:
diff changeset
   641
where
chunhan
parents:
diff changeset
   642
  "sproc_related p (pi, sec, fds, shms) = (pi = Init p)"
chunhan
parents:
diff changeset
   643
*)
chunhan
parents:
diff changeset
   644
fun init_obj_related :: "t_sobject \<Rightarrow> t_object \<Rightarrow> bool"
chunhan
parents:
diff changeset
   645
where
chunhan
parents:
diff changeset
   646
  "init_obj_related (S_proc (pi, sec, fds) tag) (O_proc p') = (pi = Init p')"
chunhan
parents:
diff changeset
   647
| "init_obj_related (S_file sfs tag) (O_file f) = (\<exists> sf \<in> sfs. sfile_related sf f)"
chunhan
parents:
diff changeset
   648
| "init_obj_related (S_dir sf) (O_dir f) = (sfile_related sf f)"
chunhan
parents:
diff changeset
   649
(*
chunhan
parents:
diff changeset
   650
| "init_obj_related (S_shm (hi, sec)) (O_shm h') = (hi = Init h')"
chunhan
parents:
diff changeset
   651
chunhan
parents:
diff changeset
   652
| "init_obj_related (S_msg (qi, sec, sms) (mi, secm, tagm)) (O_msg q' m') = (qi = Init q' \<and> mi = Init m')"
chunhan
parents:
diff changeset
   653
*)
chunhan
parents:
diff changeset
   654
| "init_obj_related _ _ = False"
chunhan
parents:
diff changeset
   655
chunhan
parents:
diff changeset
   656
chunhan
parents:
diff changeset
   657
chunhan
parents:
diff changeset
   658
(***************** for backward proof when Instancing static objects ******************)
chunhan
parents:
diff changeset
   659
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   660
(*
77
chunhan
parents:
diff changeset
   661
fun all_procs :: "t_state \<Rightarrow> t_process set"
chunhan
parents:
diff changeset
   662
where
chunhan
parents:
diff changeset
   663
  "all_procs [] = init_procs"
chunhan
parents:
diff changeset
   664
| "all_procs (Clone p p' fds # s) = insert p' (all_procs s)"
chunhan
parents:
diff changeset
   665
| "all_procs (e # s) = all_procs s"
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   666
*)
77
chunhan
parents:
diff changeset
   667
chunhan
parents:
diff changeset
   668
definition next_nat :: "nat set \<Rightarrow> nat"
chunhan
parents:
diff changeset
   669
where
chunhan
parents:
diff changeset
   670
  "next_nat nset = (Max nset) + 1"
chunhan
parents:
diff changeset
   671
chunhan
parents:
diff changeset
   672
definition new_proc :: "t_state \<Rightarrow> t_process"
chunhan
parents:
diff changeset
   673
where 
chunhan
parents:
diff changeset
   674
  "new_proc \<tau> = next_nat (current_procs \<tau>)"
chunhan
parents:
diff changeset
   675
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   676
(*
77
chunhan
parents:
diff changeset
   677
definition brandnew_proc :: "t_state \<Rightarrow> t_process"
chunhan
parents:
diff changeset
   678
where
chunhan
parents:
diff changeset
   679
  "brandnew_proc s \<equiv> next_nat (all_procs s)"
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   680
*)
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   681
77
chunhan
parents:
diff changeset
   682
chunhan
parents:
diff changeset
   683
definition new_inode_num :: "t_state \<Rightarrow> nat"
chunhan
parents:
diff changeset
   684
where
chunhan
parents:
diff changeset
   685
  "new_inode_num \<tau> = next_nat (current_inode_nums \<tau>)"
chunhan
parents:
diff changeset
   686
chunhan
parents:
diff changeset
   687
definition new_msgq :: "t_state \<Rightarrow> t_msgq"
chunhan
parents:
diff changeset
   688
where
chunhan
parents:
diff changeset
   689
  "new_msgq s = next_nat (current_msgqs s)"
chunhan
parents:
diff changeset
   690
chunhan
parents:
diff changeset
   691
definition new_msg :: "t_state \<Rightarrow> t_msgq \<Rightarrow> nat"
chunhan
parents:
diff changeset
   692
where
chunhan
parents:
diff changeset
   693
  "new_msg s q = next_nat (set (msgs_of_queue s q))"
chunhan
parents:
diff changeset
   694
chunhan
parents:
diff changeset
   695
(*
chunhan
parents:
diff changeset
   696
definition new_shm :: "t_state \<Rightarrow> nat"
chunhan
parents:
diff changeset
   697
where
chunhan
parents:
diff changeset
   698
  "new_shm \<tau> = next_nat (current_shms \<tau>)"
chunhan
parents:
diff changeset
   699
*)
chunhan
parents:
diff changeset
   700
chunhan
parents:
diff changeset
   701
definition new_proc_fd :: "t_state \<Rightarrow> t_process \<Rightarrow> t_fd"
chunhan
parents:
diff changeset
   702
where
chunhan
parents:
diff changeset
   703
  "new_proc_fd \<tau> p = next_nat (current_proc_fds \<tau> p)"
chunhan
parents:
diff changeset
   704
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   705
definition all_fname_under_dir:: "t_file \<Rightarrow> t_file set \<Rightarrow> t_fname set"
77
chunhan
parents:
diff changeset
   706
where
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   707
  "all_fname_under_dir d fs = {fn. fn # d \<in> fs}"
77
chunhan
parents:
diff changeset
   708
chunhan
parents:
diff changeset
   709
fun fname_all_a:: "nat \<Rightarrow> t_fname"
chunhan
parents:
diff changeset
   710
where
chunhan
parents:
diff changeset
   711
  "fname_all_a 0 = []" |
chunhan
parents:
diff changeset
   712
  "fname_all_a (Suc n) = ''a''@(fname_all_a n)"
chunhan
parents:
diff changeset
   713
chunhan
parents:
diff changeset
   714
definition fname_length_set :: "t_fname set \<Rightarrow> nat set"
chunhan
parents:
diff changeset
   715
where
chunhan
parents:
diff changeset
   716
  "fname_length_set fns = length`fns"
chunhan
parents:
diff changeset
   717
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   718
definition next_fname:: "t_file \<Rightarrow> t_file set \<Rightarrow> t_fname"
77
chunhan
parents:
diff changeset
   719
where
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   720
  "next_fname pf fs = fname_all_a ((Max (fname_length_set (all_fname_under_dir pf fs))) + 1)"
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   721
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   722
definition new_childf_general:: "t_file \<Rightarrow> t_file set \<Rightarrow> t_file"
93
dfde07c7cd6b new_childf generalized
chunhan
parents: 92
diff changeset
   723
where
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   724
  "new_childf_general pf fs = next_fname pf fs # pf"
77
chunhan
parents:
diff changeset
   725
chunhan
parents:
diff changeset
   726
definition new_childf:: "t_file \<Rightarrow> t_state \<Rightarrow> t_file"
chunhan
parents:
diff changeset
   727
where
94
042e1e7fd505 new childf new-version
chunhan
parents: 93
diff changeset
   728
  "new_childf pf \<tau> = new_childf_general pf (current_files \<tau>)"
77
chunhan
parents:
diff changeset
   729
chunhan
parents:
diff changeset
   730
end
chunhan
parents:
diff changeset
   731
chunhan
parents:
diff changeset
   732
end