Skip to content

Commit 670d1e8

Browse files
MatthewDaggittandreasabel
authored andcommitted
Add begin-irrefl reasoning combinator (#1470)
1 parent 437f6ba commit 670d1e8

File tree

13 files changed

+76
-23
lines changed

13 files changed

+76
-23
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,30 @@ Non-backwards compatible changes
769769
IO.Instances
770770
```
771771

772+
### Changes to triple reasoning interface
773+
774+
* The module `Relation.Binary.Reasoning.Base.Triple` now takes an extra proof that the strict
775+
relation is irreflexive.
776+
777+
* This allows the following new proof combinator:
778+
```agda
779+
begin-contradiction : (r : x IsRelatedTo x) → {s : True (IsStrict? r)} → A
780+
```
781+
that takes a proof that a value is strictly less than itself and then applies the principle of explosion.
782+
783+
* Specialised versions of this combinator are available in the following derived modules:
784+
```
785+
Data.Nat.Properties
786+
Data.Nat.Binary.Properties
787+
Data.Integer.Properties
788+
Data.Rational.Unnormalised.Properties
789+
Data.Rational.Properties
790+
Data.Vec.Relation.Binary.Lex.Strict
791+
Data.Vec.Relation.Binary.Lex.NonStrict
792+
Relation.Binary.Reasoning.StrictPartialOrder
793+
Relation.Binary.Reasoning.PartialOrder
794+
```
795+
772796
### Other
773797

774798
* In accordance with changes to the flags in Agda 2.6.3, all modules that previously used
@@ -992,6 +1016,8 @@ Major improvements
9921016
* A new module `Algebra.Lattice.Bundles.Raw` is also introduced.
9931017
* `RawLattice` has been moved from `Algebra.Lattice.Bundles` to this new module.
9941018
1019+
* In `Relation.Binary.Reasoning.Base.Triple`, added a new parameter `<-irrefl : Irreflexive _≈_ _<_`
1020+
9951021
Deprecated modules
9961022
------------------
9971023

src/Data/Integer/Properties.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ i≮i = <-irrefl refl
365365
module ≤-Reasoning where
366366
open import Relation.Binary.Reasoning.Base.Triple
367367
≤-isPreorder
368+
<-irrefl
368369
<-trans
369370
(resp₂ _<_)
370371
<⇒≤

src/Data/List/Relation/Unary/Any/Properties.agda

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ Any-×⁻ pq with Prod.map₂ (Prod.map₂ find) (find pq)
254254

255255
(p , q) ∎
256256

257-
258257
to∘from : pq Any-×⁺ {xs = xs} (Any-×⁻ pq) ≡ pq
259258
to∘from pq with find pq
260259
| (λ (f : (proj₁ (find pq) ≡_) ⋐ _) map∘find pq {f})

src/Data/Nat/Binary/Properties.agda

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ open import Relation.Binary.Consequences
3838
open import Relation.Binary.Morphism
3939
import Relation.Binary.Morphism.OrderMonomorphism as OrderMonomorphism
4040
open import Relation.Binary.PropositionalEquality
41-
import Relation.Binary.Reasoning.Base.Triple as InequalityReasoning
4241
open import Relation.Nullary using (¬_; yes; no)
4342
import Relation.Nullary.Decidable as Dec
4443
open import Relation.Nullary.Negation using (contradiction)
@@ -607,12 +606,18 @@ x ≤? y with <-cmp x y
607606
------------------------------------------------------------------------
608607
-- Equational reasoning for _≤_ and _<_
609608

610-
module ≤-Reasoning = InequalityReasoning
611-
≤-isPreorder
612-
<-trans
613-
(resp₂ _<_) <⇒≤
614-
<-≤-trans ≤-<-trans
615-
hiding (step-≈; step-≈˘)
609+
module ≤-Reasoning where
610+
611+
open import Relation.Binary.Reasoning.Base.Triple
612+
≤-isPreorder
613+
<-irrefl
614+
<-trans
615+
(resp₂ _<_)
616+
<⇒≤
617+
<-≤-trans
618+
≤-<-trans
619+
public
620+
hiding (step-≈; step-≈˘)
616621

617622
------------------------------------------------------------------------
618623
-- Properties of _<ℕ_

src/Data/Nat/Properties.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ m<1+n⇒m≤n (s≤s m≤n) = m≤n
495495
module ≤-Reasoning where
496496
open import Relation.Binary.Reasoning.Base.Triple
497497
≤-isPreorder
498+
<-irrefl
498499
<-trans
499500
(resp₂ _<_)
500501
<⇒≤

src/Data/Rational/Properties.agda

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,16 @@ _>?_ = flip _<?_
713713
module ≤-Reasoning where
714714
import Relation.Binary.Reasoning.Base.Triple
715715
≤-isPreorder
716+
<-irrefl
716717
<-trans
717718
(resp₂ _<_)
718719
<⇒≤
719720
<-≤-trans
720721
≤-<-trans
721722
as Triple
722-
open Triple public hiding (step-≈; step-≈˘)
723+
724+
open Triple public
725+
hiding (step-≈; step-≈˘)
723726

724727
infixr 2 step-≃ step-≃˘
725728

@@ -729,7 +732,6 @@ module ≤-Reasoning where
729732
syntax step-≃ x y∼z x≃y = x ≃⟨ x≃y ⟩ y∼z
730733
syntax step-≃˘ x y∼z y≃x = x ≃˘⟨ y≃x ⟩ y∼z
731734

732-
733735
------------------------------------------------------------------------
734736
-- Properties of Positive/NonPositive/Negative/NonNegative and _≤_/_<_
735737

src/Data/Rational/Unnormalised/Properties.agda

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,16 @@ _>?_ = flip _<?_
542542
module ≤-Reasoning where
543543
import Relation.Binary.Reasoning.Base.Triple
544544
≤-isPreorder
545+
<-irrefl
545546
<-trans
546547
<-resp-≃
547548
<⇒≤
548549
<-≤-trans
549550
≤-<-trans
550551
as Triple
551-
open Triple public hiding (step-≈; step-≈˘)
552+
553+
open Triple public
554+
hiding (step-≈; step-≈˘)
552555

553556
infixr 2 step-≃ step-≃˘
554557

@@ -558,7 +561,6 @@ module ≤-Reasoning where
558561
syntax step-≃ x y∼z x≃y = x ≃⟨ x≃y ⟩ y∼z
559562
syntax step-≃˘ x y∼z y≃x = x ≃˘⟨ y≃x ⟩ y∼z
560563

561-
562564
------------------------------------------------------------------------
563565
-- Properties of ↥_/↧_
564566

src/Data/Tree/AVL/Indexed/Relation/Unary/Any/Properties.agda

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ open import Relation.Binary.Construct.Add.Extrema.Strict _<_ using ([<]-injectiv
3535

3636
import Relation.Binary.Reasoning.StrictPartialOrder as <-Reasoning
3737

38-
3938
private
4039
variable
4140
v p q : Level
@@ -278,33 +277,33 @@ module _ {V : Value v} where
278277
joinʳ⁺-right⁺ kv lk ku′ bal (Any-insertWith-just ku seg′ pr rp)
279278

280279
-- impossible cases
281-
... | here eq | tri< k<k′ _ _ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
280+
... | here eq | tri< k<k′ _ _ = begin-contradiction
282281
[ k ] <⟨ [ k<k′ ]ᴿ ⟩
283282
[ k′ ] ≈⟨ [ sym eq ]ᴱ ⟩
284283
[ k ] ∎
285-
... | here eq | tri> _ _ k>k′ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
284+
... | here eq | tri> _ _ k>k′ = begin-contradiction
286285
[ k ] ≈⟨ [ eq ]ᴱ ⟩
287286
[ k′ ] <⟨ [ k>k′ ]ᴿ ⟩
288287
[ k ] ∎
289-
... | left lp | tri≈ _ k≈k′ _ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
288+
... | left lp | tri≈ _ k≈k′ _ = begin-contradiction
290289
let k″ = Any.lookup lp .key; k≈k″ = lookup-result lp; (_ , k″<k′) = lookup-bounded lp in
291290
[ k ] ≈⟨ [ k≈k″ ]ᴱ ⟩
292291
[ k″ ] <⟨ k″<k′ ⟩
293292
[ k′ ] ≈⟨ [ sym k≈k′ ]ᴱ ⟩
294293
[ k ] ∎
295-
... | left lp | tri> _ _ k>k′ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
294+
... | left lp | tri> _ _ k>k′ = begin-contradiction
296295
let k″ = Any.lookup lp .key; k≈k″ = lookup-result lp; (_ , k″<k′) = lookup-bounded lp in
297296
[ k ] ≈⟨ [ k≈k″ ]ᴱ ⟩
298297
[ k″ ] <⟨ k″<k′ ⟩
299298
[ k′ ] <⟨ [ k>k′ ]ᴿ ⟩
300299
[ k ] ∎
301-
... | right rp | tri< k<k′ _ _ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
300+
... | right rp | tri< k<k′ _ _ = begin-contradiction
302301
let k″ = Any.lookup rp .key; k≈k″ = lookup-result rp; (k′<k″ , _) = lookup-bounded rp in
303302
[ k ] <⟨ [ k<k′ ]ᴿ ⟩
304303
[ k′ ] <⟨ k′<k″ ⟩
305304
[ k″ ] ≈⟨ [ sym k≈k″ ]ᴱ ⟩
306305
[ k ] ∎
307-
... | right rp | tri≈ _ k≈k′ _ = flip contradiction (irrefl⁺ [ k ]) $ begin-strict
306+
... | right rp | tri≈ _ k≈k′ _ = begin-contradiction
308307
let k″ = Any.lookup rp .key; k≈k″ = lookup-result rp; (k′<k″ , _) = lookup-bounded rp in
309308
[ k ] ≈⟨ [ k≈k′ ]ᴱ ⟩
310309
[ k′ ] <⟨ k′<k″ ⟩

src/Data/Vec/Relation/Binary/Lex/NonStrict.agda

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ module ≤-Reasoning {_≈_ : Rel A ℓ₁} {_≼_ : Rel A ℓ₂}
261261

262262
open import Relation.Binary.Reasoning.Base.Triple
263263
(≤-isPreorder ≼-po {n})
264+
<-irrefl
264265
(<-trans ≼-po)
265266
(<-resp₂ isEquivalence ≤-resp-≈)
266267
<⇒≤

src/Data/Vec/Relation/Binary/Lex/Strict.agda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ module _ {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where
326326

327327
module ≤-Reasoning {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂}
328328
(≈-isEquivalence : IsEquivalence _≈_)
329+
(≺-irrefl : Irreflexive _≈_ _≺_)
329330
(≺-trans : Transitive _≺_)
330331
(≺-resp-≈ : _≺_ Respects₂ _≈_)
331332
(n : ℕ)
@@ -336,6 +337,7 @@ module ≤-Reasoning {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂}
336337

337338
open import Relation.Binary.Reasoning.Base.Triple
338339
(≤-isPreorder ≈-isEquivalence ≺-trans ≺-resp-≈)
340+
(<-irrefl ≺-irrefl)
339341
(<-trans ≈-isPartialEquivalence ≺-resp-≈ ≺-trans)
340342
(<-respects₂ ≈-isPartialEquivalence ≺-resp-≈)
341343
(<⇒≤ {m = n})

0 commit comments

Comments
 (0)