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