src/HOL/Lattice_Locales.thy
author kleing
Sat, 30 Apr 2005 14:18:36 +0200
changeset 15900 d6156cb8dc2e
parent 15791 446ec11266be
child 21216 1c8580913738
permissions -rw-r--r--
fixed typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15511
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Lattices.thy
nipkow
parents:
diff changeset
     2
    ID:         $Id$
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
nipkow
parents:
diff changeset
     4
*)
nipkow
parents:
diff changeset
     5
nipkow
parents:
diff changeset
     6
header {* Lattices via Locales *}
nipkow
parents:
diff changeset
     7
nipkow
parents:
diff changeset
     8
theory Lattice_Locales
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
     9
imports HOL
15511
nipkow
parents:
diff changeset
    10
begin
nipkow
parents:
diff changeset
    11
nipkow
parents:
diff changeset
    12
subsection{* Lattices *}
nipkow
parents:
diff changeset
    13
nipkow
parents:
diff changeset
    14
text{* This theory of lattice locales only defines binary sup and inf
nipkow
parents:
diff changeset
    15
operations. The extension to finite sets is done in theory @{text
nipkow
parents:
diff changeset
    16
Finite_Set}. In the longer term it may be better to define arbitrary
nipkow
parents:
diff changeset
    17
sups and infs via @{text THE}. *}
nipkow
parents:
diff changeset
    18
nipkow
parents:
diff changeset
    19
locale partial_order =
nipkow
parents:
diff changeset
    20
  fixes below :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infixl "\<sqsubseteq>" 50)
nipkow
parents:
diff changeset
    21
  assumes refl[iff]: "x \<sqsubseteq> x"
nipkow
parents:
diff changeset
    22
  and trans: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> z"
nipkow
parents:
diff changeset
    23
  and antisym: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> x \<Longrightarrow> x = y"
nipkow
parents:
diff changeset
    24
nipkow
parents:
diff changeset
    25
locale lower_semilattice = partial_order +
nipkow
parents:
diff changeset
    26
  fixes inf :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<sqinter>" 70)
nipkow
parents:
diff changeset
    27
  assumes inf_le1: "x \<sqinter> y \<sqsubseteq> x" and inf_le2: "x \<sqinter> y \<sqsubseteq> y"
nipkow
parents:
diff changeset
    28
  and inf_least: "x \<sqsubseteq> y \<Longrightarrow> x \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> y \<sqinter> z"
nipkow
parents:
diff changeset
    29
nipkow
parents:
diff changeset
    30
locale upper_semilattice = partial_order +
nipkow
parents:
diff changeset
    31
  fixes sup :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<squnion>" 65)
nipkow
parents:
diff changeset
    32
  assumes sup_ge1: "x \<sqsubseteq> x \<squnion> y" and sup_ge2: "y \<sqsubseteq> x \<squnion> y"
nipkow
parents:
diff changeset
    33
  and sup_greatest: "y \<sqsubseteq> x \<Longrightarrow> z \<sqsubseteq> x \<Longrightarrow> y \<squnion> z \<sqsubseteq> x"
nipkow
parents:
diff changeset
    34
nipkow
parents:
diff changeset
    35
locale lattice = lower_semilattice + upper_semilattice
nipkow
parents:
diff changeset
    36
nipkow
parents:
diff changeset
    37
lemma (in lower_semilattice) inf_commute: "(x \<sqinter> y) = (y \<sqinter> x)"
nipkow
parents:
diff changeset
    38
by(blast intro: antisym inf_le1 inf_le2 inf_least)
nipkow
parents:
diff changeset
    39
nipkow
parents:
diff changeset
    40
lemma (in upper_semilattice) sup_commute: "(x \<squnion> y) = (y \<squnion> x)"
nipkow
parents:
diff changeset
    41
by(blast intro: antisym sup_ge1 sup_ge2 sup_greatest)
nipkow
parents:
diff changeset
    42
nipkow
parents:
diff changeset
    43
