src/HOL/Hilbert_Choice.thy
 author haftmann Fri Apr 20 11:21:42 2007 +0200 (2007-04-20) changeset 22744 5cbe966d67a2 parent 22690 0b08f218f260 child 23433 c2c10abd2a1e permissions -rw-r--r--
Isar definitions are now added explicitly to code theorem table
```     1 (*  Title:      HOL/Hilbert_Choice.thy
```
```     2     ID: \$Id\$
```
```     3     Author:     Lawrence C Paulson
```
```     4     Copyright   2001  University of Cambridge
```
```     5 *)
```
```     6
```
```     7 header {* Hilbert's Epsilon-Operator and the Axiom of Choice *}
```
```     8
```
```     9 theory Hilbert_Choice
```
```    10 imports Nat
```
```    11 uses ("Tools/meson.ML") ("Tools/specification_package.ML")
```
```    12 begin
```
```    13
```
```    14 subsection {* Hilbert's epsilon *}
```
```    15
```
```    16 axiomatization
```
```    17   Eps :: "('a => bool) => 'a"
```
```    18 where
```
```    19   someI: "P x ==> P (Eps P)"
```
```    20
```
```    21 syntax (epsilon)
```
```    22   "_Eps"        :: "[pttrn, bool] => 'a"    ("(3\<some>_./ _)" [0, 10] 10)
```
```    23 syntax (HOL)
```
```    24   "_Eps"        :: "[pttrn, bool] => 'a"    ("(3@ _./ _)" [0, 10] 10)
```
```    25 syntax
```
```    26   "_Eps"        :: "[pttrn, bool] => 'a"    ("(3SOME _./ _)" [0, 10] 10)
```
```    27 translations
```
```    28   "SOME x. P" == "CONST Eps (%x. P)"
```
```    29
```
```    30 print_translation {*
```
```    31 (* to avoid eta-contraction of body *)
```
```    32 [(@{const_syntax Eps}, fn [Abs abs] =>
```
```    33      let val (x,t) = atomic_abs_tr' abs
```
```    34      in Syntax.const "_Eps" \$ x \$ t end)]
```
```    35 *}
```
```    36
```
```    37 constdefs
```
```    38   inv :: "('a => 'b) => ('b => 'a)"
```
```    39   "inv(f :: 'a => 'b) == %y. SOME x. f x = y"
```
```    40
```
```    41   Inv :: "'a set => ('a => 'b) => ('b => 'a)"
```
```    42   "Inv A f == %x. SOME y. y \<in> A & f y = x"
```
```    43
```
```    44
```
```    45 subsection {*Hilbert's Epsilon-operator*}
```
```    46
```
```    47 text{*Easier to apply than @{text someI} if the witness comes from an
```
```    48 existential formula*}
```
```    49 lemma someI_ex [elim?]: "\<exists>x. P x ==> P (SOME x. P x)"
```
```    50 apply (erule exE)
```
```    51 apply (erule someI)
```
```    52 done
```
```    53
```
```    54 text{*Easier to apply than @{text someI} because the conclusion has only one
```
```    55 occurrence of @{term P}.*}
```
```    56 lemma someI2: "[| P a;  !!x. P x ==> Q x |] ==> Q (SOME x. P x)"
```
```    57 by (blast intro: someI)
```
```    58
```
```    59 text{*Easier to apply than @{text someI2} if the witness comes from an
```
```    60 existential formula*}
```
```    61 lemma someI2_ex: "[| \<exists>a. P a; !!x. P x ==> Q x |] ==> Q (SOME x. P x)"
```
```    62 by (blast intro: someI2)
```
```    63
```
```    64 lemma some_equality [intro]:
```
```    65      "[| P a;  !!x. P x ==> x=a |] ==> (SOME x. P x) = a"
```
```    66 by (blast intro: someI2)
```
```    67
```
```    68 lemma some1_equality: "[| EX!x. P x; P a |] ==> (SOME x. P x) = a"
```
```    69 by (blast intro: some_equality)
```
```    70
```
```    71 lemma some_eq_ex: "P (SOME x. P x) =  (\<exists>x. P x)"
```
```    72 by (blast intro: someI)
```
```    73
```
```    74 lemma some_eq_trivial [simp]: "(SOME y. y=x) = x"
```
```    75 apply (rule some_equality)
```
```    76 apply (rule refl, assumption)
```
```    77 done
```
```    78
```
```    79 lemma some_sym_eq_trivial [simp]: "(SOME y. x=y) = x"
```
```    80 apply (rule some_equality)
```
```    81 apply (rule refl)
```
```    82 apply (erule sym)
```
```    83 done
```
```    84
```
```    85
```
```    86 subsection{*Axiom of Choice, Proved Using the Description Operator*}
```
```    87
```
```    88 text{*Used in @{text "Tools/meson.ML"}*}
```
```    89 lemma choice: "\<forall>x. \<exists>y. Q x y ==> \<exists>f. \<forall>x. Q x (f x)"
```
```    90 by (fast elim: someI)
```
```    91
```
```    92 lemma bchoice: "\<forall>x\<in>S. \<exists>y. Q x y ==> \<exists>f. \<forall>x\<in>S. Q x (f x)"
```
```    93 by (fast elim: someI)
```
```    94
```
```    95
```
```    96 subsection {*Function Inverse*}
```
```    97
```
```    98 lemma inv_id [simp]: "inv id = id"
```
```    99 by (simp add: inv_def id_def)
```
```   100
```
```   101 text{*A one-to-one function has an inverse.*}
```
```   102 lemma inv_f_f [simp]: "inj f ==> inv f (f x) = x"
```
```   103 by (simp add: inv_def inj_eq)
```
```   104
```
```   105 lemma inv_f_eq: "[| inj f;  f x = y |] ==> inv f y = x"
```
```   106 apply (erule subst)
```
```   107 apply (erule inv_f_f)
```
```   108 done
```
```   109
```
```   110 lemma inj_imp_inv_eq: "[| inj f; \<forall>x. f(g x) = x |] ==> inv f = g"
```
```   111 by (blast intro: ext inv_f_eq)
```
```   112
```
```   113 text{*But is it useful?*}
```
```   114 lemma inj_transfer:
```
```   115   assumes injf: "inj f" and minor: "!!y. y \<in> range(f) ==> P(inv f y)"
```
```   116   shows "P x"
```
```   117 proof -
```
```   118   have "f x \<in> range f" by auto
```
```   119   hence "P(inv f (f x))" by (rule minor)
```
```   120   thus "P x" by (simp add: inv_f_f [OF injf])
```
```   121 qed
```
```   122
```
```   123
```
```   124 lemma inj_iff: "(inj f) = (inv f o f = id)"
```
```   125 apply (simp add: o_def expand_fun_eq)
```
```   126 apply (blast intro: inj_on_inverseI inv_f_f)
```
```   127 done
```
```   128
```
```   129 lemma inj_imp_surj_inv: "inj f ==> surj (inv f)"
```
```   130 by (blast intro: surjI inv_f_f)
```
```   131
```
```   132 lemma f_inv_f: "y \<in> range(f) ==> f(inv f y) = y"
```
```   133 apply (simp add: inv_def)
```
```   134 apply (fast intro: someI)
```
```   135 done
```
```   136
```
```   137 lemma surj_f_inv_f: "surj f ==> f(inv f y) = y"
```
```   138 by (simp add: f_inv_f surj_range)
```
```   139
```
```   140 lemma inv_injective:
```
```   141   assumes eq: "inv f x = inv f y"
```
```   142       and x: "x: range f"
```
```   143       and y: "y: range f"
```
```   144   shows "x=y"
```
```   145 proof -
```
```   146   have "f (inv f x) = f (inv f y)" using eq by simp
```
```   147   thus ?thesis by (simp add: f_inv_f x y)
```
```   148 qed
```
```   149
```
```   150 lemma inj_on_inv: "A <= range(f) ==> inj_on (inv f) A"
```
```   151 by (fast intro: inj_onI elim: inv_injective injD)
```
```   152
```
```   153 lemma surj_imp_inj_inv: "surj f ==> inj (inv f)"
```
```   154 by (simp add: inj_on_inv surj_range)
```
```   155
```
```   156 lemma surj_iff: "(surj f) = (f o inv f = id)"
```
```   157 apply (simp add: o_def expand_fun_eq)
```
```   158 apply (blast intro: surjI surj_f_inv_f)
```
```   159 done
```
```   160
```
```   161 lemma surj_imp_inv_eq: "[| surj f; \<forall>x. g(f x) = x |] ==> inv f = g"
```
```   162 apply (rule ext)
```
```   163 apply (drule_tac x = "inv f x" in spec)
```
```   164 apply (simp add: surj_f_inv_f)
```
```   165 done
```
```   166
```
```   167 lemma bij_imp_bij_inv: "bij f ==> bij (inv f)"
```
```   168 by (simp add: bij_def inj_imp_surj_inv surj_imp_inj_inv)
```
```   169
```
```   170 lemma inv_equality: "[| !!x. g (f x) = x;  !!y. f (g y) = y |] ==> inv f = g"
```
```   171 apply (rule ext)
```
```   172 apply (auto simp add: inv_def)
```
```   173 done
```
```   174
```
```   175 lemma inv_inv_eq: "bij f ==> inv (inv f) = f"
```
```   176 apply (rule inv_equality)
```
```   177 apply (auto simp add: bij_def surj_f_inv_f)
```
```   178 done
```
```   179
```
```   180 (** bij(inv f) implies little about f.  Consider f::bool=>bool such that
```
```   181     f(True)=f(False)=True.  Then it's consistent with axiom someI that
```
```   182     inv f could be any function at all, including the identity function.
```
```   183     If inv f=id then inv f is a bijection, but inj f, surj(f) and
```
```   184     inv(inv f)=f all fail.
```
```   185 **)
```
```   186
```
```   187 lemma o_inv_distrib: "[| bij f; bij g |] ==> inv (f o g) = inv g o inv f"
```
```   188 apply (rule inv_equality)
```
```   189 apply (auto simp add: bij_def surj_f_inv_f)
```
```   190 done
```
```   191
```
```   192
```
```   193 lemma image_surj_f_inv_f: "surj f ==> f ` (inv f ` A) = A"
```
```   194 by (simp add: image_eq_UN surj_f_inv_f)
```
```   195
```
```   196 lemma image_inv_f_f: "inj f ==> (inv f) ` (f ` A) = A"
```
```   197 by (simp add: image_eq_UN)
```
```   198
```
```   199 lemma inv_image_comp: "inj f ==> inv f ` (f`X) = X"
```
```   200 by (auto simp add: image_def)
```
```   201
```
```   202 lemma bij_image_Collect_eq: "bij f ==> f ` Collect P = {y. P (inv f y)}"
```
```   203 apply auto
```
```   204 apply (force simp add: bij_is_inj)
```
```   205 apply (blast intro: bij_is_surj [THEN surj_f_inv_f, symmetric])
```
```   206 done
```
```   207
```
```   208 lemma bij_vimage_eq_inv_image: "bij f ==> f -` A = inv f ` A"
```
```   209 apply (auto simp add: bij_is_surj [THEN surj_f_inv_f])
```
```   210 apply (blast intro: bij_is_inj [THEN inv_f_f, symmetric])
```
```   211 done
```
```   212
```
```   213
```
```   214 subsection {*Inverse of a PI-function (restricted domain)*}
```
```   215
```
```   216 lemma Inv_f_f: "[| inj_on f A;  x \<in> A |] ==> Inv A f (f x) = x"
```
```   217 apply (simp add: Inv_def inj_on_def)
```
```   218 apply (blast intro: someI2)
```
```   219 done
```
```   220
```
```   221 lemma f_Inv_f: "y \<in> f`A  ==> f (Inv A f y) = y"
```
```   222 apply (simp add: Inv_def)
```
```   223 apply (fast intro: someI2)
```
```   224 done
```
```   225
```
```   226 lemma Inv_injective:
```
```   227   assumes eq: "Inv A f x = Inv A f y"
```
```   228       and x: "x: f`A"
```
```   229       and y: "y: f`A"
```
```   230   shows "x=y"
```
```   231 proof -
```
```   232   have "f (Inv A f x) = f (Inv A f y)" using eq by simp
```
```   233   thus ?thesis by (simp add: f_Inv_f x y)
```
```   234 qed
```
```   235
```
```   236 lemma inj_on_Inv: "B <= f`A ==> inj_on (Inv A f) B"
```
```   237 apply (rule inj_onI)
```
```   238 apply (blast intro: inj_onI dest: Inv_injective injD)
```
```   239 done
```
```   240
```
```   241 lemma Inv_mem: "[| f ` A = B;  x \<in> B |] ==> Inv A f x \<in> A"
```
```   242 apply (simp add: Inv_def)
```
```   243 apply (fast intro: someI2)
```
```   244 done
```
```   245
```
```   246 lemma Inv_f_eq: "[| inj_on f A; f x = y; x \<in> A |] ==> Inv A f y = x"
```
```   247   apply (erule subst)
```
```   248   apply (erule Inv_f_f, assumption)
```
```   249   done
```
```   250
```
```   251 lemma Inv_comp:
```
```   252   "[| inj_on f (g ` A); inj_on g A; x \<in> f ` g ` A |] ==>
```
```   253   Inv A (f o g) x = (Inv A g o Inv (g ` A) f) x"
```
```   254   apply simp
```
```   255   apply (rule Inv_f_eq)
```
```   256     apply (fast intro: comp_inj_on)
```
```   257    apply (simp add: f_Inv_f Inv_mem)
```
```   258   apply (simp add: Inv_mem)
```
```   259   done
```
```   260
```
```   261
```
```   262 subsection {*Other Consequences of Hilbert's Epsilon*}
```
```   263
```
```   264 text {*Hilbert's Epsilon and the @{term split} Operator*}
```
```   265
```
```   266 text{*Looping simprule*}
```
```   267 lemma split_paired_Eps: "(SOME x. P x) = (SOME (a,b). P(a,b))"
```
```   268 by (simp add: split_Pair_apply)
```
```   269
```
```   270 lemma Eps_split: "Eps (split P) = (SOME xy. P (fst xy) (snd xy))"
```
```   271 by (simp add: split_def)
```
```   272
```
```   273 lemma Eps_split_eq [simp]: "(@(x',y'). x = x' & y = y') = (x,y)"
```
```   274 by blast
```
```   275
```
```   276
```
```   277 text{*A relation is wellfounded iff it has no infinite descending chain*}
```
```   278 lemma wf_iff_no_infinite_down_chain:
```
```   279   "wf r = (~(\<exists>f. \<forall>i. (f(Suc i),f i) \<in> r))"
```
```   280 apply (simp only: wf_eq_minimal)
```
```   281 apply (rule iffI)
```
```   282  apply (rule notI)
```
```   283  apply (erule exE)
```
```   284  apply (erule_tac x = "{w. \<exists>i. w=f i}" in allE, blast)
```
```   285 apply (erule contrapos_np, simp, clarify)
```
```   286 apply (subgoal_tac "\<forall>n. nat_rec x (%i y. @z. z:Q & (z,y) :r) n \<in> Q")
```
```   287  apply (rule_tac x = "nat_rec x (%i y. @z. z:Q & (z,y) :r)" in exI)
```
```   288  apply (rule allI, simp)
```
```   289  apply (rule someI2_ex, blast, blast)
```
```   290 apply (rule allI)
```
```   291 apply (induct_tac "n", simp_all)
```
```   292 apply (rule someI2_ex, blast+)
```
```   293 done
```
```   294
```
```   295 text{*A dynamically-scoped fact for TFL *}
```
```   296 lemma tfl_some: "\<forall>P x. P x --> P (Eps P)"
```
```   297   by (blast intro: someI)
```
```   298
```
```   299
```
```   300 subsection {* Least value operator *}
```
```   301
```
```   302 constdefs
```
```   303   LeastM :: "['a => 'b::ord, 'a => bool] => 'a"
```
```   304   "LeastM m P == SOME x. P x & (\<forall>y. P y --> m x <= m y)"
```
```   305
```
```   306 syntax
```
```   307   "_LeastM" :: "[pttrn, 'a => 'b::ord, bool] => 'a"    ("LEAST _ WRT _. _" [0, 4, 10] 10)
```
```   308 translations
```
```   309   "LEAST x WRT m. P" == "LeastM m (%x. P)"
```
```   310
```
```   311 lemma LeastMI2:
```
```   312   "P x ==> (!!y. P y ==> m x <= m y)
```
```   313     ==> (!!x. P x ==> \<forall>y. P y --> m x \<le> m y ==> Q x)
```
```   314     ==> Q (LeastM m P)"
```
```   315   apply (simp add: LeastM_def)
```
```   316   apply (rule someI2_ex, blast, blast)
```
```   317   done
```
```   318
```
```   319 lemma LeastM_equality:
```
```   320   "P k ==> (!!x. P x ==> m k <= m x)
```
```   321     ==> m (LEAST x WRT m. P x) = (m k::'a::order)"
```
```   322   apply (rule LeastMI2, assumption, blast)
```
```   323   apply (blast intro!: order_antisym)
```
```   324   done
```
```   325
```
```   326 lemma wf_linord_ex_has_least:
```
```   327   "wf r ==> \<forall>x y. ((x,y):r^+) = ((y,x)~:r^*) ==> P k
```
```   328     ==> \<exists>x. P x & (!y. P y --> (m x,m y):r^*)"
```
```   329   apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]])
```
```   330   apply (drule_tac x = "m`Collect P" in spec, force)
```
```   331   done
```
```   332
```
```   333 lemma ex_has_least_nat:
```
```   334     "P k ==> \<exists>x. P x & (\<forall>y. P y --> m x <= (m y::nat))"
```
```   335   apply (simp only: pred_nat_trancl_eq_le [symmetric])
```
```   336   apply (rule wf_pred_nat [THEN wf_linord_ex_has_least])
```
```   337    apply (simp add: less_eq linorder_not_le pred_nat_trancl_eq_le, assumption)
```
```   338   done
```
```   339
```
```   340 lemma LeastM_nat_lemma:
```
```   341     "P k ==> P (LeastM m P) & (\<forall>y. P y --> m (LeastM m P) <= (m y::nat))"
```
```   342   apply (simp add: LeastM_def)
```
```   343   apply (rule someI_ex)
```
```   344   apply (erule ex_has_least_nat)
```
```   345   done
```
```   346
```
```   347 lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard]
```
```   348
```
```   349 lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)"
```
```   350 by (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp], assumption, assumption)
```
```   351
```
```   352
```
```   353 subsection {* Greatest value operator *}
```
```   354
```
```   355 constdefs
```
```   356   GreatestM :: "['a => 'b::ord, 'a => bool] => 'a"
```
```   357   "GreatestM m P == SOME x. P x & (\<forall>y. P y --> m y <= m x)"
```
```   358
```
```   359   Greatest :: "('a::ord => bool) => 'a"    (binder "GREATEST " 10)
```
```   360   "Greatest == GreatestM (%x. x)"
```
```   361
```
```   362 syntax
```
```   363   "_GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a"
```
```   364       ("GREATEST _ WRT _. _" [0, 4, 10] 10)
```
```   365
```
```   366 translations
```
```   367   "GREATEST x WRT m. P" == "GreatestM m (%x. P)"
```
```   368
```
```   369 lemma GreatestMI2:
```
```   370   "P x ==> (!!y. P y ==> m y <= m x)
```
```   371     ==> (!!x. P x ==> \<forall>y. P y --> m y \<le> m x ==> Q x)
```
```   372     ==> Q (GreatestM m P)"
```
```   373   apply (simp add: GreatestM_def)
```
```   374   apply (rule someI2_ex, blast, blast)
```
```   375   done
```
```   376
```
```   377 lemma GreatestM_equality:
```
```   378  "P k ==> (!!x. P x ==> m x <= m k)
```
```   379     ==> m (GREATEST x WRT m. P x) = (m k::'a::order)"
```
```   380   apply (rule_tac m = m in GreatestMI2, assumption, blast)
```
```   381   apply (blast intro!: order_antisym)
```
```   382   done
```
```   383
```
```   384 lemma Greatest_equality:
```
```   385   "P (k::'a::order) ==> (!!x. P x ==> x <= k) ==> (GREATEST x. P x) = k"
```
```   386   apply (simp add: Greatest_def)
```
```   387   apply (erule GreatestM_equality, blast)
```
```   388   done
```
```   389
```
```   390 lemma ex_has_greatest_nat_lemma:
```
```   391   "P k ==> \<forall>x. P x --> (\<exists>y. P y & ~ ((m y::nat) <= m x))
```
```   392     ==> \<exists>y. P y & ~ (m y < m k + n)"
```
```   393   apply (induct n, force)
```
```   394   apply (force simp add: le_Suc_eq)
```
```   395   done
```
```   396
```
```   397 lemma ex_has_greatest_nat:
```
```   398   "P k ==> \<forall>y. P y --> m y < b
```
```   399     ==> \<exists>x. P x & (\<forall>y. P y --> (m y::nat) <= m x)"
```
```   400   apply (rule ccontr)
```
```   401   apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma)
```
```   402     apply (subgoal_tac  "m k <= b", auto)
```
```   403   done
```
```   404
```
```   405 lemma GreatestM_nat_lemma:
```
```   406   "P k ==> \<forall>y. P y --> m y < b
```
```   407     ==> P (GreatestM m P) & (\<forall>y. P y --> (m y::nat) <= m (GreatestM m P))"
```
```   408   apply (simp add: GreatestM_def)
```
```   409   apply (rule someI_ex)
```
```   410   apply (erule ex_has_greatest_nat, assumption)
```
```   411   done
```
```   412
```
```   413 lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard]
```
```   414
```
```   415 lemma GreatestM_nat_le:
```
```   416   "P x ==> \<forall>y. P y --> m y < b
```
```   417     ==> (m x::nat) <= m (GreatestM m P)"
```
```   418   apply (blast dest: GreatestM_nat_lemma [THEN conjunct2, THEN spec, of P])
```
```   419   done
```
```   420
```
```   421
```
```   422 text {* \medskip Specialization to @{text GREATEST}. *}
```
```   423
```
```   424 lemma GreatestI: "P (k::nat) ==> \<forall>y. P y --> y < b ==> P (GREATEST x. P x)"
```
```   425   apply (simp add: Greatest_def)
```
```   426   apply (rule GreatestM_natI, auto)
```
```   427   done
```
```   428
```
```   429 lemma Greatest_le:
```
```   430     "P x ==> \<forall>y. P y --> y < b ==> (x::nat) <= (GREATEST x. P x)"
```
```   431   apply (simp add: Greatest_def)
```
```   432   apply (rule GreatestM_nat_le, auto)
```
```   433   done
```
```   434
```
```   435
```
```   436 subsection {* The Meson proof procedure *}
```
```   437
```
```   438 subsubsection {* Negation Normal Form *}
```
```   439
```
```   440 text {* de Morgan laws *}
```
```   441
```
```   442 lemma meson_not_conjD: "~(P&Q) ==> ~P | ~Q"
```
```   443   and meson_not_disjD: "~(P|Q) ==> ~P & ~Q"
```
```   444   and meson_not_notD: "~~P ==> P"
```
```   445   and meson_not_allD: "!!P. ~(\<forall>x. P(x)) ==> \<exists>x. ~P(x)"
```
```   446   and meson_not_exD: "!!P. ~(\<exists>x. P(x)) ==> \<forall>x. ~P(x)"
```
```   447   by fast+
```
```   448
```
```   449 text {* Removal of @{text "-->"} and @{text "<->"} (positive and
```
```   450 negative occurrences) *}
```
```   451
```
```   452 lemma meson_imp_to_disjD: "P-->Q ==> ~P | Q"
```
```   453   and meson_not_impD: "~(P-->Q) ==> P & ~Q"
```
```   454   and meson_iff_to_disjD: "P=Q ==> (~P | Q) & (~Q | P)"
```
```   455   and meson_not_iffD: "~(P=Q) ==> (P | Q) & (~P | ~Q)"
```
```   456     -- {* Much more efficient than @{prop "(P & ~Q) | (Q & ~P)"} for computing CNF *}
```
```   457   and meson_not_refl_disj_D: "x ~= x | P ==> P"
```
```   458   by fast+
```
```   459
```
```   460
```
```   461 subsubsection {* Pulling out the existential quantifiers *}
```
```   462
```
```   463 text {* Conjunction *}
```
```   464
```
```   465 lemma meson_conj_exD1: "!!P Q. (\<exists>x. P(x)) & Q ==> \<exists>x. P(x) & Q"
```
```   466   and meson_conj_exD2: "!!P Q. P & (\<exists>x. Q(x)) ==> \<exists>x. P & Q(x)"
```
```   467   by fast+
```
```   468
```
```   469
```
```   470 text {* Disjunction *}
```
```   471
```
```   472 lemma meson_disj_exD: "!!P Q. (\<exists>x. P(x)) | (\<exists>x. Q(x)) ==> \<exists>x. P(x) | Q(x)"
```
```   473   -- {* DO NOT USE with forall-Skolemization: makes fewer schematic variables!! *}
```
```   474   -- {* With ex-Skolemization, makes fewer Skolem constants *}
```
```   475   and meson_disj_exD1: "!!P Q. (\<exists>x. P(x)) | Q ==> \<exists>x. P(x) | Q"
```
```   476   and meson_disj_exD2: "!!P Q. P | (\<exists>x. Q(x)) ==> \<exists>x. P | Q(x)"
```
```   477   by fast+
```
```   478
```
```   479
```
```   480 subsubsection {* Generating clauses for the Meson Proof Procedure *}
```
```   481
```
```   482 text {* Disjunctions *}
```
```   483
```
```   484 lemma meson_disj_assoc: "(P|Q)|R ==> P|(Q|R)"
```
```   485   and meson_disj_comm: "P|Q ==> Q|P"
```
```   486   and meson_disj_FalseD1: "False|P ==> P"
```
```   487   and meson_disj_FalseD2: "P|False ==> P"
```
```   488   by fast+
```
```   489
```
```   490
```
```   491 subsection{*Lemmas for Meson, the Model Elimination Procedure*}
```
```   492
```
```   493 text{* Generation of contrapositives *}
```
```   494
```
```   495 text{*Inserts negated disjunct after removing the negation; P is a literal.
```
```   496   Model elimination requires assuming the negation of every attempted subgoal,
```
```   497   hence the negated disjuncts.*}
```
```   498 lemma make_neg_rule: "~P|Q ==> ((~P==>P) ==> Q)"
```
```   499 by blast
```
```   500
```
```   501 text{*Version for Plaisted's "Postive refinement" of the Meson procedure*}
```
```   502 lemma make_refined_neg_rule: "~P|Q ==> (P ==> Q)"
```
```   503 by blast
```
```   504
```
```   505 text{*@{term P} should be a literal*}
```
```   506 lemma make_pos_rule: "P|Q ==> ((P==>~P) ==> Q)"
```
```   507 by blast
```
```   508
```
```   509 text{*Versions of @{text make_neg_rule} and @{text make_pos_rule} that don't
```
```   510 insert new assumptions, for ordinary resolution.*}
```
```   511
```
```   512 lemmas make_neg_rule' = make_refined_neg_rule
```
```   513
```
```   514 lemma make_pos_rule': "[|P|Q; ~P|] ==> Q"
```
```   515 by blast
```
```   516
```
```   517 text{* Generation of a goal clause -- put away the final literal *}
```
```   518
```
```   519 lemma make_neg_goal: "~P ==> ((~P==>P) ==> False)"
```
```   520 by blast
```
```   521
```
```   522 lemma make_pos_goal: "P ==> ((P==>~P) ==> False)"
```
```   523 by blast
```
```   524
```
```   525
```
```   526 subsubsection{* Lemmas for Forward Proof*}
```
```   527
```
```   528 text{*There is a similarity to congruence rules*}
```
```   529
```
```   530 (*NOTE: could handle conjunctions (faster?) by
```
```   531     nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *)
```
```   532 lemma conj_forward: "[| P'&Q';  P' ==> P;  Q' ==> Q |] ==> P&Q"
```
```   533 by blast
```
```   534
```
```   535 lemma disj_forward: "[| P'|Q';  P' ==> P;  Q' ==> Q |] ==> P|Q"
```
```   536 by blast
```
```   537
```
```   538 (*Version of @{text disj_forward} for removal of duplicate literals*)
```
```   539 lemma disj_forward2:
```
```   540     "[| P'|Q';  P' ==> P;  [| Q'; P==>False |] ==> Q |] ==> P|Q"
```
```   541 apply blast
```
```   542 done
```
```   543
```
```   544 lemma all_forward: "[| \<forall>x. P'(x);  !!x. P'(x) ==> P(x) |] ==> \<forall>x. P(x)"
```
```   545 by blast
```
```   546
```
```   547 lemma ex_forward: "[| \<exists>x. P'(x);  !!x. P'(x) ==> P(x) |] ==> \<exists>x. P(x)"
```
```   548 by blast
```
```   549
```
```   550
```
```   551 text{*Many of these bindings are used by the ATP linkup, and not just by
```
```   552 legacy proof scripts.*}
```
```   553 ML
```
```   554 {*
```
```   555 val inv_def = thm "inv_def";
```
```   556 val Inv_def = thm "Inv_def";
```
```   557
```
```   558 val someI = thm "someI";
```
```   559 val someI_ex = thm "someI_ex";
```
```   560 val someI2 = thm "someI2";
```
```   561 val someI2_ex = thm "someI2_ex";
```
```   562 val some_equality = thm "some_equality";
```
```   563 val some1_equality = thm "some1_equality";
```
```   564 val some_eq_ex = thm "some_eq_ex";
```
```   565 val some_eq_trivial = thm "some_eq_trivial";
```
```   566 val some_sym_eq_trivial = thm "some_sym_eq_trivial";
```
```   567 val choice = thm "choice";
```
```   568 val bchoice = thm "bchoice";
```
```   569 val inv_id = thm "inv_id";
```
```   570 val inv_f_f = thm "inv_f_f";
```
```   571 val inv_f_eq = thm "inv_f_eq";
```
```   572 val inj_imp_inv_eq = thm "inj_imp_inv_eq";
```
```   573 val inj_transfer = thm "inj_transfer";
```
```   574 val inj_iff = thm "inj_iff";
```
```   575 val inj_imp_surj_inv = thm "inj_imp_surj_inv";
```
```   576 val f_inv_f = thm "f_inv_f";
```
```   577 val surj_f_inv_f = thm "surj_f_inv_f";
```
```   578 val inv_injective = thm "inv_injective";
```
```   579 val inj_on_inv = thm "inj_on_inv";
```
```   580 val surj_imp_inj_inv = thm "surj_imp_inj_inv";
```
```   581 val surj_iff = thm "surj_iff";
```
```   582 val surj_imp_inv_eq = thm "surj_imp_inv_eq";
```
```   583 val bij_imp_bij_inv = thm "bij_imp_bij_inv";
```
```   584 val inv_equality = thm "inv_equality";
```
```   585 val inv_inv_eq = thm "inv_inv_eq";
```
```   586 val o_inv_distrib = thm "o_inv_distrib";
```
```   587 val image_surj_f_inv_f = thm "image_surj_f_inv_f";
```
```   588 val image_inv_f_f = thm "image_inv_f_f";
```
```   589 val inv_image_comp = thm "inv_image_comp";
```
```   590 val bij_image_Collect_eq = thm "bij_image_Collect_eq";
```
```   591 val bij_vimage_eq_inv_image = thm "bij_vimage_eq_inv_image";
```
```   592 val Inv_f_f = thm "Inv_f_f";
```
```   593 val f_Inv_f = thm "f_Inv_f";
```
```   594 val Inv_injective = thm "Inv_injective";
```
```   595 val inj_on_Inv = thm "inj_on_Inv";
```
```   596 val split_paired_Eps = thm "split_paired_Eps";
```
```   597 val Eps_split = thm "Eps_split";
```
```   598 val Eps_split_eq = thm "Eps_split_eq";
```
```   599 val wf_iff_no_infinite_down_chain = thm "wf_iff_no_infinite_down_chain";
```
```   600 val Inv_mem = thm "Inv_mem";
```
```   601 val Inv_f_eq = thm "Inv_f_eq";
```
```   602 val Inv_comp = thm "Inv_comp";
```
```   603 val tfl_some = thm "tfl_some";
```
```   604 val make_neg_rule = thm "make_neg_rule";
```
```   605 val make_refined_neg_rule = thm "make_refined_neg_rule";
```
```   606 val make_pos_rule = thm "make_pos_rule";
```
```   607 val make_neg_rule' = thm "make_neg_rule'";
```
```   608 val make_pos_rule' = thm "make_pos_rule'";
```
```   609 val make_neg_goal = thm "make_neg_goal";
```
```   610 val make_pos_goal = thm "make_pos_goal";
```
```   611 val conj_forward = thm "conj_forward";
```
```   612 val disj_forward = thm "disj_forward";
```
```   613 val disj_forward2 = thm "disj_forward2";
```
```   614 val all_forward = thm "all_forward";
```
```   615 val ex_forward = thm "ex_forward";
```
```   616 *}
```
```   617
```
```   618
```
```   619 subsection {* Meson package *}
```
```   620
```
```   621 use "Tools/meson.ML"
```
```   622
```
```   623
```
```   624 subsection {* Specification package -- Hilbertized version *}
```
```   625
```
```   626 lemma exE_some: "[| Ex P ; c == Eps P |] ==> P c"
```
```   627   by (simp only: someI_ex)
```
```   628
```
```   629 use "Tools/specification_package.ML"
```
```   630
```
```   631 end
```