Skip to content

Commit 03492f0

Browse files
committed
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
1 parent 606bea8 commit 03492f0

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

CHANGELOG.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,11 @@ Additions to existing modules
800800
WeaklyDecidable : Set _
801801
```
802802

803-
* Added new proof in `Relation.Nullary.Decidable`:
803+
* Added new proofs in `Relation.Nullary.Decidable`:
804804
```agda
805805
⌊⌋-map′ : (a? : Dec A) → ⌊ map′ t f a? ⌋ ≡ ⌊ a? ⌋
806+
does-⇔ : A ⇔ B → (a? : Dec A) → (b? : Dec B) → does a? ≡ does b?
807+
does-≡ : (a? b? : Dec A) → does a? ≡ does b?
806808
```
807809

808810
* Added new definitions and proofs in `Relation.Nullary.Decidable.Core`:
@@ -822,14 +824,21 @@ Additions to existing modules
822824
```agda
823825
recompute : Reflects A b → Recomputable A
824826
recompute-constant : (r : Reflects A b) (p q : A) → recompute r p ≡ recompute r q
825-
```
827+
```
826828

827-
* Added new definitions in `Relation.Unary`
829+
* Added new definitions in `Relation.Unary`:
828830
```agda
829831
Stable : Pred A ℓ → Set _
830832
WeaklyDecidable : Pred A ℓ → Set _
831833
```
832834

835+
* Added new proofs in `Relation.Nullary.Properties`:
836+
```agda
837+
≐? : P ≐ Q → Decidable P → Decidable Q
838+
does-≐ : P ≐ Q → (P? : Decidable P) → (Q? : Decidable Q) → does ∘ P? ≗ does ∘ Q?
839+
does-≡ : (P? P?′ : Decidable P) → does ∘ P? ≗ does ∘ P?′
840+
```
841+
833842
* Enhancements to `Tactic.Cong` - see `README.Tactic.Cong` for details.
834843
- Provide a marker function, `⌞_⌟`, for user-guided anti-unification.
835844
- Improved support for equalities between terms with instance arguments,

src/Relation/Nullary/Decidable.agda

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ module Relation.Nullary.Decidable where
1010

1111
open import Level using (Level)
1212
open import Data.Bool.Base using (true; false)
13-
open import Data.Product.Base using (∃; _,_)
13+
open import Data.Product.Base using (∃; _×_; _,_)
14+
open import Function.Base using (id; _∘_)
1415
open import Function.Bundles using
15-
(Injection; module Injection; module Equivalence; _⇔_; _↔_; mk↔ₛ′)
16+
(Injection; module Injection; module Equivalence; _⇔_; mk⇔; _↔_; mk↔ₛ′)
1617
open import Relation.Binary.Bundles using (Setoid; module Setoid)
1718
open import Relation.Binary.Definitions using (Decidable)
1819
open import Relation.Nullary using (Irrelevant)
@@ -80,3 +81,10 @@ dec-yes-irr a? irr a with a′ , eq ← dec-yes a? a rewrite irr a a′ = eq
8081

8182
⌊⌋-map′ : t f (a? : Dec A) ⌊ map′ {B = B} t f a? ⌋ ≡ ⌊ a? ⌋
8283
⌊⌋-map′ t f a? = trans (isYes≗does (map′ t f a?)) (sym (isYes≗does a?))
84+
85+
does-⇔ : A ⇔ B (a? : Dec A) (b? : Dec B) does a? ≡ does b?
86+
does-⇔ A⇔B a? (yes b) = dec-true a? (Equivalence.from A⇔B b)
87+
does-⇔ A⇔B a? (no ¬b) = dec-false a? (¬b ∘ Equivalence.to A⇔B)
88+
89+
does-≡ : (a? b? : Dec A) does a? ≡ does b?
90+
does-≡ = does-⇔ (mk⇔ id id)

src/Relation/Unary/Properties.agda

+17-2
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88

99
module Relation.Unary.Properties where
1010

11+
open import Data.Bool.Base using (not)
1112
open import Data.Product.Base as Product using (_×_; _,_; swap; proj₁; zip′)
1213
open import Data.Sum.Base using (inj₁; inj₂)
1314
open import Data.Unit.Base using (tt)
1415
open import Level using (Level)
1516
open import Relation.Binary.Core as Binary
1617
open import Relation.Binary.Definitions
1718
hiding (Decidable; Universal; Irrelevant; Empty)
18-
open import Relation.Binary.PropositionalEquality.Core using (refl)
19+
open import Relation.Binary.PropositionalEquality.Core using (refl; _≗_)
1920
open import Relation.Unary
20-
open import Relation.Nullary.Decidable using (yes; no; _⊎-dec_; _×-dec_; ¬?)
21+
open import Relation.Nullary.Decidable using (yes; no; _⊎-dec_; _×-dec_; ¬?; map′; does; does-⇔)
2122
open import Function.Base using (id; _$_; _∘_)
23+
open import Function.Bundles using (mk⇔)
2224

2325
private
2426
variable
@@ -200,6 +202,10 @@ U-Universal = λ _ → _
200202
------------------------------------------------------------------------
201203
-- Decidability properties
202204

205+
≐? : {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
206+
P ≐ Q Decidable P Decidable Q
207+
≐? (P⊆Q , Q⊆P) P? x = map′ P⊆Q Q⊆P (P? x)
208+
203209
∁? : {P : Pred A ℓ} Decidable P Decidable (∁ P)
204210
∁? P? x = ¬? (P? x)
205211

@@ -233,6 +239,15 @@ _⊎?_ P? Q? (inj₂ b) = Q? b
233239
_~? : {P : Pred (A × B) ℓ} Decidable P Decidable (P ~)
234240
_~? P? = P? ∘ swap
235241

242+
does-≐ : {P : Pred A ℓ₁} {Q : Pred A ℓ₂} P ≐ Q
243+
(P? : Decidable P) (Q? : Decidable Q)
244+
does ∘ P? ≗ does ∘ Q?
245+
does-≐ (P⊆Q , Q⊆P) P? Q? x = does-⇔ (mk⇔ P⊆Q Q⊆P) (P? x) (Q? x)
246+
247+
does-≡ : {P : Pred A ℓ} (P? P?′ : Decidable P)
248+
does ∘ P? ≗ does ∘ P?′
249+
does-≡ {P} P? P?′ = does-≐ ≐-refl P? P?′
250+
236251
------------------------------------------------------------------------
237252
-- Irrelevant properties
238253

0 commit comments

Comments
 (0)