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