Debian Codegraph @

src/Relation/Binary/Construct/FromRel.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Every respectful binary relation induces a preorder. No claim is
5 -- made that this preorder is unique.
6 ------------------------------------------------------------------------
7
8 {-# OPTIONS --cubical-compatible --safe #-}
9
10 open import Relation.Binary.Core using (REL; Rel; _⇒_)
11 open import Relation.Binary.Bundles using (Setoid; Preorder)
12 open import Relation.Binary.Structures using (IsPreorder)
13 open import Relation.Binary.Definitions using (_Respects_; Transitive)
14 open Setoid using (Carrier)
15
16 module Relation.Binary.Construct.FromRel
17 {s₁ s₂} (S : Setoid s₁ s₂) -- The underlying equality
18 {a r} {A : Set a} (_R_ : REL A (Carrier S) r) -- The relation
19 where
20
21 open import Function.Base
22 open import Level using (_⊔_)
23
24 open module Eq = Setoid S using (_≈_) renaming (Carrier to B)
25
26 ------------------------------------------------------------------------
27 -- Definition
28
29 Resp : Rel B (a ⊔ r)
30 Resp x y = ∀ {a} → a R x → a R y
31
32 ------------------------------------------------------------------------
33 -- Properties
34
35 reflexive : (∀ {a} → (a R_) Respects _≈_) → _≈_ ⇒ Resp
36 reflexive resp x≈y = resp x≈y
37
38 trans : Transitive Resp
39 trans x∼y y∼z = y∼z ∘ x∼y
40
41 isPreorder : (∀ {a} → (a R_) Respects _≈_) → IsPreorder _≈_ Resp
42 isPreorder resp = record
43 { isEquivalence = Eq.isEquivalence
44 ; reflexive = reflexive resp
45 ; trans = trans
46 }
47
48 preorder : (∀ {a} → (a R_) Respects _≈_) → Preorder _ _ _
49 preorder resp = record
50 { isPreorder = isPreorder resp
51 }