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