src/ZF/Constructible/AC_in_L.thy
changeset 13543 2b3c7e319d82
child 13546 f76237c2be75
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/ZF/Constructible/AC_in_L.thy	Wed Aug 28 13:08:34 2002 +0200
     1.3 @@ -0,0 +1,528 @@
     1.4 +(*  Title:      ZF/Constructible/AC_in_L.thy
     1.5 +    ID: $Id$
     1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   2002  University of Cambridge
     1.8 +*)
     1.9 +
    1.10 +header {* The Axiom of Choice Holds in L! *}
    1.11 +
    1.12 +theory AC_in_L = Formula:
    1.13 +
    1.14 +subsection{*Extending a Wellordering over a List -- Lexicographic Power*}
    1.15 +
    1.16 +text{*This could be moved into a library.*}
    1.17 +
    1.18 +consts
    1.19 +  rlist   :: "[i,i]=>i"
    1.20 +
    1.21 +inductive
    1.22 +  domains "rlist(A,r)" \<subseteq> "list(A) * list(A)"
    1.23 +  intros
    1.24 +    shorterI:
    1.25 +      "[| length(l') < length(l); l' \<in> list(A); l \<in> list(A) |] 
    1.26 +       ==> <l', l> \<in> rlist(A,r)"
    1.27 +
    1.28 +    sameI:
    1.29 +      "[| <l',l> \<in> rlist(A,r); a \<in> A |] 
    1.30 +       ==> <Cons(a,l'), Cons(a,l)> \<in> rlist(A,r)"
    1.31 +
    1.32 +    diffI:
    1.33 +      "[| length(l') = length(l); <a',a> \<in> r; 
    1.34 +          l' \<in> list(A); l \<in> list(A); a' \<in> A; a \<in> A |] 
    1.35 +       ==> <Cons(a',l'), Cons(a,l)> \<in> rlist(A,r)"
    1.36 +  type_intros list.intros
    1.37 +
    1.38 +
    1.39 +subsubsection{*Type checking*}
    1.40 +
    1.41 +lemmas rlist_type = rlist.dom_subset
    1.42 +
    1.43 +lemmas field_rlist = rlist_type [THEN field_rel_subset]
    1.44 +
    1.45 +subsubsection{*Linearity*}
    1.46 +
    1.47 +lemma rlist_Nil_Cons [intro]:
    1.48 +    "[|a \<in> A; l \<in> list(A)|] ==> <[], Cons(a,l)> \<in> rlist(A, r)"
    1.49 +by (simp add: shorterI) 
    1.50 +
    1.51 +lemma linear_rlist:
    1.52 +    "linear(A,r) ==> linear(list(A),rlist(A,r))"
    1.53 +apply (simp (no_asm_simp) add: linear_def)
    1.54 +apply (rule ballI)  
    1.55 +apply (induct_tac x) 
    1.56 + apply (rule ballI)  
    1.57 + apply (induct_tac y)  
    1.58 +  apply (simp_all add: shorterI) 
    1.59 +apply (rule ballI)  
    1.60 +apply (erule_tac a=y in list.cases) 
    1.61 + apply (rename_tac [2] a2 l2) 
    1.62 + apply (rule_tac [2] i = "length(l)" and j = "length(l2)" in Ord_linear_lt)
    1.63 +     apply (simp_all add: shorterI) 
    1.64 +apply (erule_tac x=a and y=a2 in linearE) 
    1.65 +    apply (simp_all add: diffI) 
    1.66 +apply (blast intro: sameI) 
    1.67 +done
    1.68 +
    1.69 +
    1.70 +subsubsection{*Well-foundedness*}
    1.71 +
    1.72 +text{*Nothing preceeds Nil in this ordering.*}
    1.73 +inductive_cases rlist_NilE: " <l,[]> \<in> rlist(A,r)"
    1.74 +
    1.75 +inductive_cases rlist_ConsE: " <l', Cons(x,l)> \<in> rlist(A,r)"
    1.76 +
    1.77 +lemma not_rlist_Nil [simp]: " <l,[]> \<notin> rlist(A,r)"
    1.78 +by (blast intro: elim: rlist_NilE)
    1.79 +
    1.80 +lemma rlist_imp_length_le: "<l',l> \<in> rlist(A,r) ==> length(l') \<le> length(l)"
    1.81 +apply (erule rlist.induct)
    1.82 +apply (simp_all add: leI)  
    1.83 +done
    1.84 +
    1.85 +lemma wf_on_rlist_n:
    1.86 +  "[| n \<in> nat; wf[A](r) |] ==> wf[{l \<in> list(A). length(l) = n}](rlist(A,r))"
    1.87 +apply (induct_tac n) 
    1.88 + apply (rule wf_onI2, simp) 
    1.89 +apply (rule wf_onI2, clarify) 
    1.90 +apply (erule_tac a=y in list.cases, clarify) 
    1.91 + apply (simp (no_asm_use))
    1.92 +apply clarify 
    1.93 +apply (simp (no_asm_use))
    1.94 +apply (subgoal_tac "\<forall>l2 \<in> list(A). length(l2) = x --> Cons(a,l2) \<in> B", blast)
    1.95 +apply (erule_tac a=a in wf_on_induct, assumption)
    1.96 +apply (rule ballI)
    1.97 +apply (rule impI) 
    1.98 +apply (erule_tac a=l2 in wf_on_induct, blast, clarify)
    1.99 +apply (rename_tac a' l2 l') 
   1.100 +apply (drule_tac x="Cons(a',l')" in bspec, typecheck) 
   1.101 +apply simp 
   1.102 +apply (erule mp, clarify) 
   1.103 +apply (erule rlist_ConsE, auto)
   1.104 +done
   1.105 +
   1.106 +lemma list_eq_UN_length: "list(A) = (\<Union>n\<in>nat. {l \<in> list(A). length(l) = n})"
   1.107 +by (blast intro: length_type)
   1.108 +
   1.109 +
   1.110 +lemma wf_on_rlist: "wf[A](r) ==> wf[list(A)](rlist(A,r))"
   1.111 +apply (subst list_eq_UN_length) 
   1.112 +apply (rule wf_on_Union) 
   1.113 +  apply (rule wf_imp_wf_on [OF wf_Memrel [of nat]])
   1.114 + apply (simp add: wf_on_rlist_n)
   1.115 +apply (frule rlist_type [THEN subsetD]) 
   1.116 +apply (simp add: length_type)   
   1.117 +apply (drule rlist_imp_length_le)
   1.118 +apply (erule leE) 
   1.119 +apply (simp_all add: lt_def) 
   1.120 +done
   1.121 +
   1.122 +
   1.123 +lemma wf_rlist: "wf(r) ==> wf(rlist(field(r),r))"
   1.124 +apply (simp add: wf_iff_wf_on_field)
   1.125 +apply (rule wf_on_subset_A [OF _ field_rlist])
   1.126 +apply (blast intro: wf_on_rlist) 
   1.127 +done
   1.128 +
   1.129 +lemma well_ord_rlist:
   1.130 +     "well_ord(A,r) ==> well_ord(list(A), rlist(A,r))"
   1.131 +apply (rule well_ordI)
   1.132 +apply (simp add: well_ord_def wf_on_rlist)
   1.133 +apply (simp add: well_ord_def tot_ord_def linear_rlist)
   1.134 +done
   1.135 +
   1.136 +
   1.137 +subsection{*An Injection from Formulas into the Natural Numbers*}
   1.138 +
   1.139 +text{*There is a well-known bijection between @{term "nat*nat"} and @{term
   1.140 +nat} given by the expression f(m,n) = triangle(m+n) + m, where triangle(k)
   1.141 +enumerates the triangular numbers and can be defined by triangle(0)=0,
   1.142 +triangle(succ(k)) = succ(k + triangle(k)).  Some small amount of effort is
   1.143 +needed to show that f is a bijection.  We already know (by the theorem @{text
   1.144 +InfCard_square_eqpoll}) that such a bijection exists, but as we have no direct
   1.145 +way to refer to it, we must use a locale.*}
   1.146 +
   1.147 +text{*Locale for any arbitrary injection between @{term "nat*nat"} 
   1.148 +      and @{term nat}*}
   1.149 +locale Nat_Times_Nat =
   1.150 +  fixes fn
   1.151 +  assumes fn_inj: "fn \<in> inj(nat*nat, nat)"
   1.152 +
   1.153 +
   1.154 +consts   enum :: "[i,i]=>i"
   1.155 +primrec
   1.156 +  "enum(f, Member(x,y)) = f ` <0, f ` <x,y>>"
   1.157 +  "enum(f, Equal(x,y)) = f ` <1, f ` <x,y>>"
   1.158 +  "enum(f, Nand(p,q)) = f ` <2, f ` <enum(f,p), enum(f,q)>>"
   1.159 +  "enum(f, Forall(p)) = f ` <succ(2), enum(f,p)>"
   1.160 +
   1.161 +lemma (in Nat_Times_Nat) fn_type [TC,simp]:
   1.162 +    "[|x \<in> nat; y \<in> nat|] ==> fn`<x,y> \<in> nat"
   1.163 +by (blast intro: inj_is_fun [OF fn_inj] apply_funtype) 
   1.164 +
   1.165 +lemma (in Nat_Times_Nat) fn_iff:
   1.166 +    "[|x \<in> nat; y \<in> nat; u \<in> nat; v \<in> nat|] 
   1.167 +     ==> (fn`<x,y> = fn`<u,v>) <-> (x=u & y=v)"
   1.168 +by (blast dest: inj_apply_equality [OF fn_inj]) 
   1.169 +
   1.170 +lemma (in Nat_Times_Nat) enum_type [TC,simp]:
   1.171 +    "p \<in> formula ==> enum(fn,p) \<in> nat"
   1.172 +by (induct_tac p, simp_all) 
   1.173 +
   1.174 +lemma (in Nat_Times_Nat) enum_inject [rule_format]:
   1.175 +    "p \<in> formula ==> \<forall>q\<in>formula. enum(fn,p) = enum(fn,q) --> p=q"
   1.176 +apply (induct_tac p, simp_all) 
   1.177 +   apply (rule ballI) 
   1.178 +   apply (erule formula.cases) 
   1.179 +   apply (simp_all add: fn_iff) 
   1.180 +  apply (rule ballI) 
   1.181 +  apply (erule formula.cases) 
   1.182 +  apply (simp_all add: fn_iff) 
   1.183 + apply (rule ballI) 
   1.184 + apply (erule_tac a=qa in formula.cases) 
   1.185 + apply (simp_all add: fn_iff) 
   1.186 + apply blast 
   1.187 +apply (rule ballI) 
   1.188 +apply (erule_tac a=q in formula.cases) 
   1.189 +apply (simp_all add: fn_iff, blast) 
   1.190 +done
   1.191 +
   1.192 +lemma (in Nat_Times_Nat) inj_formula_nat:
   1.193 +    "(\<lambda>p \<in> formula. enum(fn,p)) \<in> inj(formula, nat)"
   1.194 +apply (simp add: inj_def lam_type) 
   1.195 +apply (blast intro: enum_inject) 
   1.196 +done
   1.197 +
   1.198 +lemma (in Nat_Times_Nat) well_ord_formula:
   1.199 +    "well_ord(formula, measure(formula, enum(fn)))"
   1.200 +apply (rule well_ord_measure, simp)
   1.201 +apply (blast intro: enum_inject)   
   1.202 +done
   1.203 +
   1.204 +lemmas nat_times_nat_lepoll_nat =
   1.205 +    InfCard_nat [THEN InfCard_square_eqpoll, THEN eqpoll_imp_lepoll]
   1.206 +
   1.207 +
   1.208 +text{*Not needed--but interesting?*}
   1.209 +theorem formula_lepoll_nat: "formula \<lesssim> nat"
   1.210 +apply (insert nat_times_nat_lepoll_nat)
   1.211 +apply (unfold lepoll_def)
   1.212 +apply (blast intro: exI Nat_Times_Nat.inj_formula_nat Nat_Times_Nat.intro)
   1.213 +done
   1.214 +
   1.215 +
   1.216 +subsection{*Limit Construction for Well-Orderings*}
   1.217 +
   1.218 +text{*Now we work towards the transfinite definition of wellorderings for
   1.219 +@{term "Lset(i)"}.  We assume as an inductive hypothesis that there is a family
   1.220 +of wellorderings for smaller ordinals.*}
   1.221 +
   1.222 +text{*This constant denotes the set of elements introduced at level
   1.223 +@{term "succ(i)"}*}
   1.224 +constdefs
   1.225 +  Lset_new :: "i=>i"
   1.226 +    "Lset_new(i) == {x \<in> Lset(succ(i)). lrank(x) = i}"
   1.227 +
   1.228 +lemma Lset_new_iff_lrank_eq:
   1.229 +     "Ord(i) ==> x \<in> Lset_new(i) <-> L(x) & lrank(x) = i"
   1.230 +by (auto simp add: Lset_new_def Lset_iff_lrank_lt) 
   1.231 +
   1.232 +lemma Lset_new_eq:
   1.233 +     "Ord(i) ==> Lset_new(i) = Lset(succ(i)) - Lset(i)"
   1.234 +apply (rule equality_iffI)
   1.235 +apply (simp add: Lset_new_iff_lrank_eq Lset_iff_lrank_lt, auto) 
   1.236 +apply (blast elim: leE) 
   1.237 +done
   1.238 +
   1.239 +lemma Limit_Lset_eq2:
   1.240 +    "Limit(i) ==> Lset(i) = (\<Union>j\<in>i. Lset_new(j))"
   1.241 +apply (simp add: Limit_Lset_eq) 
   1.242 +apply (rule equalityI)
   1.243 + apply safe
   1.244 + apply (subgoal_tac "Ord(y)")
   1.245 +  prefer 2 apply (blast intro: Ord_in_Ord Limit_is_Ord)
   1.246 + apply (rotate_tac -1) 
   1.247 + apply (simp_all add: Limit_is_Ord Lset_iff_lrank_lt Lset_new_def 
   1.248 +                      Ord_mem_iff_lt) 
   1.249 + apply (blast intro: lt_trans) 
   1.250 +apply (rule_tac x = "succ(lrank(x))" in bexI)
   1.251 + apply (simp add: Lset_succ_lrank_iff) 
   1.252 +apply (blast intro: Limit_has_succ ltD) 
   1.253 +done
   1.254 +
   1.255 +text{*This constant expresses the wellordering at limit ordinals.*}
   1.256 +constdefs
   1.257 +  rlimit :: "[i,i=>i]=>i"
   1.258 +    "rlimit(i,r) == 
   1.259 +       {z: Lset(i) * Lset(i).
   1.260 +        \<exists>x' x. z = <x',x> &         
   1.261 +               (lrank(x') < lrank(x) | 
   1.262 +                (lrank(x') = lrank(x) & <x',x> \<in> r(succ(lrank(x)))))}"
   1.263 +
   1.264 +lemma rlimit_eqI:
   1.265 +     "[|Limit(i); \<forall>j<i. r'(j) = r(j)|] ==> rlimit(i,r) = rlimit(i,r')"
   1.266 +apply (simp add: rlimit_def) 
   1.267 +apply (rule refl iff_refl Collect_cong ex_cong conj_cong)+
   1.268 +apply (simp add: Limit_is_Ord Lset_lrank_lt)  
   1.269 +done
   1.270 +
   1.271 +lemma wf_on_Lset:
   1.272 +    "wf[Lset(succ(j))](r(succ(j))) ==> wf[Lset_new(j)](rlimit(i,r))"
   1.273 +apply (simp add: wf_on_def Lset_new_def) 
   1.274 +apply (erule wf_subset) 
   1.275 +apply (force simp add: rlimit_def) 
   1.276 +done
   1.277 +
   1.278 +lemma wf_on_rlimit:
   1.279 +    "[|Limit(i); \<forall>j<i. wf[Lset(j)](r(j)) |] ==> wf[Lset(i)](rlimit(i,r))"
   1.280 +apply (simp add: Limit_Lset_eq2)
   1.281 +apply (rule wf_on_Union)
   1.282 +  apply (rule wf_imp_wf_on [OF wf_Memrel [of i]]) 
   1.283 + apply (blast intro: wf_on_Lset Limit_has_succ Limit_is_Ord ltI) 
   1.284 +apply (force simp add: rlimit_def Limit_is_Ord Lset_iff_lrank_lt Lset_new_def
   1.285 +                       Ord_mem_iff_lt)
   1.286 +
   1.287 +done
   1.288 +
   1.289 +lemma linear_rlimit:
   1.290 +    "[|Limit(i); \<forall>j<i. linear(Lset(j), r(j)) |]
   1.291 +     ==> linear(Lset(i), rlimit(i,r))"
   1.292 +apply (frule Limit_is_Ord) 
   1.293 +apply (simp add: Limit_Lset_eq2)
   1.294 +apply (simp add: linear_def Lset_new_def rlimit_def Ball_def) 
   1.295 +apply (simp add: lt_Ord Lset_iff_lrank_lt) 
   1.296 +apply (simp add: ltI, clarify) 
   1.297 +apply (rename_tac u v) 
   1.298 +apply (rule_tac i="lrank(u)" and j="lrank(v)" in Ord_linear_lt) 
   1.299 +apply simp_all
   1.300 +apply (drule_tac x="succ(lrank(u) Un lrank(v))" in ospec) 
   1.301 +apply (simp add: ltI)
   1.302 +apply (drule_tac x=u in spec, simp) 
   1.303 +apply (drule_tac x=v in spec, simp) 
   1.304 +done
   1.305 +
   1.306 +
   1.307 +lemma well_ord_rlimit:
   1.308 +    "[|Limit(i); \<forall>j<i. well_ord(Lset(j), r(j)) |]
   1.309 +     ==> well_ord(Lset(i), rlimit(i,r))"
   1.310 +by (blast intro: well_ordI wf_on_rlimit well_ord_is_wf 
   1.311 +                           linear_rlimit well_ord_is_linear) 
   1.312 +
   1.313 +
   1.314 +subsection{*Defining the Wellordering on @{term "Lset(succ(i))"}*}
   1.315 +
   1.316 +text{*We introduce wellorderings for environments, which are lists built over
   1.317 +@{term "Lset(succ(i))"}.  We combine it with the enumeration of formulas.  The
   1.318 +order type of the resulting wellordering gives us a map from (environment,
   1.319 +formula) pairs into the ordinals.  For each member of @{term "DPow(Lset(i))"},
   1.320 +we take the minimum such ordinal.  This yields a wellordering of
   1.321 +@{term "DPow(Lset(i))"}, which we then extend to @{term "Lset(succ(i))"}*}
   1.322 +
   1.323 +constdefs
   1.324 +  env_form_r :: "[i,i,i]=>i"
   1.325 +    --{*wellordering on (environment, formula) pairs*}
   1.326 +   "env_form_r(f,r,i) ==
   1.327 +      rmult(list(Lset(i)), rlist(Lset(i), r),
   1.328 +	    formula, measure(formula, enum(f)))"
   1.329 +
   1.330 +  env_form_map :: "[i,i,i,i]=>i"
   1.331 +    --{*map from (environment, formula) pairs to ordinals*}
   1.332 +   "env_form_map(f,r,i,z) 
   1.333 +      == ordermap(list(Lset(i)) * formula, env_form_r(f,r,i)) ` z"
   1.334 +
   1.335 +  L_new_ord :: "[i,i,i,i,i]=>o"
   1.336 +    --{*predicate that holds if @{term k} is a valid index for @{term X}*}
   1.337 +   "L_new_ord(f,r,i,X,k) ==  
   1.338 +           \<exists>env \<in> list(Lset(i)). \<exists>p \<in> formula. 
   1.339 +             arity(p) \<le> succ(length(env)) & 
   1.340 +             X = {x\<in>Lset(i). sats(Lset(i), p, Cons(x,env))} &
   1.341 +             env_form_map(f,r,i,<env,p>) = k"
   1.342 +
   1.343 +  L_new_least :: "[i,i,i,i]=>i"
   1.344 +    --{*function yielding the smallest index for @{term X}*}
   1.345 +   "L_new_least(f,r,i,X) == \<mu>k. L_new_ord(f,r,i,X,k)"
   1.346 +
   1.347 +  L_new_r :: "[i,i,i]=>i"
   1.348 +    --{*a wellordering on @{term "DPow(Lset(i))"}*}
   1.349 +   "L_new_r(f,r,i) == measure(Lset_new(i), L_new_least(f,r,i))"
   1.350 +
   1.351 +  L_succ_r :: "[i,i,i]=>i"
   1.352 +    --{*a wellordering on @{term "Lset(succ(i))"}*}
   1.353 +   "L_succ_r(f,r,i) == (L_new_r(f,r,i) Un (Lset(i) * Lset_new(i))) Un r"
   1.354 +
   1.355 +
   1.356 +lemma (in Nat_Times_Nat) well_ord_env_form_r:
   1.357 +    "well_ord(Lset(i), r) 
   1.358 +     ==> well_ord(list(Lset(i)) * formula, env_form_r(fn,r,i))"
   1.359 +by (simp add: env_form_r_def well_ord_rmult well_ord_rlist well_ord_formula) 
   1.360 +
   1.361 +lemma (in Nat_Times_Nat) Ord_env_form_map:
   1.362 +    "[|well_ord(Lset(i), r); z \<in> list(Lset(i)) * formula|]
   1.363 +     ==> Ord(env_form_map(fn,r,i,z))"
   1.364 +by (simp add: env_form_map_def Ord_ordermap well_ord_env_form_r) 
   1.365 +
   1.366 +
   1.367 +lemma DPow_imp_ex_L_new_ord:
   1.368 +    "X \<in> DPow(Lset(i)) ==> \<exists>k. L_new_ord(fn,r,i,X,k)"
   1.369 +apply (simp add: L_new_ord_def) 
   1.370 +apply (blast dest!: DPowD) 
   1.371 +done
   1.372 +
   1.373 +lemma (in Nat_Times_Nat) L_new_ord_imp_Ord:
   1.374 +     "[|L_new_ord(fn,r,i,X,k); well_ord(Lset(i), r)|] ==> Ord(k)"
   1.375 +apply (simp add: L_new_ord_def, clarify)
   1.376 +apply (simp add: Ord_env_form_map)  
   1.377 +done
   1.378 +
   1.379 +lemma (in Nat_Times_Nat) DPow_imp_L_new_least:
   1.380 +    "[|X \<in> DPow(Lset(i)); well_ord(Lset(i), r)|] 
   1.381 +     ==> L_new_ord(fn, r, i, X, L_new_least(fn,r,i,X))"
   1.382 +apply (simp add: L_new_least_def)
   1.383 +apply (blast dest!: DPow_imp_ex_L_new_ord intro: L_new_ord_imp_Ord LeastI)  
   1.384 +done
   1.385 +
   1.386 +lemma (in Nat_Times_Nat) env_form_map_inject:
   1.387 +    "[|env_form_map(fn,r,i,u) = env_form_map(fn,r,i,v); well_ord(Lset(i), r);  
   1.388 +       u \<in> list(Lset(i)) * formula;  v \<in> list(Lset(i)) * formula|] 
   1.389 +     ==> u=v"
   1.390 +apply (simp add: env_form_map_def) 
   1.391 +apply (rule inj_apply_equality [OF bij_is_inj, OF ordermap_bij, 
   1.392 +                                OF well_ord_env_form_r], assumption+)
   1.393 +done
   1.394 +
   1.395 +
   1.396 +lemma (in Nat_Times_Nat) L_new_ord_unique:
   1.397 +    "[|L_new_ord(fn,r,i,X,k); L_new_ord(fn,r,i,Y,k); well_ord(Lset(i), r)|] 
   1.398 +     ==> X=Y"
   1.399 +apply (simp add: L_new_ord_def, clarify)
   1.400 +apply (drule env_form_map_inject, auto) 
   1.401 +done
   1.402 +
   1.403 +lemma (in Nat_Times_Nat) well_ord_L_new_r:
   1.404 +    "[|Ord(i); well_ord(Lset(i), r)|]
   1.405 +     ==> well_ord(Lset_new(i), L_new_r(fn,r,i))"
   1.406 +apply (simp add: L_new_r_def) 
   1.407 +apply (rule well_ord_measure) 
   1.408 + apply (simp add: L_new_least_def Ord_Least)
   1.409 +apply (simp add: Lset_new_eq Lset_succ, clarify) 
   1.410 +apply (drule DPow_imp_L_new_least, assumption)+
   1.411 +apply simp 
   1.412 +apply (blast intro: L_new_ord_unique) 
   1.413 +done
   1.414 +
   1.415 +lemma L_new_r_subset: "L_new_r(f,r,i) <= Lset_new(i) * Lset_new(i)"
   1.416 +by (simp add: L_new_r_def measure_type)
   1.417 +
   1.418 +lemma Lset_Lset_new_disjoint: "Ord(i) ==> Lset(i) \<inter> Lset_new(i) = 0"
   1.419 +by (simp add: Lset_new_eq, blast)
   1.420 +
   1.421 +lemma (in Nat_Times_Nat) linear_L_succ_r:
   1.422 +    "[|Ord(i); well_ord(Lset(i), r)|]
   1.423 +     ==> linear(Lset(succ(i)), L_succ_r(fn, r, i))"
   1.424 +apply (frule well_ord_L_new_r, assumption) 
   1.425 +apply (drule well_ord_is_linear)+
   1.426 +apply (simp add: linear_def L_succ_r_def Lset_new_eq, auto) 
   1.427 +done
   1.428 +
   1.429 +
   1.430 +lemma (in Nat_Times_Nat) wf_L_new_r:
   1.431 +    "[|Ord(i); well_ord(Lset(i), r)|] ==> wf(L_new_r(fn,r,i))"
   1.432 +apply (rule well_ord_L_new_r [THEN well_ord_is_wf, THEN wf_on_imp_wf], 
   1.433 +       assumption+)
   1.434 +apply (rule L_new_r_subset)
   1.435 +done
   1.436 +
   1.437 +
   1.438 +lemma (in Nat_Times_Nat) well_ord_L_new_r:
   1.439 +    "[|Ord(i); well_ord(Lset(i), r); r \<subseteq> Lset(i) * Lset(i)|]
   1.440 +     ==> well_ord(Lset(succ(i)), L_succ_r(fn,r,i))"
   1.441 +apply (rule well_ordI [OF wf_imp_wf_on])
   1.442 + prefer 2 apply (blast intro: linear_L_succ_r) 
   1.443 +apply (simp add: L_succ_r_def)
   1.444 +apply (rule wf_Un)
   1.445 +  apply (cut_tac L_new_r_subset [of fn r i], simp add: Lset_new_eq, blast)
   1.446 + apply (rule wf_Un)  
   1.447 +   apply (cut_tac L_new_r_subset [of fn r i], simp add: Lset_new_eq, blast)
   1.448 +  apply (blast intro: wf_L_new_r) 
   1.449 + apply (simp add: wf_times Lset_Lset_new_disjoint)
   1.450 +apply (blast intro: well_ord_is_wf wf_on_imp_wf)
   1.451 +done
   1.452 +
   1.453 +
   1.454 +lemma (in Nat_Times_Nat) L_succ_r_type:
   1.455 +    "[|Ord(i); r \<subseteq> Lset(i) * Lset(i)|]
   1.456 +     ==> L_succ_r(fn,r,i) \<subseteq> Lset(succ(i)) * Lset(succ(i))"
   1.457 +apply (simp add: L_succ_r_def L_new_r_def measure_def Lset_new_eq) 
   1.458 +apply (blast intro: Lset_mono_mem [OF succI1, THEN subsetD] ) 
   1.459 +done				   
   1.460 +
   1.461 +
   1.462 +subsection{*Transfinite Definition of the Wellordering on @{term "L"}*}
   1.463 +
   1.464 +constdefs
   1.465 + L_r :: "[i, i] => i"
   1.466 +  "L_r(f,i) == 
   1.467 +      transrec(i, \<lambda>x r. 
   1.468 +         if x=0 then 0
   1.469 +         else if Limit(x) then rlimit(x, \<lambda>y. r`y)
   1.470 +         else L_succ_r(f, r ` Arith.pred(x), Arith.pred(x)))"
   1.471 +
   1.472 +subsubsection{*The Corresponding Recursion Equations*}
   1.473 +lemma [simp]: "L_r(f,0) = 0"
   1.474 +by (simp add: def_transrec [OF L_r_def])
   1.475 +
   1.476 +lemma [simp]: "Ord(i) ==> L_r(f, succ(i)) = L_succ_r(f, L_r(f,i), i)"
   1.477 +by (simp add: def_transrec [OF L_r_def])
   1.478 +
   1.479 +text{*Needed to handle the limit case*}
   1.480 +lemma L_r_eq:
   1.481 +     "Ord(i) ==> 
   1.482 +      L_r(f, i) =
   1.483 +      (if i = 0 then 0
   1.484 +       else if Limit(i) then rlimit(i, op `(Lambda(i, L_r(f))))
   1.485 +       else L_succ_r (f, Lambda(i, L_r(f)) ` Arith.pred(i), Arith.pred(i)))"
   1.486 +apply (induct i rule: trans_induct3_rule)
   1.487 +apply (simp_all add: def_transrec [OF L_r_def])
   1.488 +done
   1.489 +
   1.490 +text{*I don't know why the limit case is so complicated.*}
   1.491 +lemma [simp]: "Limit(i) ==> L_r(f,i) = rlimit(i, L_r(f))"
   1.492 +apply (simp add: Limit_nonzero def_transrec [OF L_r_def])
   1.493 +apply (rule rlimit_eqI, assumption)
   1.494 +apply (rule oallI)
   1.495 +apply (frule lt_Ord) 
   1.496 +apply (simp only: beta ltD L_r_eq [symmetric])  
   1.497 +done
   1.498 +
   1.499 +lemma (in Nat_Times_Nat) L_r_type:
   1.500 +    "Ord(i) ==> L_r(fn,i) \<subseteq> Lset(i) * Lset(i)"
   1.501 +apply (induct i rule: trans_induct3_rule)
   1.502 +  apply (simp_all add: L_succ_r_type well_ord_L_new_r rlimit_def, blast) 
   1.503 +done
   1.504 +
   1.505 +lemma (in Nat_Times_Nat) well_ord_L_r:
   1.506 +    "Ord(i) ==> well_ord(Lset(i), L_r(fn,i))"
   1.507 +apply (induct i rule: trans_induct3_rule)
   1.508 +apply (simp_all add: well_ord0 L_r_type well_ord_L_new_r well_ord_rlimit ltD)
   1.509 +done
   1.510 +
   1.511 +lemma well_ord_L_r:
   1.512 +    "Ord(i) ==> \<exists>r. well_ord(Lset(i), r)"
   1.513 +apply (insert nat_times_nat_lepoll_nat)
   1.514 +apply (unfold lepoll_def)
   1.515 +apply (blast intro: exI Nat_Times_Nat.well_ord_L_r Nat_Times_Nat.intro)
   1.516 +done
   1.517 +
   1.518 +
   1.519 +text{*Locale for proving results under the assumption @{text "V=L"}*}
   1.520 +locale V_equals_L =
   1.521 +  assumes VL: "L(x)"
   1.522 +
   1.523 +text{*The Axiom of Choice holds in @{term L}!  Or, to be precise, the
   1.524 +Wellordering Theorem.*}
   1.525 +theorem (in V_equals_L) AC: "\<exists>r. well_ord(x,r)"
   1.526 +apply (insert Transset_Lset VL [of x]) 
   1.527 +apply (simp add: Transset_def L_def)
   1.528 +apply (blast dest!: well_ord_L_r intro: well_ord_subset) 
   1.529 +done
   1.530 +
   1.531 +end