src/HOL/LOrder.thy
author nipkow
Sun Dec 10 07:12:26 2006 +0100 (2006-12-10)
changeset 21733 131dd2a27137
parent 21380 c4f79922bc81
child 21734 283461c15fa7
permissions -rw-r--r--
Modified lattice locale
obua@14738
     1
(*  Title:   HOL/LOrder.thy
obua@14738
     2
    ID:      $Id$
obua@14738
     3
    Author:  Steven Obua, TU Muenchen
obua@14738
     4
*)
obua@14738
     5
nipkow@21312
     6
header "Lattice Orders"
obua@14738
     7
nipkow@15131
     8
theory LOrder
haftmann@21249
     9
imports Lattices
nipkow@15131
    10
begin
obua@14738
    11
nipkow@21312
    12
text {* The theory of lattices developed here is taken from
nipkow@21312
    13
\cite{Birkhoff79}.  *}
obua@14738
    14
obua@14738
    15
constdefs
obua@14738
    16
  is_meet :: "(('a::order) \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> bool"
obua@14738
    17
  "is_meet m == ! a b x. m a b \<le> a \<and> m a b \<le> b \<and> (x \<le> a \<and> x \<le> b \<longrightarrow> x \<le> m a b)"
obua@14738
    18
  is_join :: "(('a::order) \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> bool"
obua@14738
    19
  "is_join j == ! a b x. a \<le> j a b \<and> b \<le> j a b \<and> (a \<le> x \<and> b \<le> x \<longrightarrow> j a b \<le> x)"  
obua@14738
    20
obua@14738
    21
lemma is_meet_unique: 
obua@14738
    22
  assumes "is_meet u" "is_meet v" shows "u = v"
obua@14738
    23
proof -
obua@14738
    24
  {
obua@14738
    25
    fix a b :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
obua@14738
    26
    assume a: "is_meet a"
obua@14738
    27
    assume b: "is_meet b"
obua@14738
    28
    {
obua@14738
    29
      fix x y 
obua@14738
    30
      let ?za = "a x y"
obua@14738
    31
      let ?zb = "b x y"
obua@14738
    32
      from a have za_le: "?za <= x & ?za <= y" by (auto simp add: is_meet_def)
obua@14738
    33
      with b have "?za <= ?zb" by (auto simp add: is_meet_def)
obua@14738
    34
    }
obua@14738
    35
  }
obua@14738
    36
  note f_le = this
obua@14738
    37
  show "u = v" by ((rule ext)+, simp_all add: order_antisym prems f_le) 
obua@14738
    38
qed
obua@14738
    39
obua@14738
    40
lemma is_join_unique: 
obua@14738
    41
  assumes "is_join u" "is_join v" shows "u = v"
obua@14738
    42
proof -
obua@14738
    43
  {
obua@14738
    44
    fix a b :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"
obua@14738
    45
    assume a: "is_join a"
obua@14738
    46
    assume b: "is_join b"
obua@14738
    47
    {
obua@14738
    48
      fix x y 
obua@14738
    49
      let ?za = "a x y"
obua@14738
    50
      let ?zb = "b x y"
obua@14738
    51
      from a have za_le: "x <= ?za & y <= ?za" by (auto simp add: is_join_def)
obua@14738
    52
      with b have "?zb <= ?za" by (auto simp add: is_join_def)
obua@14738
    53
    }
obua@14738
    54
  }
obua@14738
    55
  note f_le = this
obua@14738
    56
  show "u = v" by ((rule ext)+, simp_all add: order_antisym prems f_le) 
obua@14738
    57
qed
obua@14738
    58
obua@14738
    59
axclass join_semilorder < order
obua@14738
    60
  join_exists: "? j. is_join j"
obua@14738
    61
obua@14738
    62
axclass meet_semilorder < order
obua@14738
    63
  meet_exists: "? m. is_meet m"
obua@14738
    64
obua@14738
    65
axclass lorder < join_semilorder, meet_semilorder
obua@14738
    66
obua@14738
    67
constdefs
obua@14738
    68
  meet :: "('a::meet_semilorder) \<Rightarrow> 'a \<Rightarrow> 'a"
