src/HOLCF/Pcpodef.thy
author wenzelm
Tue, 21 Oct 2008 23:54:42 +0200
changeset 28659 b4fd14ae8b8a
parent 28073 5e9f00f4f209
child 29138 661a8db7e647
permissions -rw-r--r--
less ambitious default for JEDIT_JAVA_OPTIONS;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/Pcpodef.thy
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     2
    ID:         $Id$
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     3
    Author:     Brian Huffman
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     4
*)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     5
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     6
header {* Subtypes of pcpos *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     7
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     8
theory Pcpodef
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
     9
imports Adm
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents: 19519
diff changeset
    10
uses ("Tools/pcpodef_package.ML")
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    11
begin
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    12
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    13
subsection {* Proving a subtype is a partial order *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    14
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    15
text {*
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    16
  A subtype of a partial order is itself a partial order,
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    17
  if the ordering is defined in the standard way.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    18
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    19
28073
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    20
setup {* Sign.add_const_constraint (@{const_name Porder.sq_le}, NONE) *}
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    21
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    22
theorem typedef_po:
28073
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    23
  fixes Abs :: "'a::po \<Rightarrow> 'b::type"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    24
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    25
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    26
  shows "OFCLASS('b, po_class)"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    27
 apply (intro_classes, unfold less)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    28
   apply (rule refl_less)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26027
diff changeset
    29
  apply (erule (1) trans_less)
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26027
diff changeset
    30
 apply (rule type_definition.Rep_inject [OF type, THEN iffD1])
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26027
diff changeset
    31
 apply (erule (1) antisym_less)
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    32
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    33
28073
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    34
setup {* Sign.add_const_constraint (@{const_name Porder.sq_le},
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    35
  SOME @{typ "'a::sq_ord \<Rightarrow> 'a::sq_ord \<Rightarrow> bool"}) *}
5e9f00f4f209 adapted to class instantiation compliance
haftmann
parents: 27296
diff changeset
    36
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    37
subsection {* Proving a subtype is finite *}
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    38
27296
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    39
lemma typedef_finite_UNIV:
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    40
  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
    41
  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
    42
  shows "finite A \<Longrightarrow> finite (UNIV :: 'b set)"
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    43
proof -
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    44
  assume "finite A"
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    45
  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
    46
  thus "finite (UNIV :: 'b set)"
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
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    50
theorem typedef_finite_po:
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    51
  fixes Abs :: "'a::finite_po \<Rightarrow> 'b::po"
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    52
  assumes type: "type_definition Rep Abs A"
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    53
  shows "OFCLASS('b, finite_po_class)"
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    54
 apply (intro_classes)
27296
eec7a1889ca5 moved Abs_image to Typedef.thy; prove finite_UNIV outside the locale
huffman
parents: 26420
diff changeset
    55
 apply (rule typedef_finite_UNIV [OF type])
25827
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    56
 apply (rule finite)
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    57
done
c2adeb1bae5c new instance proofs for classes finite_po, chfin, flat
huffman
parents: 23152
diff changeset
    58
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    59
subsection {* Proving a subtype is chain-finite *}
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    60
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    61
lemma monofun_Rep:
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    62
  assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    63
  shows "monofun Rep"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    64
by (rule monofunI, unfold less)
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    65
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    66
lemmas ch2ch_Rep = ch2ch_monofun [OF monofun_Rep]
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    67
lemmas ub2ub_Rep = ub2ub_monofun [OF monofun_Rep]
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    68
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    69
theorem typedef_chfin:
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    70
  fixes Abs :: "'a::chfin \<Rightarrow> 'b::po"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    71
  assumes type: "type_definition Rep Abs A"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    72
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    73
  shows "OFCLASS('b, chfin_class)"
25921
0ca392ab7f37 change class axiom chfin to rule_format
huffman
parents: 25827
diff changeset
    74
 apply intro_classes
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    75
 apply (drule ch2ch_Rep [OF less])
25921
0ca392ab7f37 change class axiom chfin to rule_format
huffman
parents: 25827
diff changeset
    76
 apply (drule chfin)
17812
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    77
 apply (unfold max_in_chain_def)
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    78
 apply (simp add: type_definition.Rep_inject [OF type])
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    79
done
703005988cfe added theorem typedef_chfin
huffman
parents: 16918
diff changeset
    80
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    81
subsection {* Proving a subtype is complete *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    82
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    83
text {*
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    84
  A subtype of a cpo is itself a cpo if the ordering is
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    85
  defined in the standard way, and the defining subset
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    86
  is closed with respect to limits of chains.  A set is
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    87
  closed if and only if membership in the set is an
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    88
  admissible predicate.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    89
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    90
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
    91
lemma Abs_inverse_lub_Rep:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    92
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    93
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    94
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    95
    and adm:  "adm (\<lambda>x. x \<in> A)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
    96
  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
    97
 apply (rule type_definition.Abs_inverse [OF type])
25925
3dc4acca4388 change lemma admD to rule_format
huffman
parents: 25921
diff changeset
    98
 apply (erule admD [OF adm ch2ch_Rep [OF less]])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
    99
 apply (rule type_definition.Rep [OF type])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   100
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   101
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   102
theorem typedef_lub:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   103
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   104
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   105
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   106
    and adm: "adm (\<lambda>x. x \<in> A)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   107
  shows "chain S \<Longrightarrow> range S <<| Abs (\<Squnion>i. Rep (S i))"
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   108
 apply (frule ch2ch_Rep [OF less])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   109
 apply (rule is_lubI)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   110
  apply (rule ub_rangeI)
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   111
  apply (simp only: less Abs_inverse_lub_Rep [OF type less adm])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   112
  apply (erule is_ub_thelub)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   113
 apply (simp only: less Abs_inverse_lub_Rep [OF type less adm])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   114
 apply (erule is_lub_thelub)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   115
 apply (erule ub2ub_Rep [OF less])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   116
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   117
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   118
lemmas typedef_thelub = typedef_lub [THEN thelubI, standard]
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   119
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   120
theorem typedef_cpo:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   121
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   122
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   123
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   124
    and adm: "adm (\<lambda>x. x \<in> A)"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   125
  shows "OFCLASS('b, cpo_class)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   126
proof
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   127
  fix S::"nat \<Rightarrow> 'b" assume "chain S"
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   128
  hence "range S <<| Abs (\<Squnion>i. Rep (S i))"
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   129
    by (rule typedef_lub [OF type less adm])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   130
  thus "\<exists>x. range S <<| x" ..
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   131
qed
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   132
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   133
subsubsection {* Continuity of @{term Rep} and @{term Abs} *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   134
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   135
text {* For any sub-cpo, the @{term Rep} function is continuous. *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   136
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   137
theorem typedef_cont_Rep:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   138
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   139
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   140
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   141
    and adm: "adm (\<lambda>x. x \<in> A)"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   142
  shows "cont Rep"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   143
 apply (rule contI)
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   144
 apply (simp only: typedef_thelub [OF type less adm])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   145
 apply (simp only: Abs_inverse_lub_Rep [OF type less adm])
26027
87cb69d27558 add lemma cpo_lubI
huffman
parents: 25926
diff changeset
   146
 apply (rule cpo_lubI)
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   147
 apply (erule ch2ch_Rep [OF less])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   148
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   149
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   150
text {*
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.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   154
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   155
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   156
theorem typedef_is_lubI:
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   157
  assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   158
  shows "range (\<lambda>i. Rep (S i)) <<| Rep x \<Longrightarrow> range S <<| x"
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   159
 apply (rule is_lubI)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   160
  apply (rule ub_rangeI)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   161
  apply (subst less)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   162
  apply (erule is_ub_lub)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   163
 apply (subst less)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   164
 apply (erule is_lub_lub)
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   165
 apply (erule ub2ub_Rep [OF less])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   166
done
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   167
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   168
theorem typedef_cont_Abs:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   169
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   170
  fixes f :: "'c::cpo \<Rightarrow> 'a::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   171
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   172
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   173
    and adm: "adm (\<lambda>x. x \<in> A)" (* not used *)
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   174
    and f_in_A: "\<And>x. f x \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   175
    and cont_f: "cont f"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   176
  shows "cont (\<lambda>x. Abs (f x))"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   177
 apply (rule contI)
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   178
 apply (rule typedef_is_lubI [OF less])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   179
 apply (simp only: type_definition.Abs_inverse [OF type f_in_A])
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   180
 apply (erule cont_f [THEN contE])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   181
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   182
17833
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   183
subsection {* Proving subtype elements are compact *}
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   184
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   185
theorem typedef_compact:
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   186
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   187
  assumes type: "type_definition Rep Abs A"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   188
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   189
    and adm: "adm (\<lambda>x. x \<in> A)"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   190
  shows "compact (Rep k) \<Longrightarrow> compact k"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   191
proof (unfold compact_def)
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   192
  have cont_Rep: "cont Rep"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   193
    by (rule typedef_cont_Rep [OF type less adm])
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   194
  assume "adm (\<lambda>x. \<not> Rep k \<sqsubseteq> x)"
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   195
  with cont_Rep have "adm (\<lambda>x. \<not> Rep k \<sqsubseteq> Rep x)" by (rule adm_subst)
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   196
  thus "adm (\<lambda>x. \<not> k \<sqsubseteq> x)" by (unfold less)
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   197
qed
8631dfe017a8 added theorem typedef_compact
huffman
parents: 17812
diff changeset
   198
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   199
subsection {* Proving a subtype is pointed *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   200
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   201
text {*
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   202
  A subtype of a cpo has a least element if and only if
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   203
  the defining subset has a least element.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   204
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   205
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   206
theorem typedef_pcpo_generic:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   207
  fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   208
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   209
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   210
    and z_in_A: "z \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   211
    and z_least: "\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   212
  shows "OFCLASS('b, pcpo_class)"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   213
 apply (intro_classes)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   214
 apply (rule_tac x="Abs z" in exI, rule allI)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   215
 apply (unfold less)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   216
 apply (subst type_definition.Abs_inverse [OF type z_in_A])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   217
 apply (rule z_least [OF type_definition.Rep [OF type]])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   218
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   219
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   220
text {*
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   221
  As a special case, a subtype of a pcpo has a least element
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   222
  if the defining subset contains @{term \<bottom>}.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   223
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   224
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   225
theorem typedef_pcpo:
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   226
  fixes Abs :: "'a::pcpo \<Rightarrow> 'b::cpo"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   227
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   228
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   229
    and UU_in_A: "\<bottom> \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   230
  shows "OFCLASS('b, pcpo_class)"
16918
d0fdc7b9a33f cleaned up; renamed some theorems
huffman
parents: 16738
diff changeset
   231
by (rule typedef_pcpo_generic [OF type less UU_in_A], rule minimal)
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   232
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   233
subsubsection {* Strictness of @{term Rep} and @{term Abs} *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   234
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   235
text {*
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   236
  For a sub-pcpo where @{term \<bottom>} is a member of the defining
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   237
  subset, @{term Rep} and @{term Abs} are both strict.
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   238
*}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   239
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   240
theorem typedef_Abs_strict:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   241
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   242
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   243
    and UU_in_A: "\<bottom> \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   244
  shows "Abs \<bottom> = \<bottom>"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   245
 apply (rule UU_I, unfold less)
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   246
 apply (simp add: type_definition.Abs_inverse [OF type UU_in_A])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   247
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   248
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   249
theorem typedef_Rep_strict:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   250
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   251
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   252
    and UU_in_A: "\<bottom> \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   253
  shows "Rep \<bottom> = \<bottom>"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   254
 apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   255
 apply (rule type_definition.Abs_inverse [OF type UU_in_A])
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   256
done
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   257
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   258
theorem typedef_Abs_strict_iff:
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   259
  assumes type: "type_definition Rep Abs A"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   260
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   261
    and UU_in_A: "\<bottom> \<in> A"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   262
  shows "x \<in> A \<Longrightarrow> (Abs x = \<bottom>) = (x = \<bottom>)"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   263
 apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst])
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   264
 apply (simp add: type_definition.Abs_inject [OF type] UU_in_A)
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   265
done
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   266
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   267
theorem typedef_Rep_strict_iff:
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   268
  assumes type: "type_definition Rep Abs A"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   269
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   270
    and UU_in_A: "\<bottom> \<in> A"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   271
  shows "(Rep x = \<bottom>) = (x = \<bottom>)"
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   272
 apply (rule typedef_Rep_strict [OF type less UU_in_A, THEN subst])
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   273
 apply (simp add: type_definition.Rep_inject [OF type])
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   274
done
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   275
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   276
theorem typedef_Abs_defined:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   277
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   278
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   279
    and UU_in_A: "\<bottom> \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   280
  shows "\<lbrakk>x \<noteq> \<bottom>; x \<in> A\<rbrakk> \<Longrightarrow> Abs x \<noteq> \<bottom>"
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   281
by (simp add: typedef_Abs_strict_iff [OF type less UU_in_A])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   282
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   283
theorem typedef_Rep_defined:
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   284
  assumes type: "type_definition Rep Abs A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   285
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   286
    and UU_in_A: "\<bottom> \<in> A"
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   287
  shows "x \<noteq> \<bottom> \<Longrightarrow> Rep x \<noteq> \<bottom>"
25926
aa0eca1ccb19 pcpodef generates strict_iff lemmas
huffman
parents: 25925
diff changeset
   288
by (simp add: typedef_Rep_strict_iff [OF type less UU_in_A])
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   289
19519
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   290
subsection {* Proving a subtype is flat *}
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   291
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   292
theorem typedef_flat:
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   293
  fixes Abs :: "'a::flat \<Rightarrow> 'b::pcpo"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   294
  assumes type: "type_definition Rep Abs A"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   295
    and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   296
    and UU_in_A: "\<bottom> \<in> A"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   297
  shows "OFCLASS('b, flat_class)"
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   298
 apply (intro_classes)
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   299
 apply (unfold less)
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   300
 apply (simp add: type_definition.Rep_inject [OF type, symmetric])
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   301
 apply (simp add: typedef_Rep_strict [OF type less UU_in_A])
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   302
 apply (simp add: ax_flat)
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   303
done
8134024166b8 add theorem typdef_flat
huffman
parents: 17833
diff changeset
   304
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   305
subsection {* HOLCF type definition package *}
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   306
23152
9497234a2743 moved HOLCF tools to canonical place;
wenzelm
parents: 19519
diff changeset
   307
use "Tools/pcpodef_package.ML"
16697
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   308
007f4caab6c1 renamed from TypedefPcpo.thy;
huffman
parents:
diff changeset
   309
end