src/FOL/IFOL.thy
changeset 23393 31781b2de73d
parent 23171 861f63a35d31
child 24097 86734ba03ca2
equal deleted inserted replaced
23392:4b03e3586f7f 23393:31781b2de73d
   317    EX!x,y such that P(x,y)                    (simultaneous)
   317    EX!x,y such that P(x,y)                    (simultaneous)
   318  do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
   318  do NOT mean the same thing.  The parser treats EX!x y.P(x,y) as sequential.
   319 ***)
   319 ***)
   320 
   320 
   321 lemma ex1I:
   321 lemma ex1I:
   322   assumes "P(a)"
   322   "P(a) \<Longrightarrow> (!!x. P(x) ==> x=a) \<Longrightarrow> EX! x. P(x)"
   323     and "!!x. P(x) ==> x=a"
       
   324   shows "EX! x. P(x)"
       
   325   apply (unfold ex1_def)
   323   apply (unfold ex1_def)
   326   apply (assumption | rule assms exI conjI allI impI)+
   324   apply (assumption | rule exI conjI allI impI)+
   327   done
   325   done
   328 
   326 
   329 (*Sometimes easier to use: the premises have no shared variables.  Safe!*)
   327 (*Sometimes easier to use: the premises have no shared variables.  Safe!*)
   330 lemma ex_ex1I:
   328 lemma ex_ex1I:
   331   assumes ex: "EX x. P(x)"
   329   "EX x. P(x) \<Longrightarrow> (!!x y. [| P(x); P(y) |] ==> x=y) \<Longrightarrow> EX! x. P(x)"
   332     and eq: "!!x y. [| P(x); P(y) |] ==> x=y"
   330   apply (erule exE)
   333   shows "EX! x. P(x)"
   331   apply (rule ex1I)
   334   apply (rule ex [THEN exE])
   332    apply assumption
   335   apply (assumption | rule ex1I eq)+
   333   apply assumption
   336   done
   334   done
   337 
   335 
   338 lemma ex1E:
   336 lemma ex1E:
   339   assumes ex1: "EX! x. P(x)"
   337   "EX! x. P(x) \<Longrightarrow> (!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R) \<Longrightarrow> R"
   340     and r: "!!x. [| P(x);  ALL y. P(y) --> y=x |] ==> R"
   338   apply (unfold ex1_def)
   341   shows R
       
   342   apply (insert ex1, unfold ex1_def)
       
   343   apply (assumption | erule exE conjE)+
   339   apply (assumption | erule exE conjE)+
   344   done
   340   done
   345 
   341 
   346 
   342 
   347 (*** <-> congruence rules for simplification ***)
   343 (*** <-> congruence rules for simplification ***)
   570   by (assumption | rule impI major [THEN mp] r1 r2)+
   566   by (assumption | rule impI major [THEN mp] r1 r2)+
   571 
   567 
   572 (*Simplifies the implication.  Classical version is stronger. 
   568 (*Simplifies the implication.  Classical version is stronger. 
   573   Still UNSAFE since ~P must be provable -- backtracking needed.  *)
   569   Still UNSAFE since ~P must be provable -- backtracking needed.  *)
   574 lemma not_impE:
   570 lemma not_impE:
   575   assumes major: "~P --> S"
   571   "~P --> S \<Longrightarrow> (P ==> False) \<Longrightarrow> (S ==> R) \<Longrightarrow> R"
   576     and r1: "P ==> False"
   572   apply (drule mp)
   577     and r2: "S ==> R"
   573    apply (rule notI)
   578   shows R
   574    apply assumption
   579   apply (assumption | rule notI impI major [THEN mp] r1 r2)+
   575   apply assumption
   580   done
   576   done
   581 
   577 
   582 (*Simplifies the implication.   UNSAFE.  *)
   578 (*Simplifies the implication.   UNSAFE.  *)
   583 lemma iff_impE:
   579 lemma iff_impE:
   584   assumes major: "(P<->Q)-->S"
   580   assumes major: "(P<->Q)-->S"
   593 lemma all_impE:
   589 lemma all_impE:
   594   assumes major: "(ALL x. P(x))-->S"
   590   assumes major: "(ALL x. P(x))-->S"
   595     and r1: "!!x. P(x)"
   591     and r1: "!!x. P(x)"
   596     and r2: "S ==> R"
   592     and r2: "S ==> R"
   597   shows R
   593   shows R
   598   apply (assumption | rule allI impI major [THEN mp] r1 r2)+
   594   apply (rule allI impI major [THEN mp] r1 r2)+
   599   done
   595   done
   600 
   596 
   601 (*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
   597 (*Unsafe: (EX x.P(x))-->S  is equivalent to  ALL x.P(x)-->S.  *)
   602 lemma ex_impE:
   598 lemma ex_impE:
   603   assumes major: "(EX x. P(x))-->S"
   599   assumes major: "(EX x. P(x))-->S"
   607   done
   603   done
   608 
   604 
   609 (*** Courtesy of Krzysztof Grabczewski ***)
   605 (*** Courtesy of Krzysztof Grabczewski ***)
   610 
   606 
   611 lemma disj_imp_disj:
   607 lemma disj_imp_disj:
   612   assumes major: "P|Q"
   608   "P|Q \<Longrightarrow> (P==>R) \<Longrightarrow> (Q==>S) \<Longrightarrow> R|S"
   613     and "P==>R" and "Q==>S"
   609   apply (erule disjE)
   614   shows "R|S"
       
   615   apply (rule disjE [OF major])
       
   616   apply (rule disjI1) apply assumption
   610   apply (rule disjI1) apply assumption
   617   apply (rule disjI2) apply assumption
   611   apply (rule disjI2) apply assumption
   618   done
   612   done
   619 
   613 
   620 ML {*
   614 ML {*