Skip to content

Commit 8b11f98

Browse files
strakeMatthewDaggitt
authored andcommitted
Add Recomputable types (#762)
1 parent edd1e13 commit 8b11f98

File tree

5 files changed

+61
-8
lines changed

5 files changed

+61
-8
lines changed

CHANGELOG.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,21 +496,27 @@ Other minor additions
496496
<±-isStrictTotalOrder-≡ : IsStrictTotalOrder _≡_ _<_ → IsStrictTotalOrder _≡_ _<±_
497497
```
498498

499-
* Added new definition in `Relation.Binary.Core`:
499+
* Added new definitions in `Relation.Binary.Core`:
500500
```agda
501-
Universal _∼_ = ∀ x y → x ∼ y
501+
Universal _∼_ = ∀ x y → x ∼ y
502+
Recomputable _~_ = ∀ {x y} → .(x ~ y) → x ~ y
502503
```
503504

504-
* The relation `_≅_` in `Relation.Binary.HeterogeneousEquality` has
505-
been generalised so that the types of the two equal elements need not
506-
be at the same universe level.
505+
* Added new proof to `Relation.Binary.Consequences`:
506+
```agda
507+
dec⟶recomput : Decidable R → Recomputable R
508+
```
507509

508510
* Added new proofs to `Relation.Nullary.Construct.Add.Point`:
509511
```agda
510512
≡-dec : Decidable {A = A} _≡_ → Decidable {A = Pointed A} _≡_
511513
[]-injective : [ x ] ≡ [ y ] → x ≡ y
512514
```
513515

516+
* The relation `_≅_` in `Relation.Binary.HeterogeneousEquality` has
517+
been generalised so that the types of the two equal elements need not
518+
be at the same universe level.
519+
514520
* Added new proof to `Relation.Binary.PropositionalEquality.Core`:
515521
```agda
516522
≢-sym : Symmetric _≢_
@@ -520,3 +526,18 @@ Other minor additions
520526
```agda
521527
syntax Satisfiable P = ∃⟨ P ⟩
522528
```
529+
530+
* Defined a notion of recomputability for unary and binary relations:
531+
```agda
532+
Recomputable : Pred A ℓ → Set _
533+
Recomputable P = ∀ {x} → .(P x) → P x
534+
535+
dec⟶recomputable : Decidable P → Recomputable P
536+
```
537+
538+
```agda
539+
Recomputable : REL A B ℓ → Set _
540+
Recomputable _~_ = ∀ {x y} → .(x ~ y) → x ~ y
541+
542+
dec⟶recomputable : Decidable R → Recomputable R
543+
```

src/Relation/Binary/Consequences.agda

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ module Relation.Binary.Consequences where
1111
open import Data.Maybe.Base using (just; nothing)
1212
open import Data.Sum as Sum using (inj₁; inj₂)
1313
open import Data.Product using (_,_)
14-
open import Data.Empty using (⊥-elim)
15-
open import Function using (_∘_; flip)
14+
open import Data.Empty.Irrelevant using (⊥-elim)
15+
open import Function using (_∘_; _$_; flip)
1616
open import Level using (Level)
1717
open import Relation.Binary.Core
18-
open import Relation.Nullary using (yes; no)
18+
open import Relation.Nullary using (yes; no; recompute)
1919
open import Relation.Unary using (∁)
2020

2121
private
@@ -164,3 +164,8 @@ module _ {P : REL A B ℓ₁} {Q : REL B A ℓ₂} where
164164

165165
flip-Connex : Connex P Q Connex Q P
166166
flip-Connex f x y = Sum.swap (f y x)
167+
168+
module _ {r} {R : REL A B r} where
169+
170+
dec⟶recomputable : Decidable R Recomputable R
171+
dec⟶recomputable dec {a} {b} = recompute $ dec a b

src/Relation/Binary/Core.agda

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ WeaklyDecidable _∼_ = ∀ x y → Maybe (x ∼ y)
217217
Irrelevant : REL A B ℓ Set _
218218
Irrelevant _∼_ = {x y} (a b : x ∼ y) a ≡ b
219219

220+
-- Recomputability - we can rebuild a relevant proof given an
221+
-- irrelevant one.
222+
223+
Recomputable : REL A B ℓ Set _
224+
Recomputable _∼_ = {x y} .(x ∼ y) x ∼ y
225+
220226
-- Universal - all pairs of elements are related
221227

222228
Universal : REL A B ℓ Set _

src/Relation/Unary.agda

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ Decidable P = ∀ x → Dec (P x)
167167
Irrelevant : Pred A ℓ Set _
168168
Irrelevant P = {x} (a : P x) (b : P x) a ≡ b
169169

170+
-- Recomputability - we can rebuild a relevant proof given an
171+
-- irrelevant one.
172+
173+
Recomputable : Pred A ℓ Set _
174+
Recomputable P = {x} .(P x) P x
175+
170176
------------------------------------------------------------------------
171177
-- Operations on sets
172178

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- Some properties imply others
5+
------------------------------------------------------------------------
6+
7+
{-# OPTIONS --without-K --safe #-}
8+
9+
module Relation.Unary.Consequences where
10+
11+
open import Relation.Unary
12+
open import Relation.Nullary using (recompute)
13+
14+
dec⟶recomputable : {a ℓ : _} {A : Set a} {P : Pred A ℓ} Decidable P Recomputable P
15+
dec⟶recomputable P-dec = recompute (P-dec _)

0 commit comments

Comments
 (0)