Debian Codegraph @

src/Relation/Binary/Reasoning/Base/Single.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- The basic code for equational reasoning with a single relation
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 open import Level using (_⊔_)
10 open import Function.Base using (case_of_)
11 open import Relation.Binary.Core using (Rel; _⇒_)
12 open import Relation.Binary.Definitions using (Reflexive; Transitive; Trans)
13 open import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_)
14 open import Relation.Binary.Reasoning.Syntax
15
16 module Relation.Binary.Reasoning.Base.Single
17 {a ℓ} {A : Set a} (_∼_ : Rel A ℓ)
18 (refl : Reflexive _∼_) (trans : Transitive _∼_)
19 where
20
21 ------------------------------------------------------------------------
22 -- Definition of "related to"
23
24 -- This seemingly unnecessary type is used to make it possible to
25 -- infer arguments even if the underlying equality evaluates.
26
27 infix 4 _IsRelatedTo_
28
29 data _IsRelatedTo_ (x y : A) : Set ℓ where
30 relTo : (x∼y : x ∼ y) → x IsRelatedTo y
31
32 start : _IsRelatedTo_ ⇒ _∼_
33 start (relTo x∼y) = x∼y
34
35 ∼-go : Trans _∼_ _IsRelatedTo_ _IsRelatedTo_
36 ∼-go x∼y (relTo y∼z) = relTo (trans x∼y y∼z)
37
38 ≡-go : Trans _≡_ _IsRelatedTo_ _IsRelatedTo_
39 ≡-go x≡y (relTo y∼z) = relTo (case x≡y of λ where ≡.refl → y∼z)
40
41 stop : Reflexive _IsRelatedTo_
42 stop = relTo refl
43
44 ------------------------------------------------------------------------
45 -- Reasoning combinators
46
47 open begin-syntax _IsRelatedTo_ start public
48 open ≡-syntax _IsRelatedTo_ ≡-go public
49 open ∼-syntax _IsRelatedTo_ _IsRelatedTo_ ∼-go public
50 open end-syntax _IsRelatedTo_ stop public