src/HOL/Predicate.thy
changeset 44363 53f4f8287606
parent 44033 bc45393f497b
child 44414 fb25c131bd73
equal deleted inserted replaced
44353:02f286491568 44363:53f4f8287606
    22   "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
    22   "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
    23   "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
    23   "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
    24 
    24 
    25 
    25 
    26 subsection {* Predicates as (complete) lattices *}
    26 subsection {* Predicates as (complete) lattices *}
    27 
       
    28 
    27 
    29 text {*
    28 text {*
    30   Handy introduction and elimination rules for @{text "\<le>"}
    29   Handy introduction and elimination rules for @{text "\<le>"}
    31   on unary and binary predicates
    30   on unary and binary predicates
    32 *}
    31 *}
   420   by (cases x) simp
   419   by (cases x) simp
   421 
   420 
   422 lemma pred_eqI:
   421 lemma pred_eqI:
   423   "(\<And>w. eval P w \<longleftrightarrow> eval Q w) \<Longrightarrow> P = Q"
   422   "(\<And>w. eval P w \<longleftrightarrow> eval Q w) \<Longrightarrow> P = Q"
   424   by (cases P, cases Q) (auto simp add: fun_eq_iff)
   423   by (cases P, cases Q) (auto simp add: fun_eq_iff)
   425 
       
   426 lemma eval_mem [simp]:
       
   427   "x \<in> eval P \<longleftrightarrow> eval P x"
       
   428   by (simp add: mem_def)
       
   429 
       
   430 lemma eq_mem [simp]:
       
   431   "x \<in> (op =) y \<longleftrightarrow> x = y"
       
   432   by (auto simp add: mem_def)
       
   433 
   424 
   434 instantiation pred :: (type) complete_lattice
   425 instantiation pred :: (type) complete_lattice
   435 begin
   426 begin
   436 
   427 
   437 definition
   428 definition
   796 
   787 
   797 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a pred \<Rightarrow> 'b pred" where
   788 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a pred \<Rightarrow> 'b pred" where
   798   "map f P = P \<guillemotright>= (single o f)"
   789   "map f P = P \<guillemotright>= (single o f)"
   799 
   790 
   800 lemma eval_map [simp]:
   791 lemma eval_map [simp]:
   801   "eval (map f P) = image f (eval P)"
   792   "eval (map f P) = (\<Squnion>x\<in>{x. eval P x}. (\<lambda>y. f x = y))"
   802   by (auto simp add: map_def)
   793   by (auto simp add: map_def)
   803 
   794 
   804 enriched_type map: map
   795 enriched_type map: map
   805   by (auto intro!: pred_eqI simp add: fun_eq_iff image_compose)
   796   by (rule ext, rule pred_eqI, auto)+
   806 
   797 
   807 
   798 
   808 subsubsection {* Implementation *}
   799 subsubsection {* Implementation *}
   809 
   800 
   810 datatype 'a seq = Empty | Insert "'a" "'a pred" | Join "'a pred" "'a seq"
   801 datatype 'a seq = Empty | Insert "'a" "'a pred" | Join "'a pred" "'a seq"
  1038 fun yieldn P = anamorph yield P;
  1029 fun yieldn P = anamorph yield P;
  1039 
  1030 
  1040 end;
  1031 end;
  1041 *}
  1032 *}
  1042 
  1033 
       
  1034 lemma eval_mem [simp]:
       
  1035   "x \<in> eval P \<longleftrightarrow> eval P x"
       
  1036   by (simp add: mem_def)
       
  1037 
       
  1038 lemma eq_mem [simp]:
       
  1039   "x \<in> (op =) y \<longleftrightarrow> x = y"
       
  1040   by (auto simp add: mem_def)
       
  1041 
  1043 no_notation
  1042 no_notation
  1044   bot ("\<bottom>") and
  1043   bot ("\<bottom>") and
  1045   top ("\<top>") and
  1044   top ("\<top>") and
  1046   inf (infixl "\<sqinter>" 70) and
  1045   inf (infixl "\<sqinter>" 70) and
  1047   sup (infixl "\<squnion>" 65) and
  1046   sup (infixl "\<squnion>" 65) and