src/HOLCF/Discrete.thy
author wenzelm
Sun Oct 21 14:21:48 2007 +0200 (2007-10-21)
changeset 25131 2c8caac48ade
parent 19105 3aabd46340e0
child 25782 2d8b845dc298
permissions -rw-r--r--
modernized specifications ('definition', 'abbreviation', 'notation');
nipkow@2841
     1
(*  Title:      HOLCF/Discrete.thy
nipkow@2841
     2
    ID:         $Id$
nipkow@2841
     3
    Author:     Tobias Nipkow
nipkow@2841
     4
wenzelm@12030
     5
Discrete CPOs.
nipkow@2841
     6
*)
nipkow@2841
     7
huffman@15578
     8
header {* Discrete cpo types *}
huffman@15578
     9
huffman@15555
    10
theory Discrete
huffman@19105
    11
imports Cont
huffman@15555
    12
begin
huffman@15555
    13
huffman@15555
    14
datatype 'a discr = Discr "'a :: type"
huffman@15555
    15
huffman@15590
    16
subsection {* Type @{typ "'a discr"} is a partial order *}
huffman@15590
    17
huffman@15555
    18
instance discr :: (type) sq_ord ..
huffman@15555
    19
huffman@15555
    20
defs (overloaded)
huffman@15555
    21
less_discr_def: "((op <<)::('a::type)discr=>'a discr=>bool)  ==  op ="
huffman@15555
    22
huffman@15555
    23
lemma discr_less_eq [iff]: "((x::('a::type)discr) << y) = (x = y)"
huffman@15639
    24
by (unfold less_discr_def) (rule refl)
huffman@15555
    25
huffman@15555
    26
instance discr :: (type) po
huffman@15555
    27
proof
huffman@15555
    28
  fix x y z :: "'a discr"
huffman@15555
    29
  show "x << x" by simp
huffman@15555
    30
  { assume "x << y" and "y << x" thus "x = y" by simp }
huffman@15555
    31
  { assume "x << y" and "y << z" thus "x << z" by simp }
huffman@15555
    32
qed
nipkow@2841
    33
huffman@15590
    34
subsection {* Type @{typ "'a discr"} is a cpo *}
huffman@15590
    35
huffman@15555
    36
lemma discr_chain0: 
huffman@15555
    37
 "!!S::nat=>('a::type)discr. chain S ==> S i = S 0"
huffman@15555
    38
apply (unfold chain_def)
huffman@15555
    39
apply (induct_tac "i")
huffman@15555
    40
apply (rule refl)
huffman@15555
    41
apply (erule subst)
huffman@15555
    42
apply (rule sym)
huffman@15555
    43
apply fast
huffman@15555
    44
done
huffman@15555
    45
huffman@15639
    46
lemma discr_chain_range0 [simp]: 
huffman@15555
    47
 "!!S::nat=>('a::type)discr. chain(S) ==> range(S) = {S 0}"
huffman@15639
    48
by (fast elim: discr_chain0)
huffman@15555
    49
huffman@15555
    50
lemma discr_cpo: 
huffman@15555
    51
 "!!S. chain S ==> ? x::('a::type)discr. range(S) <<| x"
huffman@15639
    52
by (unfold is_lub_def is_ub_def) simp
huffman@15555
    53
huffman@15590
    54
instance discr :: (type) cpo
huffman@15590
    55
by intro_classes (rule discr_cpo)
huffman@15590
    56
huffman@15590
    57
subsection {* @{term undiscr} *}
nipkow@2841
    58
wenzelm@25131
    59
definition
wenzelm@25131
    60
  undiscr :: "('a::type)discr => 'a" where
wenzelm@25131
    61
  "undiscr x = (case x of Discr y => y)"
nipkow@2841
    62
huffman@15555
    63
lemma undiscr_Discr [simp]: "undiscr(Discr x) = x"
huffman@15590
    64
by (simp add: undiscr_def)
huffman@15555
    65
huffman@15555
    66
lemma discr_chain_f_range0:
huffman@15555
    67
 "!!S::nat=>('a::type)discr. chain(S) ==> range(%i. f(S i)) = {f(S 0)}"
huffman@15590
    68
by (fast dest: discr_chain0 elim: arg_cong)
huffman@15555
    69
huffman@15555
    70
lemma cont_discr [iff]: "cont(%x::('a::type)discr. f x)"
huffman@16213
    71
apply (unfold cont_def is_lub_def is_ub_def)
huffman@15590
    72
apply (simp add: discr_chain_f_range0)
huffman@15555
    73
done
huffman@15555
    74
nipkow@2841
    75
end