src/HOL/Predicate.thy
author wenzelm
Thu May 24 17:25:53 2012 +0200 (2012-05-24)
changeset 47988 e4b69e10b990
parent 47399 b72fa7bf9a10
child 51112 da97167e03f7
permissions -rw-r--r--
tuned proofs;
berghofe@22259
     1
(*  Title:      HOL/Predicate.thy
haftmann@46664
     2
    Author:     Lukas Bulwahn and Florian Haftmann, TU Muenchen
berghofe@22259
     3
*)
berghofe@22259
     4
haftmann@46664
     5
header {* Predicates as enumerations *}
berghofe@22259
     6
berghofe@22259
     7
theory Predicate
haftmann@46664
     8
imports List
berghofe@22259
     9
begin
berghofe@22259
    10
haftmann@30328
    11
notation
haftmann@41082
    12
  bot ("\<bottom>") and
haftmann@41082
    13
  top ("\<top>") and
haftmann@30328
    14
  inf (infixl "\<sqinter>" 70) and
haftmann@30328
    15
  sup (infixl "\<squnion>" 65) and
haftmann@30328
    16
  Inf ("\<Sqinter>_" [900] 900) and
haftmann@41082
    17
  Sup ("\<Squnion>_" [900] 900)
haftmann@30328
    18
haftmann@41080
    19
syntax (xsymbols)
haftmann@41082
    20
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
haftmann@41082
    21
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
    22
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
haftmann@41080
    23
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
    24
haftmann@46664
    25
subsection {* The type of predicate enumerations (a monad) *}
haftmann@30328
    26
haftmann@30328
    27
datatype 'a pred = Pred "'a \<Rightarrow> bool"
haftmann@30328
    28
haftmann@30328
    29
primrec eval :: "'a pred \<Rightarrow> 'a \<Rightarrow> bool" where
haftmann@30328
    30
  eval_pred: "eval (Pred f) = f"
haftmann@30328
    31
haftmann@30328
    32
lemma Pred_eval [simp]:
haftmann@30328
    33
  "Pred (eval x) = x"
haftmann@30328
    34
  by (cases x) simp
haftmann@30328
    35
haftmann@40616
    36
lemma pred_eqI:
haftmann@40616
    37
  "(\<And>w. eval P w \<longleftrightarrow> eval Q w) \<Longrightarrow> P = Q"
haftmann@40616
    38
  by (cases P, cases Q) (auto simp add: fun_eq_iff)
haftmann@30328
    39
haftmann@46038
    40
lemma pred_eq_iff:
haftmann@46038
    41
  "P = Q \<Longrightarrow> (\<And>w. eval P w \<longleftrightarrow> eval Q w)"
haftmann@46038
    42
  by (simp add: pred_eqI)
haftmann@46038
    43
haftmann@44033
    44
instantiation pred :: (type) complete_lattice
haftmann@30328
    45
begin
haftmann@30328
    46
haftmann@30328
    47
definition
haftmann@30328
    48
  "P \<le> Q \<longleftrightarrow> eval P \<le> eval Q"
haftmann@30328
    49
haftmann@30328
    50
definition
haftmann@30328
    51
  "P < Q \<longleftrightarrow> eval P < eval Q"
haftmann@30328
    52
haftmann@30328
    53
definition
haftmann@30328
    54
  "\<bottom> = Pred \<bottom>"
haftmann@30328
    55
haftmann@40616
    56
lemma eval_bot [simp]:
haftmann@40616
    57
  "eval \<bottom>  = \<bottom>"
haftmann@40616
    58
  by (simp add: bot_pred_def)
haftmann@40616
    59
haftmann@30328
    60
definition
haftmann@30328
    61
  "\<top> = Pred \<top>"
haftmann@30328
    62
haftmann@40616
    63
lemma eval_top [simp]:
haftmann@40616
    64
  "eval \<top>  = \<top>"
haftmann@40616
    65
  by (simp add: top_pred_def)
haftmann@40616
    66
haftmann@30328
    67
definition
haftmann@30328
    68
  "P \<sqinter> Q = Pred (eval P \<sqinter> eval Q)"
haftmann@30328
    69
haftmann@40616
    70
lemma eval_inf [simp]:
haftmann@40616
    71
  "eval (P \<sqinter> Q) = eval P \<sqinter> eval Q"
haftmann@40616
    72
  by (simp add: inf_pred_def)
haftmann@40616
    73
haftmann@30328
    74
definition
haftmann@30328
    75
  "P \<squnion> Q = Pred (eval P \<squnion> eval Q)"
haftmann@30328
    76
haftmann@40616
    77
lemma eval_sup [simp]:
haftmann@40616
    78
  "eval (P \<squnion> Q) = eval P \<squnion> eval Q"
haftmann@40616
    79
  by (simp add: sup_pred_def)
haftmann@40616
    80
haftmann@30328
    81
definition
haftmann@37767
    82
  "\<Sqinter>A = Pred (INFI A eval)"
haftmann@30328
    83
haftmann@40616
    84
lemma eval_Inf [simp]:
haftmann@40616
    85
  "eval (\<Sqinter>A) = INFI A eval"
haftmann@40616
    86
  by (simp add: Inf_pred_def)
haftmann@40616
    87
haftmann@30328
    88
definition
haftmann@37767
    89
  "\<Squnion>A = Pred (SUPR A eval)"
haftmann@30328
    90
haftmann@40616
    91
lemma eval_Sup [simp]:
haftmann@40616
    92
  "eval (\<Squnion>A) = SUPR A eval"
haftmann@40616
    93
  by (simp add: Sup_pred_def)
haftmann@40616
    94
haftmann@44033
    95
instance proof
haftmann@44415
    96
qed (auto intro!: pred_eqI simp add: less_eq_pred_def less_pred_def le_fun_def less_fun_def)
haftmann@44033
    97
haftmann@44033
    98
end
haftmann@44033
    99
haftmann@44033
   100
lemma eval_INFI [simp]:
haftmann@44033
   101
  "eval (INFI A f) = INFI A (eval \<circ> f)"
hoelzl@44928
   102
  by (simp only: INF_def eval_Inf image_compose)
haftmann@44033
   103
haftmann@44033
   104
lemma eval_SUPR [simp]:
haftmann@44033
   105
  "eval (SUPR A f) = SUPR A (eval \<circ> f)"
hoelzl@44928
   106
  by (simp only: SUP_def eval_Sup image_compose)
haftmann@44033
   107
haftmann@44033
   108
