author | nipkow |
Wed, 26 Aug 2009 19:54:19 +0200 | |
changeset 32416 | 4ea7648b6ae2 |
parent 24893 | b8ef7afe3a6b |
child 35762 | af3ff2ba4c54 |
permissions | -rw-r--r-- |
1478 | 1 |
(* Title: ZF/OrderArith.thy |
437 | 2 |
ID: $Id$ |
1478 | 3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
437 | 4 |
Copyright 1994 University of Cambridge |
5 |
||
6 |
*) |
|
7 |
||
13356 | 8 |
header{*Combining Orderings: Foundations of Ordinal Arithmetic*} |
9 |
||
16417 | 10 |
theory OrderArith imports Order Sum Ordinal begin |
437 | 11 |
|
24893 | 12 |
definition |
437 | 13 |
(*disjoint sum of two relations; underlies ordinal addition*) |
24893 | 14 |
radd :: "[i,i,i,i]=>i" where |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
15 |
"radd(A,r,B,s) == |
1155 | 16 |
{z: (A+B) * (A+B). |
1478 | 17 |
(EX x y. z = <Inl(x), Inr(y)>) | |
18 |
(EX x' x. z = <Inl(x'), Inl(x)> & <x',x>:r) | |
|
1155 | 19 |
(EX y' y. z = <Inr(y'), Inr(y)> & <y',y>:s)}" |
437 | 20 |
|
24893 | 21 |
definition |
437 | 22 |
(*lexicographic product of two relations; underlies ordinal multiplication*) |
24893 | 23 |
rmult :: "[i,i,i,i]=>i" where |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
24 |
"rmult(A,r,B,s) == |
1155 | 25 |
{z: (A*B) * (A*B). |
1478 | 26 |
EX x' y' x y. z = <<x',y'>, <x,y>> & |
1155 | 27 |
(<x',x>: r | (x'=x & <y',y>: s))}" |
437 | 28 |
|
24893 | 29 |
definition |
437 | 30 |
(*inverse image of a relation*) |
24893 | 31 |
rvimage :: "[i,i,i]=>i" where |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
32 |
"rvimage(A,f,r) == {z: A*A. EX x y. z = <x,y> & <f`x,f`y>: r}" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
33 |
|
24893 | 34 |
definition |
35 |
measure :: "[i, i\<Rightarrow>i] \<Rightarrow> i" where |
|
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
36 |
"measure(A,f) == {<x,y>: A*A. f(x) < f(y)}" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
37 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
38 |
|
13356 | 39 |
subsection{*Addition of Relations -- Disjoint Sum*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
40 |
|
13512 | 41 |
subsubsection{*Rewrite rules. Can be used to obtain introduction rules*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
42 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
43 |
lemma radd_Inl_Inr_iff [iff]: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
44 |
"<Inl(a), Inr(b)> : radd(A,r,B,s) <-> a:A & b:B" |
13356 | 45 |
by (unfold radd_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
46 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
47 |
lemma radd_Inl_iff [iff]: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
48 |
"<Inl(a'), Inl(a)> : radd(A,r,B,s) <-> a':A & a:A & <a',a>:r" |
13356 | 49 |
by (unfold radd_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
50 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
51 |
lemma radd_Inr_iff [iff]: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
52 |
"<Inr(b'), Inr(b)> : radd(A,r,B,s) <-> b':B & b:B & <b',b>:s" |
13356 | 53 |
by (unfold radd_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
54 |
|
13823 | 55 |
lemma radd_Inr_Inl_iff [simp]: |
56 |
"<Inr(b), Inl(a)> : radd(A,r,B,s) <-> False" |
|
13356 | 57 |
by (unfold radd_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
58 |
|
13823 | 59 |
declare radd_Inr_Inl_iff [THEN iffD1, dest!] |
60 |
||
13512 | 61 |
subsubsection{*Elimination Rule*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
62 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
63 |
lemma raddE: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
64 |
"[| <p',p> : radd(A,r,B,s); |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
65 |
!!x y. [| p'=Inl(x); x:A; p=Inr(y); y:B |] ==> Q; |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
66 |
!!x' x. [| p'=Inl(x'); p=Inl(x); <x',x>: r; x':A; x:A |] ==> Q; |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
67 |
!!y' y. [| p'=Inr(y'); p=Inr(y); <y',y>: s; y':B; y:B |] ==> Q |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
68 |
|] ==> Q" |
13356 | 69 |
by (unfold radd_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
70 |
|
13512 | 71 |
subsubsection{*Type checking*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
72 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
73 |
lemma radd_type: "radd(A,r,B,s) <= (A+B) * (A+B)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
74 |
apply (unfold radd_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
75 |
apply (rule Collect_subset) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
76 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
77 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
78 |
lemmas field_radd = radd_type [THEN field_rel_subset] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
79 |
|
13512 | 80 |
subsubsection{*Linearity*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
81 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
82 |
lemma linear_radd: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
83 |
"[| linear(A,r); linear(B,s) |] ==> linear(A+B,radd(A,r,B,s))" |
13356 | 84 |
by (unfold linear_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
85 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
86 |
|
13512 | 87 |
subsubsection{*Well-foundedness*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
88 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
89 |
lemma wf_on_radd: "[| wf[A](r); wf[B](s) |] ==> wf[A+B](radd(A,r,B,s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
90 |
apply (rule wf_onI2) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
91 |
apply (subgoal_tac "ALL x:A. Inl (x) : Ba") |
13512 | 92 |
--{*Proving the lemma, which is needed twice!*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
93 |
prefer 2 |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
94 |
apply (erule_tac V = "y : A + B" in thin_rl) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
95 |
apply (rule_tac ballI) |
13784 | 96 |
apply (erule_tac r = r and a = x in wf_on_induct, assumption) |
13269 | 97 |
apply blast |
13512 | 98 |
txt{*Returning to main part of proof*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
99 |
apply safe |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
100 |
apply blast |
13784 | 101 |
apply (erule_tac r = s and a = ya in wf_on_induct, assumption, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
102 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
103 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
104 |
lemma wf_radd: "[| wf(r); wf(s) |] ==> wf(radd(field(r),r,field(s),s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
105 |
apply (simp add: wf_iff_wf_on_field) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
106 |
apply (rule wf_on_subset_A [OF _ field_radd]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
107 |
apply (blast intro: wf_on_radd) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
108 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
109 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
110 |
lemma well_ord_radd: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
111 |
"[| well_ord(A,r); well_ord(B,s) |] ==> well_ord(A+B, radd(A,r,B,s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
112 |
apply (rule well_ordI) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
113 |
apply (simp add: well_ord_def wf_on_radd) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
114 |
apply (simp add: well_ord_def tot_ord_def linear_radd) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
115 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
116 |
|
13512 | 117 |
subsubsection{*An @{term ord_iso} congruence law*} |
437 | 118 |
|
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
119 |
lemma sum_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
120 |
"[| f: bij(A,C); g: bij(B,D) |] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
121 |
==> (lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) : bij(A+B, C+D)" |
13356 | 122 |
apply (rule_tac d = "case (%x. Inl (converse(f)`x), %y. Inr(converse(g)`y))" |
123 |
in lam_bijective) |
|
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
124 |
apply (typecheck add: bij_is_inj inj_is_fun) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
125 |
apply (auto simp add: left_inverse_bij right_inverse_bij) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
126 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
127 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
128 |
lemma sum_ord_iso_cong: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
129 |
"[| f: ord_iso(A,r,A',r'); g: ord_iso(B,s,B',s') |] ==> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
130 |
(lam z:A+B. case(%x. Inl(f`x), %y. Inr(g`y), z)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
131 |
: ord_iso(A+B, radd(A,r,B,s), A'+B', radd(A',r',B',s'))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
132 |
apply (unfold ord_iso_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
133 |
apply (safe intro!: sum_bij) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
134 |
(*Do the beta-reductions now*) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
135 |
apply (auto cong add: conj_cong simp add: bij_is_fun [THEN apply_type]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
136 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
137 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
138 |
(*Could we prove an ord_iso result? Perhaps |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
139 |
ord_iso(A+B, radd(A,r,B,s), A Un B, r Un s) *) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
140 |
lemma sum_disjoint_bij: "A Int B = 0 ==> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
141 |
(lam z:A+B. case(%x. x, %y. y, z)) : bij(A+B, A Un B)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
142 |
apply (rule_tac d = "%z. if z:A then Inl (z) else Inr (z) " in lam_bijective) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
143 |
apply auto |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
144 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
145 |
|
13512 | 146 |
subsubsection{*Associativity*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
147 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
148 |
lemma sum_assoc_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
149 |
"(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
150 |
: bij((A+B)+C, A+(B+C))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
151 |
apply (rule_tac d = "case (%x. Inl (Inl (x)), case (%x. Inl (Inr (x)), Inr))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
152 |
in lam_bijective) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
153 |
apply auto |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
154 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
155 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
156 |
lemma sum_assoc_ord_iso: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
157 |
"(lam z:(A+B)+C. case(case(Inl, %y. Inr(Inl(y))), %y. Inr(Inr(y)), z)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
158 |
: ord_iso((A+B)+C, radd(A+B, radd(A,r,B,s), C, t), |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
159 |
A+(B+C), radd(A, r, B+C, radd(B,s,C,t)))" |
13356 | 160 |
by (rule sum_assoc_bij [THEN ord_isoI], auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
161 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
162 |
|
13356 | 163 |
subsection{*Multiplication of Relations -- Lexicographic Product*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
164 |
|
13512 | 165 |
subsubsection{*Rewrite rule. Can be used to obtain introduction rules*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
166 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
167 |
lemma rmult_iff [iff]: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
168 |
"<<a',b'>, <a,b>> : rmult(A,r,B,s) <-> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
169 |
(<a',a>: r & a':A & a:A & b': B & b: B) | |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
170 |
(<b',b>: s & a'=a & a:A & b': B & b: B)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
171 |
|
13356 | 172 |
by (unfold rmult_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
173 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
174 |
lemma rmultE: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
175 |
"[| <<a',b'>, <a,b>> : rmult(A,r,B,s); |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
176 |
[| <a',a>: r; a':A; a:A; b':B; b:B |] ==> Q; |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
177 |
[| <b',b>: s; a:A; a'=a; b':B; b:B |] ==> Q |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
178 |
|] ==> Q" |
13356 | 179 |
by blast |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
180 |
|
13512 | 181 |
subsubsection{*Type checking*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
182 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
183 |
lemma rmult_type: "rmult(A,r,B,s) <= (A*B) * (A*B)" |
13356 | 184 |
by (unfold rmult_def, rule Collect_subset) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
185 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
186 |
lemmas field_rmult = rmult_type [THEN field_rel_subset] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
187 |
|
13512 | 188 |
subsubsection{*Linearity*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
189 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
190 |
lemma linear_rmult: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
191 |
"[| linear(A,r); linear(B,s) |] ==> linear(A*B,rmult(A,r,B,s))" |
13356 | 192 |
by (simp add: linear_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
193 |
|
13512 | 194 |
subsubsection{*Well-foundedness*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
195 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
196 |
lemma wf_on_rmult: "[| wf[A](r); wf[B](s) |] ==> wf[A*B](rmult(A,r,B,s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
197 |
apply (rule wf_onI2) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
198 |
apply (erule SigmaE) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
199 |
apply (erule ssubst) |
13269 | 200 |
apply (subgoal_tac "ALL b:B. <x,b>: Ba", blast) |
13784 | 201 |
apply (erule_tac a = x in wf_on_induct, assumption) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
202 |
apply (rule ballI) |
13784 | 203 |
apply (erule_tac a = b in wf_on_induct, assumption) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
204 |
apply (best elim!: rmultE bspec [THEN mp]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
205 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
206 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
207 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
208 |
lemma wf_rmult: "[| wf(r); wf(s) |] ==> wf(rmult(field(r),r,field(s),s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
209 |
apply (simp add: wf_iff_wf_on_field) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
210 |
apply (rule wf_on_subset_A [OF _ field_rmult]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
211 |
apply (blast intro: wf_on_rmult) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
212 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
213 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
214 |
lemma well_ord_rmult: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
215 |
"[| well_ord(A,r); well_ord(B,s) |] ==> well_ord(A*B, rmult(A,r,B,s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
216 |
apply (rule well_ordI) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
217 |
apply (simp add: well_ord_def wf_on_rmult) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
218 |
apply (simp add: well_ord_def tot_ord_def linear_rmult) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
219 |
done |
9883 | 220 |
|
221 |
||
13512 | 222 |
subsubsection{*An @{term ord_iso} congruence law*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
223 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
224 |
lemma prod_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
225 |
"[| f: bij(A,C); g: bij(B,D) |] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
226 |
==> (lam <x,y>:A*B. <f`x, g`y>) : bij(A*B, C*D)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
227 |
apply (rule_tac d = "%<x,y>. <converse (f) `x, converse (g) `y>" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
228 |
in lam_bijective) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
229 |
apply (typecheck add: bij_is_inj inj_is_fun) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
230 |
apply (auto simp add: left_inverse_bij right_inverse_bij) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
231 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
232 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
233 |
lemma prod_ord_iso_cong: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
234 |
"[| f: ord_iso(A,r,A',r'); g: ord_iso(B,s,B',s') |] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
235 |
==> (lam <x,y>:A*B. <f`x, g`y>) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
236 |
: ord_iso(A*B, rmult(A,r,B,s), A'*B', rmult(A',r',B',s'))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
237 |
apply (unfold ord_iso_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
238 |
apply (safe intro!: prod_bij) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
239 |
apply (simp_all add: bij_is_fun [THEN apply_type]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
240 |
apply (blast intro: bij_is_inj [THEN inj_apply_equality]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
241 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
242 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
243 |
lemma singleton_prod_bij: "(lam z:A. <x,z>) : bij(A, {x}*A)" |
13784 | 244 |
by (rule_tac d = snd in lam_bijective, auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
245 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
246 |
(*Used??*) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
247 |
lemma singleton_prod_ord_iso: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
248 |
"well_ord({x},xr) ==> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
249 |
(lam z:A. <x,z>) : ord_iso(A, r, {x}*A, rmult({x}, xr, A, r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
250 |
apply (rule singleton_prod_bij [THEN ord_isoI]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
251 |
apply (simp (no_asm_simp)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
252 |
apply (blast dest: well_ord_is_wf [THEN wf_on_not_refl]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
253 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
254 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
255 |
(*Here we build a complicated function term, then simplify it using |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
256 |
case_cong, id_conv, comp_lam, case_case.*) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
257 |
lemma prod_sum_singleton_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
258 |
"a~:C ==> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
259 |
(lam x:C*B + D. case(%x. x, %y.<a,y>, x)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
260 |
: bij(C*B + D, C*B Un {a}*D)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
261 |
apply (rule subst_elem) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
262 |
apply (rule id_bij [THEN sum_bij, THEN comp_bij]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
263 |
apply (rule singleton_prod_bij) |
13269 | 264 |
apply (rule sum_disjoint_bij, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
265 |
apply (simp (no_asm_simp) cong add: case_cong) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
266 |
apply (rule comp_lam [THEN trans, symmetric]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
267 |
apply (fast elim!: case_type) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
268 |
apply (simp (no_asm_simp) add: case_case) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
269 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
270 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
271 |
lemma prod_sum_singleton_ord_iso: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
272 |
"[| a:A; well_ord(A,r) |] ==> |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
273 |
(lam x:pred(A,a,r)*B + pred(B,b,s). case(%x. x, %y.<a,y>, x)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
274 |
: ord_iso(pred(A,a,r)*B + pred(B,b,s), |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
275 |
radd(A*B, rmult(A,r,B,s), B, s), |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
276 |
pred(A,a,r)*B Un {a}*pred(B,b,s), rmult(A,r,B,s))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
277 |
apply (rule prod_sum_singleton_bij [THEN ord_isoI]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
278 |
apply (simp (no_asm_simp) add: pred_iff well_ord_is_wf [THEN wf_on_not_refl]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
279 |
apply (auto elim!: well_ord_is_wf [THEN wf_on_asym] predE) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
280 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
281 |
|
13512 | 282 |
subsubsection{*Distributive law*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
283 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
284 |
lemma sum_prod_distrib_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
285 |
"(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
286 |
: bij((A+B)*C, (A*C)+(B*C))" |
13356 | 287 |
by (rule_tac d = "case (%<x,y>.<Inl (x),y>, %<x,y>.<Inr (x),y>) " |
288 |
in lam_bijective, auto) |
|
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
289 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
290 |
lemma sum_prod_distrib_ord_iso: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
291 |
"(lam <x,z>:(A+B)*C. case(%y. Inl(<y,z>), %y. Inr(<y,z>), x)) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
292 |
: ord_iso((A+B)*C, rmult(A+B, radd(A,r,B,s), C, t), |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
293 |
(A*C)+(B*C), radd(A*C, rmult(A,r,C,t), B*C, rmult(B,s,C,t)))" |
13356 | 294 |
by (rule sum_prod_distrib_bij [THEN ord_isoI], auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
295 |
|
13512 | 296 |
subsubsection{*Associativity*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
297 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
298 |
lemma prod_assoc_bij: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
299 |
"(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) : bij((A*B)*C, A*(B*C))" |
13356 | 300 |
by (rule_tac d = "%<x, <y,z>>. <<x,y>, z>" in lam_bijective, auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
301 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
302 |
lemma prod_assoc_ord_iso: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
303 |
"(lam <<x,y>, z>:(A*B)*C. <x,<y,z>>) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
304 |
: ord_iso((A*B)*C, rmult(A*B, rmult(A,r,B,s), C, t), |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
305 |
A*(B*C), rmult(A, r, B*C, rmult(B,s,C,t)))" |
13356 | 306 |
by (rule prod_assoc_bij [THEN ord_isoI], auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
307 |
|
13356 | 308 |
subsection{*Inverse Image of a Relation*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
309 |
|
13512 | 310 |
subsubsection{*Rewrite rule*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
311 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
312 |
lemma rvimage_iff: "<a,b> : rvimage(A,f,r) <-> <f`a,f`b>: r & a:A & b:A" |
13269 | 313 |
by (unfold rvimage_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
314 |
|
13512 | 315 |
subsubsection{*Type checking*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
316 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
317 |
lemma rvimage_type: "rvimage(A,f,r) <= A*A" |
13784 | 318 |
by (unfold rvimage_def, rule Collect_subset) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
319 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
320 |
lemmas field_rvimage = rvimage_type [THEN field_rel_subset] |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
321 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
322 |
lemma rvimage_converse: "rvimage(A,f, converse(r)) = converse(rvimage(A,f,r))" |
13269 | 323 |
by (unfold rvimage_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
324 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
325 |
|
13512 | 326 |
subsubsection{*Partial Ordering Properties*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
327 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
328 |
lemma irrefl_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
329 |
"[| f: inj(A,B); irrefl(B,r) |] ==> irrefl(A, rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
330 |
apply (unfold irrefl_def rvimage_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
331 |
apply (blast intro: inj_is_fun [THEN apply_type]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
332 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
333 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
334 |
lemma trans_on_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
335 |
"[| f: inj(A,B); trans[B](r) |] ==> trans[A](rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
336 |
apply (unfold trans_on_def rvimage_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
337 |
apply (blast intro: inj_is_fun [THEN apply_type]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
338 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
339 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
340 |
lemma part_ord_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
341 |
"[| f: inj(A,B); part_ord(B,r) |] ==> part_ord(A, rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
342 |
apply (unfold part_ord_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
343 |
apply (blast intro!: irrefl_rvimage trans_on_rvimage) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
344 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
345 |
|
13512 | 346 |
subsubsection{*Linearity*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
347 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
348 |
lemma linear_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
349 |
"[| f: inj(A,B); linear(B,r) |] ==> linear(A,rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
350 |
apply (simp add: inj_def linear_def rvimage_iff) |
13269 | 351 |
apply (blast intro: apply_funtype) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
352 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
353 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
354 |
lemma tot_ord_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
355 |
"[| f: inj(A,B); tot_ord(B,r) |] ==> tot_ord(A, rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
356 |
apply (unfold tot_ord_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
357 |
apply (blast intro!: part_ord_rvimage linear_rvimage) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
358 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
359 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
360 |
|
13512 | 361 |
subsubsection{*Well-foundedness*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
362 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
363 |
lemma wf_rvimage [intro!]: "wf(r) ==> wf(rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
364 |
apply (simp (no_asm_use) add: rvimage_def wf_eq_minimal) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
365 |
apply clarify |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
366 |
apply (subgoal_tac "EX w. w : {w: {f`x. x:Q}. EX x. x: Q & (f`x = w) }") |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
367 |
apply (erule allE) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
368 |
apply (erule impE) |
13269 | 369 |
apply assumption |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
370 |
apply blast |
13269 | 371 |
apply blast |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
372 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
373 |
|
13544 | 374 |
text{*But note that the combination of @{text wf_imp_wf_on} and |
22710 | 375 |
@{text wf_rvimage} gives @{prop "wf(r) ==> wf[C](rvimage(A,f,r))"}*} |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
376 |
lemma wf_on_rvimage: "[| f: A->B; wf[B](r) |] ==> wf[A](rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
377 |
apply (rule wf_onI2) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
378 |
apply (subgoal_tac "ALL z:A. f`z=f`y --> z: Ba") |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
379 |
apply blast |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
380 |
apply (erule_tac a = "f`y" in wf_on_induct) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
381 |
apply (blast intro!: apply_funtype) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
382 |
apply (blast intro!: apply_funtype dest!: rvimage_iff [THEN iffD1]) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
383 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
384 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
385 |
(*Note that we need only wf[A](...) and linear(A,...) to get the result!*) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
386 |
lemma well_ord_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
387 |
"[| f: inj(A,B); well_ord(B,r) |] ==> well_ord(A, rvimage(A,f,r))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
388 |
apply (rule well_ordI) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
389 |
apply (unfold well_ord_def tot_ord_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
390 |
apply (blast intro!: wf_on_rvimage inj_is_fun) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
391 |
apply (blast intro!: linear_rvimage) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
392 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
393 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
394 |
lemma ord_iso_rvimage: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
395 |
"f: bij(A,B) ==> f: ord_iso(A, rvimage(A,f,s), B, s)" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
396 |
apply (unfold ord_iso_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
397 |
apply (simp add: rvimage_iff) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
398 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
399 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
400 |
lemma ord_iso_rvimage_eq: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
401 |
"f: ord_iso(A,r, B,s) ==> rvimage(A,f,s) = r Int A*A" |
13356 | 402 |
by (unfold ord_iso_def rvimage_def, blast) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
403 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
404 |
|
13634 | 405 |
subsection{*Every well-founded relation is a subset of some inverse image of |
406 |
an ordinal*} |
|
407 |
||
408 |
lemma wf_rvimage_Ord: "Ord(i) \<Longrightarrow> wf(rvimage(A, f, Memrel(i)))" |
|
409 |
by (blast intro: wf_rvimage wf_Memrel) |
|
410 |
||
411 |
||
24893 | 412 |
definition |
413 |
wfrank :: "[i,i]=>i" where |
|
13634 | 414 |
"wfrank(r,a) == wfrec(r, a, %x f. \<Union>y \<in> r-``{x}. succ(f`y))" |
415 |
||
24893 | 416 |
definition |
417 |
wftype :: "i=>i" where |
|
13634 | 418 |
"wftype(r) == \<Union>y \<in> range(r). succ(wfrank(r,y))" |
419 |
||
420 |
lemma wfrank: "wf(r) ==> wfrank(r,a) = (\<Union>y \<in> r-``{a}. succ(wfrank(r,y)))" |
|
421 |
by (subst wfrank_def [THEN def_wfrec], simp_all) |
|
422 |
||
423 |
lemma Ord_wfrank: "wf(r) ==> Ord(wfrank(r,a))" |
|
424 |
apply (rule_tac a=a in wf_induct, assumption) |
|
425 |
apply (subst wfrank, assumption) |
|
426 |
apply (rule Ord_succ [THEN Ord_UN], blast) |
|
427 |
done |
|
428 |
||
429 |
lemma wfrank_lt: "[|wf(r); <a,b> \<in> r|] ==> wfrank(r,a) < wfrank(r,b)" |
|
430 |
apply (rule_tac a1 = b in wfrank [THEN ssubst], assumption) |
|
431 |
apply (rule UN_I [THEN ltI]) |
|
432 |
apply (simp add: Ord_wfrank vimage_iff)+ |
|
433 |
done |
|
434 |
||
435 |
lemma Ord_wftype: "wf(r) ==> Ord(wftype(r))" |
|
436 |
by (simp add: wftype_def Ord_wfrank) |
|
437 |
||
438 |
lemma wftypeI: "\<lbrakk>wf(r); x \<in> field(r)\<rbrakk> \<Longrightarrow> wfrank(r,x) \<in> wftype(r)" |
|
439 |
apply (simp add: wftype_def) |
|
440 |
apply (blast intro: wfrank_lt [THEN ltD]) |
|
441 |
done |
|
442 |
||
443 |
||
444 |
lemma wf_imp_subset_rvimage: |
|
445 |
"[|wf(r); r \<subseteq> A*A|] ==> \<exists>i f. Ord(i) & r <= rvimage(A, f, Memrel(i))" |
|
446 |
apply (rule_tac x="wftype(r)" in exI) |
|
447 |
apply (rule_tac x="\<lambda>x\<in>A. wfrank(r,x)" in exI) |
|
448 |
apply (simp add: Ord_wftype, clarify) |
|
449 |
apply (frule subsetD, assumption, clarify) |
|
450 |
apply (simp add: rvimage_iff wfrank_lt [THEN ltD]) |
|
451 |
apply (blast intro: wftypeI) |
|
452 |
done |
|
453 |
||
454 |
theorem wf_iff_subset_rvimage: |
|
455 |
"relation(r) ==> wf(r) <-> (\<exists>i f A. Ord(i) & r <= rvimage(A, f, Memrel(i)))" |
|
456 |
by (blast dest!: relation_field_times_field wf_imp_subset_rvimage |
|
457 |
intro: wf_rvimage_Ord [THEN wf_subset]) |
|
458 |
||
459 |
||
13544 | 460 |
subsection{*Other Results*} |
461 |
||
462 |
lemma wf_times: "A Int B = 0 ==> wf(A*B)" |
|
463 |
by (simp add: wf_def, blast) |
|
464 |
||
465 |
text{*Could also be used to prove @{text wf_radd}*} |
|
466 |
lemma wf_Un: |
|
467 |
"[| range(r) Int domain(s) = 0; wf(r); wf(s) |] ==> wf(r Un s)" |
|
468 |
apply (simp add: wf_def, clarify) |
|
469 |
apply (rule equalityI) |
|
470 |
prefer 2 apply blast |
|
471 |
apply clarify |
|
472 |
apply (drule_tac x=Z in spec) |
|
473 |
apply (drule_tac x="Z Int domain(s)" in spec) |
|
474 |
apply simp |
|
475 |
apply (blast intro: elim: equalityE) |
|
476 |
done |
|
477 |
||
478 |
subsubsection{*The Empty Relation*} |
|
479 |
||
480 |
lemma wf0: "wf(0)" |
|
481 |
by (simp add: wf_def, blast) |
|
482 |
||
483 |
lemma linear0: "linear(0,0)" |
|
484 |
by (simp add: linear_def) |
|
485 |
||
486 |
lemma well_ord0: "well_ord(0,0)" |
|
487 |
by (blast intro: wf_imp_wf_on well_ordI wf0 linear0) |
|
13512 | 488 |
|
489 |
subsubsection{*The "measure" relation is useful with wfrec*} |
|
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
490 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
491 |
lemma measure_eq_rvimage_Memrel: |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
492 |
"measure(A,f) = rvimage(A,Lambda(A,f),Memrel(Collect(RepFun(A,f),Ord)))" |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
493 |
apply (simp (no_asm) add: measure_def rvimage_def Memrel_iff) |
13269 | 494 |
apply (rule equalityI, auto) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
495 |
apply (auto intro: Ord_in_Ord simp add: lt_def) |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
496 |
done |
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
497 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
498 |
lemma wf_measure [iff]: "wf(measure(A,f))" |
13356 | 499 |
by (simp (no_asm) add: measure_eq_rvimage_Memrel wf_Memrel wf_rvimage) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
500 |
|
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
501 |
lemma measure_iff [iff]: "<x,y> : measure(A,f) <-> x:A & y:A & f(x)<f(y)" |
13356 | 502 |
by (simp (no_asm) add: measure_def) |
13140
6d97dbb189a9
converted Order.ML OrderType.ML OrderArith.ML to Isar format
paulson
parents:
9883
diff
changeset
|
503 |
|
13544 | 504 |
lemma linear_measure: |
505 |
assumes Ordf: "!!x. x \<in> A ==> Ord(f(x))" |
|
506 |
and inj: "!!x y. [|x \<in> A; y \<in> A; f(x) = f(y) |] ==> x=y" |
|
507 |
shows "linear(A, measure(A,f))" |
|
508 |
apply (auto simp add: linear_def) |
|
509 |
apply (rule_tac i="f(x)" and j="f(y)" in Ord_linear_lt) |
|
510 |
apply (simp_all add: Ordf) |
|
511 |
apply (blast intro: inj) |
|
512 |
done |
|
513 |
||
514 |
lemma wf_on_measure: "wf[B](measure(A,f))" |
|
515 |
by (rule wf_imp_wf_on [OF wf_measure]) |
|
516 |
||
517 |
lemma well_ord_measure: |
|
518 |
assumes Ordf: "!!x. x \<in> A ==> Ord(f(x))" |
|
519 |
and inj: "!!x y. [|x \<in> A; y \<in> A; f(x) = f(y) |] ==> x=y" |
|
520 |
shows "well_ord(A, measure(A,f))" |
|
521 |
apply (rule well_ordI) |
|
522 |
apply (rule wf_on_measure) |
|
523 |
apply (blast intro: linear_measure Ordf inj) |
|
524 |
done |
|
525 |
||
526 |
lemma measure_type: "measure(A,f) <= A*A" |
|
527 |
by (auto simp add: measure_def) |
|
528 |
||
13512 | 529 |
subsubsection{*Well-foundedness of Unions*} |
530 |
||
531 |
lemma wf_on_Union: |
|
532 |
assumes wfA: "wf[A](r)" |
|
533 |
and wfB: "!!a. a\<in>A ==> wf[B(a)](s)" |
|
534 |
and ok: "!!a u v. [|<u,v> \<in> s; v \<in> B(a); a \<in> A|] |
|
535 |
==> (\<exists>a'\<in>A. <a',a> \<in> r & u \<in> B(a')) | u \<in> B(a)" |
|
536 |
shows "wf[\<Union>a\<in>A. B(a)](s)" |
|
537 |
apply (rule wf_onI2) |
|
538 |
apply (erule UN_E) |
|
539 |
apply (subgoal_tac "\<forall>z \<in> B(a). z \<in> Ba", blast) |
|
540 |
apply (rule_tac a = a in wf_on_induct [OF wfA], assumption) |
|
541 |
apply (rule ballI) |
|
542 |
apply (rule_tac a = z in wf_on_induct [OF wfB], assumption, assumption) |
|
543 |
apply (rename_tac u) |
|
544 |
apply (drule_tac x=u in bspec, blast) |
|
545 |
apply (erule mp, clarify) |
|
13784 | 546 |
apply (frule ok, assumption+, blast) |
13512 | 547 |
done |
548 |
||
14120 | 549 |
subsubsection{*Bijections involving Powersets*} |
550 |
||
551 |
lemma Pow_sum_bij: |
|
552 |
"(\<lambda>Z \<in> Pow(A+B). <{x \<in> A. Inl(x) \<in> Z}, {y \<in> B. Inr(y) \<in> Z}>) |
|
553 |
\<in> bij(Pow(A+B), Pow(A)*Pow(B))" |
|
554 |
apply (rule_tac d = "%<X,Y>. {Inl (x). x \<in> X} Un {Inr (y). y \<in> Y}" |
|
555 |
in lam_bijective) |
|
556 |
apply force+ |
|
557 |
done |
|
558 |
||
559 |
text{*As a special case, we have @{term "bij(Pow(A*B), A -> Pow(B))"} *} |
|
560 |
lemma Pow_Sigma_bij: |
|
561 |
"(\<lambda>r \<in> Pow(Sigma(A,B)). \<lambda>x \<in> A. r``{x}) |
|
14171
0cab06e3bbd0
Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
14120
diff
changeset
|
562 |
\<in> bij(Pow(Sigma(A,B)), \<Pi> x \<in> A. Pow(B(x)))" |
14120 | 563 |
apply (rule_tac d = "%f. \<Union>x \<in> A. \<Union>y \<in> f`x. {<x,y>}" in lam_bijective) |
564 |
apply (blast intro: lam_type) |
|
565 |
apply (blast dest: apply_type, simp_all) |
|
566 |
apply fast (*strange, but blast can't do it*) |
|
567 |
apply (rule fun_extension, auto) |
|
568 |
by blast |
|
569 |
||
437 | 570 |
end |