src/HOLCF/Pcpo.thy
author huffman
Fri, 22 Oct 2010 07:45:32 -0700
changeset 40091 1ca61fbd8a79
parent 40089 8adc57fb8454
child 40498 5718fb91d2d8
permissions -rw-r--r--
make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2640
ee4dfce170a0 Changes of HOLCF from Oscar Slotosch:
slotosch
parents: 2394
diff changeset
     1
(*  Title:      HOLCF/Pcpo.thy
ee4dfce170a0 Changes of HOLCF from Oscar Slotosch:
slotosch
parents: 2394
diff changeset
     2
    Author:     Franz Regensburger
ee4dfce170a0 Changes of HOLCF from Oscar Slotosch:
slotosch
parents: 2394
diff changeset
     3
*)
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15563
diff changeset
     4
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15563
diff changeset
     5
header {* Classes cpo and pcpo *}
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15563
diff changeset
     6
15577
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     7
theory Pcpo
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     8
imports Porder
e16da3068ad6 fix headers
huffman
parents: 15576
diff changeset
     9
begin
243
c22b85994e17 Franz Regensburger's Higher-Order Logic of Computable Functions embedding LCF
nipkow
parents:
diff changeset
    10
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    11
subsection {* Complete partial orders *}
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    12
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    13
text {* The class cpo of chain complete partial orders *}
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    14
29614
1f7b1b0df292 simplified handling of base sort, dropped axclass
haftmann
parents: 29138
diff changeset
    15
class cpo = po +
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    16
  assumes cpo: "chain S \<Longrightarrow> \<exists>x. range S <<| x"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    17
