src/FOL/IFOL.ML
changeset 3835 9a5a4e123859
parent 3722 24af9e73451e
child 4187 2fafec5868fe
equal deleted inserted replaced
3834:278f0a1e5986 3835:9a5a4e123859
    24 qed_goal "impE" IFOL.thy 
    24 qed_goal "impE" IFOL.thy 
    25     "[| P-->Q;  P;  Q ==> R |] ==> R"
    25     "[| P-->Q;  P;  Q ==> R |] ==> R"
    26  (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
    26  (fn prems=> [ (REPEAT (resolve_tac (prems@[mp]) 1)) ]);
    27 
    27 
    28 qed_goal "allE" IFOL.thy 
    28 qed_goal "allE" IFOL.thy 
    29     "[| ALL x.P(x); P(x) ==> R |] ==> R"
    29     "[| ALL x. P(x); P(x) ==> R |] ==> R"
    30  (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
    30  (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
    31 
    31 
    32 (*Duplicates the quantifier; for use with eresolve_tac*)
    32 (*Duplicates the quantifier; for use with eresolve_tac*)
    33 qed_goal "all_dupE" IFOL.thy 
    33 qed_goal "all_dupE" IFOL.thy 
    34     "[| ALL x.P(x);  [| P(x); ALL x.P(x) |] ==> R \
    34     "[| ALL x. P(x);  [| P(x); ALL x. P(x) |] ==> R \
    35 \    |] ==> R"
    35 \    |] ==> R"
    36  (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
    36  (fn prems=> [ (REPEAT (resolve_tac (prems@[spec]) 1)) ]);
    37 
    37 
    38 
    38 
    39 (*** Negation rules, which translate between ~P and P-->False ***)
    39 (*** Negation rules, which translate between ~P and P-->False ***)
   124     "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)"
   124     "[| P(a);  !!x. P(x) ==> x=a |] ==> EX! x. P(x)"
   125  (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
   125  (fn prems => [ (REPEAT (ares_tac (prems@[exI,conjI,allI,impI]) 1)) ]);
   126 
   126 
   127 (*Sometimes easier to use: the premises have no shared variables.  Safe!*)
   127 (*Sometimes easier to use: the premises have no shared variables.  Safe!*)
   128 qed_goal "ex_ex1I" IFOL.thy
   128 qed_goal "ex_ex1I" IFOL.thy
   129     "[| EX x.P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)"
   129     "[| EX x. P(x);  !!x y. [| P(x); P(y) |] ==> x=y |] ==> EX! x. P(x)"
   130  (fn [ex,eq] => [ (rtac (ex RS exE) 1),
   130  (fn [ex,eq] => [ (rtac (ex RS exE) 1),
   131                   (REPEAT (ares_tac [ex1I,eq] 1)) ]);
   131                   (REPEAT (ares_tac [ex1I,eq] 1)) ]);
   132 
   132 
   133 qed_goalw "ex1E" IFOL.thy [ex1_def]
   133 qed_goalw "ex1E" IFOL.thy [ex1_def]
   134     "[| EX! x.P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R"
   134     "[| EX! x. P(x);  !!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R |] ==> R"
   135  (fn prems =>
   135  (fn prems =>
   136   [ (cut_facts_tac prems 1),
   136   [ (cut_facts_tac prems 1),
   137     (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
   137     (REPEAT (eresolve_tac [exE,conjE] 1 ORELSE ares_tac prems 1)) ]);
   138 
   138 
   139 
   139 
   192     (REPEAT   (ares_tac [iffI,notI] 1
   192     (REPEAT   (ares_tac [iffI,notI] 1
   193       ORELSE  mp_tac 1
   193       ORELSE  mp_tac 1
   194       ORELSE  eresolve_tac [iffE,notE] 1)) ]);
   194       ORELSE  eresolve_tac [iffE,notE] 1)) ]);
   195 
   195 
   196 qed_goal "all_cong" IFOL.thy 
   196 qed_goal "all_cong" IFOL.thy 
   197     "(!!x.P(x) <-> Q(x)) ==> (ALL x.P(x)) <-> (ALL x.Q(x))"
   197     "(!!x. P(x) <-> Q(x)) ==> (ALL x. P(x)) <-> (ALL x. Q(x))"
   198  (fn prems =>
   198  (fn prems =>
   199   [ (REPEAT   (ares_tac [iffI,allI] 1
   199   [ (REPEAT   (ares_tac [iffI,allI] 1
   200       ORELSE   mp_tac 1
   200       ORELSE   mp_tac 1
   201       ORELSE   etac allE 1 ORELSE iff_tac prems 1)) ]);
   201       ORELSE   etac allE 1 ORELSE iff_tac prems 1)) ]);
   202 
   202 
   203 qed_goal "ex_cong" IFOL.thy 
   203 qed_goal "ex_cong" IFOL.thy 
   204     "(!!x.P(x) <-> Q(x)) ==> (EX x.P(x)) <-> (EX x.Q(x))"
   204     "(!!x. P(x) <-> Q(x)) ==> (EX x. P(x)) <-> (EX x. Q(x))"
   205  (fn prems =>
   205  (fn prems =>
   206   [ (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
   206   [ (REPEAT   (etac exE 1 ORELSE ares_tac [iffI,exI] 1
   207       ORELSE   mp_tac 1
   207       ORELSE   mp_tac 1
   208       ORELSE   iff_tac prems 1)) ]);
   208       ORELSE   iff_tac prems 1)) ]);
   209 
   209 
   210 qed_goal "ex1_cong" IFOL.thy 
   210 qed_goal "ex1_cong" IFOL.thy 
   211     "(!!x.P(x) <-> Q(x)) ==> (EX! x.P(x)) <-> (EX! x.Q(x))"
   211     "(!!x. P(x) <-> Q(x)) ==> (EX! x. P(x)) <-> (EX! x. Q(x))"
   212  (fn prems =>
   212  (fn prems =>
   213   [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
   213   [ (REPEAT   (eresolve_tac [ex1E, spec RS mp] 1 ORELSE ares_tac [iffI,ex1I] 1
   214       ORELSE   mp_tac 1
   214       ORELSE   mp_tac 1
   215       ORELSE   iff_tac prems 1)) ]);
   215       ORELSE   iff_tac prems 1)) ]);
   216 
   216 
   229 bind_thm ("ssubst", sym RS subst);
   229 bind_thm ("ssubst", sym RS subst);
   230 fun stac th = CHANGED o rtac (th RS ssubst);
   230 fun stac th = CHANGED o rtac (th RS ssubst);
   231 
   231 
   232 (*A special case of ex1E that would otherwise need quantifier expansion*)
   232 (*A special case of ex1E that would otherwise need quantifier expansion*)
   233 qed_goal "ex1_equalsE" IFOL.thy
   233 qed_goal "ex1_equalsE" IFOL.thy
   234     "[| EX! x.P(x);  P(a);  P(b) |] ==> a=b"
   234     "[| EX! x. P(x);  P(a);  P(b) |] ==> a=b"
   235  (fn prems =>
   235  (fn prems =>
   236   [ (cut_facts_tac prems 1),
   236   [ (cut_facts_tac prems 1),
   237     (etac ex1E 1),
   237     (etac ex1E 1),
   238     (rtac trans 1),
   238     (rtac trans 1),
   239     (rtac sym 2),
   239     (rtac sym 2),
   350  (fn major::prems=>
   350  (fn major::prems=>
   351   [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
   351   [ (REPEAT (ares_tac ([iffI, impI, major RS mp]@prems) 1)) ]);
   352 
   352 
   353 (*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
   353 (*What if (ALL x.~~P(x)) --> ~~(ALL x.P(x)) is an assumption? UNSAFE*)
   354 qed_goal "all_impE" IFOL.thy 
   354 qed_goal "all_impE" IFOL.thy 
   355     "[| (ALL x.P(x))-->S;  !!x.P(x);  S ==> R |] ==> R"
   355     "[| (ALL x. P(x))-->S;  !!x. P(x);  S ==> R |] ==> R"
   356  (fn major::prems=>
   356  (fn major::prems=>
   357   [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
   357   [ (REPEAT (ares_tac ([allI, impI, major RS mp]@prems) 1)) ]);
   358 
   358 
   359 (*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
   359 (*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
   360 qed_goal "ex_impE" IFOL.thy 
   360 qed_goal "ex_impE" IFOL.thy 
   361     "[| (EX x.P(x))-->S;  P(x)-->S ==> R |] ==> R"
   361     "[| (EX x. P(x))-->S;  P(x)-->S ==> R |] ==> R"
   362  (fn major::prems=>
   362  (fn major::prems=>
   363   [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);
   363   [ (REPEAT (ares_tac ([exI, impI, major RS mp]@prems) 1)) ]);
   364 
   364 
   365 (*** Courtesy of Krzysztof Grabczewski ***)
   365 (*** Courtesy of Krzysztof Grabczewski ***)
   366 
   366