author | wenzelm |
Tue, 13 Sep 2005 22:19:23 +0200 | |
changeset 17339 | ab97ccef124a |
parent 17332 | 4910cf8c0cd2 |
permissions | -rw-r--r-- |
17295 | 1 |
(* Title : HOL/Hyperreal/Transfer.thy |
2 |
ID : $Id$ |
|
3 |
Author : Brian Huffman |
|
4 |
*) |
|
5 |
||
6 |
header {* Transfer Principle *} |
|
7 |
||
8 |
theory Transfer |
|
9 |
imports StarType |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
10 |
uses ("transfer.ML") |
17295 | 11 |
begin |
12 |
||
13 |
subsection {* Starting the transfer proof *} |
|
14 |
||
15 |
text {* |
|
16 |
A transfer theorem asserts an equivalence @{prop "P \<equiv> P'"} |
|
17 |
between two related propositions. Proposition @{term P} may |
|
18 |
refer to constants having star types, like @{typ "'a star"}. |
|
19 |
Proposition @{term P'} is syntactically similar, but only |
|
20 |
refers to ordinary types (i.e. @{term P'} is the un-starred |
|
21 |
version of @{term P}). |
|
22 |
*} |
|
23 |
||
24 |
text {* This introduction rule starts each transfer proof. *} |
|
25 |
||
26 |
lemma transfer_start: |
|
27 |
"P \<equiv> {n. Q} \<in> \<U> \<Longrightarrow> Trueprop P \<equiv> Trueprop Q" |
|
28 |
by (subgoal_tac "P \<equiv> Q", simp, simp add: atomize_eq) |
|
29 |
||
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
30 |
use "transfer.ML" |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
31 |
setup Transfer.setup |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
32 |
|
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
33 |
declare Ifun_defs [transfer_unfold] |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
34 |
declare Iset_of_def [transfer_unfold] |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
35 |
|
17295 | 36 |
subsection {* Transfer introduction rules *} |
37 |
||
38 |
text {* |
|
39 |
The proof of a transfer theorem is completely syntax-directed. |
|
40 |
At each step in the proof, the top-level connective determines |
|
41 |
which introduction rule to apply. Each argument to the top-level |
|
42 |
connective generates a new subgoal. |
|
43 |
*} |
|
44 |
||
45 |
text {* |
|
46 |
Subgoals in a transfer proof always have the form of an equivalence. |
|
47 |
The left side can be any term, and may contain references to star |
|
48 |
types. The form of the right side depends on its type. At type |
|
49 |
@{typ bool} it takes the form @{term "{n. P n} \<in> \<U>"}. At type |
|
50 |
@{typ "'a star"} it takes the form @{term "star_n (\<lambda>n. X n)"}. At type |
|
51 |
@{typ "'a star set"} it looks like @{term "Iset (star_n (\<lambda>n. A n))"}. |
|
52 |
And at type @{typ "'a star \<Rightarrow> 'b star"} it has the form |
|
53 |
@{term "Ifun (star_n (\<lambda>n. F n))"}. |
|
54 |
*} |
|
55 |
||
56 |
subsubsection {* Boolean operators *} |
|
57 |
||
58 |
lemma transfer_not: |
|
59 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>\<rbrakk> \<Longrightarrow> \<not> p \<equiv> {n. \<not> P n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
60 |
by (simp only: ultrafilter.Collect_not [OF ultrafilter_FUFNat]) |
17295 | 61 |
|
62 |
lemma transfer_conj: |
|
63 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk> |
|
64 |
\<Longrightarrow> p \<and> q \<equiv> {n. P n \<and> Q n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
65 |
by (simp only: filter.Collect_conj [OF filter_FUFNat]) |
17295 | 66 |
|
67 |
lemma transfer_disj: |
|
68 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk> |
|
69 |
\<Longrightarrow> p \<or> q \<equiv> {n. P n \<or> Q n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
70 |
by (simp only: ultrafilter.Collect_disj [OF ultrafilter_FUFNat]) |
17295 | 71 |
|
72 |
lemma transfer_imp: |
|
73 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk> |
|
74 |
\<Longrightarrow> p \<longrightarrow> q \<equiv> {n. P n \<longrightarrow> Q n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
75 |
by (simp only: imp_conv_disj transfer_disj transfer_not) |
17295 | 76 |
|
77 |
lemma transfer_iff: |
|
78 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk> |
|
79 |
\<Longrightarrow> p = q \<equiv> {n. P n = Q n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
80 |
by (simp only: iff_conv_conj_imp transfer_conj transfer_imp) |
17295 | 81 |
|
82 |
lemma transfer_if_bool: |
|
83 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; x \<equiv> {n. X n} \<in> \<U>; y \<equiv> {n. Y n} \<in> \<U>\<rbrakk> |
|
84 |
\<Longrightarrow> (if p then x else y) \<equiv> {n. if P n then X n else Y n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
85 |
by (simp only: if_bool_eq_conj transfer_conj transfer_imp transfer_not) |
17295 | 86 |
|
87 |
subsubsection {* Equals, If *} |
|
88 |
||
89 |
lemma transfer_eq: |
|
90 |
"\<lbrakk>x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk> \<Longrightarrow> x = y \<equiv> {n. X n = Y n} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
91 |
by (simp only: star_n_eq_iff) |
17295 | 92 |
|
93 |
lemma transfer_if: |
|
94 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk> |
|
95 |
\<Longrightarrow> (if p then x else y) \<equiv> star_n (\<lambda>n. if P n then X n else Y n)" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
96 |
apply (rule eq_reflection) |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
97 |
apply (auto simp add: star_n_eq_iff transfer_not elim!: ultra) |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
98 |
done |
17295 | 99 |
|
100 |
subsubsection {* Quantifiers *} |
|
101 |
||
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
102 |
lemma transfer_ex: |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
103 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
104 |
\<Longrightarrow> \<exists>x::'a star. p x \<equiv> {n. \<exists>x. P n x} \<in> \<U>" |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
105 |
by (simp only: ex_star_eq filter.Collect_ex [OF filter_FUFNat]) |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
106 |
|
17295 | 107 |
lemma transfer_all: |
108 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
|
109 |
\<Longrightarrow> \<forall>x::'a star. p x \<equiv> {n. \<forall>x. P n x} \<in> \<U>" |
|
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
110 |
by (simp only: all_star_eq ultrafilter.Collect_all [OF ultrafilter_FUFNat]) |
17295 | 111 |
|
112 |
lemma transfer_ex1: |
|
113 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
|
114 |
\<Longrightarrow> \<exists>!x. p x \<equiv> {n. \<exists>!x. P n x} \<in> \<U>" |
|
115 |
by (simp only: Ex1_def transfer_ex transfer_conj |
|
116 |
transfer_all transfer_imp transfer_eq) |
|
117 |
||
118 |
subsubsection {* Functions *} |
|
119 |
||
120 |
lemma transfer_Ifun: |
|
121 |
"\<lbrakk>f \<equiv> star_n F; x \<equiv> star_n X\<rbrakk> |
|
122 |
\<Longrightarrow> f \<star> x \<equiv> star_n (\<lambda>n. F n (X n))" |
|
123 |
by (simp only: Ifun_star_n) |
|
124 |
||
125 |
lemma transfer_fun_eq: |
|
126 |
"\<lbrakk>\<And>X. f (star_n X) = g (star_n X) |
|
127 |
\<equiv> {n. F n (X n) = G n (X n)} \<in> \<U>\<rbrakk> |
|
128 |
\<Longrightarrow> f = g \<equiv> {n. F n = G n} \<in> \<U>" |
|
129 |
by (simp only: expand_fun_eq transfer_all) |
|
130 |
||
131 |
subsubsection {* Sets *} |
|
132 |
||
133 |
lemma transfer_Iset: |
|
134 |
"\<lbrakk>a \<equiv> star_n A\<rbrakk> \<Longrightarrow> Iset a \<equiv> Iset (star_n (\<lambda>n. A n))" |
|
135 |
by simp |
|
136 |
||
137 |
lemma transfer_Collect: |
|
138 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
|
139 |
\<Longrightarrow> Collect p \<equiv> Iset (star_n (\<lambda>n. Collect (P n)))" |
|
140 |
by (simp add: atomize_eq expand_set_eq all_star_eq Iset_star_n) |
|
141 |
||
142 |
lemma transfer_mem: |
|
143 |
"\<lbrakk>x \<equiv> star_n X; a \<equiv> Iset (star_n A)\<rbrakk> |
|
144 |
\<Longrightarrow> x \<in> a \<equiv> {n. X n \<in> A n} \<in> \<U>" |
|
145 |
by (simp only: Iset_star_n) |
|
146 |
||
147 |
lemma transfer_set_eq: |
|
148 |
"\<lbrakk>a \<equiv> Iset (star_n A); b \<equiv> Iset (star_n B)\<rbrakk> |
|
149 |
\<Longrightarrow> a = b \<equiv> {n. A n = B n} \<in> \<U>" |
|
150 |
by (simp only: expand_set_eq transfer_all transfer_iff transfer_mem) |
|
151 |
||
152 |
lemma transfer_ball: |
|
153 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
|
154 |
\<Longrightarrow> \<forall>x\<in>a. p x \<equiv> {n. \<forall>x\<in>A n. P n x} \<in> \<U>" |
|
155 |
by (simp only: Ball_def transfer_all transfer_imp transfer_mem) |
|
156 |
||
157 |
lemma transfer_bex: |
|
158 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk> |
|
159 |
\<Longrightarrow> \<exists>x\<in>a. p x \<equiv> {n. \<exists>x\<in>A n. P n x} \<in> \<U>" |
|
160 |
by (simp only: Bex_def transfer_ex transfer_conj transfer_mem) |
|
161 |
||
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
162 |
|
17295 | 163 |
subsubsection {* Miscellaneous *} |
164 |
||
165 |
lemma transfer_unstar: |
|
166 |
"p \<equiv> star_n P \<Longrightarrow> unstar p \<equiv> {n. P n} \<in> \<U>" |
|
167 |
by (simp only: unstar_star_n) |
|
168 |
||
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
169 |
lemma transfer_star_of: "star_of x \<equiv> star_n (\<lambda>n. x)" |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
170 |
by (rule star_of_def) |
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
171 |
|
17295 | 172 |
lemma transfer_star_n: "star_n X \<equiv> star_n (\<lambda>n. X n)" |
173 |
by (rule reflexive) |
|
174 |
||
175 |
lemma transfer_bool: "p \<equiv> {n. p} \<in> \<U>" |
|
176 |
by (simp add: atomize_eq) |
|
177 |
||
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
178 |
lemmas transfer_intros [transfer_intro] = |
17295 | 179 |
transfer_star_n |
17332
4910cf8c0cd2
added theorem attributes transfer_intro, transfer_unfold, transfer_refold; simplified some proofs; some rearranging
huffman
parents:
17295
diff
changeset
|
180 |
transfer_star_of |
17295 | 181 |
transfer_Ifun |
182 |
transfer_fun_eq |
|
183 |
||
184 |
transfer_not |
|
185 |
transfer_conj |
|
186 |
transfer_disj |
|
187 |
transfer_imp |
|
188 |
transfer_iff |
|
189 |
transfer_if_bool |
|
190 |
||
191 |
transfer_all |
|
192 |
transfer_ex |
|
193 |
||
194 |
transfer_unstar |
|
195 |
transfer_bool |
|
196 |
transfer_eq |
|
197 |
transfer_if |
|
198 |
||
199 |
transfer_set_eq |
|
200 |
transfer_Iset |
|
201 |
transfer_Collect |
|
202 |
transfer_mem |
|
203 |
transfer_ball |
|
204 |
transfer_bex |
|
205 |
||
206 |
text {* Sample theorems *} |
|
207 |
||
208 |
lemma Ifun_inject: "\<And>f g. (Ifun f = Ifun g) = (f = g)" |
|
209 |
by transfer (rule refl) |
|
210 |
||
211 |
lemma unstar_inject: "\<And>x y. (unstar x = unstar y) = (x = y)" |
|
212 |
by transfer (rule refl) |
|
213 |
||
214 |
lemma Iset_inject: "\<And>A B. (Iset A = Iset B) = (A = B)" |
|
215 |
by transfer (rule refl) |
|
216 |
||
217 |
end |