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