src/HOL/HOLCF/Library/Defl_Bifinite.thy
author huffman
Wed, 22 Dec 2010 18:24:04 -0800
changeset 41394 51c866d1b53b
parent 41292 2b7bc8d9fd6e
child 41436 480978f80eae
permissions -rw-r--r--
rename function ideal_completion.basis_fun to ideal_completion.extension
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/Library/Defl_Bifinite.thy
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     3
*)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     4
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     5
header {* Algebraic deflations are a bifinite domain *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     6
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     7
theory Defl_Bifinite
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     8
imports HOLCF Infinite_Set
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
     9
begin
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    10
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    11
subsection {* Lemmas about MOST *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    12
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    13
default_sort type
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    14
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    15
lemma MOST_INFM:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    16
  assumes inf: "infinite (UNIV::'a set)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    17
  shows "MOST x::'a. P x \<Longrightarrow> INFM x::'a. P x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    18
  unfolding Alm_all_def Inf_many_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    19
  apply (auto simp add: Collect_neg_eq)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    20
  apply (drule (1) finite_UnI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    21
  apply (simp add: Compl_partition2 inf)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    22
  done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    23
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    24
lemma MOST_SucI: "MOST n. P n \<Longrightarrow> MOST n. P (Suc n)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    25
by (rule MOST_inj [OF _ inj_Suc])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    26
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    27
lemma MOST_SucD: "MOST n. P (Suc n) \<Longrightarrow> MOST n. P n"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    28
unfolding MOST_nat
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    29
apply (clarify, rule_tac x="Suc m" in exI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    30
apply (erule Suc_lessE, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    31
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    32
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    33
lemma MOST_Suc_iff: "(MOST n. P (Suc n)) \<longleftrightarrow> (MOST n. P n)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    34
by (rule iffI [OF MOST_SucD MOST_SucI])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    35
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    36
lemma INFM_finite_Bex_distrib:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    37
  "finite A \<Longrightarrow> (INFM y. \<exists>x\<in>A. P x y) \<longleftrightarrow> (\<exists>x\<in>A. INFM y. P x y)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    38
by (induct set: finite, simp, simp add: INFM_disj_distrib)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    39
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    40
lemma MOST_finite_Ball_distrib:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    41
  "finite A \<Longrightarrow> (MOST y. \<forall>x\<in>A. P x y) \<longleftrightarrow> (\<forall>x\<in>A. MOST y. P x y)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    42
by (induct set: finite, simp, simp add: MOST_conj_distrib)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    43
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    44
lemma MOST_ge_nat: "MOST n::nat. m \<le> n"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    45
unfolding MOST_nat_le by fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    46
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    47
subsection {* Eventually constant sequences *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    48
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    49
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    50
  eventually_constant :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    51
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    52
  "eventually_constant S = (\<exists>x. MOST i. S i = x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    53
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    54
lemma eventually_constant_MOST_MOST:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    55
  "eventually_constant S \<longleftrightarrow> (MOST m. MOST n. S n = S m)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    56
unfolding eventually_constant_def MOST_nat
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    57
apply safe
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    58
apply (rule_tac x=m in exI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    59
apply (rule_tac x=m in exI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    60
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    61
apply fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    62
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    63
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    64
lemma eventually_constantI: "MOST i. S i = x \<Longrightarrow> eventually_constant S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    65
unfolding eventually_constant_def by fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    66
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    67
lemma eventually_constant_comp:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    68
  "eventually_constant (\<lambda>i. S i) \<Longrightarrow> eventually_constant (\<lambda>i. f (S i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    69
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    70
apply (erule exE, rule_tac x="f x" in exI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    71
apply (erule MOST_mono, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    72
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    73
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    74
lemma eventually_constant_Suc_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    75
  "eventually_constant (\<lambda>i. S (Suc i)) \<longleftrightarrow> eventually_constant (\<lambda>i. S i)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    76
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    77
by (subst MOST_Suc_iff, rule refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    78
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    79
lemma eventually_constant_SucD:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    80
  "eventually_constant (\<lambda>i. S (Suc i)) \<Longrightarrow> eventually_constant (\<lambda>i. S i)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    81
by (rule eventually_constant_Suc_iff [THEN iffD1])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    82
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    83
subsection {* Limits of eventually constant sequences *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    84
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    85
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    86
  eventual :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a" where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    87
  "eventual S = (THE x. MOST i. S i = x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    88
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    89
lemma eventual_eqI: "MOST i. S i = x \<Longrightarrow> eventual S = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    90
unfolding eventual_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    91
apply (rule the_equality, assumption)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    92
apply (rename_tac y)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    93
apply (subgoal_tac "MOST i::nat. y = x", simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    94
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    95
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    96
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    97
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    98
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    99
lemma MOST_eq_eventual:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   100
  "eventually_constant S \<Longrightarrow> MOST i. S i = eventual S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   101
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   102
by (erule exE, simp add: eventual_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   103
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   104
lemma eventual_mem_range:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   105
  "eventually_constant S \<Longrightarrow> eventual S \<in> range S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   106
apply (drule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   107
apply (simp only: MOST_nat_le, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   108
apply (drule spec, drule mp, rule order_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   109
apply (erule range_eqI [OF sym])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   110
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   111
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   112
lemma eventually_constant_MOST_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   113
  assumes S: "eventually_constant S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   114
  shows "(MOST n. P (S n)) \<longleftrightarrow> P (eventual S)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   115
apply (subgoal_tac "(MOST n. P (S n)) \<longleftrightarrow> (MOST n::nat. P (eventual S))")
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   116
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   117
apply (rule iffI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   118
apply (rule MOST_rev_mp [OF MOST_eq_eventual [OF S]])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   119
apply (erule MOST_mono, force)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   120
apply (rule MOST_rev_mp [OF MOST_eq_eventual [OF S]])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   121
apply (erule MOST_mono, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   122
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   123
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   124
lemma MOST_eventual:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   125
  "\<lbrakk>eventually_constant S; MOST n. P (S n)\<rbrakk> \<Longrightarrow> P (eventual S)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   126
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   127
  assume "eventually_constant S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   128
  hence "MOST n. S n = eventual S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   129
    by (rule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   130
  moreover assume "MOST n. P (S n)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   131
  ultimately have "MOST n. S n = eventual S \<and> P (S n)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   132
    by (rule MOST_conj_distrib [THEN iffD2, OF conjI])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   133
  hence "MOST n::nat. P (eventual S)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   134
    by (rule MOST_mono) auto
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   135
  thus ?thesis by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   136
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   137
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   138
lemma eventually_constant_MOST_Suc_eq:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   139
  "eventually_constant S \<Longrightarrow> MOST n. S (Suc n) = S n"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   140
apply (drule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   141
apply (frule MOST_Suc_iff [THEN iffD2])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   142
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   143
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   144
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   145
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   146
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   147
lemma eventual_comp:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   148
  "eventually_constant S \<Longrightarrow> eventual (\<lambda>i. f (S i)) = f (eventual (\<lambda>i. S i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   149
apply (rule eventual_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   150
apply (rule MOST_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   151
apply (erule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   152
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   153
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   154
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   155
subsection {* Constructing finite deflations by iteration *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   156
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   157
default_sort cpo
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   158
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   159
lemma le_Suc_induct:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   160
  assumes le: "i \<le> j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   161
  assumes step: "\<And>i. P i (Suc i)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   162
  assumes refl: "\<And>i. P i i"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   163
  assumes trans: "\<And>i j k. \<lbrakk>P i j; P j k\<rbrakk> \<Longrightarrow> P i k"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   164
  shows "P i j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   165
proof (cases "i = j")
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   166
  assume "i = j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   167
  thus "P i j" by (simp add: refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   168
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   169
  assume "i \<noteq> j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   170
  with le have "i < j" by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   171
  thus "P i j" using step trans by (rule less_Suc_induct)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   172
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   173
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   174
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   175
  eventual_iterate :: "('a \<rightarrow> 'a::cpo) \<Rightarrow> ('a \<rightarrow> 'a)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   176
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   177
  "eventual_iterate f = eventual (\<lambda>n. iterate n\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   178
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   179
text {* A pre-deflation is like a deflation, but not idempotent. *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   180
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   181
locale pre_deflation =
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   182
  fixes f :: "'a \<rightarrow> 'a::cpo"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   183
  assumes below: "\<And>x. f\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   184
  assumes finite_range: "finite (range (\<lambda>x. f\<cdot>x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   185
begin
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   186
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   187
lemma iterate_below: "iterate i\<cdot>f\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   188
by (induct i, simp_all add: below_trans [OF below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   189
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   190
lemma iterate_fixed: "f\<cdot>x = x \<Longrightarrow> iterate i\<cdot>f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   191
by (induct i, simp_all)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   192
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   193
lemma antichain_iterate_app: "i \<le> j \<Longrightarrow> iterate j\<cdot>f\<cdot>x \<sqsubseteq> iterate i\<cdot>f\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   194
apply (erule le_Suc_induct)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   195
apply (simp add: below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   196
apply (rule below_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   197
apply (erule (1) below_trans)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   198
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   199
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   200
lemma finite_range_iterate_app: "finite (range (\<lambda>i. iterate i\<cdot>f\<cdot>x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   201
proof (rule finite_subset)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   202
  show "range (\<lambda>i. iterate i\<cdot>f\<cdot>x) \<subseteq> insert x (range (\<lambda>x. f\<cdot>x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   203
    by (clarify, case_tac i, simp_all)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   204
  show "finite (insert x (range (\<lambda>x. f\<cdot>x)))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   205
    by (simp add: finite_range)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   206
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   207
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   208
lemma eventually_constant_iterate_app:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   209
  "eventually_constant (\<lambda>i. iterate i\<cdot>f\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   210
unfolding eventually_constant_def MOST_nat_le
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   211
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   212
  let ?Y = "\<lambda>i. iterate i\<cdot>f\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   213
  have "\<exists>j. \<forall>k. ?Y j \<sqsubseteq> ?Y k"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   214
    apply (rule finite_range_has_max)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   215
    apply (erule antichain_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   216
    apply (rule finite_range_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   217
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   218
  then obtain j where j: "\<And>k. ?Y j \<sqsubseteq> ?Y k" by fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   219
  show "\<exists>z m. \<forall>n\<ge>m. ?Y n = z"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   220
  proof (intro exI allI impI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   221
    fix k
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   222
    assume "j \<le> k"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   223
    hence "?Y k \<sqsubseteq> ?Y j" by (rule antichain_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   224
    also have "?Y j \<sqsubseteq> ?Y k" by (rule j)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   225
    finally show "?Y k = ?Y j" .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   226
  qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   227
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   228
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   229
lemma eventually_constant_iterate:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   230
  "eventually_constant (\<lambda>n. iterate n\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   231
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   232
  have "\<forall>y\<in>range (\<lambda>x. f\<cdot>x). eventually_constant (\<lambda>i. iterate i\<cdot>f\<cdot>y)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   233
    by (simp add: eventually_constant_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   234
  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"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   235
    unfolding eventually_constant_MOST_MOST .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   236
  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"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   237
    by (simp only: MOST_finite_Ball_distrib [OF finite_range])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   238
  hence "MOST i. MOST j. \<forall>x. iterate j\<cdot>f\<cdot>(f\<cdot>x) = iterate i\<cdot>f\<cdot>(f\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   239
    by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   240
  hence "MOST i. MOST j. \<forall>x. iterate (Suc j)\<cdot>f\<cdot>x = iterate (Suc i)\<cdot>f\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   241
    by (simp only: iterate_Suc2)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   242
  hence "MOST i. MOST j. iterate (Suc j)\<cdot>f = iterate (Suc i)\<cdot>f"
40002
c5b5f7a3a3b1 new theorem names: fun_below_iff, fun_belowI, cfun_eq_iff, cfun_eqI, cfun_below_iff, cfun_belowI
huffman
parents: 39999
diff changeset
   243
    by (simp only: cfun_eq_iff)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   244
  hence "eventually_constant (\<lambda>i. iterate (Suc i)\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   245
    unfolding eventually_constant_MOST_MOST .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   246
  thus "eventually_constant (\<lambda>i. iterate i\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   247
    by (rule eventually_constant_SucD)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   248
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   249
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   250
abbreviation
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   251
  d :: "'a \<rightarrow> 'a"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   252
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   253
  "d \<equiv> eventual_iterate f"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   254
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   255
lemma MOST_d: "MOST n. P (iterate n\<cdot>f) \<Longrightarrow> P d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   256
unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   257
using eventually_constant_iterate by (rule MOST_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   258
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   259
lemma f_d: "f\<cdot>(d\<cdot>x) = d\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   260
apply (rule MOST_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   261
apply (subst iterate_Suc [symmetric])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   262
apply (rule eventually_constant_MOST_Suc_eq)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   263
apply (rule eventually_constant_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   264
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   265
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   266
lemma d_fixed_iff: "d\<cdot>x = x \<longleftrightarrow> f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   267
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   268
  assume "d\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   269
  with f_d [where x=x]
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   270
  show "f\<cdot>x = x" by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   271
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   272
  assume f: "f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   273
  have "\<forall>n. iterate n\<cdot>f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   274
    by (rule allI, rule nat.induct, simp, simp add: f)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   275
  hence "MOST n. iterate n\<cdot>f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   276
    by (rule ALL_MOST)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   277
  thus "d\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   278
    by (rule MOST_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   279
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   280
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   281
lemma finite_deflation_d: "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   282
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   283
  fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   284
  have "d \<in> range (\<lambda>n. iterate n\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   285
    unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   286
    using eventually_constant_iterate
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   287
    by (rule eventual_mem_range)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   288
  then obtain n where n: "d = iterate n\<cdot>f" ..
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   289
  have "iterate n\<cdot>f\<cdot>(d\<cdot>x) = d\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   290
    using f_d by (rule iterate_fixed)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   291
  thus "d\<cdot>(d\<cdot>x) = d\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   292
    by (simp add: n)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   293
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   294
  fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   295
  show "d\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   296
    by (rule MOST_d, simp add: iterate_below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   297
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   298
  from finite_range
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   299
  have "finite {x. f\<cdot>x = x}"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   300
    by (rule finite_range_imp_finite_fixes)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   301
  thus "finite {x. d\<cdot>x = x}"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   302
    by (simp add: d_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   303
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   304
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   305
lemma deflation_d: "deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   306
using finite_deflation_d
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   307
by (rule finite_deflation_imp_deflation)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   308
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   309
end
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   310
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   311
lemma finite_deflation_eventual_iterate:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   312
  "pre_deflation d \<Longrightarrow> finite_deflation (eventual_iterate d)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   313
by (rule pre_deflation.finite_deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   314
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   315
lemma pre_deflation_oo:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   316
  assumes "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   317
  assumes f: "\<And>x. f\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   318
  shows "pre_deflation (d oo f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   319
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   320
  interpret d: finite_deflation d by fact
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   321
  fix x
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   322
  show "\<And>x. (d oo f)\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   323
    by (simp, rule below_trans [OF d.below f])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   324
  show "finite (range (\<lambda>x. (d oo f)\<cdot>x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   325
    by (rule finite_subset [OF _ d.finite_range], auto)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   326
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   327
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   328
lemma eventual_iterate_oo_fixed_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   329
  assumes "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   330
  assumes f: "\<And>x. f\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   331
  shows "eventual_iterate (d oo f)\<cdot>x = x \<longleftrightarrow> d\<cdot>x = x \<and> f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   332
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   333
  interpret d: finite_deflation d by fact
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   334
  let ?e = "d oo f"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   335
  interpret e: pre_deflation "d oo f"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   336
    using `finite_deflation d` f
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   337
    by (rule pre_deflation_oo)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   338
  let ?g = "eventual (\<lambda>n. iterate n\<cdot>?e)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   339
  show ?thesis
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   340
    apply (subst e.d_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   341
    apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   342
    apply safe
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   343
    apply (erule subst)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   344
    apply (rule d.idem)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   345
    apply (rule below_antisym)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   346
    apply (rule f)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   347
    apply (erule subst, rule d.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   348
    apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   349
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   350
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   351
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   352
lemma eventual_mono:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   353
  assumes A: "eventually_constant A"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   354
  assumes B: "eventually_constant B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   355
  assumes below: "\<And>n. A n \<sqsubseteq> B n"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   356
  shows "eventual A \<sqsubseteq> eventual B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   357
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   358
  from A have "MOST n. A n = eventual A"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   359
    by (rule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   360
  then have "MOST n. eventual A \<sqsubseteq> B n"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   361
    by (rule MOST_mono) (erule subst, rule below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   362
  with B show "eventual A \<sqsubseteq> eventual B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   363
    by (rule MOST_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   364
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   365
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   366
lemma eventual_iterate_mono:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   367
  assumes f: "pre_deflation f" and g: "pre_deflation g" and "f \<sqsubseteq> g"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   368
  shows "eventual_iterate f \<sqsubseteq> eventual_iterate g"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   369
unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   370
apply (rule eventual_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   371
apply (rule pre_deflation.eventually_constant_iterate [OF f])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   372
apply (rule pre_deflation.eventually_constant_iterate [OF g])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   373
apply (rule monofun_cfun_arg [OF `f \<sqsubseteq> g`])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   374
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   375
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   376
lemma cont2cont_eventual_iterate_oo:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   377
  assumes d: "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   378
  assumes cont: "cont f" and below: "\<And>x y. f x\<cdot>y \<sqsubseteq> y"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   379
  shows "cont (\<lambda>x. eventual_iterate (d oo f x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   380
    (is "cont ?e")
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   381
proof (rule contI2)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   382
  show "monofun ?e"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   383
    apply (rule monofunI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   384
    apply (rule eventual_iterate_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   385
    apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   386
    apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   387
    apply (rule monofun_cfun_arg)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   388
    apply (erule cont2monofunE [OF cont])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   389
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   390
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   391
  fix Y :: "nat \<Rightarrow> 'b"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   392
  assume Y: "chain Y"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   393
  with cont have fY: "chain (\<lambda>i. f (Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   394
    by (rule ch2ch_cont)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   395
  assume eY: "chain (\<lambda>i. ?e (Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   396
  have lub_below: "\<And>x. f (\<Squnion>i. Y i)\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   397
    by (rule admD [OF _ Y], simp add: cont, rule below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   398
  have "deflation (?e (\<Squnion>i. Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   399
    apply (rule pre_deflation.deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   400
    apply (rule pre_deflation_oo [OF d lub_below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   401
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   402
  then show "?e (\<Squnion>i. Y i) \<sqsubseteq> (\<Squnion>i. ?e (Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   403
  proof (rule deflation.belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   404
    fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   405
    assume "?e (\<Squnion>i. Y i)\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   406
    hence "d\<cdot>x = x" and "f (\<Squnion>i. Y i)\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   407
      by (simp_all add: eventual_iterate_oo_fixed_iff [OF d lub_below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   408
    hence "(\<Squnion>i. f (Y i)\<cdot>x) = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   409
      apply (simp only: cont2contlubE [OF cont Y])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   410
      apply (simp only: contlub_cfun_fun [OF fY])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   411
      done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   412
    have "compact (d\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   413
      using d by (rule finite_deflation.compact)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   414
    then have "compact x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   415
      using `d\<cdot>x = x` by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   416
    then have "compact (\<Squnion>i. f (Y i)\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   417
      using `(\<Squnion>i. f (Y i)\<cdot>x) = x` by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   418
    then have "\<exists>n. max_in_chain n (\<lambda>i. f (Y i)\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   419
      by - (rule compact_imp_max_in_chain, simp add: fY, assumption)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   420
    then obtain n where n: "max_in_chain n (\<lambda>i. f (Y i)\<cdot>x)" ..
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   421
    then have "f (Y n)\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   422
      using `(\<Squnion>i. f (Y i)\<cdot>x) = x` fY by (simp add: maxinch_is_thelub)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   423
    with `d\<cdot>x = x` have "?e (Y n)\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   424
      by (simp add: eventual_iterate_oo_fixed_iff [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   425
    moreover have "?e (Y n)\<cdot>x \<sqsubseteq> (\<Squnion>i. ?e (Y i)\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   426
      by (rule is_ub_thelub, simp add: eY)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   427
    ultimately have "x \<sqsubseteq> (\<Squnion>i. ?e (Y i))\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   428
      by (simp add: contlub_cfun_fun eY)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   429
    also have "(\<Squnion>i. ?e (Y i))\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   430
      apply (rule deflation.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   431
      apply (rule admD [OF adm_deflation eY])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   432
      apply (rule pre_deflation.deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   433
      apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   434
      done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   435
    finally show "(\<Squnion>i. ?e (Y i))\<cdot>x = x" ..
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   436
  qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   437
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   438
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   439
subsection {* Take function for finite deflations *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   440
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   441
context bifinite_approx_chain
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   442
begin
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   443
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   444
definition
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   445
  defl_take :: "nat \<Rightarrow> ('a \<rightarrow> 'a) \<Rightarrow> ('a \<rightarrow> 'a)"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   446
where
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   447
  "defl_take i d = eventual_iterate (approx i oo d)"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   448
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   449
lemma finite_deflation_defl_take:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   450
  "deflation d \<Longrightarrow> finite_deflation (defl_take i d)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   451
unfolding defl_take_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   452
apply (rule pre_deflation.finite_deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   453
apply (rule pre_deflation_oo)
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   454
apply (rule finite_deflation_approx)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   455
apply (erule deflation.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   456
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   457
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   458
lemma deflation_defl_take:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   459
  "deflation d \<Longrightarrow> deflation (defl_take i d)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   460
apply (rule finite_deflation_imp_deflation)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   461
apply (erule finite_deflation_defl_take)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   462
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   463
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   464
lemma defl_take_fixed_iff:
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   465
  "deflation d \<Longrightarrow> defl_take i d\<cdot>x = x \<longleftrightarrow> approx i\<cdot>x = x \<and> d\<cdot>x = x"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   466
unfolding defl_take_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   467
apply (rule eventual_iterate_oo_fixed_iff)
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   468
apply (rule finite_deflation_approx)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   469
apply (erule deflation.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   470
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   471
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   472
lemma defl_take_below:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   473
  "\<lbrakk>a \<sqsubseteq> b; deflation a; deflation b\<rbrakk> \<Longrightarrow> defl_take i a \<sqsubseteq> defl_take i b"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   474
apply (rule deflation.belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   475
apply (erule deflation_defl_take)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   476
apply (simp add: defl_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   477
apply (erule (1) deflation.belowD)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   478
apply (erule conjunct2)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   479
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   480
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   481
lemma cont2cont_defl_take:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   482
  assumes cont: "cont f" and below: "\<And>x y. f x\<cdot>y \<sqsubseteq> y"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   483
  shows "cont (\<lambda>x. defl_take i (f x))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   484
unfolding defl_take_def
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   485
using finite_deflation_approx assms
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   486
by (rule cont2cont_eventual_iterate_oo)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   487
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   488
definition
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   489
  fd_take :: "nat \<Rightarrow> 'a fin_defl \<Rightarrow> 'a fin_defl"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   490
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   491
  "fd_take i d = Abs_fin_defl (defl_take i (Rep_fin_defl d))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   492
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   493
lemma Rep_fin_defl_fd_take:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   494
  "Rep_fin_defl (fd_take i d) = defl_take i (Rep_fin_defl d)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   495
unfolding fd_take_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   496
apply (rule Abs_fin_defl_inverse [unfolded mem_Collect_eq])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   497
apply (rule finite_deflation_defl_take)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   498
apply (rule deflation_Rep_fin_defl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   499
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   500
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   501
lemma fd_take_fixed_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   502
  "Rep_fin_defl (fd_take i d)\<cdot>x = x \<longleftrightarrow>
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   503
    approx i\<cdot>x = x \<and> Rep_fin_defl d\<cdot>x = x"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   504
unfolding Rep_fin_defl_fd_take
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   505
apply (rule defl_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   506
apply (rule deflation_Rep_fin_defl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   507
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   508
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   509
lemma fd_take_below: "fd_take n d \<sqsubseteq> d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   510
apply (rule fin_defl_belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   511
apply (simp add: fd_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   512
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   513
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   514
lemma fd_take_idem: "fd_take n (fd_take n d) = fd_take n d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   515
apply (rule fin_defl_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   516
apply (simp add: fd_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   517
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   518
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   519
lemma fd_take_mono: "a \<sqsubseteq> b \<Longrightarrow> fd_take n a \<sqsubseteq> fd_take n b"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   520
apply (rule fin_defl_belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   521
apply (simp add: fd_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   522
apply (simp add: fin_defl_belowD)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   523
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   524
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   525
lemma approx_fixed_le_lemma: "\<lbrakk>i \<le> j; approx i\<cdot>x = x\<rbrakk> \<Longrightarrow> approx j\<cdot>x = x"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   526
apply (rule deflation.belowD)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   527
apply (rule finite_deflation_imp_deflation)
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   528
apply (rule finite_deflation_approx)
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   529
apply (erule chain_mono [OF chain_approx])
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   530
apply assumption
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   531
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   532
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   533
lemma fd_take_chain: "m \<le> n \<Longrightarrow> fd_take m a \<sqsubseteq> fd_take n a"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   534
apply (rule fin_defl_belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   535
apply (simp add: fd_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   536
apply (simp add: approx_fixed_le_lemma)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   537
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   538
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   539
lemma finite_range_fd_take: "finite (range (fd_take n))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   540
apply (rule finite_imageD [where f="\<lambda>a. {x. Rep_fin_defl a\<cdot>x = x}"])
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   541
apply (rule finite_subset [where B="Pow {x. approx n\<cdot>x = x}"])
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   542
apply (clarify, simp add: fd_take_fixed_iff)
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   543
apply (simp add: finite_deflation.finite_fixes [OF finite_deflation_approx])
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   544
apply (rule inj_onI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   545
apply (simp add: set_eq_iff fin_defl_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   546
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   547
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   548
lemma fd_take_covers: "\<exists>n. fd_take n a = a"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   549
apply (rule_tac x=
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   550
  "Max ((\<lambda>x. LEAST n. approx n\<cdot>x = x) ` {x. Rep_fin_defl a\<cdot>x = x})" in exI)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   551
apply (rule below_antisym)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   552
apply (rule fd_take_below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   553
apply (rule fin_defl_belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   554
apply (simp add: fd_take_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   555
apply (rule approx_fixed_le_lemma)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   556
apply (rule Max_ge)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   557
apply (rule finite_imageI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   558
apply (rule Rep_fin_defl.finite_fixes)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   559
apply (rule imageI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   560
apply (erule CollectI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   561
apply (rule LeastI_ex)
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   562
apply (rule compact_eq_approx)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   563
apply (erule subst)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   564
apply (rule Rep_fin_defl.compact)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   565
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   566
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   567
subsection {* Chain of approx functions on algebraic deflations *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   568
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   569
definition
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   570
  defl_approx :: "nat \<Rightarrow> 'a defl \<rightarrow> 'a defl"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   571
where
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41292
diff changeset
   572
  "defl_approx = (\<lambda>i. defl.extension (\<lambda>d. defl_principal (fd_take i d)))"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   573
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   574
lemma defl_approx_principal:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   575
  "defl_approx i\<cdot>(defl_principal d) = defl_principal (fd_take i d)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   576
unfolding defl_approx_def
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41292
diff changeset
   577
by (simp add: defl.extension_principal fd_take_mono)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   578
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   579
lemma defl_approx: "approx_chain defl_approx"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   580
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   581
  show chain: "chain defl_approx"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   582
    unfolding defl_approx_def
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41292
diff changeset
   583
    by (simp add: chainI defl.extension_mono fd_take_mono fd_take_chain)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   584
  show idem: "\<And>i x. defl_approx i\<cdot>(defl_approx i\<cdot>x) = defl_approx i\<cdot>x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   585
    apply (induct_tac x rule: defl.principal_induct, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   586
    apply (simp add: defl_approx_principal fd_take_idem)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   587
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   588
  show below: "\<And>i x. defl_approx i\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   589
    apply (induct_tac x rule: defl.principal_induct, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   590
    apply (simp add: defl_approx_principal fd_take_below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   591
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   592
  show lub: "(\<Squnion>i. defl_approx i) = ID"
40002
c5b5f7a3a3b1 new theorem names: fun_below_iff, fun_belowI, cfun_eq_iff, cfun_eqI, cfun_below_iff, cfun_belowI
huffman
parents: 39999
diff changeset
   593
    apply (rule cfun_eqI, rule below_antisym)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   594
    apply (simp add: contlub_cfun_fun chain lub_below_iff chain below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   595
    apply (induct_tac x rule: defl.principal_induct, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   596
    apply (simp add: contlub_cfun_fun chain)
41394
51c866d1b53b rename function ideal_completion.basis_fun to ideal_completion.extension
huffman
parents: 41292
diff changeset
   597
    apply (simp add: compact_below_lub_iff chain)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   598
    apply (simp add: defl_approx_principal)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   599
    apply (subgoal_tac "\<exists>i. fd_take i a = a", metis below_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   600
    apply (rule fd_take_covers)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   601
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   602
  show "\<And>i. finite {x. defl_approx i\<cdot>x = x}"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   603
    apply (rule finite_range_imp_finite_fixes)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   604
    apply (rule_tac B="defl_principal ` range (fd_take i)" in rev_finite_subset)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   605
    apply (simp add: finite_range_fd_take)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   606
    apply (clarsimp, rename_tac x)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   607
    apply (induct_tac x rule: defl.principal_induct)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   608
    apply (simp add: adm_mem_finite finite_range_fd_take)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   609
    apply (simp add: defl_approx_principal)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   610
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   611
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   612
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   613
end
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   614
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   615
subsection {* Algebraic deflations are a bifinite domain *}
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   616
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   617
instance defl :: (bifinite) bifinite
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   618
proof
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   619
  obtain a :: "nat \<Rightarrow> 'a \<rightarrow> 'a" where "approx_chain a"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   620
    using bifinite ..
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   621
  hence "bifinite_approx_chain a"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   622
    unfolding bifinite_approx_chain_def .
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   623
  thus "\<exists>(a::nat \<Rightarrow> 'a defl \<rightarrow> 'a defl). approx_chain a"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   624
    by (fast intro: bifinite_approx_chain.defl_approx)
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   625
qed
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   626
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   627
subsection {* Algebraic deflations are representable *}
41286
3d7685a4a5ff reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents: 40774
diff changeset
   628
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   629
definition defl_approx :: "nat \<Rightarrow> 'a::bifinite defl \<rightarrow> 'a defl"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   630
  where "defl_approx = bifinite_approx_chain.defl_approx
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   631
    (SOME a. approx_chain a)"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   632
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   633
lemma defl_approx: "approx_chain defl_approx"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   634
unfolding defl_approx_def
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   635
apply (rule bifinite_approx_chain.defl_approx)
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   636
apply (unfold bifinite_approx_chain_def)
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   637
apply (rule someI_ex [OF bifinite])
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   638
done
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   639
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   640
instantiation defl :: (bifinite) "domain"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   641
begin
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   642
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   643
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   644
  "emb = udom_emb defl_approx"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   645
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   646
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   647
  "prj = udom_prj defl_approx"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   648
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   649
definition
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   650
  "defl (t::'a defl itself) =
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   651
    (\<Squnion>i. defl_principal (Abs_fin_defl (emb oo defl_approx i oo prj)))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   652
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   653
definition
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   654
  "(liftemb :: 'a defl u \<rightarrow> udom u) = u_map\<cdot>emb"
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   655
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   656
definition
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   657
  "(liftprj :: udom u \<rightarrow> 'a defl u) = u_map\<cdot>prj"
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   658
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   659
definition
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   660
  "liftdefl (t::'a defl itself) = pdefl\<cdot>DEFL('a defl)"
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   661
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   662
instance proof
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   663
  show ep: "ep_pair emb (prj :: udom \<rightarrow> 'a defl)"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   664
    unfolding emb_defl_def prj_defl_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   665
    by (rule ep_pair_udom [OF defl_approx])
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   666
  show "cast\<cdot>DEFL('a defl) = emb oo (prj :: udom \<rightarrow> 'a defl)"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   667
    unfolding defl_defl_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   668
    apply (subst contlub_cfun_arg)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   669
    apply (rule chainI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   670
    apply (rule defl.principal_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   671
    apply (simp add: below_fin_defl_def)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   672
    apply (simp add: Abs_fin_defl_inverse approx_chain.finite_deflation_approx [OF defl_approx]
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   673
                     ep_pair.finite_deflation_e_d_p [OF ep])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   674
    apply (intro monofun_cfun below_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   675
    apply (rule chainE)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   676
    apply (rule approx_chain.chain_approx [OF defl_approx])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   677
    apply (subst cast_defl_principal)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   678
    apply (simp add: Abs_fin_defl_inverse approx_chain.finite_deflation_approx [OF defl_approx]
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   679
                     ep_pair.finite_deflation_e_d_p [OF ep])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   680
    apply (simp add: lub_distribs approx_chain.chain_approx [OF defl_approx]
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   681
                     approx_chain.lub_approx [OF defl_approx])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   682
    done
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   683
qed (fact liftemb_defl_def liftprj_defl_def liftdefl_defl_def)+
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   684
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   685
end
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   686
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   687
end