src/HOL/HOLCF/Cpodef.thy
author haftmann
Thu, 19 Jun 2025 17:15:40 +0200
changeset 82734 89347c0cc6a3
parent 81585 adbd2e1407cc
permissions -rw-r--r--
treat map_filter similar to list_all, list_ex, list_ex1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42151
4da4fc77664b tuned headers;
wenzelm
parents: 41430
diff changeset
     1
(*  Title:      HOL/HOLCF/Cpodef.thy
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     3
*)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     4
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
     5
section \<open>Subtypes of pcpos\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     6
40772
c8b52f9e1680 rename Pcpodef.thy to Cpodef.thy;
huffman
parents: 40771
diff changeset
     7
theory Cpodef
81575
cb57350beaa9 fewer theories;
wenzelm
parents: 69913
diff changeset
     8
  imports Cpo
69913
ca515cf61651 more specific keyword kinds;
wenzelm
parents: 69605
diff changeset
     9
  keywords "pcpodef" "cpodef" :: thy_goal_defn
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    10
begin
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    11
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    12
subsection \<open>Proving a subtype is a partial order\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    13
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    14
text \<open>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    15
  A subtype of a partial order is itself a partial order,
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    16
  if the ordering is defined in the standard way.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    17
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    18
81584
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    19
theorem (in below) typedef_class_po:
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    20
  fixes Abs :: "'b::po \<Rightarrow> 'a"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    21
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    22
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
81584
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    23
  shows "class.po below"
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    24
  apply (rule class.po.intro)
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    25
  apply (unfold below)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    26
    apply (rule below_refl)
81585
adbd2e1407cc tuned proofs;
wenzelm
parents: 81584
diff changeset
    27
   apply (fact below_trans)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    28
  apply (rule type_definition.Rep_inject [OF type, THEN iffD1])
81585
adbd2e1407cc tuned proofs;
wenzelm
parents: 81584
diff changeset
    29
  apply (fact below_antisym)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    30
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    31
81584
a065d8bcfd3d clarified class/locale reasoning: avoid side-stepping constraints;
wenzelm
parents: 81575
diff changeset
    32
