115 where and_def: "P \<and> Q \<equiv> \<forall>R. (P \<longrightarrow> Q \<longrightarrow> R) \<longrightarrow> R" |
115 where and_def: "P \<and> Q \<equiv> \<forall>R. (P \<longrightarrow> Q \<longrightarrow> R) \<longrightarrow> R" |
116 |
116 |
117 definition disj :: "[bool, bool] \<Rightarrow> bool" (infixr "\<or>" 30) |
117 definition disj :: "[bool, bool] \<Rightarrow> bool" (infixr "\<or>" 30) |
118 where or_def: "P \<or> Q \<equiv> \<forall>R. (P \<longrightarrow> R) \<longrightarrow> (Q \<longrightarrow> R) \<longrightarrow> R" |
118 where or_def: "P \<or> Q \<equiv> \<forall>R. (P \<longrightarrow> R) \<longrightarrow> (Q \<longrightarrow> R) \<longrightarrow> R" |
119 |
119 |
|
120 definition Uniq :: "('a \<Rightarrow> bool) \<Rightarrow> bool" |
|
121 where "Uniq P \<equiv> (\<forall>x y. P x \<longrightarrow> P y \<longrightarrow> y = x)" |
|
122 |
120 definition Ex1 :: "('a \<Rightarrow> bool) \<Rightarrow> bool" |
123 definition Ex1 :: "('a \<Rightarrow> bool) \<Rightarrow> bool" |
121 where "Ex1 P \<equiv> \<exists>x. P x \<and> (\<forall>y. P y \<longrightarrow> y = x)" |
124 where "Ex1 P \<equiv> \<exists>x. P x \<and> (\<forall>y. P y \<longrightarrow> y = x)" |
122 |
125 |
123 |
126 |
124 subsubsection \<open>Additional concrete syntax\<close> |
127 subsubsection \<open>Additional concrete syntax\<close> |
|
128 |
|
129 syntax (ASCII) "_Uniq" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(4?< _./ _)" [0, 10] 10) |
|
130 syntax "_Uniq" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(2\<exists>\<^sub>\<le>\<^sub>1 _./ _)" [0, 10] 10) |
|
131 translations "\<exists>\<^sub>\<le>\<^sub>1x. P" \<rightleftharpoons> "CONST Uniq (\<lambda>x. P)" |
|
132 |
|
133 print_translation \<open> |
|
134 [Syntax_Trans.preserve_binder_abs_tr' \<^const_syntax>\<open>Uniq\<close> \<^syntax_const>\<open>_Uniq\<close>] |
|
135 \<close> \<comment> \<open>to avoid eta-contraction of body\<close> |
|
136 |
125 |
137 |
126 syntax (ASCII) |
138 syntax (ASCII) |
127 "_Ex1" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(3EX! _./ _)" [0, 10] 10) |
139 "_Ex1" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(3EX! _./ _)" [0, 10] 10) |
128 syntax (input) |
140 syntax (input) |
129 "_Ex1" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(3?! _./ _)" [0, 10] 10) |
141 "_Ex1" :: "pttrn \<Rightarrow> bool \<Rightarrow> bool" ("(3?! _./ _)" [0, 10] 10) |
537 by (iprover intro: classical p1 p2 notE) |
549 by (iprover intro: classical p1 p2 notE) |
538 |
550 |
539 |
551 |
540 subsubsection \<open>Unique existence\<close> |
552 subsubsection \<open>Unique existence\<close> |
541 |
553 |
|
554 lemma Uniq_I [intro?]: |
|
555 assumes "\<And>x y. \<lbrakk>P x; P y\<rbrakk> \<Longrightarrow> y = x" |
|
556 shows "Uniq P" |
|
557 unfolding Uniq_def by (iprover intro: assms allI impI) |
|
558 |
|
559 lemma Uniq_D [dest?]: "\<lbrakk>Uniq P; P a; P b\<rbrakk> \<Longrightarrow> a=b" |
|
560 unfolding Uniq_def by (iprover dest: spec mp) |
|
561 |
542 lemma ex1I: |
562 lemma ex1I: |
543 assumes "P a" "\<And>x. P x \<Longrightarrow> x = a" |
563 assumes "P a" "\<And>x. P x \<Longrightarrow> x = a" |
544 shows "\<exists>!x. P x" |
564 shows "\<exists>!x. P x" |
545 unfolding Ex1_def by (iprover intro: assms exI conjI allI impI) |
565 unfolding Ex1_def by (iprover intro: assms exI conjI allI impI) |
546 |
566 |
559 by (iprover intro: minor elim: conjE) |
579 by (iprover intro: minor elim: conjE) |
560 qed |
580 qed |
561 |
581 |
562 lemma ex1_implies_ex: "\<exists>!x. P x \<Longrightarrow> \<exists>x. P x" |
582 lemma ex1_implies_ex: "\<exists>!x. P x \<Longrightarrow> \<exists>x. P x" |
563 by (iprover intro: exI elim: ex1E) |
583 by (iprover intro: exI elim: ex1E) |
564 |
|
565 |
584 |
566 subsubsection \<open>Classical intro rules for disjunction and existential quantifiers\<close> |
585 subsubsection \<open>Classical intro rules for disjunction and existential quantifiers\<close> |
567 |
586 |
568 lemma disjCI: |
587 lemma disjCI: |
569 assumes "\<not> Q \<Longrightarrow> P" |
588 assumes "\<not> Q \<Longrightarrow> P" |
852 proof (rule ex1E [OF major minor]) |
871 proof (rule ex1E [OF major minor]) |
853 show "\<forall>y y'. P y \<and> P y' \<longrightarrow> y = y'" if "P x" and \<section>: "\<forall>y. P y \<longrightarrow> y = x" for x |
872 show "\<forall>y y'. P y \<and> P y' \<longrightarrow> y = y'" if "P x" and \<section>: "\<forall>y. P y \<longrightarrow> y = x" for x |
854 using \<open>P x\<close> \<section> \<section> by fast |
873 using \<open>P x\<close> \<section> \<section> by fast |
855 qed assumption |
874 qed assumption |
856 |
875 |
|
876 text \<open>And again using Uniq\<close> |
|
877 lemma alt_ex1E': |
|
878 assumes "\<exists>!x. P x" "\<And>x. \<lbrakk>P x; \<exists>\<^sub>\<le>\<^sub>1x. P x\<rbrakk> \<Longrightarrow> R" |
|
879 shows R |
|
880 using assms unfolding Uniq_def by fast |
|
881 |
|
882 lemma ex1_iff_ex_Uniq: "(\<exists>!x. P x) \<longleftrightarrow> (\<exists>x. P x) \<and> (\<exists>\<^sub>\<le>\<^sub>1x. P x)" |
|
883 unfolding Uniq_def by fast |
|
884 |
857 |
885 |
858 ML \<open> |
886 ML \<open> |
859 structure Blast = Blast |
887 structure Blast = Blast |
860 ( |
888 ( |
861 structure Classical = Classical |
889 structure Classical = Classical |
898 shows "Q (THE x. P x)" |
926 shows "Q (THE x. P x)" |
899 by (iprover intro: assms(2) theI2[where P=P and Q=Q] ex1E[OF assms(1)] elim: allE impE) |
927 by (iprover intro: assms(2) theI2[where P=P and Q=Q] ex1E[OF assms(1)] elim: allE impE) |
900 |
928 |
901 lemma the1_equality [elim?]: "\<lbrakk>\<exists>!x. P x; P a\<rbrakk> \<Longrightarrow> (THE x. P x) = a" |
929 lemma the1_equality [elim?]: "\<lbrakk>\<exists>!x. P x; P a\<rbrakk> \<Longrightarrow> (THE x. P x) = a" |
902 by blast |
930 by blast |
|
931 |
|
932 lemma the1_equality': "\<lbrakk>\<exists>\<^sub>\<le>\<^sub>1x. P x; P a\<rbrakk> \<Longrightarrow> (THE x. P x) = a" |
|
933 unfolding Uniq_def by blast |
903 |
934 |
904 lemma the_sym_eq_trivial: "(THE y. x = y) = x" |
935 lemma the_sym_eq_trivial: "(THE y. x = y) = x" |
905 by blast |
936 by blast |
906 |
937 |
907 |
938 |