src/HOL/Lattice_Locales.thy
author nipkow
Tue, 22 Feb 2005 10:54:30 +0100
changeset 15543 0024472afce7
parent 15524 2ef571f80a55
child 15791 446ec11266be
permissions -rw-r--r--
more setsum tuning
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
nipkow
parents:
diff changeset
    55
lemma (in lattice) inf_sup_absorb: "x \<sqinter> (x \<squnion> y) = x"
nipkow
parents:
diff changeset
    56
by(blast intro: antisym inf_le1 inf_least sup_ge1)
nipkow
parents:
diff changeset
    57
nipkow
parents:
diff changeset
    58
lemma (in lattice) sup_inf_absorb: "x \<squnion> (x \<sqinter> y) = x"
nipkow
parents:
diff changeset
    59
by(blast intro: antisym sup_ge1 sup_greatest inf_le1)
nipkow
parents:
diff changeset
    60
nipkow
parents:
diff changeset
    61
lemma (in lower_semilattice) inf_absorb: "x \<sqsubseteq> y \<Longrightarrow> x \<sqinter> y = x"
nipkow
parents:
diff changeset
    62
by(blast intro: antisym inf_le1 inf_least refl)
nipkow
parents:
diff changeset
    63
nipkow
parents:
diff changeset
    64
lemma (in upper_semilattice) sup_absorb: "x \<sqsubseteq> y \<Longrightarrow> x \<squnion> y = y"
nipkow
parents:
diff changeset
    65
by(blast intro: antisym sup_ge2 sup_greatest refl)
nipkow
parents:
diff changeset
    66
15524
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    67
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    68
lemma (in lower_semilattice) below_inf_conv[simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    69
 "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
    70
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
    71
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    72
lemma (in upper_semilattice) above_sup_conv[simp]:
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    73
 "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
    74
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
    75
2ef571f80a55 Moved oderings from HOL into the new Orderings.thy
nipkow
parents: 15511
diff changeset
    76
15511
nipkow
parents:
diff changeset
    77
text{* Towards distributivity: if you have one of them, you have them all. *}
nipkow
parents:
diff changeset
    78
nipkow
parents:
diff changeset
    79
lemma (in lattice) distrib_imp1:
nipkow
parents:
diff changeset
    80
assumes D: "!!x y z. x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
    81
shows "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
    82
proof-
nipkow
parents:
diff changeset
    83
  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
    84
  also have "\<dots> = x \<squnion> (z \<sqinter> (x \<squnion> y))" by(simp add:D inf_commute sup_assoc)
nipkow
parents:
diff changeset
    85
  also have "\<dots> = ((x \<squnion> y) \<sqinter> x) \<squnion> ((x \<squnion> y) \<sqinter> z)"
nipkow
parents:
diff changeset
    86
    by(simp add:inf_sup_absorb inf_commute)
nipkow
parents:
diff changeset
    87
  also have "\<dots> = (x \<squnion> y) \<sqinter> (x \<squnion> z)" by(simp add:D)
nipkow
parents:
diff changeset
    88
  finally show ?thesis .
nipkow
parents:
diff changeset
    89
qed
nipkow
parents:
diff changeset
    90
nipkow
parents:
diff changeset
    91
lemma (in lattice) distrib_imp2:
nipkow
parents:
diff changeset
    92
assumes D: "!!x y z. x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
    93
shows "x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
    94
proof-
nipkow
parents:
diff changeset
    95
  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
    96
  also have "\<dots> = x \<sqinter> (z \<squnion> (x \<sqinter> y))" by(simp add:D sup_commute inf_assoc)
nipkow
parents:
diff changeset
    97
  also have "\<dots> = ((x \<sqinter> y) \<squnion> x) \<sqinter> ((x \<sqinter> y) \<squnion> z)"
nipkow
parents:
diff changeset
    98
    by(simp add:sup_inf_absorb sup_commute)
nipkow
parents:
diff changeset
    99
  also have "\<dots> = (x \<sqinter> y) \<squnion> (x \<sqinter> z)" by(simp add:D)
nipkow
parents:
diff changeset
   100
  finally show ?thesis .
nipkow
parents:
diff changeset
   101
qed
nipkow
parents:
diff changeset
   102
nipkow
parents:
diff changeset
   103
text{* A package of rewrite rules for deciding equivalence wrt ACI: *}
nipkow
parents:
diff changeset
   104
nipkow
parents:
diff changeset
   105
lemma (in lower_semilattice) inf_left_commute: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)"
nipkow
parents:
diff changeset
   106
proof -
nipkow
parents:
diff changeset
   107
  have "x \<sqinter> (y \<sqinter> z) = (y \<sqinter> z) \<sqinter> x" by (simp only: inf_commute)
nipkow
parents:
diff changeset
   108
  also have "... = y \<sqinter> (z \<sqinter> x)" by (simp only: inf_assoc)
nipkow
parents:
diff changeset
   109
  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
   110
  finally(back_subst) show ?thesis .
15511
nipkow
parents:
diff changeset
   111
qed
nipkow
parents:
diff changeset
   112
