src/HOL/Predicate.thy
author haftmann
Tue Jan 11 14:12:37 2011 +0100 (2011-01-11)
changeset 41505 6d19301074cf
parent 41372 551eb49a6e91
child 41550 efa734d9b221
permissions -rw-r--r--
"enriched_type" replaces less specific "type_lifting"
     1 (*  Title:      HOL/Predicate.thy
     2     Author:     Stefan Berghofer and Lukas Bulwahn and Florian Haftmann, TU Muenchen
     3 *)
     4 
     5 header {* Predicates as relations and enumerations *}
     6 
     7 theory Predicate
     8 imports Inductive Relation
     9 begin
    10 
    11 notation
    12   bot ("\<bottom>") and
    13   top ("\<top>") and
    14   inf (infixl "\<sqinter>" 70) and
    15   sup (infixl "\<squnion>" 65) and
    16   Inf ("\<Sqinter>_" [900] 900) and
    17   Sup ("\<Squnion>_" [900] 900)
    18 
    19 syntax (xsymbols)
    20   "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
    21   "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 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)
    24 
    25 
    26 subsection {* Predicates as (complete) lattices *}
    27 
    28 
    29 text {*
    30   Handy introduction and elimination rules for @{text "\<le>"}
    31   on unary and binary predicates
    32 *}
    33 
    34 lemma predicate1I:
    35   assumes PQ: "\<And>x. P x \<Longrightarrow> Q x"
    36   shows "P \<le> Q"
    37   apply (rule le_funI)
    38   apply (rule le_boolI)
    39   apply (rule PQ)
    40   apply assumption
    41   done
    42 
    43 lemma predicate1D [Pure.dest?, dest?]:
    44   "P \<le> Q \<Longrightarrow> P x \<Longrightarrow> Q x"
    45   apply (erule le_funE)
    46   apply (erule le_boolE)
    47   apply assumption+
    48   done
    49 
    50 lemma rev_predicate1D:
    51   "P x ==> P <= Q ==> Q x"
    52   by (rule predicate1D)
    53 
    54 lemma predicate2I [Pure.intro!, intro!]:
    55   assumes PQ: "\<And>x y. P x y \<Longrightarrow> Q x y"
    56   shows "P \<le> Q"
    57   apply (rule le_funI)+
    58   apply (rule le_boolI)
    59   apply (rule PQ)
    60   apply assumption
    61   done
    62 
    63 lemma predicate2D [Pure.dest, dest]:
    64   "P \<le> Q \<Longrightarrow> P x y \<Longrightarrow> Q x y"
    65   apply (erule le_funE)+
    66   apply (erule le_boolE)
    67   apply assumption+
    68   done
    69 
    70 lemma rev_predicate2D:
    71   "P x y ==> P <= Q ==> Q x y"
    72   by (rule predicate2D)
    73 
    74 
    75 subsubsection {* Equality *}
    76 
    77 lemma pred_equals_eq: "((\<lambda>x. x \<in> R) = (\<lambda>x. x \<in> S)) = (R = S)"
    78   by (simp add: mem_def)
    79 
    80 lemma pred_equals_eq2 [pred_set_conv]: "((\<lambda>x y. (x, y) \<in> R) = (\<lambda>x y. (x, y) \<in> S)) = (R = S)"
    81   by (simp add: fun_eq_iff mem_def)
    82 
    83 
    84 subsubsection {* Order relation *}
    85 
    86 lemma pred_subset_eq: "((\<lambda>x. x \<in> R) <= (\<lambda>x. x \<in> S)) = (R <= S)"
    87   by (simp add: mem_def)
    88 
    89 lemma pred_subset_eq2 [pred_set_conv]: "((\<lambda>x y. (x, y) \<in> R) <= (\<lambda>x y. (x, y) \<in> S)) = (R <= S)"
    90   by fast
    91 
    92 
    93 subsubsection {* Top and bottom elements *}
    94 
    95 lemma bot1E [no_atp, elim!]: "bot x \<Longrightarrow> P"
    96   by (simp add: bot_fun_def bot_bool_def)
    97 
    98 lemma bot2E [elim!]: "bot x y \<Longrightarrow> P"
    99   by (simp add: bot_fun_def bot_bool_def)
   100 
   101 lemma bot_empty_eq: "bot = (\<lambda>x. x \<in> {})"
   102   by (auto simp add: fun_eq_iff)
   103 
   104 lemma bot_empty_eq2: "bot = (\<lambda>x y. (x, y) \<in> {})"
   105   by (auto simp add: fun_eq_iff)
   106 
   107 lemma top1I [intro!]: "top x"
   108   by (simp add: top_fun_def top_bool_def)
   109 
   110 lemma top2I [intro!]: "top x y"
   111   by (simp add: top_fun_def top_bool_def)
   112 
   113 
   114 subsubsection {* Binary intersection *}
   115 
   116 lemma inf1I [intro!]: "A x ==> B x ==> inf A B x"
   117   by (simp add: inf_fun_def inf_bool_def)
   118 
   119 lemma inf2I [intro!]: "A x y ==> B x y ==> inf A B x y"
   120   by (simp add: inf_fun_def inf_bool_def)
   121 
   122 lemma inf1E [elim!]: "inf A B x ==> (A x ==> B x ==> P) ==> P"
   123   by (simp add: inf_fun_def inf_bool_def)
   124 
   125 lemma inf2E [elim!]: "inf A B x y ==> (A x y ==> B x y ==> P) ==> P"
   126   by (simp add: inf_fun_def inf_bool_def)
   127 
   128 lemma inf1D1: "inf A B x ==> A x"
   129   by (simp add: inf_fun_def inf_bool_def)
   130 
   131 lemma inf2D1: "inf A B x y ==> A x y"
   132   by (simp add: inf_fun_def inf_bool_def)
   133 
   134 lemma inf1D2: "inf A B x ==> B x"
   135   by (simp add: inf_fun_def inf_bool_def)
   136 
   137 lemma inf2D2: "inf A B x y ==> B x y"
   138   by (simp add: inf_fun_def inf_bool_def)
   139 
   140 lemma inf_Int_eq: "inf (\<lambda>x. x \<in> R) (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<inter> S)"
   141   by (simp add: inf_fun_def inf_bool_def mem_def)
   142 
   143 lemma inf_Int_eq2 [pred_set_conv]: "inf (\<lambda>x y. (x, y) \<in> R) (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<inter> S)"
   144   by (simp add: inf_fun_def inf_bool_def mem_def)
   145 
   146 
   147 subsubsection {* Binary union *}
   148 
   149 lemma sup1I1 [elim?]: "A x \<Longrightarrow> sup A B x"
   150   by (simp add: sup_fun_def sup_bool_def)
   151 
   152 lemma sup2I1 [elim?]: "A x y \<Longrightarrow> sup A B x y"
   153   by (simp add: sup_fun_def sup_bool_def)
   154 
   155 lemma sup1I2 [elim?]: "B x \<Longrightarrow> sup A B x"
   156   by (simp add: sup_fun_def sup_bool_def)
   157 
   158 lemma sup2I2 [elim?]: "B x y \<Longrightarrow> sup A B x y"
   159   by (simp add: sup_fun_def sup_bool_def)
   160 
   161 lemma sup1E [elim!]: "sup A B x ==> (A x ==> P) ==> (B x ==> P) ==> P"
   162   by (simp add: sup_fun_def sup_bool_def) iprover
   163 
   164 lemma sup2E [elim!]: "sup A B x y ==> (A x y ==> P) ==> (B x y ==> P) ==> P"
   165   by (simp add: sup_fun_def sup_bool_def) iprover
   166 
   167 text {*
   168   \medskip Classical introduction rule: no commitment to @{text A} vs
   169   @{text B}.
   170 *}
   171 
   172 lemma sup1CI [intro!]: "(~ B x ==> A x) ==> sup A B x"
   173   by (auto simp add: sup_fun_def sup_bool_def)
   174 
   175 lemma sup2CI [intro!]: "(~ B x y ==> A x y) ==> sup A B x y"
   176   by (auto simp add: sup_fun_def sup_bool_def)
   177 
   178 lemma sup_Un_eq: "sup (\<lambda>x. x \<in> R) (\<lambda>x. x \<in> S) = (\<lambda>x. x \<in> R \<union> S)"
   179   by (simp add: sup_fun_def sup_bool_def mem_def)
   180 
   181 lemma sup_Un_eq2 [pred_set_conv]: "sup (\<lambda>x y. (x, y) \<in> R) (\<lambda>x y. (x, y) \<in> S) = (\<lambda>x y. (x, y) \<in> R \<union> S)"
   182   by (simp add: sup_fun_def sup_bool_def mem_def)
   183 
   184 
   185 subsubsection {* Intersections of families *}
   186 
   187 lemma INF1_iff: "(INF x:A. B x) b = (ALL x:A. B x b)"
   188   by (simp add: INFI_apply)
   189 
   190 lemma INF2_iff: "(INF x:A. B x) b c = (ALL x:A. B x b c)"
   191   by (simp add: INFI_apply)
   192 
   193 lemma INF1_I [intro!]: "(!!x. x : A ==> B x b) ==> (INF x:A. B x) b"
   194   by (auto simp add: INFI_apply)
   195 
   196 lemma INF2_I [intro!]: "(!!x. x : A ==> B x b c) ==> (INF x:A. B x) b c"
   197   by (auto simp add: INFI_apply)
   198 
   199 lemma INF1_D [elim]: "(INF x:A. B x) b ==> a : A ==> B a b"
   200   by (auto simp add: INFI_apply)
   201 
   202 lemma INF2_D [elim]: "(INF x:A. B x) b c ==> a : A ==> B a b c"
   203   by (auto simp add: INFI_apply)
   204 
   205 lemma INF1_E [elim]: "(INF x:A. B x) b ==> (B a b ==> R) ==> (a ~: A ==> R) ==> R"
   206   by (auto simp add: INFI_apply)
   207 
   208 lemma INF2_E [elim]: "(INF x:A. B x) b c ==> (B a b c ==> R) ==> (a ~: A ==> R) ==> R"
   209   by (auto simp add: INFI_apply)
   210 
   211 lemma INF_INT_eq: "(INF i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (INT i. r i))"
   212   by (simp add: INFI_apply fun_eq_iff)
   213 
   214 lemma INF_INT_eq2: "(INF i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (INT i. r i))"
   215   by (simp add: INFI_apply fun_eq_iff)
   216 
   217 
   218 subsubsection {* Unions of families *}
   219 
   220 lemma SUP1_iff: "(SUP x:A. B x) b = (EX x:A. B x b)"
   221   by (simp add: SUPR_apply)
   222 
   223 lemma SUP2_iff: "(SUP x:A. B x) b c = (EX x:A. B x b c)"
   224   by (simp add: SUPR_apply)
   225 
   226 lemma SUP1_I [intro]: "a : A ==> B a b ==> (SUP x:A. B x) b"
   227   by (auto simp add: SUPR_apply)
   228 
   229 lemma SUP2_I [intro]: "a : A ==> B a b c ==> (SUP x:A. B x) b c"
   230   by (auto simp add: SUPR_apply)
   231 
   232 lemma SUP1_E [elim!]: "(SUP x:A. B x) b ==> (!!x. x : A ==> B x b ==> R) ==> R"
   233   by (auto simp add: SUPR_apply)
   234 
   235 lemma SUP2_E [elim!]: "(SUP x:A. B x) b c ==> (!!x. x : A ==> B x b c ==> R) ==> R"
   236   by (auto simp add: SUPR_apply)
   237 
   238 lemma SUP_UN_eq: "(SUP i. (\<lambda>x. x \<in> r i)) = (\<lambda>x. x \<in> (UN i. r i))"
   239   by (simp add: SUPR_apply fun_eq_iff)
   240 
   241 lemma SUP_UN_eq2: "(SUP i. (\<lambda>x y. (x, y) \<in> r i)) = (\<lambda>x y. (x, y) \<in> (UN i. r i))"
   242   by (simp add: SUPR_apply fun_eq_iff)
   243 
   244 
   245 subsection {* Predicates as relations *}
   246 
   247 subsubsection {* Composition  *}
   248 
   249 inductive
   250   pred_comp  :: "['a => 'b => bool, 'b => 'c => bool] => 'a => 'c => bool"
   251     (infixr "OO" 75)
   252   for r :: "'a => 'b => bool" and s :: "'b => 'c => bool"
   253 where
   254   pred_compI [intro]: "r a b ==> s b c ==> (r OO s) a c"
   255 
   256 inductive_cases pred_compE [elim!]: "(r OO s) a c"
   257 
   258 lemma pred_comp_rel_comp_eq [pred_set_conv]:
   259   "((\<lambda>x y. (x, y) \<in> r) OO (\<lambda>x y. (x, y) \<in> s)) = (\<lambda>x y. (x, y) \<in> r O s)"
   260   by (auto simp add: fun_eq_iff elim: pred_compE)
   261 
   262 
   263 subsubsection {* Converse *}
   264 
   265 inductive
   266   conversep :: "('a => 'b => bool) => 'b => 'a => bool"
   267     ("(_^--1)" [1000] 1000)
   268   for r :: "'a => 'b => bool"
   269 where
   270   conversepI: "r a b ==> r^--1 b a"
   271 
   272 notation (xsymbols)
   273   conversep  ("(_\<inverse>\<inverse>)" [1000] 1000)
   274 
   275 lemma conversepD:
   276   assumes ab: "r^--1 a b"
   277   shows "r b a" using ab
   278   by cases simp
   279 
   280 lemma conversep_iff [iff]: "r^--1 a b = r b a"
   281   by (iprover intro: conversepI dest: conversepD)
   282 
   283 lemma conversep_converse_eq [pred_set_conv]:
   284   "(\<lambda>x y. (x, y) \<in> r)^--1 = (\<lambda>x y. (x, y) \<in> r^-1)"
   285   by (auto simp add: fun_eq_iff)
   286 
   287 lemma conversep_conversep [simp]: "(r^--1)^--1 = r"
   288   by (iprover intro: order_antisym conversepI dest: conversepD)
   289 
   290 lemma converse_pred_comp: "(r OO s)^--1 = s^--1 OO r^--1"
   291   by (iprover intro: order_antisym conversepI pred_compI
   292     elim: pred_compE dest: conversepD)
   293 
   294 lemma converse_meet: "(inf r s)^--1 = inf r^--1 s^--1"
   295   by (simp add: inf_fun_def inf_bool_def)
   296     (iprover intro: conversepI ext dest: conversepD)
   297 
   298 lemma converse_join: "(sup r s)^--1 = sup r^--1 s^--1"
   299   by (simp add: sup_fun_def sup_bool_def)
   300     (iprover intro: conversepI ext dest: conversepD)
   301 
   302 lemma conversep_noteq [simp]: "(op ~=)^--1 = op ~="
   303   by (auto simp add: fun_eq_iff)
   304 
   305 lemma conversep_eq [simp]: "(op =)^--1 = op ="
   306   by (auto simp add: fun_eq_iff)
   307 
   308 
   309 subsubsection {* Domain *}
   310 
   311 inductive
   312   DomainP :: "('a => 'b => bool) => 'a => bool"
   313   for r :: "'a => 'b => bool"
   314 where
   315   DomainPI [intro]: "r a b ==> DomainP r a"
   316 
   317 inductive_cases DomainPE [elim!]: "DomainP r a"
   318 
   319 lemma DomainP_Domain_eq [pred_set_conv]: "DomainP (\<lambda>x y. (x, y) \<in> r) = (\<lambda>x. x \<in> Domain r)"
   320   by (blast intro!: Orderings.order_antisym predicate1I)
   321 
   322 
   323 subsubsection {* Range *}
   324 
   325 inductive
   326   RangeP :: "('a => 'b => bool) => 'b => bool"
   327   for r :: "'a => 'b => bool"
   328 where
   329   RangePI [intro]: "r a b ==> RangeP r b"
   330 
   331 inductive_cases RangePE [elim!]: "RangeP r b"
   332 
   333 lemma RangeP_Range_eq [pred_set_conv]: "RangeP (\<lambda>x y. (x, y) \<in> r) = (\<lambda>x. x \<in> Range r)"
   334   by (blast intro!: Orderings.order_antisym predicate1I)
   335 
   336 
   337 subsubsection {* Inverse image *}
   338 
   339 definition
   340   inv_imagep :: "('b => 'b => bool) => ('a => 'b) => 'a => 'a => bool" where
   341   "inv_imagep r f == %x y. r (f x) (f y)"
   342 
   343 lemma [pred_set_conv]: "inv_imagep (\<lambda>x y. (x, y) \<in> r) f = (\<lambda>x y. (x, y) \<in> inv_image r f)"
   344   by (simp add: inv_image_def inv_imagep_def)
   345 
   346 lemma in_inv_imagep [simp]: "inv_imagep r f x y = r (f x) (f y)"
   347   by (simp add: inv_imagep_def)
   348 
   349 
   350 subsubsection {* Powerset *}
   351 
   352 definition Powp :: "('a \<Rightarrow> bool) \<Rightarrow> 'a set \<Rightarrow> bool" where
   353   "Powp A == \<lambda>B. \<forall>x \<in> B. A x"
   354 
   355 lemma Powp_Pow_eq [pred_set_conv]: "Powp (\<lambda>x. x \<in> A) = (\<lambda>x. x \<in> Pow A)"
   356   by (auto simp add: Powp_def fun_eq_iff)
   357 
   358 lemmas Powp_mono [mono] = Pow_mono [to_pred pred_subset_eq]
   359 
   360 
   361 subsubsection {* Properties of relations *}
   362 
   363 abbreviation antisymP :: "('a => 'a => bool) => bool" where
   364   "antisymP r == antisym {(x, y). r x y}"
   365 
   366 abbreviation transP :: "('a => 'a => bool) => bool" where
   367   "transP r == trans {(x, y). r x y}"
   368 
   369 abbreviation single_valuedP :: "('a => 'b => bool) => bool" where
   370   "single_valuedP r == single_valued {(x, y). r x y}"
   371 
   372 (*FIXME inconsistencies: abbreviations vs. definitions, suffix `P` vs. suffix `p`*)
   373 
   374 definition reflp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
   375   "reflp r \<longleftrightarrow> refl {(x, y). r x y}"
   376 
   377 definition symp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
   378   "symp r \<longleftrightarrow> sym {(x, y). r x y}"
   379 
   380 definition transp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
   381   "transp r \<longleftrightarrow> trans {(x, y). r x y}"
   382 
   383 lemma reflpI:
   384   "(\<And>x. r x x) \<Longrightarrow> reflp r"
   385   by (auto intro: refl_onI simp add: reflp_def)
   386 
   387 lemma reflpE:
   388   assumes "reflp r"
   389   obtains "r x x"
   390   using assms by (auto dest: refl_onD simp add: reflp_def)
   391 
   392 lemma sympI:
   393   "(\<And>x y. r x y \<Longrightarrow> r y x) \<Longrightarrow> symp r"
   394   by (auto intro: symI simp add: symp_def)
   395 
   396 lemma sympE:
   397   assumes "symp r" and "r x y"
   398   obtains "r y x"
   399   using assms by (auto dest: symD simp add: symp_def)
   400 
   401 lemma transpI:
   402   "(\<And>x y z. r x y \<Longrightarrow> r y z \<Longrightarrow> r x z) \<Longrightarrow> transp r"
   403   by (auto intro: transI simp add: transp_def)
   404   
   405 lemma transpE:
   406   assumes "transp r" and "r x y" and "r y z"
   407   obtains "r x z"
   408   using assms by (auto dest: transD simp add: transp_def)
   409 
   410 
   411 subsection {* Predicates as enumerations *}
   412 
   413 subsubsection {* The type of predicate enumerations (a monad) *}
   414 
   415 datatype 'a pred = Pred "'a \<Rightarrow> bool"
   416 
   417 primrec eval :: "'a pred \<Rightarrow> 'a \<Rightarrow> bool" where
   418   eval_pred: "eval (Pred f) = f"
   419 
   420 lemma Pred_eval [simp]:
   421   "Pred (eval x) = x"
   422   by (cases x) simp
   423 
   424 lemma pred_eqI:
   425   "(\<And>w. eval P w \<longleftrightarrow> eval Q w) \<Longrightarrow> P = Q"
   426   by (cases P, cases Q) (auto simp add: fun_eq_iff)
   427 
   428 lemma eval_mem [simp]:
   429   "x \<in> eval P \<longleftrightarrow> eval P x"
   430   by (simp add: mem_def)
   431 
   432 lemma eq_mem [simp]:
   433   "x \<in> (op =) y \<longleftrightarrow> x = y"
   434   by (auto simp add: mem_def)
   435 
   436 instantiation pred :: (type) "{complete_lattice, boolean_algebra}"
   437 begin
   438 
   439 definition
   440   "P \<le> Q \<longleftrightarrow> eval P \<le> eval Q"
   441 
   442 definition
   443   "P < Q \<longleftrightarrow> eval P < eval Q"
   444 
   445 definition
   446   "\<bottom> = Pred \<bottom>"
   447 
   448 lemma eval_bot [simp]:
   449   "eval \<bottom>  = \<bottom>"
   450   by (simp add: bot_pred_def)
   451 
   452 definition
   453   "\<top> = Pred \<top>"
   454 
   455 lemma eval_top [simp]:
   456   "eval \<top>  = \<top>"
   457   by (simp add: top_pred_def)
   458 
   459 definition
   460   "P \<sqinter> Q = Pred (eval P \<sqinter> eval Q)"
   461 
   462 lemma eval_inf [simp]:
   463   "eval (P \<sqinter> Q) = eval P \<sqinter> eval Q"
   464   by (simp add: inf_pred_def)
   465 
   466 definition
   467   "P \<squnion> Q = Pred (eval P \<squnion> eval Q)"
   468 
   469 lemma eval_sup [simp]:
   470   "eval (P \<squnion> Q) = eval P \<squnion> eval Q"
   471   by (simp add: sup_pred_def)
   472 
   473 definition
   474   "\<Sqinter>A = Pred (INFI A eval)"
   475 
   476 lemma eval_Inf [simp]:
   477   "eval (\<Sqinter>A) = INFI A eval"
   478   by (simp add: Inf_pred_def)
   479 
   480 definition
   481   "\<Squnion>A = Pred (SUPR A eval)"
   482 
   483 lemma eval_Sup [simp]:
   484   "eval (\<Squnion>A) = SUPR A eval"
   485   by (simp add: Sup_pred_def)
   486 
   487 definition
   488   "- P = Pred (- eval P)"
   489 
   490 lemma eval_compl [simp]:
   491   "eval (- P) = - eval P"
   492   by (simp add: uminus_pred_def)
   493 
   494 definition
   495   "P - Q = Pred (eval P - eval Q)"
   496 
   497 lemma eval_minus [simp]:
   498   "eval (P - Q) = eval P - eval Q"
   499   by (simp add: minus_pred_def)
   500 
   501 instance proof
   502 qed (auto intro!: pred_eqI simp add: less_eq_pred_def less_pred_def uminus_apply minus_apply)
   503 
   504 end
   505 
   506 lemma eval_INFI [simp]:
   507   "eval (INFI A f) = INFI A (eval \<circ> f)"
   508   by (unfold INFI_def) simp
   509 
   510 lemma eval_SUPR [simp]:
   511   "eval (SUPR A f) = SUPR A (eval \<circ> f)"
   512   by (unfold SUPR_def) simp
   513 
   514 definition single :: "'a \<Rightarrow> 'a pred" where
   515   "single x = Pred ((op =) x)"
   516 
   517 lemma eval_single [simp]:
   518   "eval (single x) = (op =) x"
   519   by (simp add: single_def)
   520 
   521 definition bind :: "'a pred \<Rightarrow> ('a \<Rightarrow> 'b pred) \<Rightarrow> 'b pred" (infixl "\<guillemotright>=" 70) where
   522   "P \<guillemotright>= f = (SUPR {x. eval P x} f)"
   523 
   524 lemma eval_bind [simp]:
   525   "eval (P \<guillemotright>= f) = eval (SUPR {x. eval P x} f)"
   526   by (simp add: bind_def)
   527 
   528 lemma bind_bind:
   529   "(P \<guillemotright>= Q) \<guillemotright>= R = P \<guillemotright>= (\<lambda>x. Q x \<guillemotright>= R)"
   530   by (rule pred_eqI) auto
   531 
   532 lemma bind_single:
   533   "P \<guillemotright>= single = P"
   534   by (rule pred_eqI) auto
   535 
   536 lemma single_bind:
   537   "single x \<guillemotright>= P = P x"
   538   by (rule pred_eqI) auto
   539 
   540 lemma bottom_bind:
   541   "\<bottom> \<guillemotright>= P = \<bottom>"
   542   by (rule pred_eqI) auto
   543 
   544 lemma sup_bind:
   545   "(P \<squnion> Q) \<guillemotright>= R = P \<guillemotright>= R \<squnion> Q \<guillemotright>= R"
   546   by (rule pred_eqI) auto
   547 
   548 lemma Sup_bind:
   549   "(\<Squnion>A \<guillemotright>= f) = \<Squnion>((\<lambda>x. x \<guillemotright>= f) ` A)"
   550   by (rule pred_eqI) auto
   551 
   552 lemma pred_iffI:
   553   assumes "\<And>x. eval A x \<Longrightarrow> eval B x"
   554   and "\<And>x. eval B x \<Longrightarrow> eval A x"
   555   shows "A = B"
   556   using assms by (auto intro: pred_eqI)
   557   
   558 lemma singleI: "eval (single x) x"
   559   by simp
   560 
   561 lemma singleI_unit: "eval (single ()) x"
   562   by simp
   563 
   564 lemma singleE: "eval (single x) y \<Longrightarrow> (y = x \<Longrightarrow> P) \<Longrightarrow> P"
   565   by simp
   566 
   567 lemma singleE': "eval (single x) y \<Longrightarrow> (x = y \<Longrightarrow> P) \<Longrightarrow> P"
   568   by simp
   569 
   570 lemma bindI: "eval P x \<Longrightarrow> eval (Q x) y \<Longrightarrow> eval (P \<guillemotright>= Q) y"
   571   by auto
   572 
   573 lemma bindE: "eval (R \<guillemotright>= Q) y \<Longrightarrow> (\<And>x. eval R x \<Longrightarrow> eval (Q x) y \<Longrightarrow> P) \<Longrightarrow> P"
   574   by auto
   575 
   576 lemma botE: "eval \<bottom> x \<Longrightarrow> P"
   577   by auto
   578 
   579 lemma supI1: "eval A x \<Longrightarrow> eval (A \<squnion> B) x"
   580   by auto
   581 
   582 lemma supI2: "eval B x \<Longrightarrow> eval (A \<squnion> B) x" 
   583   by auto
   584 
   585 lemma supE: "eval (A \<squnion> B) x \<Longrightarrow> (eval A x \<Longrightarrow> P) \<Longrightarrow> (eval B x \<Longrightarrow> P) \<Longrightarrow> P"
   586   by auto
   587 
   588 lemma single_not_bot [simp]:
   589   "single x \<noteq> \<bottom>"
   590   by (auto simp add: single_def bot_pred_def fun_eq_iff)
   591 
   592 lemma not_bot:
   593   assumes "A \<noteq> \<bottom>"
   594   obtains x where "eval A x"
   595   using assms by (cases A)
   596     (auto simp add: bot_pred_def, auto simp add: mem_def)
   597   
   598 
   599 subsubsection {* Emptiness check and definite choice *}
   600 
   601 definition is_empty :: "'a pred \<Rightarrow> bool" where
   602   "is_empty A \<longleftrightarrow> A = \<bottom>"
   603 
   604 lemma is_empty_bot:
   605   "is_empty \<bottom>"
   606   by (simp add: is_empty_def)
   607 
   608 lemma not_is_empty_single:
   609   "\<not> is_empty (single x)"
   610   by (auto simp add: is_empty_def single_def bot_pred_def fun_eq_iff)
   611 
   612 lemma is_empty_sup:
   613   "is_empty (A \<squnion> B) \<longleftrightarrow> is_empty A \<and> is_empty B"
   614   by (auto simp add: is_empty_def)
   615 
   616 definition singleton :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a pred \<Rightarrow> 'a" where
   617   "singleton dfault A = (if \<exists>!x. eval A x then THE x. eval A x else dfault ())"
   618 
   619 lemma singleton_eqI:
   620   "\<exists>!x. eval A x \<Longrightarrow> eval A x \<Longrightarrow> singleton dfault A = x"
   621   by (auto simp add: singleton_def)
   622 
   623 lemma eval_singletonI:
   624   "\<exists>!x. eval A x \<Longrightarrow> eval A (singleton dfault A)"
   625 proof -
   626   assume assm: "\<exists>!x. eval A x"
   627   then obtain x where "eval A x" ..
   628   moreover with assm have "singleton dfault A = x" by (rule singleton_eqI)
   629   ultimately show ?thesis by simp 
   630 qed
   631 
   632 lemma single_singleton:
   633   "\<exists>!x. eval A x \<Longrightarrow> single (singleton dfault A) = A"
   634 proof -
   635   assume assm: "\<exists>!x. eval A x"
   636   then have "eval A (singleton dfault A)"
   637     by (rule eval_singletonI)
   638   moreover from assm have "\<And>x. eval A x \<Longrightarrow> singleton dfault A = x"
   639     by (rule singleton_eqI)
   640   ultimately have "eval (single (singleton dfault A)) = eval A"
   641     by (simp (no_asm_use) add: single_def fun_eq_iff) blast
   642   then have "\<And>x. eval (single (singleton dfault A)) x = eval A x"
   643     by simp
   644   then show ?thesis by (rule pred_eqI)
   645 qed
   646 
   647 lemma singleton_undefinedI:
   648   "\<not> (\<exists>!x. eval A x) \<Longrightarrow> singleton dfault A = dfault ()"
   649   by (simp add: singleton_def)
   650 
   651 lemma singleton_bot:
   652   "singleton dfault \<bottom> = dfault ()"
   653   by (auto simp add: bot_pred_def intro: singleton_undefinedI)
   654 
   655 lemma singleton_single:
   656   "singleton dfault (single x) = x"
   657   by (auto simp add: intro: singleton_eqI singleI elim: singleE)
   658 
   659 lemma singleton_sup_single_single:
   660   "singleton dfault (single x \<squnion> single y) = (if x = y then x else dfault ())"
   661 proof (cases "x = y")
   662   case True then show ?thesis by (simp add: singleton_single)
   663 next
   664   case False
   665   have "eval (single x \<squnion> single y) x"
   666     and "eval (single x \<squnion> single y) y"
   667   by (auto intro: supI1 supI2 singleI)
   668   with False have "\<not> (\<exists>!z. eval (single x \<squnion> single y) z)"
   669     by blast
   670   then have "singleton dfault (single x \<squnion> single y) = dfault ()"
   671     by (rule singleton_undefinedI)
   672   with False show ?thesis by simp
   673 qed
   674 
   675 lemma singleton_sup_aux:
   676   "singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B
   677     else if B = \<bottom> then singleton dfault A
   678     else singleton dfault
   679       (single (singleton dfault A) \<squnion> single (singleton dfault B)))"
   680 proof (cases "(\<exists>!x. eval A x) \<and> (\<exists>!y. eval B y)")
   681   case True then show ?thesis by (simp add: single_singleton)
   682 next
   683   case False
   684   from False have A_or_B:
   685     "singleton dfault A = dfault () \<or> singleton dfault B = dfault ()"
   686     by (auto intro!: singleton_undefinedI)
   687   then have rhs: "singleton dfault
   688     (single (singleton dfault A) \<squnion> single (singleton dfault B)) = dfault ()"
   689     by (auto simp add: singleton_sup_single_single singleton_single)
   690   from False have not_unique:
   691     "\<not> (\<exists>!x. eval A x) \<or> \<not> (\<exists>!y. eval B y)" by simp
   692   show ?thesis proof (cases "A \<noteq> \<bottom> \<and> B \<noteq> \<bottom>")
   693     case True
   694     then obtain a b where a: "eval A a" and b: "eval B b"
   695       by (blast elim: not_bot)
   696     with True not_unique have "\<not> (\<exists>!x. eval (A \<squnion> B) x)"
   697       by (auto simp add: sup_pred_def bot_pred_def)
   698     then have "singleton dfault (A \<squnion> B) = dfault ()" by (rule singleton_undefinedI)
   699     with True rhs show ?thesis by simp
   700   next
   701     case False then show ?thesis by auto
   702   qed
   703 qed
   704 
   705 lemma singleton_sup:
   706   "singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B
   707     else if B = \<bottom> then singleton dfault A
   708     else if singleton dfault A = singleton dfault B then singleton dfault A else dfault ())"
   709 using singleton_sup_aux [of dfault A B] by (simp only: singleton_sup_single_single)
   710 
   711 
   712 subsubsection {* Derived operations *}
   713 
   714 definition if_pred :: "bool \<Rightarrow> unit pred" where
   715   if_pred_eq: "if_pred b = (if b then single () else \<bottom>)"
   716 
   717 definition holds :: "unit pred \<Rightarrow> bool" where
   718   holds_eq: "holds P = eval P ()"
   719 
   720 definition not_pred :: "unit pred \<Rightarrow> unit pred" where
   721   not_pred_eq: "not_pred P = (if eval P () then \<bottom> else single ())"
   722 
   723 lemma if_predI: "P \<Longrightarrow> eval (if_pred P) ()"
   724   unfolding if_pred_eq by (auto intro: singleI)
   725 
   726 lemma if_predE: "eval (if_pred b) x \<Longrightarrow> (b \<Longrightarrow> x = () \<Longrightarrow> P) \<Longrightarrow> P"
   727   unfolding if_pred_eq by (cases b) (auto elim: botE)
   728 
   729 lemma not_predI: "\<not> P \<Longrightarrow> eval (not_pred (Pred (\<lambda>u. P))) ()"
   730   unfolding not_pred_eq eval_pred by (auto intro: singleI)
   731 
   732 lemma not_predI': "\<not> eval P () \<Longrightarrow> eval (not_pred P) ()"
   733   unfolding not_pred_eq by (auto intro: singleI)
   734 
   735 lemma not_predE: "eval (not_pred (Pred (\<lambda>u. P))) x \<Longrightarrow> (\<not> P \<Longrightarrow> thesis) \<Longrightarrow> thesis"
   736   unfolding not_pred_eq
   737   by (auto split: split_if_asm elim: botE)
   738 
   739 lemma not_predE': "eval (not_pred P) x \<Longrightarrow> (\<not> eval P x \<Longrightarrow> thesis) \<Longrightarrow> thesis"
   740   unfolding not_pred_eq
   741   by (auto split: split_if_asm elim: botE)
   742 lemma "f () = False \<or> f () = True"
   743 by simp
   744 
   745 lemma closure_of_bool_cases [no_atp]:
   746 assumes "(f :: unit \<Rightarrow> bool) = (%u. False) \<Longrightarrow> P f"
   747 assumes "f = (%u. True) \<Longrightarrow> P f"
   748 shows "P f"
   749 proof -
   750   have "f = (%u. False) \<or> f = (%u. True)"
   751     apply (cases "f ()")
   752     apply (rule disjI2)
   753     apply (rule ext)
   754     apply (simp add: unit_eq)
   755     apply (rule disjI1)
   756     apply (rule ext)
   757     apply (simp add: unit_eq)
   758     done
   759   from this prems show ?thesis by blast
   760 qed
   761 
   762 lemma unit_pred_cases:
   763 assumes "P \<bottom>"
   764 assumes "P (single ())"
   765 shows "P Q"
   766 using assms
   767 unfolding bot_pred_def Collect_def empty_def single_def
   768 apply (cases Q)
   769 apply simp
   770 apply (rule_tac f="fun" in closure_of_bool_cases)
   771 apply auto
   772 apply (subgoal_tac "(%x. () = x) = (%x. True)") 
   773 apply auto
   774 done
   775 
   776 lemma holds_if_pred:
   777   "holds (if_pred b) = b"
   778 unfolding if_pred_eq holds_eq
   779 by (cases b) (auto intro: singleI elim: botE)
   780 
   781 lemma if_pred_holds:
   782   "if_pred (holds P) = P"
   783 unfolding if_pred_eq holds_eq
   784 by (rule unit_pred_cases) (auto intro: singleI elim: botE)
   785 
   786 lemma is_empty_holds:
   787   "is_empty P \<longleftrightarrow> \<not> holds P"
   788 unfolding is_empty_def holds_eq
   789 by (rule unit_pred_cases) (auto elim: botE intro: singleI)
   790 
   791 definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a pred \<Rightarrow> 'b pred" where
   792   "map f P = P \<guillemotright>= (single o f)"
   793 
   794 lemma eval_map [simp]:
   795   "eval (map f P) = image f (eval P)"
   796   by (auto simp add: map_def)
   797 
   798 enriched_type map: map
   799   by (auto intro!: pred_eqI simp add: fun_eq_iff image_compose)
   800 
   801 
   802 subsubsection {* Implementation *}
   803 
   804 datatype 'a seq = Empty | Insert "'a" "'a pred" | Join "'a pred" "'a seq"
   805 
   806 primrec pred_of_seq :: "'a seq \<Rightarrow> 'a pred" where
   807     "pred_of_seq Empty = \<bottom>"
   808   | "pred_of_seq (Insert x P) = single x \<squnion> P"
   809   | "pred_of_seq (Join P xq) = P \<squnion> pred_of_seq xq"
   810 
   811 definition Seq :: "(unit \<Rightarrow> 'a seq) \<Rightarrow> 'a pred" where
   812   "Seq f = pred_of_seq (f ())"
   813 
   814 code_datatype Seq
   815 
   816 primrec member :: "'a seq \<Rightarrow> 'a \<Rightarrow> bool"  where
   817   "member Empty x \<longleftrightarrow> False"
   818   | "member (Insert y P) x \<longleftrightarrow> x = y \<or> eval P x"
   819   | "member (Join P xq) x \<longleftrightarrow> eval P x \<or> member xq x"
   820 
   821 lemma eval_member:
   822   "member xq = eval (pred_of_seq xq)"
   823 proof (induct xq)
   824   case Empty show ?case
   825   by (auto simp add: fun_eq_iff elim: botE)
   826 next
   827   case Insert show ?case
   828   by (auto simp add: fun_eq_iff elim: supE singleE intro: supI1 supI2 singleI)
   829 next
   830   case Join then show ?case
   831   by (auto simp add: fun_eq_iff elim: supE intro: supI1 supI2)
   832 qed
   833 
   834 lemma eval_code [code]: "eval (Seq f) = member (f ())"
   835   unfolding Seq_def by (rule sym, rule eval_member)
   836 
   837 lemma single_code [code]:
   838   "single x = Seq (\<lambda>u. Insert x \<bottom>)"
   839   unfolding Seq_def by simp
   840 
   841 primrec "apply" :: "('a \<Rightarrow> 'b pred) \<Rightarrow> 'a seq \<Rightarrow> 'b seq" where
   842     "apply f Empty = Empty"
   843   | "apply f (Insert x P) = Join (f x) (Join (P \<guillemotright>= f) Empty)"
   844   | "apply f (Join P xq) = Join (P \<guillemotright>= f) (apply f xq)"
   845 
   846 lemma apply_bind:
   847   "pred_of_seq (apply f xq) = pred_of_seq xq \<guillemotright>= f"
   848 proof (induct xq)
   849   case Empty show ?case
   850     by (simp add: bottom_bind)
   851 next
   852   case Insert show ?case
   853     by (simp add: single_bind sup_bind)
   854 next
   855   case Join then show ?case
   856     by (simp add: sup_bind)
   857 qed
   858   
   859 lemma bind_code [code]:
   860   "Seq g \<guillemotright>= f = Seq (\<lambda>u. apply f (g ()))"
   861   unfolding Seq_def by (rule sym, rule apply_bind)
   862 
   863 lemma bot_set_code [code]:
   864   "\<bottom> = Seq (\<lambda>u. Empty)"
   865   unfolding Seq_def by simp
   866 
   867 primrec adjunct :: "'a pred \<Rightarrow> 'a seq \<Rightarrow> 'a seq" where
   868     "adjunct P Empty = Join P Empty"
   869   | "adjunct P (Insert x Q) = Insert x (Q \<squnion> P)"
   870   | "adjunct P (Join Q xq) = Join Q (adjunct P xq)"
   871 
   872 lemma adjunct_sup:
   873   "pred_of_seq (adjunct P xq) = P \<squnion> pred_of_seq xq"
   874   by (induct xq) (simp_all add: sup_assoc sup_commute sup_left_commute)
   875 
   876 lemma sup_code [code]:
   877   "Seq f \<squnion> Seq g = Seq (\<lambda>u. case f ()
   878     of Empty \<Rightarrow> g ()
   879      | Insert x P \<Rightarrow> Insert x (P \<squnion> Seq g)
   880      | Join P xq \<Rightarrow> adjunct (Seq g) (Join P xq))"
   881 proof (cases "f ()")
   882   case Empty
   883   thus ?thesis
   884     unfolding Seq_def by (simp add: sup_commute [of "\<bottom>"])
   885 next
   886   case Insert
   887   thus ?thesis
   888     unfolding Seq_def by (simp add: sup_assoc)
   889 next
   890   case Join
   891   thus ?thesis
   892     unfolding Seq_def
   893     by (simp add: adjunct_sup sup_assoc sup_commute sup_left_commute)
   894 qed
   895 
   896 primrec contained :: "'a seq \<Rightarrow> 'a pred \<Rightarrow> bool" where
   897     "contained Empty Q \<longleftrightarrow> True"
   898   | "contained (Insert x P) Q \<longleftrightarrow> eval Q x \<and> P \<le> Q"
   899   | "contained (Join P xq) Q \<longleftrightarrow> P \<le> Q \<and> contained xq Q"
   900 
   901 lemma single_less_eq_eval:
   902   "single x \<le> P \<longleftrightarrow> eval P x"
   903   by (auto simp add: single_def less_eq_pred_def mem_def)
   904 
   905 lemma contained_less_eq:
   906   "contained xq Q \<longleftrightarrow> pred_of_seq xq \<le> Q"
   907   by (induct xq) (simp_all add: single_less_eq_eval)
   908 
   909 lemma less_eq_pred_code [code]:
   910   "Seq f \<le> Q = (case f ()
   911    of Empty \<Rightarrow> True
   912     | Insert x P \<Rightarrow> eval Q x \<and> P \<le> Q
   913     | Join P xq \<Rightarrow> P \<le> Q \<and> contained xq Q)"
   914   by (cases "f ()")
   915     (simp_all add: Seq_def single_less_eq_eval contained_less_eq)
   916 
   917 lemma eq_pred_code [code]:
   918   fixes P Q :: "'a pred"
   919   shows "HOL.equal P Q \<longleftrightarrow> P \<le> Q \<and> Q \<le> P"
   920   by (auto simp add: equal)
   921 
   922 lemma [code nbe]:
   923   "HOL.equal (x :: 'a pred) x \<longleftrightarrow> True"
   924   by (fact equal_refl)
   925 
   926 lemma [code]:
   927   "pred_case f P = f (eval P)"
   928   by (cases P) simp
   929 
   930 lemma [code]:
   931   "pred_rec f P = f (eval P)"
   932   by (cases P) simp
   933 
   934 inductive eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" where "eq x x"
   935 
   936 lemma eq_is_eq: "eq x y \<equiv> (x = y)"
   937   by (rule eq_reflection) (auto intro: eq.intros elim: eq.cases)
   938 
   939 primrec null :: "'a seq \<Rightarrow> bool" where
   940     "null Empty \<longleftrightarrow> True"
   941   | "null (Insert x P) \<longleftrightarrow> False"
   942   | "null (Join P xq) \<longleftrightarrow> is_empty P \<and> null xq"
   943 
   944 lemma null_is_empty:
   945   "null xq \<longleftrightarrow> is_empty (pred_of_seq xq)"
   946   by (induct xq) (simp_all add: is_empty_bot not_is_empty_single is_empty_sup)
   947 
   948 lemma is_empty_code [code]:
   949   "is_empty (Seq f) \<longleftrightarrow> null (f ())"
   950   by (simp add: null_is_empty Seq_def)
   951 
   952 primrec the_only :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a seq \<Rightarrow> 'a" where
   953   [code del]: "the_only dfault Empty = dfault ()"
   954   | "the_only dfault (Insert x P) = (if is_empty P then x else let y = singleton dfault P in if x = y then x else dfault ())"
   955   | "the_only dfault (Join P xq) = (if is_empty P then the_only dfault xq else if null xq then singleton dfault P
   956        else let x = singleton dfault P; y = the_only dfault xq in
   957        if x = y then x else dfault ())"
   958 
   959 lemma the_only_singleton:
   960   "the_only dfault xq = singleton dfault (pred_of_seq xq)"
   961   by (induct xq)
   962     (auto simp add: singleton_bot singleton_single is_empty_def
   963     null_is_empty Let_def singleton_sup)
   964 
   965 lemma singleton_code [code]:
   966   "singleton dfault (Seq f) = (case f ()
   967    of Empty \<Rightarrow> dfault ()
   968     | Insert x P \<Rightarrow> if is_empty P then x
   969         else let y = singleton dfault P in
   970           if x = y then x else dfault ()
   971     | Join P xq \<Rightarrow> if is_empty P then the_only dfault xq
   972         else if null xq then singleton dfault P
   973         else let x = singleton dfault P; y = the_only dfault xq in
   974           if x = y then x else dfault ())"
   975   by (cases "f ()")
   976    (auto simp add: Seq_def the_only_singleton is_empty_def
   977       null_is_empty singleton_bot singleton_single singleton_sup Let_def)
   978 
   979 definition not_unique :: "'a pred => 'a"
   980 where
   981   [code del]: "not_unique A = (THE x. eval A x)"
   982 
   983 definition the :: "'a pred => 'a"
   984 where
   985   "the A = (THE x. eval A x)"
   986 
   987 lemma the_eqI:
   988   "(THE x. eval P x) = x \<Longrightarrow> the P = x"
   989   by (simp add: the_def)
   990 
   991 lemma the_eq [code]: "the A = singleton (\<lambda>x. not_unique A) A"
   992   by (rule the_eqI) (simp add: singleton_def not_unique_def)
   993 
   994 code_abort not_unique
   995 
   996 code_reflect Predicate
   997   datatypes pred = Seq and seq = Empty | Insert | Join
   998   functions map
   999 
  1000 ML {*
  1001 signature PREDICATE =
  1002 sig
  1003   datatype 'a pred = Seq of (unit -> 'a seq)
  1004   and 'a seq = Empty | Insert of 'a * 'a pred | Join of 'a pred * 'a seq
  1005   val yield: 'a pred -> ('a * 'a pred) option
  1006   val yieldn: int -> 'a pred -> 'a list * 'a pred
  1007   val map: ('a -> 'b) -> 'a pred -> 'b pred
  1008 end;
  1009 
  1010 structure Predicate : PREDICATE =
  1011 struct
  1012 
  1013 datatype pred = datatype Predicate.pred
  1014 datatype seq = datatype Predicate.seq
  1015 
  1016 fun map f = Predicate.map f;
  1017 
  1018 fun yield (Seq f) = next (f ())
  1019 and next Empty = NONE
  1020   | next (Insert (x, P)) = SOME (x, P)
  1021   | next (Join (P, xq)) = (case yield P
  1022      of NONE => next xq
  1023       | SOME (x, Q) => SOME (x, Seq (fn _ => Join (Q, xq))));
  1024 
  1025 fun anamorph f k x = (if k = 0 then ([], x)
  1026   else case f x
  1027    of NONE => ([], x)
  1028     | SOME (v, y) => let
  1029         val (vs, z) = anamorph f (k - 1) y
  1030       in (v :: vs, z) end);
  1031 
  1032 fun yieldn P = anamorph yield P;
  1033 
  1034 end;
  1035 *}
  1036 
  1037 no_notation
  1038   bot ("\<bottom>") and
  1039   top ("\<top>") and
  1040   inf (infixl "\<sqinter>" 70) and
  1041   sup (infixl "\<squnion>" 65) and
  1042   Inf ("\<Sqinter>_" [900] 900) and
  1043   Sup ("\<Squnion>_" [900] 900) and
  1044   bind (infixl "\<guillemotright>=" 70)
  1045 
  1046 no_syntax (xsymbols)
  1047   "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
  1048   "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
  1049   "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
  1050   "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
  1051 
  1052 hide_type (open) pred seq
  1053 hide_const (open) Pred eval single bind is_empty singleton if_pred not_pred holds
  1054   Empty Insert Join Seq member pred_of_seq "apply" adjunct null the_only eq map not_unique the
  1055 
  1056 end