begin
2394
91d8abf108be adaptions for symbol font
oheimb
parents: 2291
diff changeset
    18
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    19
text {* in cpo's everthing equal to THE lub has lub properties for every chain *}
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    20
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    21
lemma cpo_lubI: "chain S \<Longrightarrow> range S <<| (\<Squnion>i. S i)"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    22
  by (fast dest: cpo elim: lubI)
26026
f9647c040b58 add lemma cpo_lubI
huffman
parents: 26023
diff changeset
    23
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    24
lemma thelubE: "\<lbrakk>chain S; (\<Squnion>i. S i) = l\<rbrakk> \<Longrightarrow> range S <<| l"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    25
  by (blast dest: cpo intro: lubI)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    26
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    27
text {* Properties of the lub *}
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    28
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    29
lemma is_ub_thelub: "chain S \<Longrightarrow> S x \<sqsubseteq> (\<Squnion>i. S i)"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    30
  by (blast dest: cpo intro: lubI [THEN is_ub_lub])
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    31
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    32
lemma is_lub_thelub:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    33
  "\<lbrakk>chain S; range S <| x\<rbrakk> \<Longrightarrow> (\<Squnion>i. S i) \<sqsubseteq> x"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    34
  by (blast dest: cpo intro: lubI [THEN is_lub_lub])
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    35
39969
0b8e19f588a4 new lemmas about lub
huffman
parents: 39302
diff changeset
    36
lemma lub_below_iff: "chain S \<Longrightarrow> (\<Squnion>i. S i) \<sqsubseteq> x \<longleftrightarrow> (\<forall>i. S i \<sqsubseteq> x)"
0b8e19f588a4 new lemmas about lub
huffman
parents: 39302
diff changeset
    37
  by (simp add: is_lub_below_iff [OF cpo_lubI] is_ub_def)
0b8e19f588a4 new lemmas about lub
huffman
parents: 39302
diff changeset
    38
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    39
lemma lub_range_mono:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    40
  "\<lbrakk>range X \<subseteq> range Y; chain Y; chain X\<rbrakk>
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    41
    \<Longrightarrow> (\<Squnion>i. X i) \<sqsubseteq> (\<Squnion>i. Y i)"
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    42
apply (erule is_lub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    43
apply (rule ub_rangeI)
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    44
apply (subgoal_tac "\<exists>j. X i = Y j")
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    45
apply  clarsimp
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    46
apply  (erule is_ub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    47
apply auto
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    48
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    49
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    50
lemma lub_range_shift:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    51
  "chain Y \<Longrightarrow> (\<Squnion>i. Y (i + j)) = (\<Squnion>i. Y i)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
    52
apply (rule below_antisym)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    53
apply (rule lub_range_mono)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    54
apply    fast
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    55
apply   assumption
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    56
apply (erule chain_shift)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    57
apply (rule is_lub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    58
apply assumption
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    59
apply (rule ub_rangeI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
    60
apply (rule_tac y="Y (i + j)" in below_trans)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25921
diff changeset
    61
apply (erule chain_mono)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    62
apply (rule le_add1)
17813
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
    63
apply (rule is_ub_thelub)
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
    64
apply (erule chain_shift)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    65
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    66
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    67
lemma maxinch_is_thelub:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    68
  "chain Y \<Longrightarrow> max_in_chain i Y = ((\<Squnion>i. Y i) = Y i)"
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    69
apply (rule iffI)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    70
apply (fast intro!: thelubI lub_finch1)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    71
apply (unfold max_in_chain_def)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
    72
apply (safe intro!: below_antisym)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25921
diff changeset
    73
apply (fast elim!: chain_mono)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    74
apply (drule sym)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    75
apply (force elim!: is_ub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    76
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    77
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    78
text {* the @{text "\<sqsubseteq>"} relation between two chains is preserved by their lubs *}
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    79
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    80
lemma lub_mono:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    81
  "\<lbrakk>chain X; chain Y; \<And>i. X i \<sqsubseteq> Y i\<rbrakk> 
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    82
    \<Longrightarrow> (\<Squnion>i. X i) \<sqsubseteq> (\<Squnion>i. Y i)"
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    83
apply (erule is_lub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    84
apply (rule ub_rangeI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
    85
apply (rule below_trans)
25923
5fe4b543512e convert lemma lub_mono to rule_format
huffman
parents: 25922
diff changeset
    86
apply (erule meta_spec)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    87
apply (erule is_ub_thelub)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    88
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    89
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
    90
text {* the = relation between two chains is preserved by their lubs *}
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    91
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    92
lemma lub_equal:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
    93
  "\<lbrakk>chain X; chain Y; \<forall>k. X k = Y k\<rbrakk>
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
    94
    \<Longrightarrow> (\<Squnion>i. X i) = (\<Squnion>i. Y i)"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39199
diff changeset
    95
  by (simp only: fun_eq_iff [symmetric])
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
    96
35492
5d200f2d7a4f add lemma lub_eq
huffman
parents: 33523
diff changeset
    97
lemma lub_eq:
5d200f2d7a4f add lemma lub_eq
huffman
parents: 33523
diff changeset
    98
  "(\<And>i. X i = Y i) \<Longrightarrow> (\<Squnion>i. X i) = (\<Squnion>i. Y i)"
5d200f2d7a4f add lemma lub_eq
huffman
parents: 33523
diff changeset
    99
  by simp
5d200f2d7a4f add lemma lub_eq
huffman
parents: 33523
diff changeset
   100
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   101
text {* more results about mono and = of lubs of chains *}
3326
930c9bed5a09 Moved the classes flat chfin from Fix to Pcpo.
slotosch
parents: 2640
diff changeset
   102
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   103
lemma lub_mono2:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   104
  "\<lbrakk>\<exists>j. \<forall>i>j. X i = Y i; chain X; chain Y\<rbrakk>
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   105
    \<Longrightarrow> (\<Squnion>i. X i) \<sqsubseteq> (\<Squnion>i. Y i)"
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   106
apply (erule exE)
17813
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
   107
apply (subgoal_tac "(\<Squnion>i. X (i + Suc j)) \<sqsubseteq> (\<Squnion>i. Y (i + Suc j))")
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
   108
apply (thin_tac "\<forall>i>j. X i = Y i")
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
   109
apply (simp only: lub_range_shift)
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   110
apply simp
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   111
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   112
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   113
lemma lub_equal2:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   114
  "\<lbrakk>\<exists>j. \<forall>i>j. X i = Y i; chain X; chain Y\<rbrakk>
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   115
    \<Longrightarrow> (\<Squnion>i. X i) = (\<Squnion>i. Y i)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   116
  by (blast intro: below_antisym lub_mono2 sym)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   117
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   118
lemma lub_mono3:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   119
  "\<lbrakk>chain Y; chain X; \<forall>i. \<exists>j. Y i \<sqsubseteq> X j\<rbrakk>
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   120
    \<Longrightarrow> (\<Squnion>i. Y i) \<sqsubseteq> (\<Squnion>i. X i)"
17813
03133f6606a1 cleaned up
huffman
parents: 16739
diff changeset
   121
apply (erule is_lub_thelub)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   122
apply (rule ub_rangeI)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   123
apply (erule allE)
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   124
apply (erule exE)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   125
apply (erule below_trans)
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   126
apply (erule is_ub_thelub)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   127
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   128
16203
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   129
lemma ch2ch_lub:
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   130
  assumes 1: "\<And>j. chain (\<lambda>i. Y i j)"
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   131
  assumes 2: "\<And>i. chain (\<lambda>j. Y i j)"
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   132
  shows "chain (\<lambda>i. \<Squnion>j. Y i j)"
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   133
apply (rule chainI)
25923
5fe4b543512e convert lemma lub_mono to rule_format
huffman
parents: 25922
diff changeset
   134
apply (rule lub_mono [OF 2 2])
16203
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   135
apply (rule chainE [OF 1])
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   136
done
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   137
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   138
lemma diag_lub:
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   139
  assumes 1: "\<And>j. chain (\<lambda>i. Y i j)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   140
  assumes 2: "\<And>i. chain (\<lambda>j. Y i j)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   141
  shows "(\<Squnion>i. \<Squnion>j. Y i j) = (\<Squnion>i. Y i i)"
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   142
proof (rule below_antisym)
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   143
  have 3: "chain (\<lambda>i. Y i i)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   144
    apply (rule chainI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   145
    apply (rule below_trans)
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   146
    apply (rule chainE [OF 1])
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   147
    apply (rule chainE [OF 2])
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   148
    done
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   149
  have 4: "chain (\<lambda>i. \<Squnion>j. Y i j)"
16203
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   150
    by (rule ch2ch_lub [OF 1 2])
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   151
  show "(\<Squnion>i. \<Squnion>j. Y i j) \<sqsubseteq> (\<Squnion>i. Y i i)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   152
    apply (rule is_lub_thelub [OF 4])
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   153
    apply (rule ub_rangeI)
16203
b3268fe39838 added theorem ch2ch_lub
huffman
parents: 16201
diff changeset
   154
    apply (rule lub_mono3 [rule_format, OF 2 3])
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   155
    apply (rule exI)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   156
    apply (rule below_trans)
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25921
diff changeset
   157
    apply (rule chain_mono [OF 1 le_maxI1])
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25921
diff changeset
   158
    apply (rule chain_mono [OF 2 le_maxI2])
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   159
    done
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   160
  show "(\<Squnion>i. Y i i) \<sqsubseteq> (\<Squnion>i. \<Squnion>j. Y i j)"
25923
5fe4b543512e convert lemma lub_mono to rule_format
huffman
parents: 25922
diff changeset
   161
    apply (rule lub_mono [OF 3 4])
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   162
    apply (rule is_ub_thelub [OF 2])
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   163
    done
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   164
qed
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   165
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   166
lemma ex_lub:
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   167
  assumes 1: "\<And>j. chain (\<lambda>i. Y i j)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   168
  assumes 2: "\<And>i. chain (\<lambda>j. Y i j)"
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   169
  shows "(\<Squnion>i. \<Squnion>j. Y i j) = (\<Squnion>j. \<Squnion>i. Y i j)"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   170
  by (simp add: diag_lub 1 2)
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   171
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   172
end
16201
7bb51c8196cb added theorems diag_lub and ex_lub
huffman
parents: 16070
diff changeset
   173
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   174
subsection {* Pointed cpos *}
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   175
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   176
text {* The class pcpo of pointed cpos *}
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   177
29614
1f7b1b0df292 simplified handling of base sort, dropped axclass
haftmann
parents: 29138
diff changeset
   178
class pcpo = cpo +
1f7b1b0df292 simplified handling of base sort, dropped axclass
haftmann
parents: 29138
diff changeset
   179
  assumes least: "\<exists>x. \<forall>y. x \<sqsubseteq> y"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   180
begin
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   181
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   182
definition UU :: 'a where
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   183
  "UU = (THE x. \<forall>y. x \<sqsubseteq> y)"
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   184
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   185
notation (xsymbols)
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   186
  UU  ("\<bottom>")
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   187
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   188
text {* derive the old rule minimal *}
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   189
 
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   190
lemma UU_least: "\<forall>z. \<bottom> \<sqsubseteq> z"
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   191
apply (unfold UU_def)
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   192
apply (rule theI')
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   193
apply (rule ex_ex1I)
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   194
apply (rule least)
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   195
apply (blast intro: below_antisym)
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   196
done
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   197
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   198
lemma minimal [iff]: "\<bottom> \<sqsubseteq> x"
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   199
by (rule UU_least [THEN spec])
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   200
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   201
end
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   202
31024
0fdf666e08bf reimplement reorientation simproc using theory data
huffman
parents: 29634
diff changeset
   203
text {* Simproc to rewrite @{term "\<bottom> = x"} to @{term "x = \<bottom>"}. *}
16739
9ffd706ae402 add UU_reorient_simproc
huffman
parents: 16627
diff changeset
   204
31024
0fdf666e08bf reimplement reorientation simproc using theory data
huffman
parents: 29634
diff changeset
   205
setup {*
33523
96730ad673be modernized structure Reorient_Proc;
wenzelm
parents: 31076
diff changeset
   206
  Reorient_Proc.add
31024
0fdf666e08bf reimplement reorientation simproc using theory data
huffman
parents: 29634
diff changeset
   207
    (fn Const(@{const_name UU}, _) => true | _ => false)
0fdf666e08bf reimplement reorientation simproc using theory data
huffman
parents: 29634
diff changeset
   208
*}
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   209
33523
96730ad673be modernized structure Reorient_Proc;
wenzelm
parents: 31076
diff changeset
   210
simproc_setup reorient_bottom ("\<bottom> = x") = Reorient_Proc.proc
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   211
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   212
context pcpo
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   213
begin
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   214
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   215
text {* useful lemmas about @{term \<bottom>} *}
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   216
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   217
lemma below_UU_iff [simp]: "(x \<sqsubseteq> \<bottom>) = (x = \<bottom>)"
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   218
by (simp add: po_eq_conv)
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   219
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   220
lemma eq_UU_iff: "(x = \<bottom>) = (x \<sqsubseteq> \<bottom>)"
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   221
by simp
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   222
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   223
lemma UU_I: "x \<sqsubseteq> \<bottom> \<Longrightarrow> x = \<bottom>"
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   224
by (subst eq_UU_iff)
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   225
40045
e0f372e18f3e add lemma lub_eq_bottom_iff
huffman
parents: 39969
diff changeset
   226
lemma lub_eq_bottom_iff: "chain Y \<Longrightarrow> (\<Squnion>i. Y i) = \<bottom> \<longleftrightarrow> (\<forall>i. Y i = \<bottom>)"
e0f372e18f3e add lemma lub_eq_bottom_iff
huffman
parents: 39969
diff changeset
   227
by (simp only: eq_UU_iff lub_below_iff)
e0f372e18f3e add lemma lub_eq_bottom_iff
huffman
parents: 39969
diff changeset
   228
25723
80c06e4d4db6 move bottom-related stuff back into Pcpo.thy
huffman
parents: 25701
diff changeset
   229
lemma chain_UU_I: "\<lbrakk>chain Y; (\<Squnion>i. Y i) = \<bottom>\<rbrakk> \<Longrightarrow> \<forall>i. Y i = \<bottom>"
40045
e0f372e18f3e add lemma lub_eq_bottom_iff
huffman
parents: 39969
diff changeset
   230
by (simp add: lub_eq_bottom_iff)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   231
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   232
lemma chain_UU_I_inverse: "\<forall>i::nat. Y i = \<bottom> \<Longrightarrow> (\<Squnion>i. Y i) = \<bottom>"
40045
e0f372e18f3e add lemma lub_eq_bottom_iff
huffman
parents: 39969
diff changeset
   233
by simp
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   234
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   235
lemma chain_UU_I_inverse2: "(\<Squnion>i. Y i) \<noteq> \<bottom> \<Longrightarrow> \<exists>i::nat. Y i \<noteq> \<bottom>"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   236
  by (blast intro: chain_UU_I_inverse)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   237
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   238
lemma notUU_I: "\<lbrakk>x \<sqsubseteq> y; x \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> y \<noteq> \<bottom>"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   239
  by (blast intro: UU_I)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   240
16627
a2844e212da4 cleaned up
huffman
parents: 16626
diff changeset
   241
lemma chain_mono2: "\<lbrakk>\<exists>j. Y j \<noteq> \<bottom>; chain Y\<rbrakk> \<Longrightarrow> \<exists>j. \<forall>i>j. Y i \<noteq> \<bottom>"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   242
  by (blast dest: notUU_I chain_mono_less)
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   243
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   244
end
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   245
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   246
subsection {* Chain-finite and flat cpos *}
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   247
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   248
text {* further useful classes for HOLCF domains *}
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   249
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   250
class chfin = po +
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   251
  assumes chfin: "chain Y \<Longrightarrow> \<exists>n. max_in_chain n Y"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   252
begin
25814
eb181909e7a4 new axclass finite_po < finite, po
huffman
parents: 25781
diff changeset
   253
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   254
subclass cpo
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   255
apply default
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   256
apply (frule chfin)
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   257
apply (blast intro: lub_finch1)
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   258
done
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   259
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   260
lemma chfin2finch: "chain Y \<Longrightarrow> finite_chain Y"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   261
  by (simp add: chfin finite_chain_def)
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   262
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   263
end
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   264
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   265
class flat = pcpo +
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   266
  assumes ax_flat: "x \<sqsubseteq> y \<Longrightarrow> x = \<bottom> \<or> x = y"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   267
begin
15640
2d1d6ea579a1 chfin now a subclass of po, proved instance chfin < cpo
huffman
parents: 15588
diff changeset
   268
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   269
subclass chfin
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   270
apply default
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   271
apply (unfold max_in_chain_def)
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   272
apply (case_tac "\<forall>i. Y i = \<bottom>")
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   273
apply simp
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   274
apply simp
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   275
apply (erule exE)
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   276
apply (rule_tac x="i" in exI)
15588
14e3228f18cc arranged for document generation, cleaned up some proofs
huffman
parents: 15577
diff changeset
   277
apply clarify
25922
cb04d05e95fb rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents: 25921
diff changeset
   278
apply (blast dest: chain_mono ax_flat)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   279
done
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   280
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   281
lemma flat_below_iff:
25826
f9aa43287e42 new lemma flat_less_iff
huffman
parents: 25814
diff changeset
   282
  shows "(x \<sqsubseteq> y) = (x = \<bottom> \<or> x = y)"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   283
  by (safe dest!: ax_flat)
25826
f9aa43287e42 new lemma flat_less_iff
huffman
parents: 25814
diff changeset
   284
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   285
lemma flat_eq: "a \<noteq> \<bottom> \<Longrightarrow> a \<sqsubseteq> b = (a = b)"
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   286
  by (safe dest!: ax_flat)
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   287
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   288
end
15563
9e125b675253 converted to new-style theory
huffman
parents: 14981
diff changeset
   289
40091
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   290
subsection {* Discrete cpos *}
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   291
31076
99fe356cbbc2 rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents: 31071
diff changeset
   292
class discrete_cpo = below +
29614
1f7b1b0df292 simplified handling of base sort, dropped axclass
haftmann
parents: 29138
diff changeset
   293
  assumes discrete_cpo [simp]: "x \<sqsubseteq> y \<longleftrightarrow> x = y"
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   294
begin
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   295
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   296
subclass po
29614
1f7b1b0df292 simplified handling of base sort, dropped axclass
haftmann
parents: 29138
diff changeset
   297
proof qed simp_all
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   298
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   299
text {* In a discrete cpo, every chain is constant *}
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   300
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   301
lemma discrete_chain_const:
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   302
  assumes S: "chain S"
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   303
  shows "\<exists>x. S = (\<lambda>i. x)"
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   304
proof (intro exI ext)
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   305
  fix i :: nat
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   306
  have "S 0 \<sqsubseteq> S i" using S le0 by (rule chain_mono)
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   307
  hence "S 0 = S i" by simp
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   308
  thus "S i = S 0" by (rule sym)
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   309
qed
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   310
40091
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   311
subclass chfin
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   312
proof
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   313
  fix S :: "nat \<Rightarrow> 'a"
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   314
  assume S: "chain S"
40091
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   315
  hence "\<exists>x. S = (\<lambda>i. x)" by (rule discrete_chain_const)
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   316
  hence "max_in_chain 0 S"
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   317
    unfolding max_in_chain_def by auto
1ca61fbd8a79 make discrete_cpo a subclass of chfin; remove chfin instances for fun, cfun
huffman
parents: 40089
diff changeset
   318
  thus "\<exists>i. max_in_chain i S" ..
26023
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   319
qed
29c1e3e98276 new discrete_cpo axclass
huffman
parents: 25923
diff changeset
   320
31071
845a6acd3bf3 localized (complete) partial order classes
haftmann
parents: 31024
diff changeset
   321
end
15576
efb95d0d01f7 converted to new-style theories, and combined numbered files
huffman
parents: 15563
diff changeset
   322
16626
d28314d2dce3 cleaned up
huffman
parents: 16203
diff changeset
   323
end