src/ZF/OrdQuant.thy
author paulson
Fri Jun 28 11:24:36 2002 +0200 (2002-06-28)
changeset 13253 edbf32029d33
parent 13244 7b37e218f298
child 13289 53e201efdaa2
permissions -rw-r--r--
added class quantifiers
     1 (*  Title:      ZF/AC/OrdQuant.thy
     2     ID:         $Id$
     3     Authors:    Krzysztof Grabczewski and L C Paulson
     4 *)
     5 
     6 header {*Special quantifiers*}
     7 
     8 theory OrdQuant = Ordinal:
     9 
    10 subsection {*Quantifiers and union operator for ordinals*}
    11 
    12 constdefs
    13   
    14   (* Ordinal Quantifiers *)
    15   oall :: "[i, i => o] => o"
    16     "oall(A, P) == ALL x. x<A --> P(x)"
    17   
    18   oex :: "[i, i => o] => o"
    19     "oex(A, P)  == EX x. x<A & P(x)"
    20 
    21   (* Ordinal Union *)
    22   OUnion :: "[i, i => i] => i"
    23     "OUnion(i,B) == {z: UN x:i. B(x). Ord(i)}"
    24   
    25 syntax
    26   "@oall"     :: "[idt, i, o] => o"        ("(3ALL _<_./ _)" 10)
    27   "@oex"      :: "[idt, i, o] => o"        ("(3EX _<_./ _)" 10)
    28   "@OUNION"   :: "[idt, i, i] => i"        ("(3UN _<_./ _)" 10)
    29 
    30 translations
    31   "ALL x<a. P"  == "oall(a, %x. P)"
    32   "EX x<a. P"   == "oex(a, %x. P)"
    33   "UN x<a. B"   == "OUnion(a, %x. B)"
    34 
    35 syntax (xsymbols)
    36   "@oall"     :: "[idt, i, o] => o"        ("(3\<forall>_<_./ _)" 10)
    37   "@oex"      :: "[idt, i, o] => o"        ("(3\<exists>_<_./ _)" 10)
    38   "@OUNION"   :: "[idt, i, i] => i"        ("(3\<Union>_<_./ _)" 10)
    39 
    40 
    41 (** simplification of the new quantifiers **)
    42 
    43 
    44 (*MOST IMPORTANT that this is added to the simpset BEFORE Ord_atomize
    45   is proved.  Ord_atomize would convert this rule to 
    46     x < 0 ==> P(x) == True, which causes dire effects!*)
    47 lemma [simp]: "(ALL x<0. P(x))"
    48 by (simp add: oall_def) 
    49 
    50 lemma [simp]: "~(EX x<0. P(x))"
    51 by (simp add: oex_def) 
    52 
    53 lemma [simp]: "(ALL x<succ(i). P(x)) <-> (Ord(i) --> P(i) & (ALL x<i. P(x)))"
    54 apply (simp add: oall_def le_iff) 
    55 apply (blast intro: lt_Ord2) 
    56 done
    57 
    58 lemma [simp]: "(EX x<succ(i). P(x)) <-> (Ord(i) & (P(i) | (EX x<i. P(x))))"
    59 apply (simp add: oex_def le_iff) 
    60 apply (blast intro: lt_Ord2) 
    61 done
    62 
    63 (** Union over ordinals **)
    64 
    65 lemma Ord_OUN [intro,simp]:
    66      "[| !!x. x<A ==> Ord(B(x)) |] ==> Ord(\<Union>x<A. B(x))"
    67 by (simp add: OUnion_def ltI Ord_UN) 
    68 
    69 lemma OUN_upper_lt:
    70      "[| a<A;  i < b(a);  Ord(\<Union>x<A. b(x)) |] ==> i < (\<Union>x<A. b(x))"
    71 by (unfold OUnion_def lt_def, blast )
    72 
    73 lemma OUN_upper_le:
    74      "[| a<A;  i\<le>b(a);  Ord(\<Union>x<A. b(x)) |] ==> i \<le> (\<Union>x<A. b(x))"
    75 apply (unfold OUnion_def, auto)
    76 apply (rule UN_upper_le )
    77 apply (auto simp add: lt_def) 
    78 done
    79 
    80 lemma Limit_OUN_eq: "Limit(i) ==> (UN x<i. x) = i"
    81 by (simp add: OUnion_def Limit_Union_eq Limit_is_Ord)
    82 
    83 (* No < version; consider (UN i:nat.i)=nat *)
    84 lemma OUN_least:
    85      "(!!x. x<A ==> B(x) \<subseteq> C) ==> (UN x<A. B(x)) \<subseteq> C"
    86 by (simp add: OUnion_def UN_least ltI)
    87 
    88 (* No < version; consider (UN i:nat.i)=nat *)
    89 lemma OUN_least_le:
    90      "[| Ord(i);  !!x. x<A ==> b(x) \<le> i |] ==> (UN x<A. b(x)) \<le> i"
    91 by (simp add: OUnion_def UN_least_le ltI Ord_0_le)
    92 
    93 lemma le_implies_OUN_le_OUN:
    94      "[| !!x. x<A ==> c(x) \<le> d(x) |] ==> (UN x<A. c(x)) \<le> (UN x<A. d(x))"
    95 by (blast intro: OUN_least_le OUN_upper_le le_Ord2 Ord_OUN)
    96 
    97 lemma OUN_UN_eq:
    98      "(!!x. x:A ==> Ord(B(x)))
    99       ==> (UN z < (UN x:A. B(x)). C(z)) = (UN  x:A. UN z < B(x). C(z))"
   100 by (simp add: OUnion_def) 
   101 
   102 lemma OUN_Union_eq:
   103      "(!!x. x:X ==> Ord(x))
   104       ==> (UN z < Union(X). C(z)) = (UN x:X. UN z < x. C(z))"
   105 by (simp add: OUnion_def) 
   106 
   107 (*So that rule_format will get rid of ALL x<A...*)
   108 lemma atomize_oall [symmetric, rulify]:
   109      "(!!x. x<A ==> P(x)) == Trueprop (ALL x<A. P(x))"
   110 by (simp add: oall_def atomize_all atomize_imp)
   111 
   112 (*** universal quantifier for ordinals ***)
   113 
   114 lemma oallI [intro!]:
   115     "[| !!x. x<A ==> P(x) |] ==> ALL x<A. P(x)"
   116 by (simp add: oall_def) 
   117 
   118 lemma ospec: "[| ALL x<A. P(x);  x<A |] ==> P(x)"
   119 by (simp add: oall_def) 
   120 
   121 lemma oallE:
   122     "[| ALL x<A. P(x);  P(x) ==> Q;  ~x<A ==> Q |] ==> Q"
   123 apply (simp add: oall_def, blast) 
   124 done
   125 
   126 lemma rev_oallE [elim]:
   127     "[| ALL x<A. P(x);  ~x<A ==> Q;  P(x) ==> Q |] ==> Q"
   128 apply (simp add: oall_def, blast)  
   129 done
   130 
   131 
   132 (*Trival rewrite rule;   (ALL x<a.P)<->P holds only if a is not 0!*)
   133 lemma oall_simp [simp]: "(ALL x<a. True) <-> True"
   134 by blast
   135 
   136 (*Congruence rule for rewriting*)
   137 lemma oall_cong [cong]:
   138     "[| a=a';  !!x. x<a' ==> P(x) <-> P'(x) |] ==> oall(a,P) <-> oall(a',P')"
   139 by (simp add: oall_def)
   140 
   141 
   142 (*** existential quantifier for ordinals ***)
   143 
   144 lemma oexI [intro]:
   145     "[| P(x);  x<A |] ==> EX x<A. P(x)"
   146 apply (simp add: oex_def, blast) 
   147 done
   148 
   149 (*Not of the general form for such rules; ~EX has become ALL~ *)
   150 lemma oexCI:
   151    "[| ALL x<A. ~P(x) ==> P(a);  a<A |] ==> EX x<A. P(x)"
   152 apply (simp add: oex_def, blast) 
   153 done
   154 
   155 lemma oexE [elim!]:
   156     "[| EX x<A. P(x);  !!x. [| x<A; P(x) |] ==> Q |] ==> Q"
   157 apply (simp add: oex_def, blast) 
   158 done
   159 
   160 lemma oex_cong [cong]:
   161     "[| a=a';  !!x. x<a' ==> P(x) <-> P'(x) |] ==> oex(a,P) <-> oex(a',P')"
   162 apply (simp add: oex_def cong add: conj_cong)
   163 done
   164 
   165 
   166 (*** Rules for Ordinal-Indexed Unions ***)
   167 
   168 lemma OUN_I [intro]: "[| a<i;  b: B(a) |] ==> b: (UN z<i. B(z))"
   169 by (unfold OUnion_def lt_def, blast)
   170 
   171 lemma OUN_E [elim!]:
   172     "[| b : (UN z<i. B(z));  !!a.[| b: B(a);  a<i |] ==> R |] ==> R"
   173 apply (unfold OUnion_def lt_def, blast)
   174 done
   175 
   176 lemma OUN_iff: "b : (UN x<i. B(x)) <-> (EX x<i. b : B(x))"
   177 by (unfold OUnion_def oex_def lt_def, blast)
   178 
   179 lemma OUN_cong [cong]:
   180     "[| i=j;  !!x. x<j ==> C(x)=D(x) |] ==> (UN x<i. C(x)) = (UN x<j. D(x))"
   181 by (simp add: OUnion_def lt_def OUN_iff)
   182 
   183 lemma lt_induct: 
   184     "[| i<k;  !!x.[| x<k;  ALL y<x. P(y) |] ==> P(x) |]  ==>  P(i)"
   185 apply (simp add: lt_def oall_def)
   186 apply (erule conjE) 
   187 apply (erule Ord_induct, assumption, blast) 
   188 done
   189 
   190 
   191 subsection {*Quantification over a class*}
   192 
   193 constdefs
   194   "rall"     :: "[i=>o, i=>o] => o"
   195     "rall(M, P) == ALL x. M(x) --> P(x)"
   196 
   197   "rex"      :: "[i=>o, i=>o] => o"
   198     "rex(M, P) == EX x. M(x) & P(x)"
   199 
   200 syntax
   201   "@rall"     :: "[pttrn, i=>o, o] => o"        ("(3ALL _[_]./ _)" 10)
   202   "@rex"      :: "[pttrn, i=>o, o] => o"        ("(3EX _[_]./ _)" 10)
   203 
   204 syntax (xsymbols)
   205   "@rall"     :: "[pttrn, i=>o, o] => o"        ("(3\<forall>_[_]./ _)" 10)
   206   "@rex"      :: "[pttrn, i=>o, o] => o"        ("(3\<exists>_[_]./ _)" 10)
   207 
   208 translations
   209   "ALL x[M]. P"  == "rall(M, %x. P)"
   210   "EX x[M]. P"   == "rex(M, %x. P)"
   211 
   212 (*** Relativized universal quantifier ***)
   213 
   214 lemma rallI [intro!]: "[| !!x. M(x) ==> P(x) |] ==> ALL x[M]. P(x)"
   215 by (simp add: rall_def)
   216 
   217 lemma rspec: "[| ALL x[M]. P(x); M(x) |] ==> P(x)"
   218 by (simp add: rall_def)
   219 
   220 (*Instantiates x first: better for automatic theorem proving?*)
   221 lemma rev_rallE [elim]: 
   222     "[| ALL x[M]. P(x);  ~ M(x) ==> Q;  P(x) ==> Q |] ==> Q"
   223 by (simp add: rall_def, blast) 
   224 
   225 lemma rallE: "[| ALL x[M]. P(x);  P(x) ==> Q;  ~ M(x) ==> Q |] ==> Q"
   226 by blast
   227 
   228 (*Trival rewrite rule;   (ALL x[M].P)<->P holds only if A is nonempty!*)
   229 lemma rall_triv [simp]: "(ALL x[M]. P) <-> ((EX x. M(x)) --> P)"
   230 by (simp add: rall_def)
   231 
   232 (*Congruence rule for rewriting*)
   233 lemma rall_cong [cong]:
   234     "(!!x. M(x) ==> P(x) <-> P'(x)) ==> rall(M,P) <-> rall(M,P')"
   235 by (simp add: rall_def)
   236 
   237 (*** Relativized existential quantifier ***)
   238 
   239 lemma rexI [intro]: "[| P(x); M(x) |] ==> EX x[M]. P(x)"
   240 by (simp add: rex_def, blast)
   241 
   242 (*The best argument order when there is only one M(x)*)
   243 lemma rev_rexI: "[| M(x);  P(x) |] ==> EX x[M]. P(x)"
   244 by blast
   245 
   246 (*Not of the general form for such rules; ~EX has become ALL~ *)
   247 lemma rexCI: "[| ALL x[M]. ~P(x) ==> P(a); M(a) |] ==> EX x[M]. P(x)"
   248 by blast
   249 
   250 lemma rexE [elim!]: "[| EX x[M]. P(x);  !!x. [| M(x); P(x) |] ==> Q |] ==> Q"
   251 by (simp add: rex_def, blast)
   252 
   253 (*We do not even have (EX x[M]. True) <-> True unless A is nonempty!!*)
   254 lemma rex_triv [simp]: "(EX x[M]. P) <-> ((EX x. M(x)) & P)"
   255 by (simp add: rex_def)
   256 
   257 lemma rex_cong [cong]:
   258     "(!!x. M(x) ==> P(x) <-> P'(x)) ==> rex(M,P) <-> rex(M,P')"
   259 by (simp add: rex_def cong: conj_cong)
   260 
   261 lemma atomize_rall: "(!!x. M(x) ==> P(x)) == Trueprop (ALL x[M]. P(x))";
   262 by (simp add: rall_def atomize_all atomize_imp)
   263 
   264 declare atomize_rall [symmetric, rulify]
   265 
   266 lemma rall_simps1:
   267      "(ALL x[M]. P(x) & Q)   <-> (ALL x[M]. P(x)) & ((ALL x[M]. False) | Q)"
   268      "(ALL x[M]. P(x) | Q)   <-> ((ALL x[M]. P(x)) | Q)"
   269      "(ALL x[M]. P(x) --> Q) <-> ((EX x[M]. P(x)) --> Q)"
   270      "(~(ALL x[M]. P(x))) <-> (EX x[M]. ~P(x))" 
   271 by blast+
   272 
   273 lemma rall_simps2:
   274      "(ALL x[M]. P & Q(x))   <-> ((ALL x[M]. False) | P) & (ALL x[M]. Q(x))"
   275      "(ALL x[M]. P | Q(x))   <-> (P | (ALL x[M]. Q(x)))"
   276      "(ALL x[M]. P --> Q(x)) <-> (P --> (ALL x[M]. Q(x)))"
   277 by blast+
   278 
   279 lemmas rall_simps = rall_simps1 rall_simps2
   280 
   281 lemma rall_conj_distrib:
   282     "(ALL x[M]. P(x) & Q(x)) <-> ((ALL x[M]. P(x)) & (ALL x[M]. Q(x)))"
   283 by blast
   284 
   285 lemma rex_simps1:
   286      "(EX x[M]. P(x) & Q) <-> ((EX x[M]. P(x)) & Q)"
   287      "(EX x[M]. P(x) | Q) <-> (EX x[M]. P(x)) | ((EX x[M]. True) & Q)"
   288      "(EX x[M]. P(x) --> Q) <-> ((ALL x[M]. P(x)) --> ((EX x[M]. True) & Q))"
   289      "(~(EX x[M]. P(x))) <-> (ALL x[M]. ~P(x))"
   290 by blast+
   291 
   292 lemma rex_simps2:
   293      "(EX x[M]. P & Q(x)) <-> (P & (EX x[M]. Q(x)))"
   294      "(EX x[M]. P | Q(x)) <-> ((EX x[M]. True) & P) | (EX x[M]. Q(x))"
   295      "(EX x[M]. P --> Q(x)) <-> (((ALL x[M]. False) | P) --> (EX x[M]. Q(x)))"
   296 by blast+
   297 
   298 lemmas rex_simps = rex_simps1 rex_simps2
   299 
   300 lemma rex_disj_distrib:
   301     "(EX x[M]. P(x) | Q(x)) <-> ((EX x[M]. P(x)) | (EX x[M]. Q(x)))"
   302 by blast
   303 
   304 
   305 (** One-point rule for bounded quantifiers: see HOL/Set.ML **)
   306 
   307 lemma rex_triv_one_point1 [simp]: "(EX x[M]. x=a) <-> ( M(a))"
   308 by blast
   309 
   310 lemma rex_triv_one_point2 [simp]: "(EX x[M]. a=x) <-> ( M(a))"
   311 by blast
   312 
   313 lemma rex_one_point1 [simp]: "(EX x[M]. x=a & P(x)) <-> ( M(a) & P(a))"
   314 by blast
   315 
   316 lemma rex_one_point2 [simp]: "(EX x[M]. a=x & P(x)) <-> ( M(a) & P(a))"
   317 by blast
   318 
   319 lemma rall_one_point1 [simp]: "(ALL x[M]. x=a --> P(x)) <-> ( M(a) --> P(a))"
   320 by blast
   321 
   322 lemma rall_one_point2 [simp]: "(ALL x[M]. a=x --> P(x)) <-> ( M(a) --> P(a))"
   323 by blast
   324 
   325 
   326 ML
   327 {*
   328 val oall_def = thm "oall_def"
   329 val oex_def = thm "oex_def"
   330 val OUnion_def = thm "OUnion_def"
   331 
   332 val oallI = thm "oallI";
   333 val ospec = thm "ospec";
   334 val oallE = thm "oallE";
   335 val rev_oallE = thm "rev_oallE";
   336 val oall_simp = thm "oall_simp";
   337 val oall_cong = thm "oall_cong";
   338 val oexI = thm "oexI";
   339 val oexCI = thm "oexCI";
   340 val oexE = thm "oexE";
   341 val oex_cong = thm "oex_cong";
   342 val OUN_I = thm "OUN_I";
   343 val OUN_E = thm "OUN_E";
   344 val OUN_iff = thm "OUN_iff";
   345 val OUN_cong = thm "OUN_cong";
   346 val lt_induct = thm "lt_induct";
   347 
   348 val rall_def = thm "rall_def"
   349 val rex_def = thm "rex_def"
   350 
   351 val rallI = thm "rallI";
   352 val rspec = thm "rspec";
   353 val rallE = thm "rallE";
   354 val rev_oallE = thm "rev_oallE";
   355 val rall_cong = thm "rall_cong";
   356 val rexI = thm "rexI";
   357 val rexCI = thm "rexCI";
   358 val rexE = thm "rexE";
   359 val rex_cong = thm "rex_cong";
   360 
   361 val Ord_atomize =
   362     atomize ([("OrdQuant.oall", [ospec]),("OrdQuant.rall", [rspec])]@
   363                  ZF_conn_pairs, 
   364              ZF_mem_pairs);
   365 simpset_ref() := simpset() setmksimps (map mk_eq o Ord_atomize o gen_all);
   366 *}
   367 
   368 text{*Setting up the one-point-rule simproc*}
   369 ML
   370 {*
   371 
   372 let
   373 val ex_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
   374                                 ("EX x[M]. P(x) & Q(x)", FOLogic.oT)
   375 
   376 val prove_rex_tac = rewtac rex_def THEN
   377                     Quantifier1.prove_one_point_ex_tac;
   378 
   379 val rearrange_bex = Quantifier1.rearrange_bex prove_rex_tac;
   380 
   381 val all_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
   382                                  ("ALL x[M]. P(x) --> Q(x)", FOLogic.oT)
   383 
   384 val prove_rall_tac = rewtac rall_def THEN 
   385                      Quantifier1.prove_one_point_all_tac;
   386 
   387 val rearrange_ball = Quantifier1.rearrange_ball prove_rall_tac;
   388 
   389 val defREX_regroup = mk_simproc "defined REX" [ex_pattern] rearrange_bex;
   390 val defRALL_regroup = mk_simproc "defined RALL" [all_pattern] rearrange_ball;
   391 in
   392 
   393 Addsimprocs [defRALL_regroup,defREX_regroup]
   394 
   395 end;
   396 *}
   397 
   398 end