diff -r 924ab7a4e7fa -r 271e9818b6f6 simple_selinux/Finite_current.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simple_selinux/Finite_current.thy Mon Dec 02 10:52:40 2013 +0800 @@ -0,0 +1,108 @@ +theory Finite_current +imports Main Valid_prop Flask Flask_type Proc_fd_of_file_prop +begin + +context flask begin + +lemma finite_cf: "valid \ \ finite (current_files \)" +apply (induct \) +apply (simp add:current_files_def inum_of_file.simps) +apply (rule_tac B = "init_files" in finite_subset) +apply (clarsimp dest!:inof_has_file_tag, simp add:init_finite_sets) + +apply (frule vt_grant_os, frule vd_cons, simp, case_tac a) + +apply (auto simp:current_files_def os_grant.simps inum_of_file.simps split:if_splits option.splits) +apply (rule_tac B = "insert list {f. \i. inum_of_file \ f = Some i}" in finite_subset, clarsimp, simp) +apply (rule_tac B = "{f. \i. inum_of_file \ f = Some i}" in finite_subset, clarsimp, simp) +apply (rule_tac B = "{f. \i. inum_of_file \ f = Some i}" in finite_subset, clarsimp, simp) +apply (rule_tac B = "{f. \i. inum_of_file \ f = Some i}" in finite_subset, clarsimp, simp) +apply (rule_tac B = "insert list {f. \i. inum_of_file \ f = Some i}" in finite_subset, clarsimp, simp) +done + +lemma finite_cp: "finite (current_procs \)" +apply (induct \) +apply (simp add:current_procs.simps init_finite_sets) +apply (case_tac a, auto simp:current_procs.simps) +done + +lemma finite_cfd: "valid \ \ finite (current_proc_fds \ p)" +apply (induct \ arbitrary:p) +apply (simp add:current_proc_fds.simps init_finite_sets) +apply (frule vd_cons, frule vt_grant_os, case_tac a, auto simp:current_proc_fds.simps) +apply (erule finite_subset) +apply (frule_tac s = \ and p = nat in file_fds_subset_pfds) +apply (erule finite_subset, simp) +apply (erule finite_subset) +apply (frule_tac s = \ and p = nat1 in file_fds_subset_pfds) +apply (erule finite_subset, simp) +done + +lemma finite_pair: "\finite A; finite B\ \ finite {(x, y). x \ A \ y \ B}" +by auto + +lemma finite_UN_I': "\finite X; \ x. x \ X \ finite (f x)\ \ finite {(x, y). x \ X \ y \ f x}" +apply (frule_tac B = f in finite_UN_I, simp) +apply (drule_tac finite_pair, simp) +apply (rule_tac B = "{(x, y). x \ X \ y \ (\a\X. f a)}" in finite_subset, auto) +done + +lemma finite_init_netobjs: "finite init_sockets" +apply (subgoal_tac "finite {(p, fd). p \ init_procs \ fd \ init_fds_of_proc p}") +apply (rule_tac B = "{(p, fd). p \ init_procs \ fd \ init_fds_of_proc p}" in finite_subset) +apply (clarsimp dest!:init_socket_has_inode, simp) +using init_finite_sets finite_UN_I' +by (metis Collect_mem_eq SetCompr_Sigma_eq internal_split_def) + +lemma finite_cn_aux: "valid \ \ finite {s. \i. inum_of_socket \ s = Some i}" +apply (induct \) +apply (rule_tac B = "init_sockets" in finite_subset) +apply (clarsimp simp:inum_of_socket.simps dest!:inos_has_sock_tag, simp add:finite_init_netobjs) + +apply (frule vd_cons, frule vt_grant_os, simp, case_tac a) +apply (auto split:option.splits if_splits) +apply (rule_tac B = "{s. \i. inum_of_socket \ s = Some i}" in finite_subset, clarsimp split:if_splits, simp) +apply (rule_tac B = "{s. \i. inum_of_socket \ s = Some i} \ {(p, fd). \ i. inum_of_socket \ (nat1, fd) = Some i \ p = nat2 \ fd \ set}" in finite_subset, clarsimp split:if_splits) +apply (simp only:finite_Un, rule conjI, simp) +apply (rule_tac B = "{(p, fd). \ i. inum_of_socket \ (nat1, fd) = Some i \ p = nat2}" in finite_subset, clarsimp) +apply (drule_tac h = "\ (p, fd). if (p = nat1) then (nat2, fd) else (p, fd)" in finite_imageI) +apply (rule_tac B = "((\(p, fd). if p = nat1 then (nat2, fd) else (p, fd)) ` {a. \i. inum_of_socket \ a = Some i})" in finite_subset) +apply (rule subsetI,erule CollectE, case_tac x, simp, (erule exE|erule conjE)+) +unfolding image_def +apply (rule CollectI, rule_tac x = "(nat1, b)" in bexI, simp+) +apply (rule_tac B = "{s. \i. inum_of_socket \ s = Some i}" in finite_subset, clarsimp split:if_splits, simp)+ +apply (rule_tac B = "insert (nat1, nat2) {s. \i. inum_of_socket \ s = Some i}" in finite_subset, clarsimp, simp) +apply (rule_tac B = "insert (nat1, nat4) {s. \i. inum_of_socket \ s = Some i}" in finite_subset, clarsimp, simp) +done + +lemma finite_cn: "valid \ \ finite (current_sockets \)" +apply (simp add:current_sockets_def inum_of_socket.simps) +using finite_cn_aux[where \ = \] by auto + +lemma finite_cm: "finite (current_msgqs \)" +apply (induct \) defer +apply (case_tac a, auto simp: init_finite_sets) +done + + +lemma finite_option: "finite {x. \ y. f x = Some y} \ finite {y. \ x. f x = Some y}" +apply (drule_tac h = f in finite_imageI) +apply (clarsimp simp only:image_def) +apply (rule_tac f = Some in finite_imageD) +apply (rule_tac B = "{y. \x. (\y. f x = Some y) \ y = f x}" in finite_subset) +unfolding image_def +apply auto +done + +lemma finite_ci: "valid \ \ finite (current_inode_nums \)" +apply (simp add:current_inode_nums_def current_file_inums_def current_sock_inums_def) +apply (rule conjI, drule finite_cf, simp add:current_files_def, erule finite_option) +using finite_cn[where \ = \] +apply (simp add:current_sockets_def, drule_tac finite_option, simp) +done + +end + +end + +