Debian Codegraph @

src/Relation/Binary/Properties/DecSetoid.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Every decidable setoid induces tight apartness relation.
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Relation.Binary.Bundles using (DecSetoid; ApartnessRelation)
10
11 module Relation.Binary.Properties.DecSetoid {c ℓ} (S : DecSetoid c ℓ) where
12
13 open import Data.Product using (_,_)
14 open import Data.Sum using (inj₁; inj₂)
15 open import Relation.Binary.Definitions
16 using (Cotransitive; Tight)
17 import Relation.Binary.Properties.Setoid as SetoidProperties
18 open import Relation.Binary.Structures
19 using (IsApartnessRelation; IsDecEquivalence)
20 open import Relation.Nullary.Decidable.Core
21 using (yes; no; decidable-stable)
22
23 open DecSetoid S using (_≈_; _≉_; _≟_; setoid; trans)
24 open SetoidProperties setoid
25
26 ≉-cotrans : Cotransitive _≉_
27 ≉-cotrans {x} {y} x≉y z with x ≟ z | z ≟ y
28 ... | _ | no z≉y = inj₂ z≉y
29 ... | no x≉z | _ = inj₁ x≉z
30 ... | yes x≈z | yes z≈y = inj₁ λ _ → x≉y (trans x≈z z≈y)
31
32 ≉-isApartnessRelation : IsApartnessRelation _≈_ _≉_
33 ≉-isApartnessRelation = record
34 { irrefl = ≉-irrefl
35 ; sym = ≉-sym
36 ; cotrans = ≉-cotrans
37 }
38
39 ≉-apartnessRelation : ApartnessRelation c ℓ ℓ
40 ≉-apartnessRelation = record { isApartnessRelation = ≉-isApartnessRelation }
41
42 ≉-tight : Tight _≈_ _≉_
43 ≉-tight x y = decidable-stable (x ≟ y) , ≉-irrefl