instantiation pred :: (type) complete_boolean_algebra
haftmann@44033
   109
begin
haftmann@44033
   110
haftmann@32578
   111
definition
haftmann@32578
   112
  "- P = Pred (- eval P)"
haftmann@32578
   113
haftmann@40616
   114
lemma eval_compl [simp]:
haftmann@40616
   115
  "eval (- P) = - eval P"
haftmann@40616
   116
  by (simp add: uminus_pred_def)
haftmann@40616
   117
haftmann@32578
   118
definition
haftmann@32578
   119
  "P - Q = Pred (eval P - eval Q)"
haftmann@32578
   120
haftmann@40616
   121
lemma eval_minus [simp]:
haftmann@40616
   122
  "eval (P - Q) = eval P - eval Q"
haftmann@40616
   123
  by (simp add: minus_pred_def)
haftmann@40616
   124
haftmann@32578
   125
instance proof
noschinl@46884
   126
qed (auto intro!: pred_eqI)
haftmann@30328
   127
berghofe@22259
   128
end
haftmann@30328
   129
haftmann@40616
   130
definition single :: "'a \<Rightarrow> 'a pred" where
haftmann@40616
   131
  "single x = Pred ((op =) x)"
haftmann@40616
   132
haftmann@40616
   133
lemma eval_single [simp]:
haftmann@40616
   134
  "eval (single x) = (op =) x"
haftmann@40616
   135
  by (simp add: single_def)
haftmann@40616
   136
haftmann@40616
   137
definition bind :: "'a pred \<Rightarrow> ('a \<Rightarrow> 'b pred) \<Rightarrow> 'b pred" (infixl "\<guillemotright>=" 70) where
haftmann@41080
   138
  "P \<guillemotright>= f = (SUPR {x. eval P x} f)"
haftmann@40616
   139
haftmann@40616
   140
lemma eval_bind [simp]:
haftmann@41080
   141
  "eval (P \<guillemotright>= f) = eval (SUPR {x. eval P x} f)"
haftmann@40616
   142
  by (simp add: bind_def)
haftmann@40616
   143
haftmann@30328
   144
lemma bind_bind:
haftmann@30328
   145
  "(P \<guillemotright>= Q) \<guillemotright>= R = P \<guillemotright>= (\<lambda>x. Q x \<guillemotright>= R)"
noschinl@46884
   146
  by (rule pred_eqI) auto
haftmann@30328
   147
haftmann@30328
   148
lemma bind_single:
haftmann@30328
   149
  "P \<guillemotright>= single = P"
haftmann@40616
   150
  by (rule pred_eqI) auto
haftmann@30328
   151
haftmann@30328
   152
lemma single_bind:
haftmann@30328
   153
  "single x \<guillemotright>= P = P x"
haftmann@40616
   154
  by (rule pred_eqI) auto
haftmann@30328
   155
haftmann@30328
   156
lemma bottom_bind:
haftmann@30328
   157
  "\<bottom> \<guillemotright>= P = \<bottom>"
haftmann@40674
   158
  by (rule pred_eqI) auto
haftmann@30328
   159
haftmann@30328
   160
lemma sup_bind:
haftmann@30328
   161
  "(P \<squnion> Q) \<guillemotright>= R = P \<guillemotright>= R \<squnion> Q \<guillemotright>= R"
haftmann@40674
   162
  by (rule pred_eqI) auto
haftmann@30328
   163
haftmann@40616
   164
lemma Sup_bind:
haftmann@40616
   165
  "(\<Squnion>A \<guillemotright>= f) = \<Squnion>((\<lambda>x. x \<guillemotright>= f) ` A)"
noschinl@46884
   166
  by (rule pred_eqI) auto
haftmann@30328
   167
haftmann@30328
   168
lemma pred_iffI:
haftmann@30328
   169
  assumes "\<And>x. eval A x \<Longrightarrow> eval B x"
haftmann@30328
   170
  and "\<And>x. eval B x \<Longrightarrow> eval A x"
haftmann@30328
   171
  shows "A = B"
haftmann@40616
   172
  using assms by (auto intro: pred_eqI)
haftmann@30328
   173
  
haftmann@30328
   174
lemma singleI: "eval (single x) x"
haftmann@40616
   175
  by simp
haftmann@30328
   176
haftmann@30328
   177
lemma singleI_unit: "eval (single ()) x"
haftmann@40616
   178
  by simp
haftmann@30328
   179
haftmann@30328
   180
lemma singleE: "eval (single x) y \<Longrightarrow> (y = x \<Longrightarrow> P) \<Longrightarrow> P"
haftmann@40616
   181
  by simp
haftmann@30328
   182
haftmann@30328
   183
lemma singleE': "eval (single x) y \<Longrightarrow> (x = y \<Longrightarrow> P) \<Longrightarrow> P"
haftmann@40616
   184
  by simp
haftmann@30328
   185
haftmann@30328
   186
lemma bindI: "eval P x \<Longrightarrow> eval (Q x) y \<Longrightarrow> eval (P \<guillemotright>= Q) y"
haftmann@40616
   187
  by auto
haftmann@30328
   188
haftmann@30328
   189
lemma bindE: "eval (R \<guillemotright>= Q) y \<Longrightarrow> (\<And>x. eval R x \<Longrightarrow> eval (Q x) y \<Longrightarrow> P) \<Longrightarrow> P"
haftmann@40616
   190
  by auto
haftmann@30328
   191
haftmann@30328
   192
lemma botE: "eval \<bottom> x \<Longrightarrow> P"
haftmann@40616
   193
  by auto
haftmann@30328
   194
haftmann@30328
   195
lemma supI1: "eval A x \<Longrightarrow> eval (A \<squnion> B) x"
haftmann@40616
   196
  by auto
haftmann@30328
   197
haftmann@30328
   198
lemma supI2: "eval B x \<Longrightarrow> eval (A \<squnion> B) x" 
haftmann@40616
   199
  by auto
haftmann@30328
   200
haftmann@30328
   201
lemma supE: "eval (A \<squnion> B) x \<Longrightarrow> (eval A x \<Longrightarrow> P) \<Longrightarrow> (eval B x \<Longrightarrow> P) \<Longrightarrow> P"
haftmann@40616
   202
  by auto
haftmann@30328
   203
haftmann@32578
   204
lemma single_not_bot [simp]:
haftmann@32578
   205
  "single x \<noteq> \<bottom>"
nipkow@39302
   206
  by (auto simp add: single_def bot_pred_def fun_eq_iff)
