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