diff --git a/CHANGELOG.md b/CHANGELOG.md index ba601e31d3..fe1c031294 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ Bug-fixes This has been deprecated in favor or `rightInverse`, and a corrected (and correctly-named) function `leftInverse` has been added. +* The implementation of `_IsRelatedTo_` in `Relation.Binary.Reasoning.Base.Partial` + has been modified to correctly support equational reasoning at the beginning and the end. + The detail of this issue is described in [#2677](https://github.com/agda/agda-stdlib/pull/2677). Since the names of constructors + of `_IsRelatedTo_` are changed and the reduction behaviour of reasoning steps + are changed, this modification is non-backwards compatible. + Non-backwards compatible changes -------------------------------- diff --git a/src/Relation/Binary/Reasoning/Base/Partial.agda b/src/Relation/Binary/Reasoning/Base/Partial.agda index 5da6792f64..e8e0cbc920 100644 --- a/src/Relation/Binary/Reasoning/Base/Partial.agda +++ b/src/Relation/Binary/Reasoning/Base/Partial.agda @@ -22,52 +22,55 @@ module Relation.Binary.Reasoning.Base.Partial ------------------------------------------------------------------------ -- Definition of "related to" --- This seemingly unnecessary type is used to make it possible to --- infer arguments even if the underlying equality evaluates. +-- This type allows us to track whether reasoning steps +-- include _∼_ or not. 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 + reflexive : ∀ {x y} → x ≡ y → x IsRelatedTo y + relTo : ∀ {x y} (x∼y : x ∼ y) → x IsRelatedTo y + +≡-go : Trans _≡_ _IsRelatedTo_ _IsRelatedTo_ +≡-go x≡y (reflexive y≡z) = reflexive (case x≡y of λ where ≡.refl → y≡z) +≡-go x≡y (relTo y∼z) = relTo (case x≡y of λ where ≡.refl → y∼z) ∼-go : Trans _∼_ _IsRelatedTo_ _IsRelatedTo_ -∼-go x∼y (singleStep y) = multiStep x∼y -∼-go x∼y (multiStep y∼z) = multiStep (trans x∼y y∼z) +∼-go x∼y (reflexive y≡z) = relTo (case y≡z of λ where ≡.refl → x∼y) +∼-go x∼y (relTo y∼z) = relTo (trans x∼y y∼z) stop : Reflexive _IsRelatedTo_ -stop = singleStep _ +stop = reflexive ≡.refl ------------------------------------------------------------------------ -- Types that are used to ensure that the final relation proved by the -- chain of reasoning can be converted into the required relation. -data IsMultiStep {x y} : x IsRelatedTo y → Set (a ⊔ ℓ) where - isMultiStep : ∀ x∼y → IsMultiStep (multiStep x∼y) +data IsRelTo {x y} : x IsRelatedTo y → Set (a ⊔ ℓ) where + isRelTo : ∀ x∼y → IsRelTo (relTo x∼y) -IsMultiStep? : ∀ {x y} (x∼y : x IsRelatedTo y) → Dec (IsMultiStep x∼y) -IsMultiStep? (multiStep x