haftmann@32578
   207
haftmann@32578
   208
lemma not_bot:
haftmann@32578
   209
  assumes "A \<noteq> \<bottom>"
haftmann@32578
   210
  obtains x where "eval A x"
haftmann@45970
   211
  using assms by (cases A) (auto simp add: bot_pred_def)
haftmann@45970
   212
haftmann@32578
   213
haftmann@46664
   214
subsection {* Emptiness check and definite choice *}
haftmann@32578
   215
haftmann@32578
   216
definition is_empty :: "'a pred \<Rightarrow> bool" where
haftmann@32578
   217
  "is_empty A \<longleftrightarrow> A = \<bottom>"
haftmann@32578
   218
haftmann@32578
   219
lemma is_empty_bot:
haftmann@32578
   220
  "is_empty \<bottom>"
haftmann@32578
   221
  by (simp add: is_empty_def)
haftmann@32578
   222
haftmann@32578
   223
lemma not_is_empty_single:
haftmann@32578
   224
  "\<not> is_empty (single x)"
nipkow@39302
   225
  by (auto simp add: is_empty_def single_def bot_pred_def fun_eq_iff)
haftmann@32578
   226
haftmann@32578
   227
lemma is_empty_sup:
haftmann@32578
   228
  "is_empty (A \<squnion> B) \<longleftrightarrow> is_empty A \<and> is_empty B"
huffman@36008
   229
  by (auto simp add: is_empty_def)
haftmann@32578
   230
haftmann@40616
   231
definition singleton :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a pred \<Rightarrow> 'a" where
bulwahn@33111
   232
  "singleton dfault A = (if \<exists>!x. eval A x then THE x. eval A x else dfault ())"
haftmann@32578
   233
haftmann@32578
   234
lemma singleton_eqI:
bulwahn@33110
   235
  "\<exists>!x. eval A x \<Longrightarrow> eval A x \<Longrightarrow> singleton dfault A = x"
haftmann@32578
   236
  by (auto simp add: singleton_def)
haftmann@32578
   237
haftmann@32578
   238
lemma eval_singletonI:
bulwahn@33110
   239
  "\<exists>!x. eval A x \<Longrightarrow> eval A (singleton dfault A)"
haftmann@32578
   240
proof -
haftmann@32578
   241
  assume assm: "\<exists>!x. eval A x"
haftmann@32578
   242
  then obtain x where "eval A x" ..
bulwahn@33110
   243
  moreover with assm have "singleton dfault A = x" by (rule singleton_eqI)
haftmann@32578
   244
  ultimately show ?thesis by simp 
haftmann@32578
   245
qed
haftmann@32578
   246
haftmann@32578
   247
lemma single_singleton:
bulwahn@33110
   248
  "\<exists>!x. eval A x \<Longrightarrow> single (singleton dfault A) = A"
haftmann@32578
   249
proof -
haftmann@32578
   250
  assume assm: "\<exists>!x. eval A x"
bulwahn@33110
   251
  then have "eval A (singleton dfault A)"
haftmann@32578
   252
    by (rule eval_singletonI)
bulwahn@33110
   253
  moreover from assm have "\<And>x. eval A x \<Longrightarrow> singleton dfault A = x"
haftmann@32578
   254
    by (rule singleton_eqI)
bulwahn@33110
   255
  ultimately have "eval (single (singleton dfault A)) = eval A"
nipkow@39302
   256
    by (simp (no_asm_use) add: single_def fun_eq_iff) blast
haftmann@40616
   257
  then have "\<And>x. eval (single (singleton dfault A)) x = eval A x"
haftmann@40616
   258
    by simp
haftmann@40616
   259
  then show ?thesis by (rule pred_eqI)
haftmann@32578
   260
qed
haftmann@32578
   261
haftmann@32578
   262
lemma singleton_undefinedI:
bulwahn@33111
   263
  "\<not> (\<exists>!x. eval A x) \<Longrightarrow> singleton dfault A = dfault ()"
haftmann@32578
   264
  by (simp add: singleton_def)
haftmann@32578
   265
haftmann@32578
   266
lemma singleton_bot:
bulwahn@33111
   267
  "singleton dfault \<bottom> = dfault ()"
haftmann@32578
   268
  by (auto simp add: bot_pred_def intro: singleton_undefinedI)
haftmann@32578
   269
haftmann@32578
   270
lemma singleton_single:
bulwahn@33110
   271
  "singleton dfault (single x) = x"
haftmann@32578
   272
  by (auto simp add: intro: singleton_eqI singleI elim: singleE)
haftmann@32578
   273
haftmann@32578
   274
lemma singleton_sup_single_single:
bulwahn@33111
   275
  "singleton dfault (single x \<squnion> single y) = (if x = y then x else dfault ())"
haftmann@32578
   276
proof (cases "x = y")
haftmann@32578
   277
  case True then show ?thesis by (simp add: singleton_single)
haftmann@32578
   278
next
haftmann@32578
   279
  case False
haftmann@32578
   280
  have "eval (single x \<squnion> single y) x"
haftmann@32578
   281
    and "eval (single x \<squnion> single y) y"
haftmann@32578
   282
  by (auto intro: supI1 supI2 singleI)
haftmann@32578
   283
  with False have "\<not> (\<exists>!z. eval (single x \<squnion> single y) z)"
haftmann@32578
   284
    by blast
bulwahn@33111
   285
  then have "singleton dfault (single x \<squnion> single y) = dfault ()"
haftmann@32578
   286
    by (rule singleton_undefinedI)
haftmann@32578
   287
  with False show ?thesis by simp
haftmann@32578
   288
qed
haftmann@32578
   289
haftmann@32578
   290
lemma singleton_sup_aux:
bulwahn@33110
   291
  "singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B
bulwahn@33110
   292
    else if B = \<bottom> then singleton dfault A
bulwahn@33110
   293
    else singleton dfault
bulwahn@33110
   294
      (single (singleton dfault A) \<squnion> single (singleton dfault B)))"
haftmann@32578
   295
proof (cases "(\<exists>!x. eval A x) \<and> (\<exists>!y. eval B y)")
haftmann@32578
   296
  case True then show ?thesis by (simp add: single_singleton)
haftmann@32578
   297
next
haftmann@32578
   298
  case False
haftmann@32578
   299
  from False have A_or_B:
bulwahn@33111
   300
    "singleton dfault A = dfault () \<or> singleton dfault B = dfault ()"
