{-# OPTIONS --cubical-compatible --safe #-}
open import Relation.Binary.Core
open import Relation.Binary.Definitions
open import Level using (_⊔_)
open import Relation.Binary.PropositionalEquality.Core as P
using (_≡_)
open import Relation.Nullary.Decidable using (Dec; yes; no)
open import Relation.Nullary.Decidable using (True)
module Relation.Binary.Reasoning.Base.Partial
{a ℓ} {A : Set a} (_∼_ : Rel A ℓ) (trans : Transitive _∼_)
where
infix 4 _IsRelatedTo_
data _IsRelatedTo_ : A → A → Set (a ⊔ ℓ) where
singleStep : ∀ x → x IsRelatedTo x
multiStep : ∀ {x y} (x∼y : x ∼ y) → x IsRelatedTo y
data IsMultiStep {x y} : x IsRelatedTo y → Set (a ⊔ ℓ) where
isMultiStep : ∀ x∼y → IsMultiStep (multiStep x∼y)
IsMultiStep? : ∀ {x y} (x∼y : x IsRelatedTo y) → Dec (IsMultiStep x∼y)
IsMultiStep? (multiStep x<y) = yes (isMultiStep x<y)
IsMultiStep? (singleStep _) = no λ()
infix 1 begin_
infixr 2 step-∼ step-≡ step-≡˘
infixr 2 _≡⟨⟩_
infix 3 _∎⟨_⟩ _∎
begin_ : ∀ {x y} (x∼y : x IsRelatedTo y) → {True (IsMultiStep? x∼y)} → x ∼ y
begin (multiStep x∼y) = x∼y
step-∼ : ∀ x {y z} → y IsRelatedTo z → x ∼ y → x IsRelatedTo z
step-∼ _ (singleStep _) x∼y = multiStep x∼y
step-∼ _ (multiStep y∼z) x∼y = multiStep (trans x∼y y∼z)
step-≡ : ∀ x {y z} → y IsRelatedTo z → x ≡ y → x IsRelatedTo z
step-≡ _ x∼z P.refl = x∼z
step-≡˘ : ∀ x {y z} → y IsRelatedTo z → y ≡ x → x IsRelatedTo z
step-≡˘ _ x∼z P.refl = x∼z
_≡⟨⟩_ : ∀ x {y} → x IsRelatedTo y → x IsRelatedTo y
_ ≡⟨⟩ x∼y = x∼y
_∎ : ∀ x → x IsRelatedTo x
_∎ = singleStep
syntax step-∼ x y∼z x∼y = x ∼⟨ x∼y ⟩ y∼z
syntax step-≡ x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
syntax step-≡˘ x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z
_∎⟨_⟩ : ∀ x → x ∼ x → x IsRelatedTo x
_ ∎⟨ x∼x ⟩ = multiStep x∼x
{-# WARNING_ON_USAGE _∎⟨_⟩
"Warning: _∎⟨_⟩ was deprecated in v1.6.
Please use _∎ instead if used in a chain, otherwise simply provide
the proof of reflexivity directly without using these combinators."
#-}