Lattice.v 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. (* Copyright © 2019 Ariadne Devos
  2. SPDX-License-Identifier: GPL-2.0 or GPL-3.0 *)
  3. Require Import Coq.Classes.Equivalence.
  4. Require Import Coq.Classes.Morphisms.
  5. Require Import Coq.Relations.Relations.
  6. Require Import Coq.Setoids.Setoid.
  7. (* Proof further properties on an as-needed basis *)
  8. Section lattice.
  9. Variable A : Type.
  10. Variable eqv : relation A.
  11. Variable eqv_equiv : Equivalence eqv.
  12. Section definition.
  13. Variable join : A -> A -> A.
  14. Variable meet : A -> A -> A.
  15. Local Open Scope signature_scope.
  16. Variable join_morphism : Proper (eqv ==> eqv ==> eqv) join.
  17. Variable meet_morphism : Proper (eqv ==> eqv ==> eqv) meet.
  18. Local Notation "a '≡' b" := (eqv (a : A) (b : A)) (at level 100).
  19. Local Notation "a '∨' b" := (join (a : A) (b : A)) (at level 50).
  20. Local Notation "a '∧' b" := (meet (a : A) (b : A)) (at level 50).
  21. Record lattice_theory := {
  22. join_comm : forall x y, x ∨ y ≡ y ∨ x;
  23. join_assoc : forall x y z, x ∨ (y ∨ z) ≡ (x ∨ y) ∨ z;
  24. meet_comm : forall x y, x ∧ y ≡ y ∧ x;
  25. meet_assoc : forall x y z, x ∧ (y ∧ z) ≡ (x ∧ y) ∧ z;
  26. join_absorb : forall x y, x ∨ (x ∧ y) ≡ x;
  27. meet_absorb : forall x y, x ∧ (x ∨ y) ≡ x;
  28. }.
  29. Section laws.
  30. Variable lattice : lattice_theory.
  31. Theorem join_idempotent : forall x, x ∨ x ≡ x.
  32. Proof.
  33. intros.
  34. (* Wikipedia note 1 (from Richard Dedekind):
  35. a ∨ a = a ∨ (a ∧ (a ∨ a)) = a *)
  36. rewrite <- (join_absorb lattice x (x ∨ x)).
  37. rewrite meet_absorb.
  38. + reflexivity.
  39. + assumption.
  40. Qed.
  41. Theorem meet_idempotent : forall x, x ∧ x ≡ x.
  42. Proof.
  43. intros.
  44. (* Wikipedia note 1 (from Richard Dedekind):
  45. a ∨ a = a ∨ (a ∧ (a ∨ a)) = a *)
  46. rewrite <- (meet_absorb lattice x (x ∧ x)).
  47. rewrite join_absorb.
  48. + reflexivity.
  49. + assumption.
  50. Qed.
  51. End laws.
  52. Section bounded.
  53. Variable bottom : A.
  54. Variable top : A.
  55. Record bounded_lattice_theory := {
  56. lattice : lattice_theory;
  57. join_bottom : forall x, x ∨ bottom ≡ x;
  58. join_top : forall x, x ∨ top ≡ top;
  59. meet_bottom : forall x, x ∧ bottom ≡ bottom;
  60. meet_top : forall x, x ∧ top ≡ x;
  61. }.
  62. End bounded.
  63. Section distributive.
  64. Record distributive_theory := {
  65. join_meet_distr : forall x y z, (x ∧ y) ∨ (x ∧ z) ≡ x ∧ (y ∨ z);
  66. meet_join_distr : forall x y z, (x ∨ y) ∧ (x ∨ z) ≡ x ∨ (y ∧ z);
  67. }.
  68. End distributive.
  69. End definition.
  70. Section duality.
  71. Variable join : A -> A -> A.
  72. Variable meet : A -> A -> A.
  73. Variable join_morphism : Proper (eqv ==> eqv ==> eqv) join.
  74. Variable meet_morphism : Proper (eqv ==> eqv ==> eqv) meet.
  75. Theorem lattice_dual : lattice_theory join meet -> lattice_theory meet join.
  76. Proof. firstorder. Qed.
  77. Theorem distributive_dual : distributive_theory join meet -> distributive_theory join meet.
  78. Proof. firstorder. Qed.
  79. End duality.
  80. End lattice.