nipkow
parents:
diff changeset
   113
lemma (in upper_semilattice) sup_left_commute: "x \<squnion> (y \<squnion> z) = y \<squnion> (x \<squnion> z)"
nipkow
parents:
diff changeset
   114
proof -
nipkow
parents:
diff changeset
   115
  have "x \<squnion> (y \<squnion> z) = (y \<squnion> z) \<squnion> x" by (simp only: sup_commute)
nipkow
parents:
diff changeset
   116
  also have "... = y \<squnion> (z \<squnion> x)" by (simp only: sup_assoc)
nipkow
parents:
diff changeset
   117
  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
   118
  finally(back_subst) show ?thesis .
15511
nipkow
parents:
diff changeset
   119
qed
nipkow
parents:
diff changeset
   120
nipkow
parents:
diff changeset
   121
lemma (in lower_semilattice) inf_left_idem: "x \<sqinter> (x \<sqinter> y) = x \<sqinter> y"
nipkow
parents:
diff changeset
   122
proof -
nipkow
parents:
diff changeset
   123
  have "x \<sqinter> (x \<sqinter> y) = (x \<sqinter> x) \<sqinter> y" by(simp only:inf_assoc)
nipkow
parents:
diff changeset
   124
  also have "\<dots> = x \<sqinter> y" by(simp)
nipkow
parents:
diff changeset
   125
  finally show ?thesis .
nipkow
parents:
diff changeset
   126
qed
nipkow
parents:
diff changeset
   127
nipkow
parents:
diff changeset
   128
lemma (in upper_semilattice) sup_left_idem: "x \<squnion> (x \<squnion> y) = x \<squnion> y"
nipkow
parents:
diff changeset
   129
proof -
nipkow
parents:
diff changeset
   130
  have "x \<squnion> (x \<squnion> y) = (x \<squnion> x) \<squnion> y" by(simp only:sup_assoc)
nipkow
parents:
diff changeset
   131
  also have "\<dots> = x \<squnion> y" by(simp)
nipkow
parents:
diff changeset
   132
  finally show ?thesis .
nipkow
parents:
diff changeset
   133
qed
nipkow
parents:
diff changeset
   134
nipkow
parents:
diff changeset
   135
nipkow
parents:
diff changeset
   136
lemmas (in lower_semilattice) inf_ACI =
nipkow
parents:
diff changeset
   137
 inf_commute inf_assoc inf_left_commute inf_left_idem
nipkow
parents:
diff changeset
   138
nipkow
parents:
diff changeset
   139
lemmas (in upper_semilattice) sup_ACI =
nipkow
parents:
diff changeset
   140
 sup_commute sup_assoc sup_left_commute sup_left_idem
nipkow
parents:
diff changeset
   141
nipkow
parents:
diff changeset
   142
lemmas (in lattice) ACI = inf_ACI sup_ACI
nipkow
parents:
diff changeset
   143
nipkow
parents:
diff changeset
   144
nipkow
parents:
diff changeset
   145
subsection{* Distributive lattices *}
nipkow
parents:
diff changeset
   146
nipkow
parents:
diff changeset
   147
locale distrib_lattice = lattice +
nipkow
parents:
diff changeset
   148
  assumes sup_inf_distrib1: "x \<squnion> (y \<sqinter> z) = (x \<squnion> y) \<sqinter> (x \<squnion> z)"
nipkow
parents:
diff changeset
   149
nipkow
parents:
diff changeset
   150
lemma (in distrib_lattice) sup_inf_distrib2:
nipkow
parents:
diff changeset
   151
 "(y \<sqinter> z) \<squnion> x = (y \<squnion> x) \<sqinter> (z \<squnion> x)"
nipkow
parents:
diff changeset
   152
by(simp add:ACI sup_inf_distrib1)
nipkow
parents:
diff changeset
   153
nipkow
parents:
diff changeset
   154
lemma (in distrib_lattice) inf_sup_distrib1:
nipkow
parents:
diff changeset
   155
 "x \<sqinter> (y \<squnion> z) = (x \<sqinter> y) \<squnion> (x \<sqinter> z)"
nipkow
parents:
diff changeset
   156
by(rule distrib_imp2[OF sup_inf_distrib1])
nipkow
parents:
diff changeset
   157
nipkow
parents:
diff changeset
   158
lemma (in distrib_lattice) inf_sup_distrib2:
nipkow
parents:
diff changeset
   159
 "(y \<squnion> z) \<sqinter> x = (y \<sqinter> x) \<squnion> (z \<sqinter> x)"
nipkow
parents:
diff changeset
   160
by(simp add:ACI inf_sup_distrib1)
nipkow
parents:
diff changeset
   161
nipkow
parents:
diff changeset
   162
lemmas (in distrib_lattice) distrib =
nipkow
parents:
diff changeset
   163
  sup_inf_distrib1 sup_inf_distrib2 inf_sup_distrib1 inf_sup_distrib2
nipkow
parents:
diff changeset
   164
nipkow
parents:
diff changeset
   165
nipkow
parents:
diff changeset
   166
end