obua@14738
    69
  "meet == THE m. is_meet m"
obua@14738
    70
  join :: "('a::join_semilorder) \<Rightarrow> 'a \<Rightarrow> 'a"
obua@14738
    71
  "join ==  THE j. is_join j"
obua@14738
    72
obua@14738
    73
lemma is_meet_meet: "is_meet (meet::'a \<Rightarrow> 'a \<Rightarrow> ('a::meet_semilorder))"
obua@14738
    74
proof -
obua@14738
    75
  from meet_exists obtain k::"'a \<Rightarrow> 'a \<Rightarrow> 'a" where "is_meet k" ..
obua@14738
    76
  with is_meet_unique[of _ k] show ?thesis
obua@14738
    77
    by (simp add: meet_def theI[of is_meet])    
obua@14738
    78
qed
obua@14738
    79
obua@14738
    80
lemma meet_unique: "(is_meet m) = (m = meet)" 
obua@14738
    81
by (insert is_meet_meet, auto simp add: is_meet_unique)
obua@14738
    82
obua@14738
    83
lemma is_join_join: "is_join (join::'a \<Rightarrow> 'a \<Rightarrow> ('a::join_semilorder))"
obua@14738
    84
proof -
obua@14738
    85
  from join_exists obtain k::"'a \<Rightarrow> 'a \<Rightarrow> 'a" where "is_join k" ..
obua@14738
    86
  with is_join_unique[of _ k] show ?thesis
obua@14738
    87
    by (simp add: join_def theI[of is_join])    
obua@14738
    88
qed
obua@14738
    89
obua@14738
    90
lemma join_unique: "(is_join j) = (j = join)"
obua@14738
    91
by (insert is_join_join, auto simp add: is_join_unique)
obua@14738
    92
nipkow@21733
    93
interpretation meet_semilat:
nipkow@21733
    94
  lower_semilattice ["op \<le> \<Colon> 'a\<Colon>meet_semilorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" meet]
haftmann@21380
    95
proof unfold_locales
nipkow@21733
    96
  fix x y z :: "'a\<Colon>meet_semilorder"
haftmann@21380
    97
  from is_meet_meet have "is_meet meet" by blast
haftmann@21380
    98
  note meet = this is_meet_def
haftmann@21380
    99
  from meet show "meet x y \<le> x" by blast
haftmann@21380
   100
  from meet show "meet x y \<le> y" by blast
haftmann@21380
   101
  from meet show "x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> meet y z" by blast
nipkow@21733
   102
qed
nipkow@21733
   103
nipkow@21733
   104
interpretation join_semilat:
nipkow@21733
   105
  upper_semilattice ["op \<le> \<Colon> 'a\<Colon>join_semilorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" join]
nipkow@21733
   106
proof unfold_locales
nipkow@21733
   107
  fix x y z :: "'a\<Colon>join_semilorder"
haftmann@21380
   108
  from is_join_join have "is_join join" by blast
haftmann@21380
   109
  note join = this is_join_def
haftmann@21380
   110
  from join show "x \<le> join x y" by blast
haftmann@21380
   111
  from join show "y \<le> join x y" by blast
nipkow@21733
   112
  from join show "x \<le> z \<Longrightarrow> y \<le> z \<Longrightarrow> join x y \<le> z" by blast
haftmann@21380
   113
qed
haftmann@21380
   114
nipkow@21733
   115
declare
nipkow@21733
   116
 join_semilat.antisym_intro[rule del] meet_semilat.antisym_intro[rule del]
nipkow@21733
   117
 join_semilat.less_eq_supE[rule del] meet_semilat.less_eq_infE[rule del]
obua@14738
   118
nipkow@21733
   119
interpretation meet_join_lat:
nipkow@21733
   120
  lattice ["op \<le> \<Colon> 'a\<Colon>lorder \<Rightarrow> 'a \<Rightarrow> bool" "op <" meet join]
nipkow@21733
   121
by unfold_locales
obua@14738
   122
nipkow@21733
   123
lemmas meet_left_le = meet_semilat.inf_le1
nipkow@21733
   124
lemmas meet_right_le = meet_semilat.inf_le2
nipkow@21733
   125
