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