|
12 | 12 | module Relation.Nullary.Decidable.Core where
|
13 | 13 |
|
14 | 14 | open import Agda.Builtin.Equality using (_≡_)
|
15 |
| -open import Level using (Level; Lift) |
| 15 | +open import Level using (Level) |
16 | 16 | open import Data.Bool.Base using (Bool; T; false; true; not; _∧_; _∨_)
|
17 | 17 | open import Data.Unit.Polymorphic.Base using (⊤)
|
18 | 18 | open import Data.Product.Base using (_×_)
|
19 |
| -open import Data.Sum.Base using (_⊎_) |
| 19 | +open import Data.Sum.Base using (_⊎_; inj₁; inj₂) |
20 | 20 | open import Function.Base using (_∘_; const; _$_; flip)
|
21 | 21 | open import Relation.Nullary.Recomputable as Recomputable hiding (recompute-constant)
|
22 | 22 | open import Relation.Nullary.Reflects as Reflects hiding (recompute; recompute-constant)
|
@@ -103,6 +103,17 @@ _→-dec_ : Dec A → Dec B → Dec (A → B)
|
103 | 103 | does (a? →-dec b?) = not (does a?) ∨ does b?
|
104 | 104 | proof (a? →-dec b?) = proof a? →-reflects proof b?
|
105 | 105 |
|
| 106 | +------------------------------------------------------------------------ |
| 107 | +-- Relationship with Sum |
| 108 | + |
| 109 | +toSum : Dec A → A ⊎ ¬ A |
| 110 | +toSum ( true because [p]) = inj₁ (invert [p]) |
| 111 | +toSum (false because [¬p]) = inj₂ (invert [¬p]) |
| 112 | + |
| 113 | +fromSum : A ⊎ ¬ A → Dec A |
| 114 | +fromSum (inj₁ p) = yes p |
| 115 | +fromSum (inj₂ ¬p) = no ¬p |
| 116 | + |
106 | 117 | ------------------------------------------------------------------------
|
107 | 118 | -- Relationship with booleans
|
108 | 119 |
|
@@ -201,3 +212,17 @@ excluded-middle = ¬¬-excluded-middle
|
201 | 212 | "Warning: excluded-middle was deprecated in v2.0.
|
202 | 213 | Please use ¬¬-excluded-middle instead."
|
203 | 214 | #-}
|
| 215 | + |
| 216 | +-- Version 2.1 |
| 217 | + |
| 218 | +fromDec = toSum |
| 219 | +{-# WARNING_ON_USAGE fromDec |
| 220 | +"Warning: fromDec was deprecated in v2.1. |
| 221 | +Please use Relation.Nullary.Decidable.Core.toSum instead." |
| 222 | +#-} |
| 223 | + |
| 224 | +toDec = fromSum |
| 225 | +{-# WARNING_ON_USAGE toDec |
| 226 | +"Warning: toDec was deprecated in v2.1. |
| 227 | +Please use Relation.Nullary.Decidable.Core.fromSum instead." |
| 228 | +#-} |
0 commit comments