lemmas le_meetI[rule del] = meet_semilat.less_eq_infI
nipkow@21733
   126
(* intro! breaks a proof in Hyperreal/SEQ and NumberTheory/IntPrimes *)
nipkow@21733
   127
lemmas join_left_le = join_semilat.sup_ge1
nipkow@21733
   128
lemmas join_right_le = join_semilat.sup_ge2
nipkow@21733
   129
lemmas join_leI[rule del] = join_semilat.less_eq_supI
nipkow@21312
   130
nipkow@21733
   131
lemmas meet_join_le = meet_left_le meet_right_le join_left_le join_right_le
nipkow@21312
   132
nipkow@21733
   133
lemmas le_meet = meet_semilat.less_eq_inf_conv
nipkow@21312
   134
nipkow@21733
   135
lemmas le_join = join_semilat.above_sup_conv
obua@14738
   136
obua@14738
   137
lemma is_meet_min: "is_meet (min::'a \<Rightarrow> 'a \<Rightarrow> ('a::linorder))"
obua@14738
   138
by (auto simp add: is_meet_def min_def)
obua@14738
   139
obua@14738
   140
lemma is_join_max: "is_join (max::'a \<Rightarrow> 'a \<Rightarrow> ('a::linorder))"
obua@14738
   141
by (auto simp add: is_join_def max_def)
obua@14738
   142
obua@14738
   143
instance linorder \<subseteq> meet_semilorder
obua@14738
   144
proof
obua@14738
   145
  from is_meet_min show "? (m::'a\<Rightarrow>'a\<Rightarrow>('a::linorder)). is_meet m" by auto
obua@14738
   146
qed
obua@14738
   147
obua@14738
   148
instance linorder \<subseteq> join_semilorder
obua@14738
   149
proof
obua@14738
   150
  from is_join_max show "? (j::'a\<Rightarrow>'a\<Rightarrow>('a::linorder)). is_join j" by auto 
obua@14738
   151
qed
obua@14738
   152
    
obua@14738
   153
instance linorder \<subseteq> lorder ..
obua@14738
   154
obua@14738
   155
lemma meet_min: "meet = (min :: 'a\<Rightarrow>'a\<Rightarrow>('a::linorder))" 
obua@14738
   156
by (simp add: is_meet_meet is_meet_min is_meet_unique)
obua@14738
   157
obua@14738
   158
lemma join_max: "join = (max :: 'a\<Rightarrow>'a\<Rightarrow>('a::linorder))"
obua@14738
   159
by (simp add: is_join_join is_join_max is_join_unique)
obua@14738
   160
nipkow@21733
   161
lemmas meet_idempotent = meet_semilat.inf_idem
nipkow@21733
   162
lemmas join_idempotent = join_semilat.sup_idem
nipkow@21733
   163
lemmas meet_comm = meet_semilat.inf_commute
nipkow@21733
   164
lemmas join_comm = join_semilat.sup_commute
nipkow@21733
   165
lemmas meet_leI1[rule del] = meet_semilat.less_eq_infI1
nipkow@21733
   166
lemmas meet_leI2[rule del] = meet_semilat.less_eq_infI2
nipkow@21733
   167
lemmas le_joinI1[rule del] = join_semilat.less_eq_supI1
nipkow@21733
   168
lemmas le_joinI2[rule del] = join_semilat.less_eq_supI2
nipkow@21733
   169
lemmas meet_assoc = meet_semilat.inf_assoc
nipkow@21733
   170
lemmas join_assoc = join_semilat.sup_assoc
nipkow@21733
   171
lemmas meet_left_comm = meet_semilat.inf_left_commute
nipkow@21733
   172
lemmas meet_left_idempotent = meet_semilat.inf_left_idem
nipkow@21733
   173
lemmas join_left_comm = join_semilat.sup_left_commute
nipkow@21733
   174
lemmas join_left_idempotent= join_semilat.sup_left_idem
obua@14738
   175
    
obua@14738
   176
lemmas meet_aci = meet_assoc meet_comm meet_left_comm meet_left_idempotent
obua@14738
   177
