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