haftmann@32578
   301
    by (auto intro!: singleton_undefinedI)
bulwahn@33110
   302
  then have rhs: "singleton dfault
bulwahn@33111
   303
    (single (singleton dfault A) \<squnion> single (singleton dfault B)) = dfault ()"
haftmann@32578
   304
    by (auto simp add: singleton_sup_single_single singleton_single)
haftmann@32578
   305
  from False have not_unique:
haftmann@32578
   306
    "\<not> (\<exists>!x. eval A x) \<or> \<not> (\<exists>!y. eval B y)" by simp
haftmann@32578
   307
  show ?thesis proof (cases "A \<noteq> \<bottom> \<and> B \<noteq> \<bottom>")
haftmann@32578
   308
    case True
haftmann@32578
   309
    then obtain a b where a: "eval A a" and b: "eval B b"
haftmann@32578
   310
      by (blast elim: not_bot)
haftmann@32578
   311
    with True not_unique have "\<not> (\<exists>!x. eval (A \<squnion> B) x)"
haftmann@32578
   312
      by (auto simp add: sup_pred_def bot_pred_def)
bulwahn@33111
   313
    then have "singleton dfault (A \<squnion> B) = dfault ()" by (rule singleton_undefinedI)
haftmann@32578
   314
    with True rhs show ?thesis by simp
haftmann@32578
   315
  next
haftmann@32578
   316
    case False then show ?thesis by auto
haftmann@32578
   317
  qed
haftmann@32578
   318
qed
haftmann@32578
   319
haftmann@32578
   320
lemma singleton_sup:
bulwahn@33110
   321
  "singleton dfault (A \<squnion> B) = (if A = \<bottom> then singleton dfault B
bulwahn@33110
   322
    else if B = \<bottom> then singleton dfault A
bulwahn@33111
   323
    else if singleton dfault A = singleton dfault B then singleton dfault A else dfault ())"
bulwahn@33110
   324
using singleton_sup_aux [of dfault A B] by (simp only: singleton_sup_single_single)
haftmann@32578
   325
haftmann@30328
   326
haftmann@46664
   327
subsection {* Derived operations *}
haftmann@30328
   328
haftmann@30328
   329
definition if_pred :: "bool \<Rightarrow> unit pred" where
haftmann@30328
   330
  if_pred_eq: "if_pred b = (if b then single () else \<bottom>)"
haftmann@30328
   331
bulwahn@33754
   332
definition holds :: "unit pred \<Rightarrow> bool" where
bulwahn@33754
   333
  holds_eq: "holds P = eval P ()"
bulwahn@33754
   334
haftmann@30328
   335
definition not_pred :: "unit pred \<Rightarrow> unit pred" where
haftmann@30328
   336
  not_pred_eq: "not_pred P = (if eval P () then \<bottom> else single ())"
haftmann@30328
   337
haftmann@30328
   338
lemma if_predI: "P \<Longrightarrow> eval (if_pred P) ()"
haftmann@30328
   339
  unfolding if_pred_eq by (auto intro: singleI)
haftmann@30328
   340
haftmann@30328
   341
lemma if_predE: "eval (if_pred b) x \<Longrightarrow> (b \<Longrightarrow> x = () \<Longrightarrow> P) \<Longrightarrow> P"
haftmann@30328
   342
  unfolding if_pred_eq by (cases b) (auto elim: botE)
haftmann@30328
   343
haftmann@30328
   344
lemma not_predI: "\<not> P \<Longrightarrow> eval (not_pred (Pred (\<lambda>u. P))) ()"
haftmann@30328
   345
  unfolding not_pred_eq eval_pred by (auto intro: singleI)
haftmann@30328
   346
haftmann@30328
   347
lemma not_predI': "\<not> eval P () \<Longrightarrow> eval (not_pred P) ()"
haftmann@30328
   348
  unfolding not_pred_eq by (auto intro: singleI)
haftmann@30328
   349
haftmann@30328
   350
lemma not_predE: "eval (not_pred (Pred (\<lambda>u. P))) x \<Longrightarrow> (\<not> P \<Longrightarrow> thesis) \<Longrightarrow> thesis"
haftmann@30328
   351
  unfolding not_pred_eq
haftmann@30328
   352
  by (auto split: split_if_asm elim: botE)
haftmann@30328
   353
haftmann@30328
   354
lemma not_predE': "eval (not_pred P) x \<Longrightarrow> (\<not> eval P x \<Longrightarrow> thesis) \<Longrightarrow> thesis"
haftmann@30328
   355
  unfolding not_pred_eq
haftmann@30328
   356
  by (auto split: split_if_asm elim: botE)
bulwahn@33754
   357
lemma "f () = False \<or> f () = True"
bulwahn@33754
   358
by simp
haftmann@30328
   359
blanchet@37549
   360
lemma closure_of_bool_cases [no_atp]:
haftmann@44007
   361
  fixes f :: "unit \<Rightarrow> bool"
haftmann@44007
   362
  assumes "f = (\<lambda>u. False) \<Longrightarrow> P f"
haftmann@44007
   363
  assumes "f = (\<lambda>u. True) \<Longrightarrow> P f"
haftmann@44007
   364
  shows "P f"
bulwahn@33754
   365
proof -
haftmann@44007
   366
  have "f = (\<lambda>u. False) \<or> f = (\<lambda>u. True)"
bulwahn@33754
   367
    apply (cases "f ()")
bulwahn@33754
   368
    apply (rule disjI2)
bulwahn@33754
   369
    apply (rule ext)
bulwahn@33754
   370
    apply (simp add: unit_eq)
bulwahn@33754
   371
    apply (rule disjI1)
bulwahn@33754
   372
    apply (rule ext)
bulwahn@33754
   373
    apply (simp add: unit_eq)
bulwahn@33754
   374
    done
wenzelm@41550
   375
  from this assms show ?thesis by blast
bulwahn@33754
   376
qed
bulwahn@33754
   377
bulwahn@33754
   378
lemma unit_pred_cases:
haftmann@44007
   379
  assumes "P \<bottom>"
haftmann@44007
   380
  assumes "P (single ())"
haftmann@44007
   381
  shows "P Q"
haftmann@44415
   382
using assms unfolding bot_pred_def bot_fun_def bot_bool_def empty_def single_def proof (cases Q)
haftmann@44007
   383
  fix f
haftmann@44007
   384
  assume "P (Pred (\<lambda>u. False))" "P (Pred (\<lambda>u. () = u))"
haftmann@44007
   385
  then have "P (Pred f)" 