lemma (in lower_semilattice) inf_assoc: "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
nipkow
parents:
diff changeset
    44
by(blast intro: antisym inf_le1 inf_le2 inf_least trans del:refl)
nipkow
parents:
diff changeset
    45
nipkow
parents:
diff changeset
    46
lemma (in upper_semilattice) sup_assoc: "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
nipkow
parents:
diff changeset
    47
by(blast intro!: antisym sup_ge1 sup_ge2 intro: sup_greatest trans del:refl)
nipkow
parents:
diff changeset
    48
nipkow
parents:
diff changeset
    49
lemma (in lower_semilattice) inf_idem[simp]: "x \<sqinter> x = x"
nipkow
parents:
diff changeset
    50
by(blast intro: antisym inf_le1 inf_le2 inf_least refl)
nipkow
parents:
diff changeset
    51
nipkow
parents:
diff changeset
    52
lemma (in upper_semilattice) sup_idem[simp]: "x \<squnion> x = x"
nipkow
parents:
diff changeset
    53
by(blast intro: antisym sup_ge1 sup_ge2 sup_greatest refl)
nipkow
parents:
diff changeset
    54
15791
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    55
lemma (in lower_semilattice) inf_left_idem[simp]: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y"
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    56
by (simp add: inf_assoc[symmetric])
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    57
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    58
lemma (in upper_semilattice) sup_left_idem[simp]: "x \<squnion> (x \<squnion> y) = x \<squnion> y"
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    59
by (simp add: sup_assoc[symmetric])
446ec11266be tuning locales
nipkow
parents: 15524
diff changeset
    60
15511
nipkow
parents:
diff changeset
    61
lemma (in lattice) inf_sup_absorb: "x \<sqinter> (x \<squnion> y) = x"
nipkow
parents:
diff changeset
    62
by(blast intro: antisym inf_le1 inf_least sup_ge1)
nipkow
parents:
diff changeset
    63
nipkow
parents:
diff changeset
    64
lemma (in lattice) sup_inf_absorb: "x \<squnion> (x \<sqinter> y) = x"
nipkow
parents:
diff changeset
    65
by(blast intro: antisym sup_ge1 sup_greatest inf_le1)
nipkow
parents:
diff changeset
    66
nipkow
parents:
diff changeset
    67
lemma (in lower_semilattice) inf_absorb: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
nipkow
parents:
diff changeset
    68
by(blast intro: antisym inf_le1 inf_least refl)
nipkow
parents:
diff changeset
    69
nipkow
parents:
diff changeset
    70
lemma (in upper_semilattice) sup_absorb: "x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y"
nipkow
parents:
diff changeset
    71
