Skip to content

Commit ab0038b

Browse files
mildsunrisejamesmckinnaMatthewDaggitt
authored
Add proofs on truth value (#2418)
* Add proofs on truth value Adds a handful of properties that prove the truth value of a decidable: - `Relation.Nullary.Decidable`: - `does-≡`: decidables over the same type have the same truth value - `does-⇔`: generalization of `does-≡` to mutually implied types - `Relation.Unary.Properties`: - `≐?`: generalization of `Decidable.map` to predicates (if two predicates are equivalent, one is decidable if the other is) - `does-≡`: generalization of `does-≡` to predicates - `does-≐`: generalization of `does-⇔` to predicates * fixup! use ⇔-id * simplify * fixup! use qualified import instead of renaming * Update src/Relation/Unary/Properties.agda Co-authored-by: jamesmckinna <[email protected]> * Update src/Relation/Unary/Properties.agda Co-authored-by: jamesmckinna <[email protected]> * rename ≐? to map --------- Co-authored-by: jamesmckinna <[email protected]> Co-authored-by: MatthewDaggitt <[email protected]>
1 parent 2a53fae commit ab0038b

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,16 @@ Additions to existing modules
7171
```agda
7272
_≡?_ : DecidableEquality (Vec A n)
7373
```
74+
75+
* In `Relation.Nullary.Decidable`:
76+
```agda
77+
does-⇔ : A ⇔ B → (a? : Dec A) → (b? : Dec B) → does a? ≡ does b?
78+
does-≡ : (a? b? : Dec A) → does a? ≡ does b?
79+
```
80+
81+
* In `Relation.Nullary.Properties`:
82+
```agda
83+
map : P ≐ Q → Decidable P → Decidable Q
84+
does-≐ : P ≐ Q → (P? : Decidable P) → (Q? : Decidable Q) → does ∘ P? ≗ does ∘ Q?
85+
does-≡ : (P? P?′ : Decidable P) → does ∘ P? ≗ does ∘ P?′
86+
```

src/Relation/Nullary/Decidable.agda

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,10 @@ dec-yes-irr a? irr a with a′ , eq ← dec-yes a? a rewrite irr a a′ = eq
8080

8181
⌊⌋-map′ : t f (a? : Dec A) ⌊ map′ {B = B} t f a? ⌋ ≡ ⌊ a? ⌋
8282
⌊⌋-map′ t f a? = trans (isYes≗does (map′ t f a?)) (sym (isYes≗does a?))
83+
84+
does-≡ : (a? b? : Dec A) does a? ≡ does b?
85+
does-≡ a? (yes a) = dec-true a? a
86+
does-≡ a? (no ¬a) = dec-false a? ¬a
87+
88+
does-⇔ : A ⇔ B (a? : Dec A) (b? : Dec B) does a? ≡ does b?
89+
does-⇔ A⇔B a? = does-≡ (map A⇔B a?)

src/Relation/Unary/Properties.agda

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ open import Level using (Level)
1515
open import Relation.Binary.Core as Binary
1616
open import Relation.Binary.Definitions
1717
hiding (Decidable; Universal; Irrelevant; Empty)
18-
open import Relation.Binary.PropositionalEquality.Core using (refl)
18+
open import Relation.Binary.PropositionalEquality.Core using (refl; _≗_)
1919
open import Relation.Unary
20-
open import Relation.Nullary.Decidable using (yes; no; _⊎-dec_; _×-dec_; ¬?)
20+
open import Relation.Nullary.Decidable as Dec using (yes; no; _⊎-dec_; _×-dec_; ¬?; map′; does)
2121
open import Function.Base using (id; _$_; _∘_)
2222

2323
private
@@ -200,6 +200,10 @@ U-Universal = λ _ → _
200200
------------------------------------------------------------------------
201201
-- Decidability properties
202202

203+
map : {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
204+
P ≐ Q Decidable P Decidable Q
205+
map (P⊆Q , Q⊆P) P? x = map′ P⊆Q Q⊆P (P? x)
206+
203207
∁? : {P : Pred A ℓ} Decidable P Decidable (∁ P)
204208
∁? P? x = ¬? (P? x)
205209

@@ -233,6 +237,15 @@ _⊎?_ P? Q? (inj₂ b) = Q? b
233237
_~? : {P : Pred (A × B) ℓ} Decidable P Decidable (P ~)
234238
_~? P? = P? ∘ swap
235239

240+
does-≡ : {P : Pred A ℓ} (P? P?′ : Decidable P)
241+
does ∘ P? ≗ does ∘ P?′
242+
does-≡ P? P?′ x = Dec.does-≡ (P? x) (P?′ x)
243+
244+
does-≐ : {P : Pred A ℓ₁} {Q : Pred A ℓ₂} P ≐ Q
245+
(P? : Decidable P) (Q? : Decidable Q)
246+
does ∘ P? ≗ does ∘ Q?
247+
does-≐ P≐Q P? = does-≡ (map P≐Q P?)
248+
236249
------------------------------------------------------------------------
237250
-- Irrelevant properties
238251

0 commit comments

Comments
 (0)