haftmann@44007
   386
    by (cases _ f rule: closure_of_bool_cases) simp_all
haftmann@44007
   387
  moreover assume "Q = Pred f"
haftmann@44007
   388
  ultimately show "P Q" by simp
haftmann@44007
   389
qed
haftmann@44007
   390
  
bulwahn@33754
   391
lemma holds_if_pred:
bulwahn@33754
   392
  "holds (if_pred b) = b"
bulwahn@33754
   393
unfolding if_pred_eq holds_eq
bulwahn@33754
   394
by (cases b) (auto intro: singleI elim: botE)
bulwahn@33754
   395
bulwahn@33754
   396
lemma if_pred_holds:
bulwahn@33754
   397
  "if_pred (holds P) = P"
bulwahn@33754
   398
unfolding if_pred_eq holds_eq
bulwahn@33754
   399
by (rule unit_pred_cases) (auto intro: singleI elim: botE)
bulwahn@33754
   400
bulwahn@33754
   401
lemma is_empty_holds:
bulwahn@33754
   402
  "is_empty P \<longleftrightarrow> \<not> holds P"
bulwahn@33754
   403
unfolding is_empty_def holds_eq
bulwahn@33754
   404
by (rule unit_pred_cases) (auto elim: botE intro: singleI)
haftmann@30328
   405
haftmann@41311
   406
definition map :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a pred \<Rightarrow> 'b pred" where
haftmann@41311
   407
  "map f P = P \<guillemotright>= (single o f)"
haftmann@41311
   408
haftmann@41311
   409
lemma eval_map [simp]:
haftmann@44363
   410
  "eval (map f P) = (\<Squnion>x\<in>{x. eval P x}. (\<lambda>y. f x = y))"
haftmann@44415
   411
  by (auto simp add: map_def comp_def)
haftmann@41311
   412
haftmann@41505
   413
enriched_type map: map
haftmann@44363
   414
  by (rule ext, rule pred_eqI, auto)+
haftmann@41311
   415
haftmann@41311
   416
haftmann@46664
   417
subsection {* Implementation *}
haftmann@30328
   418
haftmann@30328
   419
datatype 'a seq = Empty | Insert "'a" "'a pred" | Join "'a pred" "'a seq"
haftmann@30328
   420
haftmann@30328
   421
primrec pred_of_seq :: "'a seq \<Rightarrow> 'a pred" where
haftmann@44414
   422
  "pred_of_seq Empty = \<bottom>"
haftmann@44414
   423
| "pred_of_seq (Insert x P) = single x \<squnion> P"
haftmann@44414
   424
| "pred_of_seq (Join P xq) = P \<squnion> pred_of_seq xq"
haftmann@30328
   425
haftmann@30328
   426
definition Seq :: "(unit \<Rightarrow> 'a seq) \<Rightarrow> 'a pred" where
haftmann@30328
   427
  "Seq f = pred_of_seq (f ())"
haftmann@30328
   428
haftmann@30328
   429
code_datatype Seq
haftmann@30328
   430
haftmann@30328
   431
primrec member :: "'a seq \<Rightarrow> 'a \<Rightarrow> bool"  where
haftmann@30328
   432
  "member Empty x \<longleftrightarrow> False"
haftmann@44414
   433
| "member (Insert y P) x \<longleftrightarrow> x = y \<or> eval P x"
haftmann@44414
   434
| "member (Join P xq) x \<longleftrightarrow> eval P x \<or> member xq x"
haftmann@30328
   435
haftmann@30328
   436
lemma eval_member:
haftmann@30328
   437
  "member xq = eval (pred_of_seq xq)"
haftmann@30328
   438
proof (induct xq)
haftmann@30328
   439
  case Empty show ?case
nipkow@39302
   440
  by (auto simp add: fun_eq_iff elim: botE)
haftmann@30328
   441
next
haftmann@30328
   442
  case Insert show ?case
nipkow@39302
   443
  by (auto simp add: fun_eq_iff elim: supE singleE intro: supI1 supI2 singleI)
haftmann@30328
   444
next
haftmann@30328
   445
  case Join then show ?case
nipkow@39302
   446
  by (auto simp add: fun_eq_iff elim: supE intro: supI1 supI2)
haftmann@30328
   447
qed
haftmann@30328
   448
haftmann@46038
   449
lemma eval_code [(* FIXME declare simp *)code]: "eval (Seq f) = member (f ())"
haftmann@30328
   450
  unfolding Seq_def by (rule sym, rule eval_member)
haftmann@30328
   451
haftmann@30328
   452
lemma single_code [code]:
haftmann@30328
   453
  "single x = Seq (\<lambda>u. Insert x \<bottom>)"
haftmann@30328
   454
  unfolding Seq_def by simp
haftmann@30328
   455
haftmann@41080
   456
primrec "apply" :: "('a \<Rightarrow> 'b pred) \<Rightarrow> 'a seq \<Rightarrow> 'b seq" where
haftmann@44415
   457
  "apply f Empty = Empty"
haftmann@44415
   458
| "apply f (Insert x P) = Join (f x) (Join (P \<guillemotright>= f) Empty)"
haftmann@44415
   459
| "apply f (Join P xq) = Join (P \<guillemotright>= f) (apply f xq)"
haftmann@30328
   460
haftmann@30328
   461
lemma apply_bind:
haftmann@30328
   462
  "pred_of_seq (apply f xq) = pred_of_seq xq \<guillemotright>= f"
haftmann@30328
   463
proof (induct xq)
haftmann@30328
   464
  case Empty show ?case
haftmann@30328
   465
    by (simp add: bottom_bind)
haftmann@30328
   466
next
haftmann@30328
   467
  case Insert show ?case
haftmann@30328
   468
    by (simp add: single_bind sup_bind)
haftmann@30328
   469
next
haftmann@30328
   470
  case Join then show ?case
haftmann@30328
   471
    by (simp add: sup_bind)
haftmann@30328
   472
qed
haftmann@30328
   473
  
haftmann@30328
   474
lemma bind_code [code]:
haftmann@30328
   475
  "Seq g \<guillemotright>= f = Seq (\<lambda>u. apply f (g ()))"
haftmann@30328
   476
  unfolding Seq_def by (rule sym, rule apply_bind)
haftmann@30328
   477
haftmann@30328
   478
lemma bot_set_code [code]:
haftmann@30328
   479
  "\<bottom> = Seq (\<lambda>u. Empty)"
haftmann@30328
   480
  unfolding Seq_def by simp