by(blast intro: antisym sup_ge2 sup_greatest refl)
nipkow
parents:
diff changeset
    72
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    73
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    74
lemma (in lower_semilattice) below_inf_conv[simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    75
 "x \<sqsubseteq> y \<sqinter> z = (x \<sqsubseteq> y \<and> x \<sqsubseteq> z)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    76
by(blast intro: antisym inf_le1 inf_le2 inf_least refl trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    77
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    78
lemma (in upper_semilattice) above_sup_conv[simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    79
 "x \<squnion> y \<sqsubseteq> z = (x \<sqsubseteq> z \<and> y \<sqsubseteq> z)"
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    80
by(blast intro: antisym sup_ge1 sup_ge2 sup_greatest refl trans)
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    81
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    82
15511
nipkow
parents:
diff changeset
    83
text{* Towards distributivity: if you have one of them, you have them all. *}
nipkow
parents:
diff changeset
    84
nipkow
parents:
diff changeset
    85
lemma (in lattice) distrib_imp1:
nipkow
parents:
diff changeset
    86
assumes D: "!!x y z. x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
    87
shows "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
    88
proof-
nipkow
parents:
diff changeset
    89
  have "x \<squnion> (y \<sqinter> z) = (x \<squnion> (x \<sqinter> z)) \<squnion> (y \<sqinter> z)" by(simp add:sup_inf_absorb)
nipkow
parents:
diff changeset
    90
  also have "\<dots> = x \<squnion> (z \<sqinter> (x \<squnion> y))" by(simp add:D inf_commute sup_assoc)
nipkow
parents:
diff changeset
    91
  also have "\<dots> = ((x \<squnion> y) \<sqinter> x) \<squnion> ((x \<squnion> y) \<sqinter> z)"
nipkow
parents:
diff changeset
    92
    by(simp add:inf_sup_absorb inf_commute)
nipkow
parents:
diff changeset
    93
  also have "\<dots> = (x \<squnion> y) \<sqinter> (x \<squnion> z)" by(simp add:D)
nipkow
parents:
diff changeset
    94
  finally show ?thesis .
nipkow
parents:
diff changeset
    95
qed
nipkow
parents:
diff changeset
    96
nipkow
parents:
diff changeset
    97
lemma (in lattice) distrib_imp2:
nipkow
parents:
diff changeset
    98
assumes D: "!!x y z. x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
    99
shows "x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
   100
proof-
nipkow
parents:
diff changeset
   101
  have "x \<sqinter> (y \<squnion> z) = (x \<sqinter> (x \<squnion> z)) \<sqinter> (y \<squnion> z)" by(simp add:inf_sup_absorb)
nipkow
parents:
diff changeset
   102
  also have "\<dots> = x \<sqinter> (z \<squnion> (x \<sqinter> y))" by(simp add:D sup_commute inf_assoc)
nipkow
parents:
diff changeset
   103
  also have "\<dots> = ((x \<sqinter> y) \<squnion> x) \<sqinter> ((x \<sqinter> y) \<squnion> z)"
nipkow
parents:
diff changeset
   104
    by(simp add:sup_inf_absorb sup_commute)
nipkow
parents:
diff changeset
   105
  also have "\<dots> = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" by(simp add:D)
nipkow
parents:
diff changeset
   106
  finally show ?thesis .
nipkow
parents:
diff changeset
   107
qed
nipkow
parents:
diff changeset
   108
nipkow
parents:
diff changeset
   109
text{* A package of rewrite rules for deciding equivalence wrt ACI: *}
nipkow
parents:
diff changeset
   110
nipkow
parents:
diff changeset
   111
lemma (in lower_semilattice) inf_left_commute: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)"
nipkow
parents:
diff changeset
   112
proof -
nipkow
parents:
diff changeset
   113
  have "x \<sqinter> (y \<sqinter> z) = (y \<sqinter> z) \<sqinter> x" by (simp only: inf_commute)
nipkow
parents:
diff changeset
   114
  also have "... = y \<sqinter> (z \<sqinter> x)" by (simp only: inf_assoc)
nipkow
parents:
diff changeset
   115
  also have "z \<sqinter> x = x \<sqinter> z" by (simp only: inf_commute)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
   116
  finally(back_subst) show ?thesis .
15511
nipkow
parents:
diff changeset
   117
qed
nipkow
parents:
diff changeset
   118
nipkow
parents:
diff changeset
   119
lemma (in upper_semilattice) sup_left_commute: "x \<squnion> (y \<squnion> z) = y \<squnion> (x \<squnion> z)"
nipkow
parents:
diff changeset
   120
proof -
nipkow
parents:
diff changeset
   121
  have "x \<squnion> (y \<squnion> z) = (y \<squnion> z) \<squnion> x" by (simp only: sup_commute)
nipkow
parents:
diff changeset
   122
  also have "... = y \<squnion> (z \<squnion> x)" by (simp only: sup_assoc)
nipkow
parents:
diff changeset
   123
  also have "z \<squnion> x = x \<squnion> z" by (simp only: sup_commute)
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
   124
  finally(back_subst) show ?thesis .
15511
nipkow
parents:
diff changeset
   125
qed
nipkow
parents:
diff changeset
   126
nipkow
parents:
diff changeset
   127
lemma (in lower_semilattice) inf_left_idem: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y"
nipkow
parents:
diff changeset
   128
proof -
nipkow
parents:
diff changeset
   129
  have "x \<sqinter> (x \<sqinter> y) = (x \<sqinter> x) \<sqinter> y" by(simp only:inf_assoc)
nipkow
parents:
diff changeset
   130
  also have "\<dots> = x \<sqinter> y" by(simp)
nipkow
parents:
diff changeset
   131
  finally show ?thesis .
nipkow
parents:
diff changeset
   132
qed
nipkow
parents:
diff changeset
   133
nipkow
parents:
diff changeset
   134
lemma (in upper_semilattice) sup_left_idem: "x \<squnion> (x \<squnion> y) = x \<squnion> y"
nipkow
parents:
diff changeset
   135
proof -
nipkow
parents:
diff changeset
   136
  have "x \<squnion> (x \<squnion> y) = (x \<squnion> x) \<squnion> y" by(simp only:sup_assoc)
nipkow
parents:
diff changeset
   137
  also have "\<dots> = x \<squnion> y" by(simp)
nipkow
parents:
diff changeset
   138
  finally show ?thesis .
nipkow
parents:
diff changeset
   139
qed
nipkow
parents:
diff changeset
   140
nipkow
parents:
diff changeset
   141
nipkow
parents:
diff changeset
   142
lemmas (in lower_semilattice) inf_ACI =
nipkow
parents:
diff changeset
   143
 inf_commute inf_assoc inf_left_commute inf_left_idem
nipkow
parents:
diff changeset
   144
nipkow
parents:
diff changeset
   145
lemmas (in upper_semilattice) sup_ACI =
nipkow
parents:
diff changeset
   146
 sup_commute sup_assoc sup_left_commute sup_left_idem
nipkow
parents:
diff changeset
   147
nipkow
parents:
diff changeset
   148
lemmas (in lattice) ACI = inf_ACI sup_ACI
nipkow
parents:
diff changeset
   149
nipkow
parents:
diff changeset
   150
nipkow
parents:
diff changeset
   151
subsection{* Distributive lattices *}
nipkow
parents:
diff changeset
   152
nipkow
parents:
diff changeset
   153
locale distrib_lattice = lattice +
nipkow
parents:
diff changeset
   154
  assumes sup_inf_distrib1: "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
   155
nipkow
parents:
diff changeset
   156
lemma (in distrib_lattice) sup_inf_distrib2:
nipkow
parents:
diff changeset
   157
 "(y \<sqinter> z) \<squnion> x = (y \<squnion> x) \<sqinter> (z \<squnion> x)"
nipkow
parents:
diff changeset
   158
by(simp add:ACI sup_inf_distrib1)
nipkow
parents:
diff changeset
   159
nipkow
parents:
diff changeset
   160
lemma (in distrib_lattice) inf_sup_distrib1:
nipkow
parents:
diff changeset
   161
 "x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
   162
by(rule distrib_imp2[OF sup_inf_distrib1])
nipkow
parents:
diff changeset
   163
nipkow
parents:
diff changeset
   164
lemma (in distrib_lattice) inf_sup_distrib2:
nipkow
parents:
diff changeset
   165
 "(y \<squnion> z) \<sqinter> x = (y \<sqinter> x) \<squnion> (z \<sqinter> x)"
nipkow
parents:
diff changeset
   166
by(simp add:ACI inf_sup_distrib1)
nipkow
parents:
diff changeset
   167
nipkow
parents:
diff changeset
   168
lemmas (in distrib_lattice) distrib =
nipkow
parents:
diff changeset
   169
  sup_inf_distrib1 sup_inf_distrib2 inf_sup_distrib1 inf_sup_distrib2
nipkow
parents:
diff changeset
   170
nipkow
parents:
diff changeset
   171
nipkow
parents:
diff changeset
   172
end