154 "[| P(a); !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a" |
154 "[| P(a); !!x. P(x) ==> x=a |] ==> (THE x. P(x)) = a" |
155 apply (unfold the_def) |
155 apply (unfold the_def) |
156 apply (fast dest: subst) |
156 apply (fast dest: subst) |
157 done |
157 done |
158 |
158 |
159 (* Only use this if you already know EX!x. P(x) *) |
159 (* Only use this if you already know \<exists>!x. P(x) *) |
160 lemma the_equality2: "[| EX! x. P(x); P(a) |] ==> (THE x. P(x)) = a" |
160 lemma the_equality2: "[| \<exists>!x. P(x); P(a) |] ==> (THE x. P(x)) = a" |
161 by blast |
161 by blast |
162 |
162 |
163 lemma theI: "EX! x. P(x) ==> P(THE x. P(x))" |
163 lemma theI: "\<exists>!x. P(x) ==> P(THE x. P(x))" |
164 apply (erule ex1E) |
164 apply (erule ex1E) |
165 apply (subst the_equality) |
165 apply (subst the_equality) |
166 apply (blast+) |
166 apply (blast+) |
167 done |
167 done |
168 |
168 |
169 (*No congruence rule is necessary: if @{term"\<forall>y.P(y)\<longleftrightarrow>Q(y)"} then |
169 (*No congruence rule is necessary: if @{term"\<forall>y.P(y)\<longleftrightarrow>Q(y)"} then |
170 @{term "THE x.P(x)"} rewrites to @{term "THE x.Q(x)"} *) |
170 @{term "THE x.P(x)"} rewrites to @{term "THE x.Q(x)"} *) |
171 |
171 |
172 (*If it's "undefined", it's zero!*) |
172 (*If it's "undefined", it's zero!*) |
173 lemma the_0: "~ (EX! x. P(x)) ==> (THE x. P(x))=0" |
173 lemma the_0: "~ (\<exists>!x. P(x)) ==> (THE x. P(x))=0" |
174 apply (unfold the_def) |
174 apply (unfold the_def) |
175 apply (blast elim!: ReplaceE) |
175 apply (blast elim!: ReplaceE) |
176 done |
176 done |
177 |
177 |
178 (*Easier to apply than theI: conclusion has only one occurrence of P*) |
178 (*Easier to apply than theI: conclusion has only one occurrence of P*) |
179 lemma theI2: |
179 lemma theI2: |
180 assumes p1: "~ Q(0) ==> EX! x. P(x)" |
180 assumes p1: "~ Q(0) ==> \<exists>!x. P(x)" |
181 and p2: "!!x. P(x) ==> Q(x)" |
181 and p2: "!!x. P(x) ==> Q(x)" |
182 shows "Q(THE x. P(x))" |
182 shows "Q(THE x. P(x))" |
183 apply (rule classical) |
183 apply (rule classical) |
184 apply (rule p2) |
184 apply (rule p2) |
185 apply (rule theI) |
185 apply (rule theI) |