lemmas join_aci = join_assoc join_comm join_left_comm join_left_idempotent
obua@14738
   178
nipkow@21312
   179
lemma le_def_meet: "(x <= y) = (meet x y = x)"
nipkow@21312
   180
apply rule
nipkow@21312
   181
apply(simp add: order_antisym)
nipkow@21312
   182
apply(subgoal_tac "meet x y <= y")
nipkow@21312
   183
apply(simp)
nipkow@21312
   184
apply(simp (no_asm))
nipkow@21312
   185
done
obua@14738
   186
nipkow@21312
   187
lemma le_def_join: "(x <= y) = (join x y = y)"
nipkow@21312
   188
apply rule
nipkow@21312
   189
apply(simp add: order_antisym)
nipkow@21312
   190
apply(subgoal_tac "x <= join x y")
nipkow@21312
   191
apply(simp)
nipkow@21312
   192
apply(simp (no_asm))
nipkow@21312
   193
done
nipkow@21312
   194
nipkow@21733
   195
lemmas join_absorp2 = join_semilat.sup_absorb2
nipkow@21733
   196
lemmas join_absorp1 = join_semilat.sup_absorb1
nipkow@21312
   197
nipkow@21733
   198
lemmas meet_absorp1 = meet_semilat.inf_absorb1
nipkow@21733
   199
lemmas meet_absorp2 = meet_semilat.inf_absorb2
obua@14738
   200
obua@14738
   201
lemma meet_join_absorp: "meet x (join x y) = x"
nipkow@21312
   202
by(simp add:meet_absorp1)
obua@14738
   203
obua@14738
   204
lemma join_meet_absorp: "join x (meet x y) = x"
nipkow@21312
   205
by(simp add:join_absorp1)
obua@14738
   206
obua@14738
   207
lemma meet_mono: "y \<le> z \<Longrightarrow> meet x y \<le> meet x z"
nipkow@21312
   208
by(simp add:meet_leI2)
obua@14738
   209
obua@14738
   210
lemma join_mono: "y \<le> z \<Longrightarrow> join x y \<le> join x z"
nipkow@21312
   211
by(simp add:le_joinI2)
obua@14738
   212
obua@14738
   213
lemma distrib_join_le: "join x (meet y z) \<le> meet (join x y) (join x z)" (is "_ <= ?r")
obua@14738
   214
proof -
nipkow@21312
   215
  have a: "x <= ?r" by (simp_all add:le_meetI)
nipkow@21312
   216
  have b: "meet y z <= ?r" by (simp add:le_joinI2)
nipkow@21312
   217
  from a b show ?thesis by (simp add: join_leI)
obua@14738
   218
qed
obua@14738
   219
  
nipkow@21312
   220
lemma distrib_meet_le: "join (meet x y) (meet x z) \<le> meet x (join y z)" (is "?l <= _")
obua@14738
   221
proof -
nipkow@21312
   222
  have a: "?l <= x" by (simp_all add: join_leI)
nipkow@21312
   223
  have b: "?l <= join y z" by (simp add:meet_leI2)
nipkow@21312
   224
  from a b show ?thesis by (simp add: le_meetI)
obua@14738
   225
qed
obua@14738
   226
obua@14738
   227
lemma meet_join_eq_imp_le: "a = c \<or> a = d \<or> b = c \<or> b = d \<Longrightarrow> meet a b \<le> join c d"
nipkow@21312
   228
by (auto simp:meet_leI2 meet_leI1)
obua@14738
   229
obua@14738
   230
lemma modular_le: "x \<le> z \<Longrightarrow> join x (meet y z) \<le> meet (join x y) z" (is "_ \<Longrightarrow> ?t <= _")
obua@14738
   231
proof -
obua@14738
   232
  assume a: "x <= z"
nipkow@21312
   233
  have b: "?t <= join x y" by (simp_all add: join_leI meet_join_eq_imp_le )
nipkow@21312
   234
  have c: "?t <= z" by (simp_all add: a join_leI)
nipkow@21312
   235
  from b c show ?thesis by (simp add: le_meetI)
obua@14738
   236
qed
obua@14738
   237
nipkow@15131
   238
end