------------------------------------------------------------------------ -- The Agda standard library -- -- A bunch of properties ------------------------------------------------------------------------ {-# OPTIONS --cubical-compatible --safe #-} module Data.Bool.Properties where open import Algebra.Bundles using (Magma; Semigroup; Band; CommutativeMonoid ; IdempotentCommutativeMonoid; CommutativeSemiring; CommutativeRing) open import Algebra.Lattice.Bundles using (Lattice; DistributiveLattice; BooleanAlgebra; Semilattice) import Algebra.Lattice.Properties.BooleanAlgebra as BooleanAlgebraProperties open import Data.Bool.Base using (Bool; true; false; not; _∧_; _∨_; _xor_ ; if_then_else_; T; _≤_; _<_ ; b≤b; f≤t; f; _Respects₂_) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; sym; cong; cong₂; subst; trans; _≢_) open import Relation.Binary.PropositionalEquality.Properties using (module ≡-Reasoning; setoid; decSetoid; isEquivalence) open import Relation.Nullary.Decidable.Core using (True; yes; no; fromWitness ; toWitness) open import Relation.Nullary.Negation.Core using (contradiction) import Relation.Unary as U open import Algebra.Definitions {A = Bool} _≡_ open import Algebra.Structures {A = Bool} _≡_ open import Algebra.Lattice.Structures {A = Bool} _≡_ open ≡-Reasoning private variable a b : Level A : Set a B : Set b ------------------------------------------------------------------------ -- Properties of _≡_ infix 4 _≟_ _≟_ : DecidableEquality Bool true ≟ true = yes refl false ≟ false = yes refl true ≟ false = no λ() false ≟ true = no λ() ≡-setoid : Setoid 0ℓ 0ℓ ≡-setoid = setoid Bool ≡-decSetoid : DecSetoid 0ℓ 0ℓ ≡-decSetoid = decSetoid _≟_ ------------------------------------------------------------------------ -- Properties of _≤_ -- Relational properties ≤-reflexive : _≡_ ⇒ _≤_ ≤-reflexive refl = b≤b ≤-refl : Reflexive _≤_ ≤-refl = ≤-reflexive refl ≤-trans : Transitive _≤_ ≤-trans b≤b p = p ≤-trans f≤t b≤b = f≤t ≤-antisym : Antisymmetric _≡_ _≤_ ≤-antisym b≤b _ = refl ≤-minimum : Minimum _≤_ false ≤-minimum false = b≤b ≤-minimum true = f≤t ≤-maximum : Maximum _≤_ true ≤-maximum false = f≤t ≤-maximum true = b≤b ≤-total : Total _≤_ ≤-total false b = inj₁ (≤-minimum b) ≤-total true b = inj₂ (≤-maximum b) infix 4 _≤?_ _≤?_ : Decidable _≤_ false ≤? b = yes (≤-minimum b) true ≤? false = no λ () true ≤? true = yes b≤b ≤-irrelevant : Irrelevant _≤_ ≤-irrelevant {_} f≤t f≤t = refl ≤-irrelevant {false} b≤b b≤b = refl ≤-irrelevant {true} b≤b b≤b = refl -- Structures ≤-isPreorder : IsPreorder _≡_ _≤_ ≤-isPreorder = record { isEquivalence = isEquivalence ; reflexive = ≤-reflexive ; trans = ≤-trans } ≤-isPartialOrder : IsPartialOrder _≡_ _≤_ ≤-isPartialOrder = record { isPreorder = ≤-isPreorder ; antisym = ≤-antisym } ≤-isTotalOrder : IsTotalOrder _≡_ _≤_ ≤-isTotalOrder = record { isPartialOrder = ≤-isPartialOrder ; total = ≤-total } ≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_ ≤-isDecTotalOrder = record { isTotalOrder = ≤-isTotalOrder ; _≟_ = _≟_ ; _≤?_ = _≤?_ } -- Bundles ≤-poset : Poset 0ℓ 0ℓ 0ℓ ≤-poset = record { isPartialOrder = ≤-isPartialOrder } ≤-preorder : Preorder 0ℓ 0ℓ 0ℓ ≤-preorder = record { isPreorder = ≤-isPreorder } ≤-totalOrder : TotalOrder 0ℓ 0ℓ 0ℓ ≤-totalOrder = record { isTotalOrder = ≤-isTotalOrder } ≤-decTotalOrder : DecTotalOrder 0ℓ 0ℓ 0ℓ ≤-decTotalOrder = record { isDecTotalOrder = ≤-isDecTotalOrder } ------------------------------------------------------------------------ -- Properties of _<_ -- Relational properties <-irrefl : Irreflexive _≡_ _<_ <-irrefl refl () <-asym : Asymmetric _<_ <-asym f (λ()) (λ()) f