src/HOL/Hilbert_Choice.thy
author nipkow
Thu Feb 21 17:33:58 2008 +0100 (2008-02-21)
changeset 26105 ae06618225ec
parent 26072 f65a7fa2da6c
child 26347 105f55201077
permissions -rw-r--r--
moved bij_betw from Library/FuncSet to Fun, redistributed some lemmas, and
added some
     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 Wellfounded_Recursion
    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 lemma bij_betw_Inv: "bij_betw f A B \<Longrightarrow> bij_betw (Inv A f) B A"
   272   apply (auto simp add: bij_betw_def inj_on_Inv Inv_mem)
   273   apply (simp add: image_compose [symmetric] o_def)
   274   apply (simp add: image_def Inv_f_f)
   275   done
   276 
   277 subsection {*Other Consequences of Hilbert's Epsilon*}
   278 
   279 text {*Hilbert's Epsilon and the @{term split} Operator*}
   280 
   281 text{*Looping simprule*}
   282 lemma split_paired_Eps: "(SOME x. P x) = (SOME (a,b). P(a,b))"
   283 by (simp add: split_Pair_apply)
   284 
   285 lemma Eps_split: "Eps (split P) = (SOME xy. P (fst xy) (snd xy))"
   286 by (simp add: split_def)
   287 
   288 lemma Eps_split_eq [simp]: "(@(x',y'). x = x' & y = y') = (x,y)"
   289 by blast
   290 
   291 
   292 text{*A relation is wellfounded iff it has no infinite descending chain*}
   293 lemma wf_iff_no_infinite_down_chain:
   294   "wf r = (~(\<exists>f. \<forall>i. (f(Suc i),f i) \<in> r))"
   295 apply (simp only: wf_eq_minimal)
   296 apply (rule iffI)
   297  apply (rule notI)
   298  apply (erule exE)
   299  apply (erule_tac x = "{w. \<exists>i. w=f i}" in allE, blast)
   300 apply (erule contrapos_np, simp, clarify)
   301 apply (subgoal_tac "\<forall>n. nat_rec x (%i y. @z. z:Q & (z,y) :r) n \<in> Q")
   302  apply (rule_tac x = "nat_rec x (%i y. @z. z:Q & (z,y) :r)" in exI)
   303  apply (rule allI, simp)
   304  apply (rule someI2_ex, blast, blast)
   305 apply (rule allI)
   306 apply (induct_tac "n", simp_all)
   307 apply (rule someI2_ex, blast+)
   308 done
   309 
   310 text{*A dynamically-scoped fact for TFL *}
   311 lemma tfl_some: "\<forall>P x. P x --> P (Eps P)"
   312   by (blast intro: someI)
   313 
   314 
   315 subsection {* Least value operator *}
   316 
   317 constdefs
   318   LeastM :: "['a => 'b::ord, 'a => bool] => 'a"
   319   "LeastM m P == SOME x. P x & (\<forall>y. P y --> m x <= m y)"
   320 
   321 syntax
   322   "_LeastM" :: "[pttrn, 'a => 'b::ord, bool] => 'a"    ("LEAST _ WRT _. _" [0, 4, 10] 10)
   323 translations
   324   "LEAST x WRT m. P" == "LeastM m (%x. P)"
   325 
   326 lemma LeastMI2:
   327   "P x ==> (!!y. P y ==> m x <= m y)
   328     ==> (!!x. P x ==> \<forall>y. P y --> m x \<le> m y ==> Q x)
   329     ==> Q (LeastM m P)"
   330   apply (simp add: LeastM_def)
   331   apply (rule someI2_ex, blast, blast)
   332   done
   333 
   334 lemma LeastM_equality:
   335   "P k ==> (!!x. P x ==> m k <= m x)
   336     ==> m (LEAST x WRT m. P x) = (m k::'a::order)"
   337   apply (rule LeastMI2, assumption, blast)
   338   apply (blast intro!: order_antisym)
   339   done
   340 
   341 lemma wf_linord_ex_has_least:
   342   "wf r ==> \<forall>x y. ((x,y):r^+) = ((y,x)~:r^*) ==> P k
   343     ==> \<exists>x. P x & (!y. P y --> (m x,m y):r^*)"
   344   apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]])
   345   apply (drule_tac x = "m`Collect P" in spec, force)
   346   done
   347 
   348 lemma ex_has_least_nat:
   349     "P k ==> \<exists>x. P x & (\<forall>y. P y --> m x <= (m y::nat))"
   350   apply (simp only: pred_nat_trancl_eq_le [symmetric])
   351   apply (rule wf_pred_nat [THEN wf_linord_ex_has_least])
   352    apply (simp add: less_eq linorder_not_le pred_nat_trancl_eq_le, assumption)
   353   done
   354 
   355 lemma LeastM_nat_lemma:
   356     "P k ==> P (LeastM m P) & (\<forall>y. P y --> m (LeastM m P) <= (m y::nat))"
   357   apply (simp add: LeastM_def)
   358   apply (rule someI_ex)
   359   apply (erule ex_has_least_nat)
   360   done
   361 
   362 lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard]
   363 
   364 lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)"
   365 by (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp], assumption, assumption)
   366 
   367 
   368 subsection {* Greatest value operator *}
   369 
   370 constdefs
   371   GreatestM :: "['a => 'b::ord, 'a => bool] => 'a"
   372   "GreatestM m P == SOME x. P x & (\<forall>y. P y --> m y <= m x)"
   373 
   374   Greatest :: "('a::ord => bool) => 'a"    (binder "GREATEST " 10)
   375   "Greatest == GreatestM (%x. x)"
   376 
   377 syntax
   378   "_GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a"
   379       ("GREATEST _ WRT _. _" [0, 4, 10] 10)
   380 
   381 translations
   382   "GREATEST x WRT m. P" == "GreatestM m (%x. P)"
   383 
   384 lemma GreatestMI2:
   385   "P x ==> (!!y. P y ==> m y <= m x)
   386     ==> (!!x. P x ==> \<forall>y. P y --> m y \<le> m x ==> Q x)
   387     ==> Q (GreatestM m P)"
   388   apply (simp add: GreatestM_def)
   389   apply (rule someI2_ex, blast, blast)
   390   done
   391 
   392 lemma GreatestM_equality:
   393  "P k ==> (!!x. P x ==> m x <= m k)
   394     ==> m (GREATEST x WRT m. P x) = (m k::'a::order)"
   395   apply (rule_tac m = m in GreatestMI2, assumption, blast)
   396   apply (blast intro!: order_antisym)
   397   done
   398 
   399 lemma Greatest_equality:
   400   "P (k::'a::order) ==> (!!x. P x ==> x <= k) ==> (GREATEST x. P x) = k"
   401   apply (simp add: Greatest_def)
   402   apply (erule GreatestM_equality, blast)
   403   done
   404 
   405 lemma ex_has_greatest_nat_lemma:
   406   "P k ==> \<forall>x. P x --> (\<exists>y. P y & ~ ((m y::nat) <= m x))
   407     ==> \<exists>y. P y & ~ (m y < m k + n)"
   408   apply (induct n, force)
   409   apply (force simp add: le_Suc_eq)
   410   done
   411 
   412 lemma ex_has_greatest_nat:
   413   "P k ==> \<forall>y. P y --> m y < b
   414     ==> \<exists>x. P x & (\<forall>y. P y --> (m y::nat) <= m x)"
   415   apply (rule ccontr)
   416   apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma)
   417     apply (subgoal_tac [3] "m k <= b", auto)
   418   done
   419 
   420 lemma GreatestM_nat_lemma:
   421   "P k ==> \<forall>y. P y --> m y < b
   422     ==> P (GreatestM m P) & (\<forall>y. P y --> (m y::nat) <= m (GreatestM m P))"
   423   apply (simp add: GreatestM_def)
   424   apply (rule someI_ex)
   425   apply (erule ex_has_greatest_nat, assumption)
   426   done
   427 
   428 lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard]
   429 
   430 lemma GreatestM_nat_le:
   431   "P x ==> \<forall>y. P y --> m y < b
   432     ==> (m x::nat) <= m (GreatestM m P)"
   433   apply (blast dest: GreatestM_nat_lemma [THEN conjunct2, THEN spec, of P])
   434   done
   435 
   436 
   437 text {* \medskip Specialization to @{text GREATEST}. *}
   438 
   439 lemma GreatestI: "P (k::nat) ==> \<forall>y. P y --> y < b ==> P (GREATEST x. P x)"
   440   apply (simp add: Greatest_def)
   441   apply (rule GreatestM_natI, auto)
   442   done
   443 
   444 lemma Greatest_le:
   445     "P x ==> \<forall>y. P y --> y < b ==> (x::nat) <= (GREATEST x. P x)"
   446   apply (simp add: Greatest_def)
   447   apply (rule GreatestM_nat_le, auto)
   448   done
   449 
   450 
   451 subsection {* The Meson proof procedure *}
   452 
   453 subsubsection {* Negation Normal Form *}
   454 
   455 text {* de Morgan laws *}
   456 
   457 lemma meson_not_conjD: "~(P&Q) ==> ~P | ~Q"
   458   and meson_not_disjD: "~(P|Q) ==> ~P & ~Q"
   459   and meson_not_notD: "~~P ==> P"
   460   and meson_not_allD: "!!P. ~(\<forall>x. P(x)) ==> \<exists>x. ~P(x)"
   461   and meson_not_exD: "!!P. ~(\<exists>x. P(x)) ==> \<forall>x. ~P(x)"
   462   by fast+
   463 
   464 text {* Removal of @{text "-->"} and @{text "<->"} (positive and
   465 negative occurrences) *}
   466 
   467 lemma meson_imp_to_disjD: "P-->Q ==> ~P | Q"
   468   and meson_not_impD: "~(P-->Q) ==> P & ~Q"
   469   and meson_iff_to_disjD: "P=Q ==> (~P | Q) & (~Q | P)"
   470   and meson_not_iffD: "~(P=Q) ==> (P | Q) & (~P | ~Q)"
   471     -- {* Much more efficient than @{prop "(P & ~Q) | (Q & ~P)"} for computing CNF *}
   472   and meson_not_refl_disj_D: "x ~= x | P ==> P"
   473   by fast+
   474 
   475 
   476 subsubsection {* Pulling out the existential quantifiers *}
   477 
   478 text {* Conjunction *}
   479 
   480 lemma meson_conj_exD1: "!!P Q. (\<exists>x. P(x)) & Q ==> \<exists>x. P(x) & Q"
   481   and meson_conj_exD2: "!!P Q. P & (\<exists>x. Q(x)) ==> \<exists>x. P & Q(x)"
   482   by fast+
   483 
   484 
   485 text {* Disjunction *}
   486 
   487 lemma meson_disj_exD: "!!P Q. (\<exists>x. P(x)) | (\<exists>x. Q(x)) ==> \<exists>x. P(x) | Q(x)"
   488   -- {* DO NOT USE with forall-Skolemization: makes fewer schematic variables!! *}
   489   -- {* With ex-Skolemization, makes fewer Skolem constants *}
   490   and meson_disj_exD1: "!!P Q. (\<exists>x. P(x)) | Q ==> \<exists>x. P(x) | Q"
   491   and meson_disj_exD2: "!!P Q. P | (\<exists>x. Q(x)) ==> \<exists>x. P | Q(x)"
   492   by fast+
   493 
   494 
   495 subsubsection {* Generating clauses for the Meson Proof Procedure *}
   496 
   497 text {* Disjunctions *}
   498 
   499 lemma meson_disj_assoc: "(P|Q)|R ==> P|(Q|R)"
   500   and meson_disj_comm: "P|Q ==> Q|P"
   501   and meson_disj_FalseD1: "False|P ==> P"
   502   and meson_disj_FalseD2: "P|False ==> P"
   503   by fast+
   504 
   505 
   506 subsection{*Lemmas for Meson, the Model Elimination Procedure*}
   507 
   508 text{* Generation of contrapositives *}
   509 
   510 text{*Inserts negated disjunct after removing the negation; P is a literal.
   511   Model elimination requires assuming the negation of every attempted subgoal,
   512   hence the negated disjuncts.*}
   513 lemma make_neg_rule: "~P|Q ==> ((~P==>P) ==> Q)"
   514 by blast
   515 
   516 text{*Version for Plaisted's "Postive refinement" of the Meson procedure*}
   517 lemma make_refined_neg_rule: "~P|Q ==> (P ==> Q)"
   518 by blast
   519 
   520 text{*@{term P} should be a literal*}
   521 lemma make_pos_rule: "P|Q ==> ((P==>~P) ==> Q)"
   522 by blast
   523 
   524 text{*Versions of @{text make_neg_rule} and @{text make_pos_rule} that don't
   525 insert new assumptions, for ordinary resolution.*}
   526 
   527 lemmas make_neg_rule' = make_refined_neg_rule
   528 
   529 lemma make_pos_rule': "[|P|Q; ~P|] ==> Q"
   530 by blast
   531 
   532 text{* Generation of a goal clause -- put away the final literal *}
   533 
   534 lemma make_neg_goal: "~P ==> ((~P==>P) ==> False)"
   535 by blast
   536 
   537 lemma make_pos_goal: "P ==> ((P==>~P) ==> False)"
   538 by blast
   539 
   540 
   541 subsubsection{* Lemmas for Forward Proof*}
   542 
   543 text{*There is a similarity to congruence rules*}
   544 
   545 (*NOTE: could handle conjunctions (faster?) by
   546     nf(th RS conjunct2) RS (nf(th RS conjunct1) RS conjI) *)
   547 lemma conj_forward: "[| P'&Q';  P' ==> P;  Q' ==> Q |] ==> P&Q"
   548 by blast
   549 
   550 lemma disj_forward: "[| P'|Q';  P' ==> P;  Q' ==> Q |] ==> P|Q"
   551 by blast
   552 
   553 (*Version of @{text disj_forward} for removal of duplicate literals*)
   554 lemma disj_forward2:
   555     "[| P'|Q';  P' ==> P;  [| Q'; P==>False |] ==> Q |] ==> P|Q"
   556 apply blast 
   557 done
   558 
   559 lemma all_forward: "[| \<forall>x. P'(x);  !!x. P'(x) ==> P(x) |] ==> \<forall>x. P(x)"
   560 by blast
   561 
   562 lemma ex_forward: "[| \<exists>x. P'(x);  !!x. P'(x) ==> P(x) |] ==> \<exists>x. P(x)"
   563 by blast
   564 
   565 
   566 text{*Many of these bindings are used by the ATP linkup, and not just by
   567 legacy proof scripts.*}
   568 ML
   569 {*
   570 val inv_def = thm "inv_def";
   571 val Inv_def = thm "Inv_def";
   572 
   573 val someI = thm "someI";
   574 val someI_ex = thm "someI_ex";
   575 val someI2 = thm "someI2";
   576 val someI2_ex = thm "someI2_ex";
   577 val some_equality = thm "some_equality";
   578 val some1_equality = thm "some1_equality";
   579 val some_eq_ex = thm "some_eq_ex";
   580 val some_eq_trivial = thm "some_eq_trivial";
   581 val some_sym_eq_trivial = thm "some_sym_eq_trivial";
   582 val choice = thm "choice";
   583 val bchoice = thm "bchoice";
   584 val inv_id = thm "inv_id";
   585 val inv_f_f = thm "inv_f_f";
   586 val inv_f_eq = thm "inv_f_eq";
   587 val inj_imp_inv_eq = thm "inj_imp_inv_eq";
   588 val inj_transfer = thm "inj_transfer";
   589 val inj_iff = thm "inj_iff";
   590 val inj_imp_surj_inv = thm "inj_imp_surj_inv";
   591 val f_inv_f = thm "f_inv_f";
   592 val surj_f_inv_f = thm "surj_f_inv_f";
   593 val inv_injective = thm "inv_injective";
   594 val inj_on_inv = thm "inj_on_inv";
   595 val surj_imp_inj_inv = thm "surj_imp_inj_inv";
   596 val surj_iff = thm "surj_iff";
   597 val surj_imp_inv_eq = thm "surj_imp_inv_eq";
   598 val bij_imp_bij_inv = thm "bij_imp_bij_inv";
   599 val inv_equality = thm "inv_equality";
   600 val inv_inv_eq = thm "inv_inv_eq";
   601 val o_inv_distrib = thm "o_inv_distrib";
   602 val image_surj_f_inv_f = thm "image_surj_f_inv_f";
   603 val image_inv_f_f = thm "image_inv_f_f";
   604 val inv_image_comp = thm "inv_image_comp";
   605 val bij_image_Collect_eq = thm "bij_image_Collect_eq";
   606 val bij_vimage_eq_inv_image = thm "bij_vimage_eq_inv_image";
   607 val Inv_f_f = thm "Inv_f_f";
   608 val f_Inv_f = thm "f_Inv_f";
   609 val Inv_injective = thm "Inv_injective";
   610 val inj_on_Inv = thm "inj_on_Inv";
   611 val split_paired_Eps = thm "split_paired_Eps";
   612 val Eps_split = thm "Eps_split";
   613 val Eps_split_eq = thm "Eps_split_eq";
   614 val wf_iff_no_infinite_down_chain = thm "wf_iff_no_infinite_down_chain";
   615 val Inv_mem = thm "Inv_mem";
   616 val Inv_f_eq = thm "Inv_f_eq";
   617 val Inv_comp = thm "Inv_comp";
   618 val tfl_some = thm "tfl_some";
   619 val make_neg_rule = thm "make_neg_rule";
   620 val make_refined_neg_rule = thm "make_refined_neg_rule";
   621 val make_pos_rule = thm "make_pos_rule";
   622 val make_neg_rule' = thm "make_neg_rule'";
   623 val make_pos_rule' = thm "make_pos_rule'";
   624 val make_neg_goal = thm "make_neg_goal";
   625 val make_pos_goal = thm "make_pos_goal";
   626 val conj_forward = thm "conj_forward";
   627 val disj_forward = thm "disj_forward";
   628 val disj_forward2 = thm "disj_forward2";
   629 val all_forward = thm "all_forward";
   630 val ex_forward = thm "ex_forward";
   631 *}
   632 
   633 
   634 subsection {* Meson package *}
   635 
   636 use "Tools/meson.ML"
   637 
   638 
   639 subsection {* Specification package -- Hilbertized version *}
   640 
   641 lemma exE_some: "[| Ex P ; c == Eps P |] ==> P c"
   642   by (simp only: someI_ex)
   643 
   644 use "Tools/specification_package.ML"
   645 
   646 end