src/ZF/Constructible/Datatype_absolute.thy
author paulson
Wed, 17 Jul 2002 15:48:54 +0200
changeset 13385 31df66ca0780
parent 13382 b37764a46b16
child 13386 f3e9e8b21aba
permissions -rw-r--r--
Expressing Lset and L without using length and arity; simplifies Separation proofs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13306
6eebcddee32b more internalized formulas and separation proofs
paulson
parents: 13293
diff changeset
     1
header {*Absoluteness Properties for Recursive Datatypes*}
6eebcddee32b more internalized formulas and separation proofs
paulson
parents: 13293
diff changeset
     2
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13268
diff changeset
     3
theory Datatype_absolute = Formula + WF_absolute:
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
     4
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
     5
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
     6
subsection{*The lfp of a continuous function can be expressed as a union*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
     7
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
     8
constdefs
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
     9
  directed :: "i=>o"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    10
   "directed(A) == A\<noteq>0 & (\<forall>x\<in>A. \<forall>y\<in>A. x \<union> y \<in> A)"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    11
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    12
  contin :: "(i=>i) => o"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    13
   "contin(h) == (\<forall>A. directed(A) --> h(\<Union>A) = (\<Union>X\<in>A. h(X)))"
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    14
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    15
lemma bnd_mono_iterates_subset: "[|bnd_mono(D, h); n \<in> nat|] ==> h^n (0) <= D"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    16
apply (induct_tac n) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    17
 apply (simp_all add: bnd_mono_def, blast) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    18
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    19
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    20
lemma bnd_mono_increasing [rule_format]:
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    21
     "[|i \<in> nat; j \<in> nat; bnd_mono(D,h)|] ==> i \<le> j --> h^i(0) \<subseteq> h^j(0)"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    22
apply (rule_tac m=i and n=j in diff_induct, simp_all)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    23
apply (blast del: subsetI
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    24
	     intro: bnd_mono_iterates_subset bnd_monoD2 [of concl: h] ) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    25
done
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    26
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    27
lemma directed_iterates: "bnd_mono(D,h) ==> directed({h^n (0). n\<in>nat})"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    28
apply (simp add: directed_def, clarify) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    29
apply (rename_tac i j)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    30
apply (rule_tac x="i \<union> j" in bexI) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    31
apply (rule_tac i = i and j = j in Ord_linear_le)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    32
apply (simp_all add: subset_Un_iff [THEN iffD1] le_imp_subset
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    33
                     subset_Un_iff2 [THEN iffD1])
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    34
apply (simp_all add: subset_Un_iff [THEN iff_sym] bnd_mono_increasing
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    35
                     subset_Un_iff2 [THEN iff_sym])
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    36
done
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    37
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    38
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    39
lemma contin_iterates_eq: 
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    40
    "[|bnd_mono(D, h); contin(h)|] 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    41
     ==> h(\<Union>n\<in>nat. h^n (0)) = (\<Union>n\<in>nat. h^n (0))"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    42
apply (simp add: contin_def directed_iterates) 
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    43
apply (rule trans) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    44
apply (rule equalityI) 
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    45
 apply (simp_all add: UN_subset_iff)
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    46
 apply safe
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    47
 apply (erule_tac [2] natE) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    48
  apply (rule_tac a="succ(x)" in UN_I) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    49
   apply simp_all 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    50
apply blast 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    51
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    52
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    53
lemma lfp_subset_Union:
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    54
     "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) <= (\<Union>n\<in>nat. h^n(0))"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    55
apply (rule lfp_lowerbound) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    56
 apply (simp add: contin_iterates_eq) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    57
apply (simp add: contin_def bnd_mono_iterates_subset UN_subset_iff) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    58
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    59
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    60
lemma Union_subset_lfp:
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    61
     "bnd_mono(D,h) ==> (\<Union>n\<in>nat. h^n(0)) <= lfp(D,h)"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    62
apply (simp add: UN_subset_iff)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    63
apply (rule ballI)  
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 13306
diff changeset
    64
apply (induct_tac n, simp_all) 
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    65
apply (rule subset_trans [of _ "h(lfp(D,h))"])
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    66
 apply (blast dest: bnd_monoD2 [OF _ _ lfp_subset] )  
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    67
apply (erule lfp_lemma2) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    68
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    69
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    70
lemma lfp_eq_Union:
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    71
     "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) = (\<Union>n\<in>nat. h^n(0))"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    72
by (blast del: subsetI 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    73
          intro: lfp_subset_Union Union_subset_lfp)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    74
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
    75
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    76
subsubsection{*Some Standard Datatype Constructions Preserve Continuity*}
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    77
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    78
lemma contin_imp_mono: "[|X\<subseteq>Y; contin(F)|] ==> F(X) \<subseteq> F(Y)"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    79
apply (simp add: contin_def) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    80
apply (drule_tac x="{X,Y}" in spec) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    81
apply (simp add: directed_def subset_Un_iff2 Un_commute) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    82
done
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    83
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    84
lemma sum_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) + G(X))"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    85
by (simp add: contin_def, blast)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    86
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    87
lemma prod_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) * G(X))" 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    88
apply (subgoal_tac "\<forall>B C. F(B) \<subseteq> F(B \<union> C)")
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    89
 prefer 2 apply (simp add: Un_upper1 contin_imp_mono) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    90
