src/HOLCF/Algebraic.thy
author wenzelm
Fri, 15 Aug 2008 16:08:08 +0200
changeset 27893 7c97cf70d663
parent 27419 ff2a2b8fcd09
child 28611 983c1855a7af
permissions -rw-r--r--
added README;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27409
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/Algebraic.thy
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     2
    ID:         $Id$
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     3
    Author:     Brian Huffman
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     4
*)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     5
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     6
header {* Algebraic deflations *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     7
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     8
theory Algebraic
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
     9
imports Completion Fix Eventual
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    10
begin
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    11
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    12
subsection {* Constructing finite deflations by iteration *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    13
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    14
lemma finite_deflation_imp_deflation:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    15
  "finite_deflation d \<Longrightarrow> deflation d"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    16
unfolding finite_deflation_def by simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    17
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    18
lemma le_Suc_induct:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    19
  assumes le: "i \<le> j"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    20
  assumes step: "\<And>i. P i (Suc i)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    21
  assumes refl: "\<And>i. P i i"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    22
  assumes trans: "\<And>i j k. \<lbrakk>P i j; P j k\<rbrakk> \<Longrightarrow> P i k"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    23
  shows "P i j"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    24
proof (cases "i = j")
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    25
  assume "i = j"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    26
  thus "P i j" by (simp add: refl)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    27
next
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    28
  assume "i \<noteq> j"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    29
  with le have "i < j" by simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    30
  thus "P i j" using step trans by (rule less_Suc_induct)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    31
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    32
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    33
text {* A pre-deflation is like a deflation, but not idempotent. *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    34
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    35
locale pre_deflation =
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    36
  fixes f :: "'a \<rightarrow> 'a::cpo"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    37
  assumes less: "\<And>x. f\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    38
  assumes finite_range: "finite (range (\<lambda>x. f\<cdot>x))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    39
begin
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    40
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    41
lemma iterate_less: "iterate i\<cdot>f\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    42
by (induct i, simp_all add: trans_less [OF less])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    43
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    44
lemma iterate_fixed: "f\<cdot>x = x \<Longrightarrow> iterate i\<cdot>f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    45
by (induct i, simp_all)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    46
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    47
lemma antichain_iterate_app: "i \<le> j \<Longrightarrow> iterate j\<cdot>f\<cdot>x \<sqsubseteq> iterate i\<cdot>f\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    48
apply (erule le_Suc_induct)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    49
apply (simp add: less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    50
apply (rule refl_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    51
apply (erule (1) trans_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    52
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    53
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    54
lemma finite_range_iterate_app: "finite (range (\<lambda>i. iterate i\<cdot>f\<cdot>x))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    55
proof (rule finite_subset)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    56
  show "range (\<lambda>i. iterate i\<cdot>f\<cdot>x) \<subseteq> insert x (range (\<lambda>x. f\<cdot>x))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    57
    by (clarify, case_tac i, simp_all)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    58
  show "finite (insert x (range (\<lambda>x. f\<cdot>x)))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    59
    by (simp add: finite_range)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    60
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    61
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    62
lemma eventually_constant_iterate_app:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    63
  "eventually_constant (\<lambda>i. iterate i\<cdot>f\<cdot>x)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    64
unfolding eventually_constant_def MOST_nat_le
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    65
proof -
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    66
  let ?Y = "\<lambda>i. iterate i\<cdot>f\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    67
  have "\<exists>j. \<forall>k. ?Y j \<sqsubseteq> ?Y k"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    68
    apply (rule finite_range_has_max)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    69
    apply (erule antichain_iterate_app)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    70
    apply (rule finite_range_iterate_app)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    71
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    72
  then obtain j where j: "\<And>k. ?Y j \<sqsubseteq> ?Y k" by fast
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    73
  show "\<exists>z m. \<forall>n\<ge>m. ?Y n = z"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    74
  proof (intro exI allI impI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    75
    fix k
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    76
    assume "j \<le> k"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    77
    hence "?Y k \<sqsubseteq> ?Y j" by (rule antichain_iterate_app)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    78
    also have "?Y j \<sqsubseteq> ?Y k" by (rule j)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    79
    finally show "?Y k = ?Y j" .
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    80
  qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    81
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    82
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    83
lemma eventually_constant_iterate:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    84
  "eventually_constant (\<lambda>n. iterate n\<cdot>f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    85
proof -
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    86
  have "\<forall>y\<in>range (\<lambda>x. f\<cdot>x). eventually_constant (\<lambda>i. iterate i\<cdot>f\<cdot>y)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    87
    by (simp add: eventually_constant_iterate_app)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    88
  hence "\<forall>y\<in>range (\<lambda>x. f\<cdot>x). MOST i. MOST j. iterate j\<cdot>f\<cdot>y = iterate i\<cdot>f\<cdot>y"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    89
    unfolding eventually_constant_MOST_MOST .
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    90
  hence "MOST i. MOST j. \<forall>y\<in>range (\<lambda>x. f\<cdot>x). iterate j\<cdot>f\<cdot>y = iterate i\<cdot>f\<cdot>y"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    91
    by (simp only: MOST_finite_Ball_distrib [OF finite_range])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    92
  hence "MOST i. MOST j. \<forall>x. iterate j\<cdot>f\<cdot>(f\<cdot>x) = iterate i\<cdot>f\<cdot>(f\<cdot>x)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    93
    by simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    94
  hence "MOST i. MOST j. \<forall>x. iterate (Suc j)\<cdot>f\<cdot>x = iterate (Suc i)\<cdot>f\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    95
    by (simp only: iterate_Suc2)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    96
  hence "MOST i. MOST j. iterate (Suc j)\<cdot>f = iterate (Suc i)\<cdot>f"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    97
    by (simp only: expand_cfun_eq)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    98
  hence "eventually_constant (\<lambda>i. iterate (Suc i)\<cdot>f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
    99
    unfolding eventually_constant_MOST_MOST .
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   100
  thus "eventually_constant (\<lambda>i. iterate i\<cdot>f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   101
    by (rule eventually_constant_SucD)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   102
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   103
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   104
abbreviation
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   105
  d :: "'a \<rightarrow> 'a"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   106
where
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   107
  "d \<equiv> eventual (\<lambda>n. iterate n\<cdot>f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   108
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   109
lemma MOST_d: "MOST n. P (iterate n\<cdot>f) \<Longrightarrow> P d"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   110
using eventually_constant_iterate by (rule MOST_eventual)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   111
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   112
lemma f_d: "f\<cdot>(d\<cdot>x) = d\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   113
apply (rule MOST_d)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   114
apply (subst iterate_Suc [symmetric])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   115
apply (rule eventually_constant_MOST_Suc_eq)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   116
apply (rule eventually_constant_iterate_app)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   117
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   118
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   119
lemma d_fixed_iff: "d\<cdot>x = x \<longleftrightarrow> f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   120
proof
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   121
  assume "d\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   122
  with f_d [where x=x]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   123
  show "f\<cdot>x = x" by simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   124
next
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   125
  assume f: "f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   126
  have "\<forall>n. iterate n\<cdot>f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   127
    by (rule allI, rule nat.induct, simp, simp add: f)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   128
  hence "MOST n. iterate n\<cdot>f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   129
    by (rule ALL_MOST)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   130
  thus "d\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   131
    by (rule MOST_d)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   132
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   133
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   134
lemma finite_deflation_d: "finite_deflation d"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   135
proof
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   136
  fix x :: 'a
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   137
  have "d \<in> range (\<lambda>n. iterate n\<cdot>f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   138
    using eventually_constant_iterate
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   139
    by (rule eventual_mem_range)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   140
  then obtain n where n: "d = iterate n\<cdot>f" ..
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   141
  have "iterate n\<cdot>f\<cdot>(d\<cdot>x) = d\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   142
    using f_d by (rule iterate_fixed)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   143
  thus "d\<cdot>(d\<cdot>x) = d\<cdot>x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   144
    by (simp add: n)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   145
next
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   146
  fix x :: 'a
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   147
  show "d\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   148
    by (rule MOST_d, simp add: iterate_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   149
next
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   150
  from finite_range
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   151
  have "finite {x. f\<cdot>x = x}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   152
    by (rule finite_range_imp_finite_fixes)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   153
  thus "finite {x. d\<cdot>x = x}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   154
    by (simp add: d_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   155
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   156
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   157
end
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   158
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   159
lemma pre_deflation_d_f:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   160
  includes finite_deflation d
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   161
  assumes f: "\<And>x. f\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   162
  shows "pre_deflation (d oo f)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   163
proof
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   164
  fix x
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   165
  show "\<And>x. (d oo f)\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   166
    by (simp, rule trans_less [OF d.less f])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   167
  show "finite (range (\<lambda>x. (d oo f)\<cdot>x))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   168
    by (rule finite_subset [OF _ d.finite_range], auto)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   169
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   170
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   171
lemma eventual_iterate_oo_fixed_iff:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   172
  includes finite_deflation d
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   173
  assumes f: "\<And>x. f\<cdot>x \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   174
  shows "eventual (\<lambda>n. iterate n\<cdot>(d oo f))\<cdot>x = x \<longleftrightarrow> d\<cdot>x = x \<and> f\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   175
proof -
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   176
  let ?e = "d oo f"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   177
  interpret e: pre_deflation ["d oo f"]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   178
    using `finite_deflation d` f
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   179
    by (rule pre_deflation_d_f)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   180
  let ?g = "eventual (\<lambda>n. iterate n\<cdot>?e)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   181
  show ?thesis
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   182
    apply (subst e.d_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   183
    apply simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   184
    apply safe
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   185
    apply (erule subst)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   186
    apply (rule d.idem)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   187
    apply (rule antisym_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   188
    apply (rule f)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   189
    apply (erule subst, rule d.less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   190
    apply simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   191
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   192
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   193
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   194
subsection {* Type constructor for finite deflations *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   195
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   196
defaultsort profinite
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   197
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   198
typedef (open) 'a fin_defl = "{d::'a \<rightarrow> 'a. finite_deflation d}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   199
by (fast intro: finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   200
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   201
instantiation fin_defl :: (profinite) sq_ord
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   202
begin
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   203
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   204
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   205
  sq_le_fin_defl_def:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   206
    "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep_fin_defl x \<sqsubseteq> Rep_fin_defl y"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   207
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   208
instance ..
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   209
end
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   210
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   211
instance fin_defl :: (profinite) po
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   212
by (rule typedef_po [OF type_definition_fin_defl sq_le_fin_defl_def])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   213
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   214
lemma finite_deflation_Rep_fin_defl: "finite_deflation (Rep_fin_defl d)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   215
using Rep_fin_defl by simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   216
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   217
interpretation Rep_fin_defl: finite_deflation ["Rep_fin_defl d"]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   218
by (rule finite_deflation_Rep_fin_defl)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   219
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   220
lemma fin_defl_lessI:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   221
  "(\<And>x. Rep_fin_defl a\<cdot>x = x \<Longrightarrow> Rep_fin_defl b\<cdot>x = x) \<Longrightarrow> a \<sqsubseteq> b"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   222
unfolding sq_le_fin_defl_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   223
by (rule Rep_fin_defl.lessI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   224
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   225
lemma fin_defl_lessD:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   226
  "\<lbrakk>a \<sqsubseteq> b; Rep_fin_defl a\<cdot>x = x\<rbrakk> \<Longrightarrow> Rep_fin_defl b\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   227
unfolding sq_le_fin_defl_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   228
by (rule Rep_fin_defl.lessD)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   229
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   230
lemma fin_defl_eqI:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   231
  "(\<And>x. Rep_fin_defl a\<cdot>x = x \<longleftrightarrow> Rep_fin_defl b\<cdot>x = x) \<Longrightarrow> a = b"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   232
apply (rule antisym_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   233
apply (rule fin_defl_lessI, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   234
apply (rule fin_defl_lessI, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   235
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   236
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   237
lemma Abs_fin_defl_mono:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   238
  "\<lbrakk>finite_deflation a; finite_deflation b; a \<sqsubseteq> b\<rbrakk>
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   239
    \<Longrightarrow> Abs_fin_defl a \<sqsubseteq> Abs_fin_defl b"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   240
unfolding sq_le_fin_defl_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   241
by (simp add: Abs_fin_defl_inverse)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   242
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   243
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   244
subsection {* Take function for finite deflations *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   245
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   246
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   247
  fd_take :: "nat \<Rightarrow> 'a fin_defl \<Rightarrow> 'a fin_defl"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   248
where
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   249
  "fd_take i d = Abs_fin_defl (eventual (\<lambda>n. iterate n\<cdot>(approx i oo Rep_fin_defl d)))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   250
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   251
lemma Rep_fin_defl_fd_take:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   252
  "Rep_fin_defl (fd_take i d) =
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   253
    eventual (\<lambda>n. iterate n\<cdot>(approx i oo Rep_fin_defl d))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   254
unfolding fd_take_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   255
apply (rule Abs_fin_defl_inverse [unfolded mem_Collect_eq])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   256
apply (rule pre_deflation.finite_deflation_d)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   257
apply (rule pre_deflation_d_f)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   258
apply (rule finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   259
apply (rule Rep_fin_defl.less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   260
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   261
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   262
lemma fd_take_fixed_iff:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   263
  "Rep_fin_defl (fd_take i d)\<cdot>x = x \<longleftrightarrow>
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   264
    approx i\<cdot>x = x \<and> Rep_fin_defl d\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   265
unfolding Rep_fin_defl_fd_take
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   266
by (rule eventual_iterate_oo_fixed_iff
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   267
    [OF finite_deflation_approx Rep_fin_defl.less])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   268
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   269
lemma fd_take_less: "fd_take n d \<sqsubseteq> d"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   270
apply (rule fin_defl_lessI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   271
apply (simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   272
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   273
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   274
lemma fd_take_idem: "fd_take n (fd_take n d) = fd_take n d"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   275
apply (rule fin_defl_eqI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   276
apply (simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   277
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   278
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   279
lemma fd_take_mono: "a \<sqsubseteq> b \<Longrightarrow> fd_take n a \<sqsubseteq> fd_take n b"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   280
apply (rule fin_defl_lessI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   281
apply (simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   282
apply (simp add: fin_defl_lessD)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   283
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   284
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   285
lemma approx_fixed_le_lemma: "\<lbrakk>i \<le> j; approx i\<cdot>x = x\<rbrakk> \<Longrightarrow> approx j\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   286
by (erule subst, simp add: min_def)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   287
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   288
lemma fd_take_chain: "m \<le> n \<Longrightarrow> fd_take m a \<sqsubseteq> fd_take n a"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   289
apply (rule fin_defl_lessI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   290
apply (simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   291
apply (simp add: approx_fixed_le_lemma)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   292
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   293
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   294
lemma finite_range_fd_take: "finite (range (fd_take n))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   295
apply (rule finite_imageD [where f="\<lambda>a. {x. Rep_fin_defl a\<cdot>x = x}"])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   296
apply (rule finite_subset [where B="Pow {x. approx n\<cdot>x = x}"])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   297
apply (clarify, simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   298
apply (simp add: finite_fixes_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   299
apply (rule inj_onI, clarify)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   300
apply (simp add: expand_set_eq fin_defl_eqI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   301
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   302
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   303
lemma fd_take_covers: "\<exists>n. fd_take n a = a"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   304
apply (rule_tac x=
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   305
  "Max ((\<lambda>x. LEAST n. approx n\<cdot>x = x) ` {x. Rep_fin_defl a\<cdot>x = x})" in exI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   306
apply (rule antisym_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   307
apply (rule fd_take_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   308
apply (rule fin_defl_lessI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   309
apply (simp add: fd_take_fixed_iff)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   310
apply (rule approx_fixed_le_lemma)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   311
apply (rule Max_ge)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   312
apply (rule finite_imageI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   313
apply (rule Rep_fin_defl.finite_fixes)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   314
apply (rule imageI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   315
apply (erule CollectI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   316
apply (rule LeastI_ex)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   317
apply (rule profinite_compact_eq_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   318
apply (erule subst)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   319
apply (rule Rep_fin_defl.compact)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   320
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   321
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   322
interpretation fin_defl: basis_take [sq_le fd_take]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   323
apply default
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   324
apply (rule fd_take_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   325
apply (rule fd_take_idem)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   326
apply (erule fd_take_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   327
apply (rule fd_take_chain, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   328
apply (rule finite_range_fd_take)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   329
apply (rule fd_take_covers)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   330
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   331
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   332
subsection {* Defining algebraic deflations by ideal completion *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   333
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   334
typedef (open) 'a alg_defl =
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   335
  "{S::'a fin_defl set. sq_le.ideal S}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   336
by (fast intro: sq_le.ideal_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   337
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   338
instantiation alg_defl :: (profinite) sq_ord
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   339
begin
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   340
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   341
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   342
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_alg_defl x \<subseteq> Rep_alg_defl y"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   343
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   344
instance ..
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   345
end
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   346
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   347
instance alg_defl :: (profinite) po
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   348
by (rule sq_le.typedef_ideal_po
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   349
    [OF type_definition_alg_defl sq_le_alg_defl_def])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   350
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   351
instance alg_defl :: (profinite) cpo
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   352
by (rule sq_le.typedef_ideal_cpo
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   353
    [OF type_definition_alg_defl sq_le_alg_defl_def])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   354
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   355
lemma Rep_alg_defl_lub:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   356
  "chain Y \<Longrightarrow> Rep_alg_defl (\<Squnion>i. Y i) = (\<Union>i. Rep_alg_defl (Y i))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   357
by (rule sq_le.typedef_ideal_rep_contlub
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   358
    [OF type_definition_alg_defl sq_le_alg_defl_def])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   359
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   360
lemma ideal_Rep_alg_defl: "sq_le.ideal (Rep_alg_defl xs)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   361
by (rule Rep_alg_defl [unfolded mem_Collect_eq])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   362
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   363
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   364
  alg_defl_principal :: "'a fin_defl \<Rightarrow> 'a alg_defl" where
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   365
  "alg_defl_principal t = Abs_alg_defl {u. u \<sqsubseteq> t}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   366
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   367
lemma Rep_alg_defl_principal:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   368
  "Rep_alg_defl (alg_defl_principal t) = {u. u \<sqsubseteq> t}"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   369
unfolding alg_defl_principal_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   370
by (simp add: Abs_alg_defl_inverse sq_le.ideal_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   371
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   372
interpretation alg_defl:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   373
  ideal_completion [sq_le fd_take alg_defl_principal Rep_alg_defl]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   374
apply default
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   375
apply (rule ideal_Rep_alg_defl)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   376
apply (erule Rep_alg_defl_lub)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   377
apply (rule Rep_alg_defl_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   378
apply (simp only: sq_le_alg_defl_def)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   379
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   380
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   381
text {* Algebraic deflations are pointed *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   382
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   383
lemma finite_deflation_UU: "finite_deflation \<bottom>"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   384
by default simp_all
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   385
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   386
lemma alg_defl_minimal:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   387
  "alg_defl_principal (Abs_fin_defl \<bottom>) \<sqsubseteq> x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   388
apply (induct x rule: alg_defl.principal_induct, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   389
apply (rule alg_defl.principal_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   390
apply (induct_tac a)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   391
apply (rule Abs_fin_defl_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   392
apply (rule finite_deflation_UU)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   393
apply simp
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   394
apply (rule minimal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   395
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   396
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   397
instance alg_defl :: (bifinite) pcpo
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   398
by intro_classes (fast intro: alg_defl_minimal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   399
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   400
lemma inst_alg_defl_pcpo: "\<bottom> = alg_defl_principal (Abs_fin_defl \<bottom>)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   401
by (rule alg_defl_minimal [THEN UU_I, symmetric])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   402
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   403
text {* Algebraic deflations are profinite *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   404
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   405
instantiation alg_defl :: (profinite) profinite
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   406
begin
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   407
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   408
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   409
  approx_alg_defl_def: "approx = alg_defl.completion_approx"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   410
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   411
instance
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   412
apply (intro_classes, unfold approx_alg_defl_def)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   413
apply (rule alg_defl.chain_completion_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   414
apply (rule alg_defl.lub_completion_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   415
apply (rule alg_defl.completion_approx_idem)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   416
apply (rule alg_defl.finite_fixes_completion_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   417
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   418
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   419
end
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   420
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   421
instance alg_defl :: (bifinite) bifinite ..
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   422
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   423
lemma approx_alg_defl_principal [simp]:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   424
  "approx n\<cdot>(alg_defl_principal t) = alg_defl_principal (fd_take n t)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   425
unfolding approx_alg_defl_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   426
by (rule alg_defl.completion_approx_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   427
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   428
lemma approx_eq_alg_defl_principal:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   429
  "\<exists>t\<in>Rep_alg_defl xs. approx n\<cdot>xs = alg_defl_principal (fd_take n t)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   430
unfolding approx_alg_defl_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   431
by (rule alg_defl.completion_approx_eq_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   432
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   433
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   434
subsection {* Applying algebraic deflations *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   435
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   436
definition
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   437
  cast :: "'a alg_defl \<rightarrow> 'a \<rightarrow> 'a"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   438
where
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   439
  "cast = alg_defl.basis_fun Rep_fin_defl"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   440
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   441
lemma cast_alg_defl_principal:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   442
  "cast\<cdot>(alg_defl_principal a) = Rep_fin_defl a"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   443
unfolding cast_def
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   444
apply (rule alg_defl.basis_fun_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   445
apply (simp only: sq_le_fin_defl_def)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   446
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   447
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   448
lemma deflation_cast: "deflation (cast\<cdot>d)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   449
apply (induct d rule: alg_defl.principal_induct)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   450
apply (rule adm_subst [OF _ adm_deflation], simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   451
apply (simp add: cast_alg_defl_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   452
apply (rule finite_deflation_imp_deflation)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   453
apply (rule finite_deflation_Rep_fin_defl)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   454
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   455
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   456
lemma finite_deflation_cast:
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   457
  "compact d \<Longrightarrow> finite_deflation (cast\<cdot>d)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   458
apply (drule alg_defl.compact_imp_principal, clarify)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   459
apply (simp add: cast_alg_defl_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   460
apply (rule finite_deflation_Rep_fin_defl)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   461
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   462
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   463
interpretation cast: deflation ["cast\<cdot>d"]
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   464
by (rule deflation_cast)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   465
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   466
lemma "cast\<cdot>(\<Squnion>i. alg_defl_principal (Abs_fin_defl (approx i)))\<cdot>x = x"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   467
apply (subst contlub_cfun_arg)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   468
apply (rule chainI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   469
apply (rule alg_defl.principal_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   470
apply (rule Abs_fin_defl_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   471
apply (rule finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   472
apply (rule finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   473
apply (rule chainE)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   474
apply (rule chain_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   475
apply (simp add: cast_alg_defl_principal Abs_fin_defl_inverse finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   476
done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   477
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   478
text {* This lemma says that if we have an ep-pair from
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   479
a bifinite domain into a universal domain, then e oo p
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   480
is an algebraic deflation. *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   481
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   482
lemma
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   483
  includes ep_pair e p
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   484
  constrains e :: "'a::profinite \<rightarrow> 'b::profinite"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   485
  shows "\<exists>d. cast\<cdot>d = e oo p"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   486
proof
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   487
  let ?a = "\<lambda>i. e oo approx i oo p"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   488
  have a: "\<And>i. finite_deflation (?a i)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   489
    apply (rule finite_deflation_e_d_p)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   490
    apply (rule finite_deflation_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   491
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   492
  let ?d = "\<Squnion>i. alg_defl_principal (Abs_fin_defl (?a i))"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   493
  show "cast\<cdot>?d = e oo p"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   494
    apply (subst contlub_cfun_arg)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   495
    apply (rule chainI)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   496
    apply (rule alg_defl.principal_mono)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   497
    apply (rule Abs_fin_defl_mono [OF a a])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   498
    apply (rule chainE, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   499
    apply (subst cast_alg_defl_principal)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   500
    apply (simp add: Abs_fin_defl_inverse a)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   501
    apply (simp add: expand_cfun_eq lub_distribs)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   502
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   503
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   504
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   505
text {* This lemma says that if we have an ep-pair
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   506
from a cpo into a bifinite domain, and e oo p is
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   507
an algebraic deflation, then the cpo is bifinite. *}
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   508
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   509
lemma
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   510
  includes ep_pair e p
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   511
  constrains e :: "'a::cpo \<rightarrow> 'b::profinite"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   512
  assumes d: "\<And>x. cast\<cdot>d\<cdot>x = e\<cdot>(p\<cdot>x)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   513
  obtains a :: "nat \<Rightarrow> 'a \<rightarrow> 'a" where
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   514
    "\<And>i. finite_deflation (a i)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   515
    "(\<Squnion>i. a i) = ID"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   516
proof
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   517
  let ?a = "\<lambda>i. p oo cast\<cdot>(approx i\<cdot>d) oo e"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   518
  show "\<And>i. finite_deflation (?a i)"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   519
    apply (rule finite_deflation_p_d_e)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   520
    apply (rule finite_deflation_cast)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   521
    apply (rule compact_approx)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   522
    apply (rule sq_ord_less_eq_trans [OF _ d])
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   523
    apply (rule monofun_cfun_fun)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   524
    apply (rule monofun_cfun_arg)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   525
    apply (rule approx_less)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   526
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   527
  show "(\<Squnion>i. ?a i) = ID"
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   528
    apply (rule ext_cfun, simp)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   529
    apply (simp add: lub_distribs)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   530
    apply (simp add: d)
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   531
    done
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   532
qed
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   533
f65a889f97f9 theory of algebraic deflations
huffman
parents:
diff changeset
   534
end