haftmann@30328
   481
haftmann@30376
   482
primrec adjunct :: "'a pred \<Rightarrow> 'a seq \<Rightarrow> 'a seq" where
haftmann@44415
   483
  "adjunct P Empty = Join P Empty"
haftmann@44415
   484
| "adjunct P (Insert x Q) = Insert x (Q \<squnion> P)"
haftmann@44415
   485
| "adjunct P (Join Q xq) = Join Q (adjunct P xq)"
haftmann@30376
   486
haftmann@30376
   487
lemma adjunct_sup:
haftmann@30376
   488
  "pred_of_seq (adjunct P xq) = P \<squnion> pred_of_seq xq"
haftmann@30376
   489
  by (induct xq) (simp_all add: sup_assoc sup_commute sup_left_commute)
haftmann@30376
   490
haftmann@30328
   491
lemma sup_code [code]:
haftmann@30328
   492
  "Seq f \<squnion> Seq g = Seq (\<lambda>u. case f ()
haftmann@30328
   493
    of Empty \<Rightarrow> g ()
haftmann@30328
   494
     | Insert x P \<Rightarrow> Insert x (P \<squnion> Seq g)
haftmann@30376
   495
     | Join P xq \<Rightarrow> adjunct (Seq g) (Join P xq))"
haftmann@30328
   496
proof (cases "f ()")
haftmann@30328
   497
  case Empty
haftmann@30328
   498
  thus ?thesis
haftmann@34007
   499
    unfolding Seq_def by (simp add: sup_commute [of "\<bottom>"])
haftmann@30328
   500
next
haftmann@30328
   501
  case Insert
haftmann@30328
   502
  thus ?thesis
haftmann@30328
   503
    unfolding Seq_def by (simp add: sup_assoc)
haftmann@30328
   504
next
haftmann@30328
   505
  case Join
haftmann@30328
   506
  thus ?thesis
haftmann@30376
   507
    unfolding Seq_def
haftmann@30376
   508
    by (simp add: adjunct_sup sup_assoc sup_commute sup_left_commute)
haftmann@30328
   509
qed
haftmann@30328
   510
haftmann@46664
   511
lemma [code]:
haftmann@46664
   512
  "size (P :: 'a Predicate.pred) = 0" by (cases P) simp
haftmann@46664
   513
haftmann@46664
   514
lemma [code]:
haftmann@46664
   515
  "pred_size f P = 0" by (cases P) simp
haftmann@46664
   516
haftmann@30430
   517
primrec contained :: "'a seq \<Rightarrow> 'a pred \<Rightarrow> bool" where
haftmann@44415
   518
  "contained Empty Q \<longleftrightarrow> True"
haftmann@44415
   519
| "contained (Insert x P) Q \<longleftrightarrow> eval Q x \<and> P \<le> Q"
haftmann@44415
   520
| "contained (Join P xq) Q \<longleftrightarrow> P \<le> Q \<and> contained xq Q"
haftmann@30430
   521
haftmann@30430
   522
lemma single_less_eq_eval:
haftmann@30430
   523
  "single x \<le> P \<longleftrightarrow> eval P x"
haftmann@44415
   524
  by (auto simp add: less_eq_pred_def le_fun_def)
haftmann@30430
   525
haftmann@30430
   526
lemma contained_less_eq:
haftmann@30430
   527
  "contained xq Q \<longleftrightarrow> pred_of_seq xq \<le> Q"
haftmann@30430
   528
  by (induct xq) (simp_all add: single_less_eq_eval)
haftmann@30430
   529
haftmann@30430
   530
lemma less_eq_pred_code [code]:
haftmann@30430
   531
  "Seq f \<le> Q = (case f ()
haftmann@30430
   532
   of Empty \<Rightarrow> True
haftmann@30430
   533
    | Insert x P \<Rightarrow> eval Q x \<and> P \<le> Q
haftmann@30430
   534
    | Join P xq \<Rightarrow> P \<le> Q \<and> contained xq Q)"
haftmann@30430
   535
  by (cases "f ()")
haftmann@30430
   536
    (simp_all add: Seq_def single_less_eq_eval contained_less_eq)
haftmann@30430
   537
haftmann@30430
   538
lemma eq_pred_code [code]:
haftmann@31133
   539
  fixes P Q :: "'a pred"
haftmann@38857
   540
  shows "HOL.equal P Q \<longleftrightarrow> P \<le> Q \<and> Q \<le> P"
haftmann@38857
   541
  by (auto simp add: equal)
haftmann@38857
   542
haftmann@38857
   543
lemma [code nbe]:
haftmann@38857
   544
  "HOL.equal (x :: 'a pred) x \<longleftrightarrow> True"
haftmann@38857
   545
  by (fact equal_refl)
haftmann@30430
   546
haftmann@30430
   547
lemma [code]:
haftmann@30430
   548
  "pred_case f P = f (eval P)"
haftmann@30430
   549
  by (cases P) simp
haftmann@30430
   550
haftmann@30430
   551
lemma [code]:
haftmann@30430
   552
  "pred_rec f P = f (eval P)"
haftmann@30430
   553
  by (cases P) simp
haftmann@30328
   554
bulwahn@31105
   555
inductive eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" where "eq x x"
bulwahn@31105
   556
bulwahn@31105
   557
lemma eq_is_eq: "eq x y \<equiv> (x = y)"
haftmann@31108
   558
  by (rule eq_reflection) (auto intro: eq.intros elim: eq.cases)
haftmann@30948
   559
haftmann@32578
   560
primrec null :: "'a seq \<Rightarrow> bool" where
haftmann@44415
   561
  "null Empty \<longleftrightarrow> True"
haftmann@44415
   562
| "null (Insert x P) \<longleftrightarrow> False"
haftmann@44415
   563
| "null (Join P xq) \<longleftrightarrow> is_empty P \<and> null xq"
haftmann@32578
   564
haftmann@32578
   565
lemma null_is_empty:
haftmann@32578
   566
  "null xq \<longleftrightarrow> is_empty (pred_of_seq xq)"
haftmann@32578
   567
  by (induct xq) (simp_all add: is_empty_bot not_is_empty_single is_empty_sup)
haftmann@32578
   568
haftmann@32578
   569
lemma is_empty_code [code]:
haftmann@32578
   570
  "is_empty (Seq f) \<longleftrightarrow> null (f ())"
haftmann@32578
   571
  by (simp add: null_is_empty Seq_def)
haftmann@32578
   572