apply (subgoal_tac "\<forall>B C. G(C) \<subseteq> G(B \<union> C)")
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    91
 prefer 2 apply (simp add: Un_upper2 contin_imp_mono) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    92
apply (simp add: contin_def, clarify) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    93
apply (rule equalityI) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    94
 prefer 2 apply blast 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    95
apply clarify 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    96
apply (rename_tac B C) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    97
apply (rule_tac a="B \<union> C" in UN_I) 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    98
 apply (simp add: directed_def, blast)  
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
    99
done
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   100
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   101
lemma const_contin: "contin(\<lambda>X. A)"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   102
by (simp add: contin_def directed_def)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   103
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   104
lemma id_contin: "contin(\<lambda>X. X)"
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   105
by (simp add: contin_def)
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   106
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   107
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   108
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   109
subsection {*lists without univ*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   110
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   111
lemmas datatype_univs = Inl_in_univ Inr_in_univ 
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   112
                        Pair_in_univ nat_into_univ A_into_univ 
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   113
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   114
lemma list_fun_bnd_mono: "bnd_mono(univ(A), \<lambda>X. {0} + A*X)"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   115
apply (rule bnd_monoI)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   116
 apply (intro subset_refl zero_subset_univ A_subset_univ 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   117
	      sum_subset_univ Sigma_subset_univ) 
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   118
apply (rule subset_refl sum_mono Sigma_mono | assumption)+
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   119
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   120
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   121
lemma list_fun_contin: "contin(\<lambda>X. {0} + A*X)"
13385
31df66ca0780 Expressing Lset and L without using length and arity; simplifies Separation
paulson
parents: 13382
diff changeset
   122
by (intro sum_contin prod_contin id_contin const_contin) 
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   123
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   124
text{*Re-expresses lists using sum and product*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   125
lemma list_eq_lfp2: "list(A) = lfp(univ(A), \<lambda>X. {0} + A*X)"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   126
apply (simp add: list_def) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   127
apply (rule equalityI) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   128
 apply (rule lfp_lowerbound) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   129
  prefer 2 apply (rule lfp_subset)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   130
 apply (clarify, subst lfp_unfold [OF list_fun_bnd_mono])
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   131
 apply (simp add: Nil_def Cons_def)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   132
 apply blast 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   133
txt{*Opposite inclusion*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   134
apply (rule lfp_lowerbound) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   135
 prefer 2 apply (rule lfp_subset) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   136
apply (clarify, subst lfp_unfold [OF list.bnd_mono]) 
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   137
apply (simp add: Nil_def Cons_def)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   138
apply (blast intro: datatype_univs
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   139
             dest: lfp_subset [THEN subsetD])
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   140
done
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   141
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   142
text{*Re-expresses lists using "iterates", no univ.*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   143
lemma list_eq_Union:
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   144
     "list(A) = (\<Union>n\<in>nat. (\<lambda>X. {0} + A*X) ^ n (0))"
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   145
by (simp add: list_eq_lfp2 lfp_eq_Union list_fun_bnd_mono list_fun_contin)
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   146
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   147
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   148
subsection {*Absoluteness for "Iterates"*}
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   149
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   150
constdefs
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   151
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   152
  iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o"
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   153
   "iterates_MH(M,isF,v,n,g,z) ==
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   154
        is_nat_case(M, v, \<lambda>m u. \<exists>gm[M]. fun_apply(M,g,m,gm) & isF(gm,u),
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   155
                    n, z)"
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   156
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   157
  iterates_replacement :: "[i=>o, [i,i]=>o, i] => o"
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   158
   "iterates_replacement(M,isF,v) ==
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   159
      \<forall>n[M]. n\<in>nat --> 
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   160
         wfrec_replacement(M, iterates_MH(M,isF,v), Memrel(succ(n)))"
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   161
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   162
lemma (in M_axioms) iterates_MH_abs:
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   163
  "[| relativize1(M,isF,F); M(n); M(g); M(z) |] 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   164
   ==> iterates_MH(M,isF,v,n,g,z) <-> z = nat_case(v, \<lambda>m. F(g`m), n)"
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   165
by (simp add: nat_case_abs [of _ "\<lambda>m. F(g ` m)"]
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   166
              relativize1_def iterates_MH_def)  
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   167
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   168
lemma (in M_axioms) iterates_imp_wfrec_replacement:
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   169
  "[|relativize1(M,isF,F); n \<in> nat; iterates_replacement(M,isF,v)|] 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   170
   ==> wfrec_replacement(M, \<lambda>n f z. z = nat_case(v, \<lambda>m. F(f`m), n), 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   171
                       Memrel(succ(n)))" 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   172
by (simp add: iterates_replacement_def iterates_MH_abs)
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   173
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   174
theorem (in M_trancl) iterates_abs:
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   175
  "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   176
      n \<in> nat; M(v); M(z); \<forall>x[M]. M(F(x)) |] 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   177
   ==> is_wfrec(M, iterates_MH(M,isF,v), Memrel(succ(n)), n, z) <->
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   178
       z = iterates(F,n,v)" 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   179
apply (frule iterates_imp_wfrec_replacement, assumption+)
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   180
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   181
                 relativize2_def iterates_MH_abs 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   182
                 iterates_nat_def recursor_def transrec_def 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   183
                 eclose_sing_Ord_eq nat_into_M
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   184
         trans_wfrec_abs [of _ _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   185
done
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   186
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   187
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   188
lemma (in M_wfrank) iterates_closed [intro,simp]:
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   189
  "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   190
      n \<in> nat; M(v); \<forall>x[M]. M(F(x)) |] 
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   191
   ==> M(iterates(F,n,v))"
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   192
apply (frule iterates_imp_wfrec_replacement, assumption+)
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   193
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   194
                 relativize2_def iterates_MH_abs 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   195
                 iterates_nat_def recursor_def transrec_def 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   196
                 eclose_sing_Ord_eq nat_into_M
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   197
         trans_wfrec_closed [of _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   198
done
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   199
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   200
13350
paulson
parents: 13348
diff changeset
   201
constdefs
paulson
parents: 13348
diff changeset
   202
  is_list_functor :: "[i=>o,i,i,i] => o"
paulson
parents: 13348
diff changeset
   203
    "is_list_functor(M,A,X,Z) == 
paulson
parents: 13348
diff changeset
   204
        \<exists>n1[M]. \<exists>AX[M]. 
paulson
parents: 13348
diff changeset
   205
         number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)"
paulson
parents: 13348
diff changeset
   206
paulson
parents: 13348
diff changeset
   207
lemma (in M_axioms) list_functor_abs [simp]: 
paulson
parents: 13348
diff changeset
   208
     "[| M(A); M(X); M(Z) |] ==> is_list_functor(M,A,X,Z) <-> (Z = {0} + A*X)"
paulson
parents: 13348
diff changeset
   209
by (simp add: is_list_functor_def singleton_0 nat_into_M)
paulson
parents: 13348
diff changeset
   210
paulson
parents: 13348
diff changeset
   211
13382
b37764a46b16 adapted locales;
wenzelm
parents: 13363
diff changeset
   212
locale (open) M_datatypes = M_wfrank +
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   213
 assumes list_replacement1: 
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   214
   "M(A) ==> iterates_replacement(M, is_list_functor(M,A), 0)"
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   215
  and list_replacement2: 
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   216
   "M(A) ==> strong_replacement(M, 
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   217
         \<lambda>n y. n\<in>nat & 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   218
               (\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   219
               is_wfrec(M, iterates_MH(M,is_list_functor(M,A), 0), 
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   220
                        msn, n, y)))"
13350
paulson
parents: 13348
diff changeset
   221
13348
374d05460db4 Separation/Replacement up to M_wfrank!
paulson
parents: 13339
diff changeset
   222
lemma (in M_datatypes) list_replacement2': 
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   223
  "M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. {0} + A * X)^n (0))"
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   224
apply (insert list_replacement2 [of A]) 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   225
apply (rule strong_replacement_cong [THEN iffD1])  
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   226
apply (rule conj_cong [OF iff_refl iterates_abs [of "is_list_functor(M,A)"]]) 
13363
c26eeb000470 instantiation of locales M_trancl and M_wfrank;
paulson
parents: 13353
diff changeset
   227
apply (simp_all add: list_replacement1 relativize1_def) 
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   228
done
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   229
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   230
lemma (in M_datatypes) list_closed [intro,simp]:
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   231
     "M(A) ==> M(list(A))"
13353
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   232
apply (insert list_replacement1)
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   233
by  (simp add: RepFun_closed2 list_eq_Union 
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   234
               list_replacement2' relativize1_def
1800e7134d2e towards relativization of "iterates" and "wfrec"
paulson
parents: 13352
diff changeset
   235
               iterates_closed [of "is_list_functor(M,A)"])
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   236
13293
paulson
parents: 13269
diff changeset
   237
13268
240509babf00 more use of relativized quantifiers
paulson
parents:
diff changeset
   238
end