lemmas typedef_po_class = below.typedef_class_po [THEN po.intro_of_class]
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    33
28073
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    34
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    35
subsection \<open>Proving a subtype is finite\<close>
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    36
27296
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    37
lemma typedef_finite_UNIV:
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    38
  fixes Abs :: "'a::type \<Rightarrow> 'b::type"
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    39
  assumes type: "type_definition Rep Abs A"
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    40
  shows "finite A \<Longrightarrow> finite (UNIV :: 'b set)"
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    41
proof -
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    42
  assume "finite A"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    43
  then have "finite (Abs ` A)"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    44
    by (rule finite_imageI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    45
  then show "finite (UNIV :: 'b set)"
27296
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    46
    by (simp only: type_definition.Abs_image [OF type])
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    47
qed
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    48
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    49
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    50
subsection \<open>Proving a subtype is chain-finite\<close>
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    51
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
    52
lemma ch2ch_Rep:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    53
  assumes below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
    54
  shows "chain S \<Longrightarrow> chain (\<lambda>i. Rep (S i))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    55
  unfolding chain_def below .
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    56
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    57
theorem typedef_chfin:
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    58
  fixes Abs :: "'a::chfin \<Rightarrow> 'b::po"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    59
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    60
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    61
  shows "OFCLASS('b, chfin_class)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    62
  apply intro_classes
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    63
  apply (drule ch2ch_Rep [OF below])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    64
  apply (drule chfin)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    65
  apply (unfold max_in_chain_def)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    66
  apply (simp add: type_definition.Rep_inject [OF type])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    67
  done
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    68
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    69
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    70
subsection \<open>Proving a subtype is complete\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    71
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    72
text \<open>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    73
  A subtype of a cpo is itself a cpo if the ordering is
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    74
  defined in the standard way, and the defining subset
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    75
  is closed with respect to limits of chains.  A set is
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    76
  closed if and only if membership in the set is an
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    77
  admissible predicate.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
    78
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    79
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
    80
lemma typedef_is_lubI:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    81
  assumes below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
    82
  shows "range (\<lambda>i. Rep (S i)) <<| Rep x \<Longrightarrow> range S <<| x"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    83
  by (simp add: is_lub_def is_ub_def below)
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
    84
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
    85
lemma Abs_inverse_lub_Rep:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    86
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    87
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    88
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    89
    and adm:  "adm (\<lambda>x. x \<in> A)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
    90
  shows "chain S \<Longrightarrow> Rep (Abs (\<Squnion>i. Rep (S i))) = (\<Squnion>i. Rep (S i))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    91
  apply (rule type_definition.Abs_inverse [OF type])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    92
  apply (erule admD [OF adm ch2ch_Rep [OF below]])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    93
  apply (rule type_definition.Rep [OF type])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
    94
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    95
40770
6023808b38d4 rename cpodef theorems: lub_foo -> is_lub_foo, thelub_foo -> lub_foo
huffman
parents: 40325
diff changeset
    96
theorem typedef_is_lub:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    97
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    98
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
    99
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   100
    and adm: "adm (\<lambda>x. x \<in> A)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   101
  assumes S: "chain S"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   102
  shows "range S <<| Abs (\<Squnion>i. Rep (S i))"
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
   103
proof -
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   104
  from S have "chain (\<lambda>i. Rep (S i))"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   105
    by (rule ch2ch_Rep [OF below])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   106
  then have "range (\<lambda>i. Rep (S i)) <<| (\<Squnion>i. Rep (S i))"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   107
    by (rule cpo_lubI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   108
  then have "range (\<lambda>i. Rep (S i)) <<| Rep (Abs (\<Squnion>i. Rep (S i)))"
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
   109
    by (simp only: Abs_inverse_lub_Rep [OF type below adm S])
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   110
  then show "range S <<| Abs (\<Squnion>i. Rep (S i))"
40035
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
   111
    by (rule typedef_is_lubI [OF below])
a12d35795cb9 simplify some proofs
huffman
parents: 35900
diff changeset
   112
qed
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   113
45606
b1e1508643b1 eliminated obsolete "standard";
wenzelm
parents: 42151
diff changeset
   114
lemmas typedef_lub = typedef_is_lub [THEN lub_eqI]
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   115
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   116
theorem typedef_cpo:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   117
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   118
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   119
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   120
    and adm: "adm (\<lambda>x. x \<in> A)"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   121
  shows "OFCLASS('b, cpo_class)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   122
proof
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   123
  fix S :: "nat \<Rightarrow> 'b"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   124
  assume "chain S"
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   125
  then have "range S <<| Abs (\<Squnion>i. Rep (S i))"
40770
6023808b38d4 rename cpodef theorems: lub_foo -> is_lub_foo, thelub_foo -> lub_foo
huffman
parents: 40325
diff changeset
   126
    by (rule typedef_is_lub [OF type below adm])
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   127
  then show "\<exists>x. range S <<| x" ..
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   128
qed
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   129
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   130
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   131
subsubsection \<open>Continuity of \emph{Rep} and \emph{Abs}\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   132
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   133
text \<open>For any sub-cpo, the \<^term>\<open>Rep\<close> function is continuous.\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   134
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   135
theorem typedef_cont_Rep:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   136
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   137
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   138
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   139
    and adm: "adm (\<lambda>x. x \<in> A)"
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40774
diff changeset
   140
  shows "cont (\<lambda>x. f x) \<Longrightarrow> cont (\<lambda>x. Rep (f x))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   141
  apply (erule cont_apply [OF _ _ cont_const])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   142
  apply (rule contI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   143
  apply (simp only: typedef_lub [OF type below adm])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   144
  apply (simp only: Abs_inverse_lub_Rep [OF type below adm])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   145
  apply (rule cpo_lubI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   146
  apply (erule ch2ch_Rep [OF below])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   147
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   148
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   149
text \<open>
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   150
  For a sub-cpo, we can make the \<^term>\<open>Abs\<close> function continuous
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   151
  only if we restrict its domain to the defining subset by
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   152
  composing it with another continuous function.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   153
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   154
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   155
theorem typedef_cont_Abs:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   156
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   157
  fixes f :: "'c::cpo \<Rightarrow> 'a::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   158
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   159
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   160
    and adm: "adm (\<lambda>x. x \<in> A)" (* not used *)
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   161
    and f_in_A: "\<And>x. f x \<in> A"
40325
24971566ff4f simplify proof of typedef_cont_Abs
huffman
parents: 40321
diff changeset
   162
  shows "cont f \<Longrightarrow> cont (\<lambda>x. Abs (f x))"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   163
  unfolding cont_def is_lub_def is_ub_def ball_simps below
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   164
  by (simp add: type_definition.Abs_inverse [OF type f_in_A])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   165
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   166
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   167
subsection \<open>Proving subtype elements are compact\<close>
17833
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   168
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   169
theorem typedef_compact:
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   170
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   171
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   172
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
17833
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   173
    and adm: "adm (\<lambda>x. x \<in> A)"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   174
  shows "compact (Rep k) \<Longrightarrow> compact k"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   175
proof (unfold compact_def)
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   176
  have cont_Rep: "cont Rep"
40834
a1249aeff5b6 change cpodef-generated cont_Rep rules to cont2cont format
huffman
parents: 40774
diff changeset
   177
    by (rule typedef_cont_Rep [OF type below adm cont_id])
41182
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41029
diff changeset
   178
  assume "adm (\<lambda>x. Rep k \<notsqsubseteq> x)"
717404c7d59a add notsqsubseteq syntax
huffman
parents: 41029
diff changeset
   179
  with cont_Rep have "adm (\<lambda>x. Rep k \<notsqsubseteq> Rep x)" by (rule adm_subst)
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   180
  then show "adm (\<lambda>x. k \<notsqsubseteq> x)" by (unfold below)
17833
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   181
qed
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   182
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   183
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   184
subsection \<open>Proving a subtype is pointed\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   185
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   186
text \<open>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   187
  A subtype of a cpo has a least element if and only if
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   188
  the defining subset has a least element.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   189
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   190
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   191
theorem typedef_pcpo_generic:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   192
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   193
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   194
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   195
    and z_in_A: "z \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   196
    and z_least: "\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   197
  shows "OFCLASS('b, pcpo_class)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   198
  apply (intro_classes)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   199
  apply (rule_tac x="Abs z" in exI, rule allI)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   200
  apply (unfold below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   201
  apply (subst type_definition.Abs_inverse [OF type z_in_A])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   202
  apply (rule z_least [OF type_definition.Rep [OF type]])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   203
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   204
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   205
text \<open>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   206
  As a special case, a subtype of a pcpo has a least element
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   207
  if the defining subset contains \<^term>\<open>\<bottom>\<close>.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   208
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   209
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   210
theorem typedef_pcpo:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   211
  fixes Abs :: "'a::pcpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   212
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   213
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   214
    and bottom_in_A: "\<bottom> \<in> A"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   215
  shows "OFCLASS('b, pcpo_class)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   216
  by (rule typedef_pcpo_generic [OF type below bottom_in_A], rule minimal)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   217
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   218
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   219
subsubsection \<open>Strictness of \emph{Rep} and \emph{Abs}\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   220
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   221
text \<open>
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   222
  For a sub-pcpo where \<^term>\<open>\<bottom>\<close> is a member of the defining
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   223
  subset, \<^term>\<open>Rep\<close> and \<^term>\<open>Abs\<close> are both strict.
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   224
\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   225
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   226
theorem typedef_Abs_strict:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   227
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   228
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   229
    and bottom_in_A: "\<bottom> \<in> A"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   230
  shows "Abs \<bottom> = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   231
  apply (rule bottomI, unfold below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   232
  apply (simp add: type_definition.Abs_inverse [OF type bottom_in_A])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   233
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   234
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   235
theorem typedef_Rep_strict:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   236
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   237
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   238
    and bottom_in_A: "\<bottom> \<in> A"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   239
  shows "Rep \<bottom> = \<bottom>"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   240
  apply (rule typedef_Abs_strict [OF type below bottom_in_A, THEN subst])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   241
  apply (rule type_definition.Abs_inverse [OF type bottom_in_A])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   242
  done
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   243
40321
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40089
diff changeset
   244
theorem typedef_Abs_bottom_iff:
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   245
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   246
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   247
    and bottom_in_A: "\<bottom> \<in> A"
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   248
  shows "x \<in> A \<Longrightarrow> (Abs x = \<bottom>) = (x = \<bottom>)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   249
  apply (rule typedef_Abs_strict [OF type below bottom_in_A, THEN subst])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   250
  apply (simp add: type_definition.Abs_inject [OF type] bottom_in_A)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   251
  done
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   252
40321
d065b195ec89 rename lemmas *_defined_iff and *_strict_iff to *_bottom_iff
huffman
parents: 40089
diff changeset
   253
theorem typedef_Rep_bottom_iff:
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   254
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   255
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   256
    and bottom_in_A: "\<bottom> \<in> A"
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   257
  shows "(Rep x = \<bottom>) = (x = \<bottom>)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   258
  apply (rule typedef_Rep_strict [OF type below bottom_in_A, THEN subst])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   259
  apply (simp add: type_definition.Rep_inject [OF type])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   260
  done
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   261
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   262
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   263
subsection \<open>Proving a subtype is flat\<close>
19519
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   264
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   265
theorem typedef_flat:
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   266
  fixes Abs :: "'a::flat \<Rightarrow> 'b::pcpo"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   267
  assumes type: "type_definition Rep Abs A"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67312
diff changeset
   268
    and below: "(\<sqsubseteq>) \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
41430
1aa23e9f2c87 change some lemma names containing 'UU' to 'bottom'
huffman
parents: 41182
diff changeset
   269
    and bottom_in_A: "\<bottom> \<in> A"
19519
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   270
  shows "OFCLASS('b, flat_class)"
67312
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   271
  apply (intro_classes)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   272
  apply (unfold below)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   273
  apply (simp add: type_definition.Rep_inject [OF type, symmetric])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   274
  apply (simp add: typedef_Rep_strict [OF type below bottom_in_A])
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   275
  apply (simp add: ax_flat)
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   276
  done
0d25e02759b7 misc tuning and modernization;
wenzelm
parents: 62175
diff changeset
   277
19519
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   278
62175
8ffc4d0e652d isabelle update_cartouches -c -t;
wenzelm
parents: 58880
diff changeset
   279
subsection \<open>HOLCF type definition package\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   280
69605
a96320074298 isabelle update -u path_cartouches;
wenzelm
parents: 69597
diff changeset
   281
ML_file \<open>Tools/cpodef.ML\<close>
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   282
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   283
end