bulwahn@33111
   573
primrec the_only :: "(unit \<Rightarrow> 'a) \<Rightarrow> 'a seq \<Rightarrow> 'a" where
bulwahn@33111
   574
  [code del]: "the_only dfault Empty = dfault ()"
haftmann@44415
   575
| "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 ())"
haftmann@44415
   576
| "the_only dfault (Join P xq) = (if is_empty P then the_only dfault xq else if null xq then singleton dfault P
bulwahn@33110
   577
       else let x = singleton dfault P; y = the_only dfault xq in
bulwahn@33111
   578
       if x = y then x else dfault ())"
haftmann@32578
   579
haftmann@32578
   580
lemma the_only_singleton:
bulwahn@33110
   581
  "the_only dfault xq = singleton dfault (pred_of_seq xq)"
haftmann@32578
   582
  by (induct xq)
haftmann@32578
   583
    (auto simp add: singleton_bot singleton_single is_empty_def
haftmann@32578
   584
    null_is_empty Let_def singleton_sup)
haftmann@32578
   585
haftmann@32578
   586
lemma singleton_code [code]:
bulwahn@33110
   587
  "singleton dfault (Seq f) = (case f ()
bulwahn@33111
   588
   of Empty \<Rightarrow> dfault ()
haftmann@32578
   589
    | Insert x P \<Rightarrow> if is_empty P then x
bulwahn@33110
   590
        else let y = singleton dfault P in
bulwahn@33111
   591
          if x = y then x else dfault ()
bulwahn@33110
   592
    | Join P xq \<Rightarrow> if is_empty P then the_only dfault xq
bulwahn@33110
   593
        else if null xq then singleton dfault P
bulwahn@33110
   594
        else let x = singleton dfault P; y = the_only dfault xq in
bulwahn@33111
   595
          if x = y then x else dfault ())"
haftmann@32578
   596
  by (cases "f ()")
haftmann@32578
   597
   (auto simp add: Seq_def the_only_singleton is_empty_def
haftmann@32578
   598
      null_is_empty singleton_bot singleton_single singleton_sup Let_def)
haftmann@32578
   599
haftmann@44414
   600
definition the :: "'a pred \<Rightarrow> 'a" where
haftmann@37767
   601
  "the A = (THE x. eval A x)"
bulwahn@33111
   602
haftmann@40674
   603
lemma the_eqI:
haftmann@41080
   604
  "(THE x. eval P x) = x \<Longrightarrow> the P = x"
haftmann@40674
   605
  by (simp add: the_def)
haftmann@40674
   606
haftmann@44414
   607
definition not_unique :: "'a pred \<Rightarrow> 'a" where
haftmann@44414
   608
  [code del]: "not_unique A = (THE x. eval A x)"
haftmann@44414
   609
haftmann@44414
   610
code_abort not_unique
haftmann@44414
   611
haftmann@40674
   612
lemma the_eq [code]: "the A = singleton (\<lambda>x. not_unique A) A"
haftmann@40674
   613
  by (rule the_eqI) (simp add: singleton_def not_unique_def)
bulwahn@33110
   614
haftmann@36531
   615
code_reflect Predicate
haftmann@36513
   616
  datatypes pred = Seq and seq = Empty | Insert | Join
haftmann@36513
   617
  functions map
haftmann@36513
   618
haftmann@30948
   619
ML {*
haftmann@30948
   620
signature PREDICATE =
haftmann@30948
   621
sig
haftmann@30948
   622
  datatype 'a pred = Seq of (unit -> 'a seq)
haftmann@30948
   623
  and 'a seq = Empty | Insert of 'a * 'a pred | Join of 'a pred * 'a seq
haftmann@30959
   624
  val yield: 'a pred -> ('a * 'a pred) option
haftmann@30959
   625
  val yieldn: int -> 'a pred -> 'a list * 'a pred
haftmann@31222
   626
  val map: ('a -> 'b) -> 'a pred -> 'b pred
haftmann@30948
   627
end;
haftmann@30948
   628
haftmann@30948
   629
structure Predicate : PREDICATE =
haftmann@30948
   630
struct
haftmann@30948
   631
haftmann@36513
   632
datatype pred = datatype Predicate.pred
haftmann@36513
   633
datatype seq = datatype Predicate.seq
haftmann@36513
   634
haftmann@36513
   635
fun map f = Predicate.map f;
haftmann@30959
   636
haftmann@36513
   637
fun yield (Seq f) = next (f ())
haftmann@36513
   638
and next Empty = NONE
haftmann@36513
   639
  | next (Insert (x, P)) = SOME (x, P)
haftmann@36513
   640
  | next (Join (P, xq)) = (case yield P
haftmann@30959
   641
     of NONE => next xq
haftmann@36513
   642
      | SOME (x, Q) => SOME (x, Seq (fn _ => Join (Q, xq))));
haftmann@30959
   643
haftmann@30959
   644
fun anamorph f k x = (if k = 0 then ([], x)
haftmann@30959
   645
  else case f x
haftmann@30959
   646
   of NONE => ([], x)
haftmann@30959
   647
    | SOME (v, y) => let
haftmann@30959
   648
        val (vs, z) = anamorph f (k - 1) y
haftmann@33607
   649
      in (v :: vs, z) end);
haftmann@30959
   650
haftmann@30959
   651
fun yieldn P = anamorph yield P;
haftmann@30948
   652
haftmann@30948
   653
end;
haftmann@30948
   654
*}
haftmann@30948
   655
haftmann@46038
   656
text {* Conversion from and to sets *}
haftmann@46038
   657
haftmann@46038
   658
definition pred_of_set :: "'a set \<Rightarrow> 'a pred" where
haftmann@46038
   659
  "pred_of_set = Pred \<circ> (\<lambda>A x. x \<in> A)"
haftmann@46038
   660
haftmann@46038
   661
lemma eval_pred_of_set [simp]:
haftmann@46038
   662
  "eval (pred_of_set A) x \<longleftrightarrow> x \<in>A"
haftmann@46038
   663
  by (simp add: pred_of_set_def)
haftmann@46038
   664
haftmann@46038
   665
definition set_of_pred :: "'a pred \<Rightarrow> 'a set" where
haftmann@46038
   666
  "set_of_pred = Collect \<circ> eval"
haftmann@46038
   667
haftmann@46038
   668
lemma member_set_of_pred [simp]:
haftmann@46038
   669
  "x \<in> set_of_pred P \<longleftrightarrow> Predicate.eval P x"
