src/HOL/HOLCF/Library/Defl_Bifinite.thy
author immler
Sun, 27 Oct 2019 21:51:14 -0400
changeset 71035 6fe5a0e1fa8e
parent 66453 cc19f7ca2ed6
permissions -rw-r--r--
moved theory Interval from the AFP
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41533
diff changeset
     1
(*  Title:      HOL/HOLCF/Library/Defl_Bifinite.thy
39999
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
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
     5
section \<open>Algebraic deflations are a bifinite domain\<close>
39999
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
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 62175
diff changeset
     8
imports HOLCF "HOL-Library.Infinite_Set"
39999
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
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    11
subsection \<open>Lemmas about MOST\<close>
39999
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
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    15
subsection \<open>Eventually constant sequences\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    16
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    17
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    18
  eventually_constant :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    19
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    20
  "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
    21
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    22
lemma eventually_constant_MOST_MOST:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    23
  "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
    24
unfolding eventually_constant_def MOST_nat
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    25
apply safe
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    26
apply (rule_tac x=m in exI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    27
apply (rule_tac x=m in exI, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    28
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    29
apply fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    30
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    31
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    32
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
    33
unfolding eventually_constant_def by fast
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    34
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    35
lemma eventually_constant_comp:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    36
  "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
    37
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    38
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
    39
apply (erule MOST_mono, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    40
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    41
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    42
lemma eventually_constant_Suc_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    43
  "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
    44
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    45
by (subst MOST_Suc_iff, rule refl)
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
lemma eventually_constant_SucD:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    48
  "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
    49
by (rule eventually_constant_Suc_iff [THEN iffD1])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    50
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
    51
subsection \<open>Limits of eventually constant sequences\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    52
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    53
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    54
  eventual :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a" where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    55
  "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
    56
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    57
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
    58
unfolding eventual_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    59
apply (rule the_equality, assumption)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    60
apply (rename_tac y)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    61
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
    62
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    63
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    64
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    65
done
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 MOST_eq_eventual:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    68
  "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
    69
unfolding eventually_constant_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    70
by (erule exE, simp add: eventual_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    71
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    72
lemma eventual_mem_range:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    73
  "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
    74
apply (drule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    75
apply (simp only: MOST_nat_le, clarify)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    76
apply (drule spec, drule mp, rule order_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    77
apply (erule range_eqI [OF sym])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    78
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    79
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    80
lemma eventually_constant_MOST_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    81
  assumes S: "eventually_constant S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    82
  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
    83
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
    84
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    85
apply (rule iffI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    86
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
    87
apply (erule MOST_mono, force)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    88
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
    89
apply (erule MOST_mono, simp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    90
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    91
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    92
lemma MOST_eventual:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    93
  "\<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
    94
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    95
  assume "eventually_constant S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    96
  hence "MOST n. S n = eventual S"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    97
    by (rule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    98
  moreover assume "MOST n. P (S n)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
    99
  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
   100
    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
   101
  hence "MOST n::nat. P (eventual S)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   102
    by (rule MOST_mono) auto
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   103
  thus ?thesis by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   104
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   105
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   106
lemma eventually_constant_MOST_Suc_eq:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   107
  "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
   108
apply (drule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   109
apply (frule MOST_Suc_iff [THEN iffD2])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   110
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   111
apply (erule MOST_rev_mp)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   112
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   113
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   114
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   115
lemma eventual_comp:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   116
  "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
   117
apply (rule eventual_eqI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   118
apply (rule MOST_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   119
apply (erule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   120
apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   121
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   122
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   123
subsection \<open>Constructing finite deflations by iteration\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   124
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   125
default_sort cpo
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   126
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   127
lemma le_Suc_induct:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   128
  assumes le: "i \<le> j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   129
  assumes step: "\<And>i. P i (Suc i)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   130
  assumes refl: "\<And>i. P i i"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   131
  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
   132
  shows "P i j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   133
proof (cases "i = j")
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   134
  assume "i = j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   135
  thus "P i j" by (simp add: refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   136
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   137
  assume "i \<noteq> j"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   138
  with le have "i < j" by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   139
  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
   140
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   141
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   142
definition
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   143
  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
   144
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   145
  "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
   146
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   147
text \<open>A pre-deflation is like a deflation, but not idempotent.\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   148
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   149
locale pre_deflation =
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   150
  fixes f :: "'a \<rightarrow> 'a::cpo"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   151
  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
   152
  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
   153
begin
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
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
   156
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
   157
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   158
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
   159
by (induct i, simp_all)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   160
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   161
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
   162
apply (erule le_Suc_induct)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   163
apply (simp add: below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   164
apply (rule below_refl)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   165
apply (erule (1) below_trans)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   166
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   167
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   168
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
   169
proof (rule finite_subset)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   170
  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
   171
    by (clarify, case_tac i, simp_all)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   172
  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
   173
    by (simp add: finite_range)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   174
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   175
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   176
lemma eventually_constant_iterate_app:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   177
  "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
   178
unfolding eventually_constant_def MOST_nat_le
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   179
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   180
  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
   181
  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
   182
    apply (rule finite_range_has_max)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   183
    apply (erule antichain_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   184
    apply (rule finite_range_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   185
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   186
  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
   187
  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
   188
  proof (intro exI allI impI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   189
    fix k
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   190
    assume "j \<le> k"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   191
    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
   192
    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
   193
    finally show "?Y k = ?Y j" .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   194
  qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   195
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   196
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   197
lemma eventually_constant_iterate:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   198
  "eventually_constant (\<lambda>n. iterate n\<cdot>f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   199
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   200
  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
   201
    by (simp add: eventually_constant_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   202
  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
   203
    unfolding eventually_constant_MOST_MOST .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   204
  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
   205
    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
   206
  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
   207
    by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   208
  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
   209
    by (simp only: iterate_Suc2)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   210
  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
   211
    by (simp only: cfun_eq_iff)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   212
  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
   213
    unfolding eventually_constant_MOST_MOST .
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   214
  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
   215
    by (rule eventually_constant_SucD)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   216
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   217
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   218
abbreviation
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   219
  d :: "'a \<rightarrow> 'a"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   220
where
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   221
  "d \<equiv> eventual_iterate f"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   222
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   223
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
   224
unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   225
using eventually_constant_iterate by (rule MOST_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   226
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   227
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
   228
apply (rule MOST_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   229
apply (subst iterate_Suc [symmetric])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   230
apply (rule eventually_constant_MOST_Suc_eq)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   231
apply (rule eventually_constant_iterate_app)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   232
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   233
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   234
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
   235
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   236
  assume "d\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   237
  with f_d [where x=x]
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   238
  show "f\<cdot>x = x" by simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   239
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   240
  assume f: "f\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   241
  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
   242
    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
   243
  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
   244
    by (rule ALL_MOST)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   245
  thus "d\<cdot>x = x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   246
    by (rule MOST_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   247
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   248
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   249
lemma finite_deflation_d: "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   250
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   251
  fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   252
  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
   253
    unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   254
    using eventually_constant_iterate
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   255
    by (rule eventual_mem_range)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   256
  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
   257
  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
   258
    using f_d by (rule iterate_fixed)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   259
  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
   260
    by (simp add: n)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   261
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   262
  fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   263
  show "d\<cdot>x \<sqsubseteq> x"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   264
    by (rule MOST_d, simp add: iterate_below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   265
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   266
  from finite_range
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   267
  have "finite {x. f\<cdot>x = x}"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   268
    by (rule finite_range_imp_finite_fixes)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   269
  thus "finite {x. d\<cdot>x = x}"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   270
    by (simp add: d_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   271
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   272
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   273
lemma deflation_d: "deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   274
using finite_deflation_d
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   275
by (rule finite_deflation_imp_deflation)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   276
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   277
end
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   278
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   279
lemma finite_deflation_eventual_iterate:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   280
  "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
   281
by (rule pre_deflation.finite_deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   282
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   283
lemma pre_deflation_oo:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   284
  assumes "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   285
  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
   286
  shows "pre_deflation (d oo f)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   287
proof
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   288
  interpret d: finite_deflation d by fact
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   289
  fix x
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   290
  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
   291
    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
   292
  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
   293
    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
   294
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   295
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   296
lemma eventual_iterate_oo_fixed_iff:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   297
  assumes "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   298
  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
   299
  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
   300
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   301
  interpret d: finite_deflation d by fact
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   302
  let ?e = "d oo f"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   303
  interpret e: pre_deflation "d oo f"
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   304
    using \<open>finite_deflation d\<close> f
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   305
    by (rule pre_deflation_oo)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   306
  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
   307
  show ?thesis
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   308
    apply (subst e.d_fixed_iff)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   309
    apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   310
    apply safe
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   311
    apply (erule subst)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   312
    apply (rule d.idem)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   313
    apply (rule below_antisym)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   314
    apply (rule f)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   315
    apply (erule subst, rule d.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   316
    apply simp
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   317
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   318
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   319
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   320
lemma eventual_mono:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   321
  assumes A: "eventually_constant A"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   322
  assumes B: "eventually_constant B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   323
  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
   324
  shows "eventual A \<sqsubseteq> eventual B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   325
proof -
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   326
  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
   327
    by (rule MOST_eq_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   328
  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
   329
    by (rule MOST_mono) (erule subst, rule below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   330
  with B show "eventual A \<sqsubseteq> eventual B"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   331
    by (rule MOST_eventual)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   332
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   333
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   334
lemma eventual_iterate_mono:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   335
  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
   336
  shows "eventual_iterate f \<sqsubseteq> eventual_iterate g"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   337
unfolding eventual_iterate_def
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   338
apply (rule eventual_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   339
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
   340
apply (rule pre_deflation.eventually_constant_iterate [OF g])
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   341
apply (rule monofun_cfun_arg [OF \<open>f \<sqsubseteq> g\<close>])
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   342
done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   343
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   344
lemma cont2cont_eventual_iterate_oo:
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   345
  assumes d: "finite_deflation d"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   346
  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
   347
  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
   348
    (is "cont ?e")
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   349
proof (rule contI2)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   350
  show "monofun ?e"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   351
    apply (rule monofunI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   352
    apply (rule eventual_iterate_mono)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   353
    apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   354
    apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   355
    apply (rule monofun_cfun_arg)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   356
    apply (erule cont2monofunE [OF cont])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   357
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   358
next
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   359
  fix Y :: "nat \<Rightarrow> 'b"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   360
  assume Y: "chain Y"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   361
  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
   362
    by (rule ch2ch_cont)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   363
  assume eY: "chain (\<lambda>i. ?e (Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   364
  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
   365
    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
   366
  have "deflation (?e (\<Squnion>i. Y i))"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   367
    apply (rule pre_deflation.deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   368
    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
   369
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   370
  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
   371
  proof (rule deflation.belowI)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   372
    fix x :: 'a
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   373
    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
   374
    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
   375
      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
   376
    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
   377
      apply (simp only: cont2contlubE [OF cont Y])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   378
      apply (simp only: contlub_cfun_fun [OF fY])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   379
      done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   380
    have "compact (d\<cdot>x)"
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   381
      using d by (rule finite_deflation.compact)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   382
    then have "compact x"
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   383
      using \<open>d\<cdot>x = x\<close> by simp
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   384
    then have "compact (\<Squnion>i. f (Y i)\<cdot>x)"
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   385
      using \<open>(\<Squnion>i. f (Y i)\<cdot>x) = x\<close> by simp
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   386
    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
   387
      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
   388
    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
   389
    then have "f (Y n)\<cdot>x = x"
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   390
      using \<open>(\<Squnion>i. f (Y i)\<cdot>x) = x\<close> fY by (simp add: maxinch_is_thelub)
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   391
    with \<open>d\<cdot>x = x\<close> have "?e (Y n)\<cdot>x = x"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   392
      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
   393
    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
   394
      by (rule is_ub_thelub, simp add: eY)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   395
    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
   396
      by (simp add: contlub_cfun_fun eY)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   397
    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
   398
      apply (rule deflation.below)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   399
      apply (rule admD [OF adm_deflation eY])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   400
      apply (rule pre_deflation.deflation_d)
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   401
      apply (rule pre_deflation_oo [OF d below])
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   402
      done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   403
    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
   404
  qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   405
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   406
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   407
subsection \<open>Intersection of algebraic deflations\<close>
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   408
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   409
default_sort bifinite
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   410
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   411
definition meet_fin_defl :: "'a fin_defl \<Rightarrow> 'a fin_defl \<Rightarrow> 'a fin_defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   412
  where "meet_fin_defl a b =
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   413
    Abs_fin_defl (eventual_iterate (Rep_fin_defl a oo Rep_fin_defl b))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   414
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   415
lemma Rep_meet_fin_defl:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   416
  "Rep_fin_defl (meet_fin_defl a b) =
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   417
    eventual_iterate (Rep_fin_defl a oo Rep_fin_defl b)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   418
unfolding meet_fin_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   419
apply (rule Abs_fin_defl_inverse [simplified])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   420
apply (rule finite_deflation_eventual_iterate)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   421
apply (rule pre_deflation_oo)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   422
apply (rule finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   423
apply (rule Rep_fin_defl.below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   424
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   425
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   426
lemma Rep_meet_fin_defl_fixed_iff:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   427
  "Rep_fin_defl (meet_fin_defl a b)\<cdot>x = x \<longleftrightarrow>
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   428
    Rep_fin_defl a\<cdot>x = x \<and> Rep_fin_defl b\<cdot>x = x"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   429
unfolding Rep_meet_fin_defl
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   430
apply (rule eventual_iterate_oo_fixed_iff)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   431
apply (rule finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   432
apply (rule Rep_fin_defl.below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   433
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   434
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   435
lemma meet_fin_defl_mono:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   436
  "\<lbrakk>a \<sqsubseteq> b; c \<sqsubseteq> d\<rbrakk> \<Longrightarrow> meet_fin_defl a c \<sqsubseteq> meet_fin_defl b d"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   437
unfolding below_fin_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   438
apply (rule Rep_fin_defl.belowI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   439
apply (simp add: Rep_meet_fin_defl_fixed_iff Rep_fin_defl.belowD)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   440
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   441
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   442
lemma meet_fin_defl_below1: "meet_fin_defl a b \<sqsubseteq> a"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   443
unfolding below_fin_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   444
apply (rule Rep_fin_defl.belowI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   445
apply (simp add: Rep_meet_fin_defl_fixed_iff Rep_fin_defl.belowD)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   446
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   447
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   448
lemma meet_fin_defl_below2: "meet_fin_defl a b \<sqsubseteq> b"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   449
unfolding below_fin_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   450
apply (rule Rep_fin_defl.belowI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   451
apply (simp add: Rep_meet_fin_defl_fixed_iff Rep_fin_defl.belowD)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   452
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   453
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   454
lemma meet_fin_defl_greatest: "\<lbrakk>a \<sqsubseteq> b; a \<sqsubseteq> c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> meet_fin_defl b c"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   455
unfolding below_fin_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   456
apply (rule Rep_fin_defl.belowI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   457
apply (simp add: Rep_meet_fin_defl_fixed_iff Rep_fin_defl.belowD)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   458
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   459
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   460
definition meet_defl :: "'a defl \<rightarrow> 'a defl \<rightarrow> 'a defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   461
  where "meet_defl = defl.extension (\<lambda>a. defl.extension (\<lambda>b.
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   462
    defl_principal (meet_fin_defl a b)))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   463
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   464
lemma meet_defl_principal:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   465
  "meet_defl\<cdot>(defl_principal a)\<cdot>(defl_principal b) =
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   466
    defl_principal (meet_fin_defl a b)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   467
unfolding meet_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   468
by (simp add: defl.extension_principal defl.extension_mono meet_fin_defl_mono)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   469
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   470
lemma meet_defl_below1: "meet_defl\<cdot>a\<cdot>b \<sqsubseteq> a"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   471
apply (induct a rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   472
apply (induct b rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   473
apply (simp add: meet_defl_principal meet_fin_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   474
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   475
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   476
lemma meet_defl_below2: "meet_defl\<cdot>a\<cdot>b \<sqsubseteq> b"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   477
apply (induct a rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   478
apply (induct b rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   479
apply (simp add: meet_defl_principal meet_fin_defl_below2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   480
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   481
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   482
lemma meet_defl_greatest: "\<lbrakk>a \<sqsubseteq> b; a \<sqsubseteq> c\<rbrakk> \<Longrightarrow> a \<sqsubseteq> meet_defl\<cdot>b\<cdot>c"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   483
apply (induct a rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   484
apply (induct b rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   485
apply (induct c rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   486
apply (simp add: meet_defl_principal meet_fin_defl_greatest)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   487
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   488
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   489
lemma meet_defl_eq2: "b \<sqsubseteq> a \<Longrightarrow> meet_defl\<cdot>a\<cdot>b = b"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   490
by (fast intro: below_antisym meet_defl_below2 meet_defl_greatest)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   491
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   492
interpretation meet_defl: semilattice "\<lambda>a b. meet_defl\<cdot>a\<cdot>b"
61169
4de9ff3ea29a tuned proofs -- less legacy;
wenzelm
parents: 60040
diff changeset
   493
by standard
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   494
  (fast intro: below_antisym meet_defl_greatest
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   495
   meet_defl_below1 [THEN below_trans] meet_defl_below2 [THEN below_trans])+
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   496
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   497
lemma deflation_meet_defl: "deflation (meet_defl\<cdot>a)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   498
apply (rule deflation.intro)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   499
apply (rule meet_defl.left_idem)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   500
apply (rule meet_defl_below2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   501
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   502
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   503
lemma finite_deflation_meet_defl:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   504
  assumes "compact a"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   505
  shows "finite_deflation (meet_defl\<cdot>a)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   506
proof (rule finite_deflation_intro)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   507
  obtain d where a: "a = defl_principal d"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   508
    using defl.compact_imp_principal [OF assms] ..
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   509
  have "finite (defl_set -` Pow (defl_set a))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   510
    apply (rule finite_vimageI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   511
    apply (rule finite_Pow_iff [THEN iffD2])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   512
    apply (simp add: defl_set_def a cast_defl_principal Abs_fin_defl_inverse)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   513
    apply (rule Rep_fin_defl.finite_fixes)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   514
    apply (rule injI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   515
    apply (simp add: po_eq_conv defl_set_subset_iff [symmetric])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   516
    done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   517
  hence "finite (range (\<lambda>b. meet_defl\<cdot>a\<cdot>b))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   518
    apply (rule rev_finite_subset)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   519
    apply (clarsimp, erule rev_subsetD)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   520
    apply (simp add: defl_set_subset_iff meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   521
    done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   522
  thus "finite {b. meet_defl\<cdot>a\<cdot>b = b}"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   523
    by (rule finite_range_imp_finite_fixes)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   524
qed (rule deflation_meet_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   525
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   526
lemma compact_iff_finite_deflation_cast:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   527
  "compact d \<longleftrightarrow> finite_deflation (cast\<cdot>d)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   528
apply (safe dest!: defl.compact_imp_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   529
apply (simp add: cast_defl_principal finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   530
apply (rule compact_cast_iff [THEN iffD1])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   531
apply (erule finite_deflation_imp_compact)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   532
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   534
lemma compact_iff_finite_defl_set:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   535
  "compact d \<longleftrightarrow> finite (defl_set d)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   536
by (simp add: compact_iff_finite_deflation_cast defl_set_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   537
  finite_deflation_def deflation_cast finite_deflation_axioms_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   538
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   539
lemma compact_meet_defl1: "compact a \<Longrightarrow> compact (meet_defl\<cdot>a\<cdot>b)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   540
apply (simp add: compact_iff_finite_defl_set)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   541
apply (erule rev_finite_subset)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   542
apply (simp add: defl_set_subset_iff meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   543
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   544
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   545
lemma compact_meet_defl2: "compact b \<Longrightarrow> compact (meet_defl\<cdot>a\<cdot>b)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   546
by (subst meet_defl.commute, rule compact_meet_defl1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   547
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   548
subsection \<open>Chain of approx functions on algebraic deflations\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   549
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   550
context bifinite_approx_chain
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   551
begin
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   552
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   553
definition defl_approx :: "nat \<Rightarrow> 'a defl \<rightarrow> 'a defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   554
  where "defl_approx i = meet_defl\<cdot>(defl_principal (Abs_fin_defl (approx i)))"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   555
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   556
lemma defl_approx: "approx_chain defl_approx"
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   557
proof (rule approx_chain.intro)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   558
  have chain1: "chain (\<lambda>i. defl_principal (Abs_fin_defl (approx i)))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   559
    apply (rule chainI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   560
    apply (rule defl.principal_mono)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   561
    apply (simp add: below_fin_defl_def Abs_fin_defl_inverse)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   562
    apply (rule chainE [OF chain_approx])
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   563
    done
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   564
  show chain: "chain (\<lambda>i. defl_approx i)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   565
    unfolding defl_approx_def by (simp add: chain1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   566
  have below: "\<And>i d. defl_approx i\<cdot>d \<sqsubseteq> d"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   567
    unfolding defl_approx_def by (rule meet_defl_below2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   568
  show "(\<Squnion>i. defl_approx i) = ID"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   569
    apply (rule cfun_eqI, rename_tac d, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   570
    apply (rule below_antisym)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   571
    apply (simp add: contlub_cfun_fun chain)
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   572
    apply (simp add: lub_below chain below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   573
    apply (simp add: defl_approx_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   574
    apply (simp add: lub_distribs chain1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   575
    apply (rule meet_defl_greatest [OF _ below_refl])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   576
    apply (rule cast_below_imp_below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   577
    apply (simp add: contlub_cfun_arg chain1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   578
    apply (simp add: cast_defl_principal Abs_fin_defl_inverse)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   579
    apply (rule cast.below_ID)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   580
    done
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   581
  show "\<And>i. finite_deflation (defl_approx i)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   582
    unfolding defl_approx_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   583
    apply (rule finite_deflation_meet_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   584
    apply (rule defl.compact_principal)
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   585
    done
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   586
qed
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   587
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   588
end
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   589
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   590
subsection \<open>Algebraic deflations are a bifinite domain\<close>
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   591
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   592
instance defl :: (bifinite) bifinite
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   593
proof
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   594
  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
   595
    using bifinite ..
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   596
  hence "bifinite_approx_chain a"
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   597
    unfolding bifinite_approx_chain_def .
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   598
  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
   599
    by (fast intro: bifinite_approx_chain.defl_approx)
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   600
qed
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   601
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 61169
diff changeset
   602
subsection \<open>Algebraic deflations are representable\<close>
41286
3d7685a4a5ff reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents: 40774
diff changeset
   603
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   604
default_sort "domain"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   605
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   606
definition defl_emb :: "udom defl \<rightarrow> udom"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   607
  where "defl_emb = udom_emb (bifinite_approx_chain.defl_approx udom_approx)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   608
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   609
definition defl_prj :: "udom \<rightarrow> udom defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   610
  where "defl_prj = udom_prj (bifinite_approx_chain.defl_approx udom_approx)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   611
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   612
lemma ep_pair_defl: "ep_pair defl_emb defl_prj"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   613
unfolding defl_emb_def defl_prj_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   614
apply (rule ep_pair_udom)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   615
apply (rule bifinite_approx_chain.defl_approx)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   616
apply (simp add: bifinite_approx_chain_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   617
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   618
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   619
text "Deflation combinator for deflation type constructor"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   620
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   621
definition defl_defl :: "udom defl \<rightarrow> udom defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   622
  where defl_deflation_def:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   623
  "defl_defl = defl.extension (\<lambda>a. defl_principal
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   624
    (Abs_fin_defl (defl_emb oo meet_defl\<cdot>(defl_principal a) oo defl_prj)))"
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   625
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   626
lemma cast_defl_defl:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   627
  "cast\<cdot>(defl_defl\<cdot>a) = defl_emb oo meet_defl\<cdot>a oo defl_prj"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   628
apply (induct a rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   629
apply (subst defl_deflation_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   630
apply (subst defl.extension_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   631
apply (simp add: below_fin_defl_def Abs_fin_defl_inverse
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   632
  ep_pair.finite_deflation_e_d_p ep_pair_defl
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   633
  finite_deflation_meet_defl monofun_cfun)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   634
apply (simp add: cast_defl_principal
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   635
  below_fin_defl_def Abs_fin_defl_inverse
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   636
  ep_pair.finite_deflation_e_d_p ep_pair_defl
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   637
  finite_deflation_meet_defl monofun_cfun)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   638
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   639
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   640
definition defl_map_emb :: "'a::domain defl \<rightarrow> udom defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   641
  where "defl_map_emb = defl_fun1 emb prj ID"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   642
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   643
definition defl_map_prj :: "udom defl \<rightarrow> 'a::domain defl"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   644
  where "defl_map_prj = defl.extension (\<lambda>a. defl_principal (Abs_fin_defl (prj oo cast\<cdot>(meet_defl\<cdot>DEFL('a)\<cdot>(defl_principal a)) oo emb)))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   645
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   646
lemma defl_map_emb_principal:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   647
  "defl_map_emb\<cdot>(defl_principal a) =
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   648
    defl_principal (Abs_fin_defl (emb oo Rep_fin_defl a oo prj))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   649
unfolding defl_map_emb_def defl_fun1_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   650
apply (subst defl.extension_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   651
apply (rule defl.principal_mono)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   652
apply (simp add: below_fin_defl_def Abs_fin_defl_inverse monofun_cfun
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   653
       domain.finite_deflation_e_d_p finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   654
apply simp
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   655
done
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   656
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   657
lemma defl_map_prj_principal:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   658
  "(defl_map_prj\<cdot>(defl_principal a) :: 'a::domain defl) =
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   659
  defl_principal (Abs_fin_defl (prj oo cast\<cdot>(meet_defl\<cdot>DEFL('a)\<cdot>(defl_principal a)) oo emb))"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   660
unfolding defl_map_prj_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   661
apply (rule defl.extension_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   662
apply (rule defl.principal_mono)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   663
apply (simp add: below_fin_defl_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   664
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   665
apply (rule domain.finite_deflation_p_d_e)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   666
apply (rule finite_deflation_cast)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   667
apply (simp add: compact_meet_defl2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   668
apply (subst emb_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   669
apply (intro monofun_cfun below_refl meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   670
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   671
apply (rule domain.finite_deflation_p_d_e)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   672
apply (rule finite_deflation_cast)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   673
apply (simp add: compact_meet_defl2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   674
apply (subst emb_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   675
apply (intro monofun_cfun below_refl meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   676
apply (simp add: monofun_cfun below_fin_defl_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   677
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   678
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   679
lemma defl_map_prj_defl_map_emb: "defl_map_prj\<cdot>(defl_map_emb\<cdot>d) = d"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   680
apply (rule cast_eq_imp_eq)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   681
apply (induct_tac d rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   682
apply (subst defl_map_emb_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   683
apply (subst defl_map_prj_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   684
apply (simp add: cast_defl_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   685
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   686
apply (rule domain.finite_deflation_p_d_e)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   687
apply (rule finite_deflation_cast)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   688
apply (simp add: compact_meet_defl2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   689
apply (subst emb_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   690
apply (intro monofun_cfun below_refl meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   691
apply (subst meet_defl_eq2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   692
apply (rule cast_below_imp_below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   693
apply (simp add: cast_DEFL)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   694
apply (simp add: cast_defl_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   695
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   696
apply (rule domain.finite_deflation_e_d_p)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   697
apply (rule finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   698
apply (rule cfun_belowI, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   699
apply (rule Rep_fin_defl.below)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   700
apply (simp add: cast_defl_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   701
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   702
apply (rule domain.finite_deflation_e_d_p)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   703
apply (rule finite_deflation_Rep_fin_defl)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   704
apply (simp add: cfun_eqI)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   705
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   706
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   707
lemma defl_map_emb_defl_map_prj:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   708
  "defl_map_emb\<cdot>(defl_map_prj\<cdot>d :: 'a defl) = meet_defl\<cdot>DEFL('a)\<cdot>d"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   709
apply (induct_tac d rule: defl.principal_induct, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   710
apply (subst defl_map_prj_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   711
apply (subst defl_map_emb_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   712
apply (subst Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   713
apply (rule domain.finite_deflation_p_d_e)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   714
apply (rule finite_deflation_cast)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   715
apply (simp add: compact_meet_defl2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   716
apply (subst emb_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   717
apply (intro monofun_cfun below_refl meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   718
apply (rule cast_eq_imp_eq)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   719
apply (subst cast_defl_principal)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   720
apply (simp add: cfcomp1 emb_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   721
apply (subst deflation_below_comp2 [OF deflation_cast deflation_cast])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   722
apply (rule monofun_cfun_arg, rule meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   723
apply (subst deflation_below_comp1 [OF deflation_cast deflation_cast])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   724
apply (rule monofun_cfun_arg, rule meet_defl_below1)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   725
apply (simp add: eta_cfun)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   726
apply (rule Abs_fin_defl_inverse, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   727
apply (rule finite_deflation_cast)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   728
apply (rule compact_meet_defl2, simp)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   729
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   730
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   731
lemma ep_pair_defl_map_emb_defl_map_prj:
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   732
  "ep_pair defl_map_emb defl_map_prj"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   733
apply (rule ep_pair.intro)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   734
apply (rule defl_map_prj_defl_map_emb)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   735
apply (simp add: defl_map_emb_defl_map_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   736
apply (rule meet_defl_below2)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   737
done
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   738
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   739
instantiation defl :: ("domain") "domain"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   740
begin
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   741
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   742
definition
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   743
  "emb = defl_emb oo defl_map_emb"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   744
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   745
definition
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   746
  "prj = defl_map_prj oo defl_prj"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   747
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   748
definition
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   749
  "defl (t::'a defl itself) = defl_defl\<cdot>DEFL('a)"
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   750
40491
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   751
definition
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   752
  "(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
   753
6de5839e2fb3 add 'predomain' class: unpointed version of bifinite
huffman
parents: 40002
diff changeset
   754
definition
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   755
  "(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
   756
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   757
definition
41436
480978f80eae rename constant pdefl to liftdefl_of
huffman
parents: 41394
diff changeset
   758
  "liftdefl (t::'a defl itself) = liftdefl_of\<cdot>DEFL('a defl)"
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   759
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   760
instance proof
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   761
  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
   762
    unfolding emb_defl_def prj_defl_def
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   763
    apply (rule ep_pair_comp [OF _ ep_pair_defl])
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   764
    apply (rule ep_pair_defl_map_emb_defl_map_prj)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   765
    done
41287
029a6fc1bfb8 type 'defl' takes a type parameter again (cf. b525988432e9)
huffman
parents: 41286
diff changeset
   766
  show "cast\<cdot>DEFL('a defl) = emb oo (prj :: udom \<rightarrow> 'a defl)"
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   767
    unfolding defl_defl_def emb_defl_def prj_defl_def
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   768
    by (simp add: cast_defl_defl cfcomp1 defl_map_emb_defl_map_prj)
41292
2b7bc8d9fd6e use deflations over type 'udom u' to represent predomains;
huffman
parents: 41290
diff changeset
   769
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
   770
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   771
end
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   772
41533
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   773
lemma DEFL_defl [domain_defl_simps]: "DEFL('a defl) = defl_defl\<cdot>DEFL('a)"
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   774
by (rule defl_defl_def)
869b5ea478b0 proper 'domain' class instance for 'a defl, with deflation combinator
huffman
parents: 41477
diff changeset
   775
39999
e3948547b541 add HOLCF/Library/Defl_Bifinite.thy, which proves instance defl :: bifinite
huffman
parents:
diff changeset
   776
end