haftmann@46038
   670
  by (simp add: set_of_pred_def)
haftmann@46038
   671
haftmann@46038
   672
definition set_of_seq :: "'a seq \<Rightarrow> 'a set" where
haftmann@46038
   673
  "set_of_seq = set_of_pred \<circ> pred_of_seq"
haftmann@46038
   674
haftmann@46038
   675
lemma member_set_of_seq [simp]:
haftmann@46038
   676
  "x \<in> set_of_seq xq = Predicate.member xq x"
haftmann@46038
   677
  by (simp add: set_of_seq_def eval_member)
haftmann@46038
   678
haftmann@46038
   679
lemma of_pred_code [code]:
haftmann@46038
   680
  "set_of_pred (Predicate.Seq f) = (case f () of
haftmann@46038
   681
     Predicate.Empty \<Rightarrow> {}
haftmann@46038
   682
   | Predicate.Insert x P \<Rightarrow> insert x (set_of_pred P)
haftmann@46038
   683
   | Predicate.Join P xq \<Rightarrow> set_of_pred P \<union> set_of_seq xq)"
haftmann@46038
   684
  by (auto split: seq.split simp add: eval_code)
haftmann@46038
   685
haftmann@46038
   686
lemma of_seq_code [code]:
haftmann@46038
   687
  "set_of_seq Predicate.Empty = {}"
haftmann@46038
   688
  "set_of_seq (Predicate.Insert x P) = insert x (set_of_pred P)"
haftmann@46038
   689
  "set_of_seq (Predicate.Join P xq) = set_of_pred P \<union> set_of_seq xq"
haftmann@46038
   690
  by auto
haftmann@46038
   691
haftmann@46664
   692
text {* Lazy Evaluation of an indexed function *}
haftmann@46664
   693
haftmann@46664
   694
function iterate_upto :: "(code_numeral \<Rightarrow> 'a) \<Rightarrow> code_numeral \<Rightarrow> code_numeral \<Rightarrow> 'a Predicate.pred"
haftmann@46664
   695
where
haftmann@46664
   696
  "iterate_upto f n m =
haftmann@46664
   697
    Predicate.Seq (%u. if n > m then Predicate.Empty
haftmann@46664
   698
     else Predicate.Insert (f n) (iterate_upto f (n + 1) m))"
haftmann@46664
   699
by pat_completeness auto
haftmann@46664
   700
haftmann@46664
   701
termination by (relation "measure (%(f, n, m). Code_Numeral.nat_of (m + 1 - n))") auto
haftmann@46664
   702
haftmann@46664
   703
text {* Misc *}
haftmann@46664
   704
haftmann@47399
   705
declare Inf_set_fold [where 'a = "'a Predicate.pred", code]
haftmann@47399
   706
declare Sup_set_fold [where 'a = "'a Predicate.pred", code]
haftmann@46664
   707
haftmann@46664
   708
(* FIXME: better implement conversion by bisection *)
haftmann@46664
   709
haftmann@46664
   710
lemma pred_of_set_fold_sup:
haftmann@46664
   711
  assumes "finite A"
haftmann@46664
   712
  shows "pred_of_set A = Finite_Set.fold sup bot (Predicate.single ` A)" (is "?lhs = ?rhs")
haftmann@46664
   713
proof (rule sym)
haftmann@46664
   714
  interpret comp_fun_idem "sup :: 'a Predicate.pred \<Rightarrow> 'a Predicate.pred \<Rightarrow> 'a Predicate.pred"
haftmann@46664
   715
    by (fact comp_fun_idem_sup)
haftmann@46664
   716
  from `finite A` show "?rhs = ?lhs" by (induct A) (auto intro!: pred_eqI)
haftmann@46664
   717
qed
haftmann@46664
   718
haftmann@46664
   719
lemma pred_of_set_set_fold_sup:
haftmann@46664
   720
  "pred_of_set (set xs) = fold sup (List.map Predicate.single xs) bot"
haftmann@46664
   721
proof -
haftmann@46664
   722
  interpret comp_fun_idem "sup :: 'a Predicate.pred \<Rightarrow> 'a Predicate.pred \<Rightarrow> 'a Predicate.pred"
haftmann@46664
   723
    by (fact comp_fun_idem_sup)
haftmann@46664
   724
  show ?thesis by (simp add: pred_of_set_fold_sup fold_set_fold [symmetric])
haftmann@46664
   725
qed
haftmann@46664
   726
haftmann@46664
   727
lemma pred_of_set_set_foldr_sup [code]:
haftmann@46664
   728
  "pred_of_set (set xs) = foldr sup (List.map Predicate.single xs) bot"
haftmann@46664
   729
  by (simp add: pred_of_set_set_fold_sup ac_simps foldr_fold fun_eq_iff)
haftmann@46664
   730
haftmann@30328
   731
no_notation
haftmann@41082
   732
  bot ("\<bottom>") and
haftmann@41082
   733
  top ("\<top>") and
haftmann@30328
   734
  inf (infixl "\<sqinter>" 70) and
haftmann@30328
   735
  sup (infixl "\<squnion>" 65) and
haftmann@30328
   736
  Inf ("\<Sqinter>_" [900] 900) and
haftmann@30328
   737
  Sup ("\<Squnion>_" [900] 900) and
haftmann@30328
   738
  bind (infixl "\<guillemotright>=" 70)
haftmann@30328
   739
haftmann@41080
   740
no_syntax (xsymbols)
haftmann@41082
   741
  "_INF1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Sqinter>_./ _)" [0, 10] 10)
haftmann@41082
   742
  "_INF"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Sqinter>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
   743
  "_SUP1"     :: "pttrns \<Rightarrow> 'b \<Rightarrow> 'b"           ("(3\<Squnion>_./ _)" [0, 10] 10)
haftmann@41080
   744
  "_SUP"      :: "pttrn \<Rightarrow> 'a set \<Rightarrow> 'b \<Rightarrow> 'b"  ("(3\<Squnion>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@41080
   745
wenzelm@36176
   746
hide_type (open) pred seq
wenzelm@36176
   747
hide_const (open) Pred eval single bind is_empty singleton if_pred not_pred holds
bulwahn@33111
   748
  Empty Insert Join Seq member pred_of_seq "apply" adjunct null the_only eq map not_unique the
haftmann@46664
   749
  iterate_upto
haftmann@46664
   750
hide_fact (open) null_def member_def
haftmann@30328
   751
haftmann@30328
   752
end
haftmann@46664
   753