Skip to content

Add proofs on truth value #2418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,16 @@ Additions to existing modules
```agda
_≡?_ : DecidableEquality (Vec A n)
```

* In `Relation.Nullary.Decidable`:
```agda
does-⇔ : A ⇔ B → (a? : Dec A) → (b? : Dec B) → does a? ≡ does b?
does-≡ : (a? b? : Dec A) → does a? ≡ does b?
```

* In `Relation.Nullary.Properties`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed this (copy/paste error?) during review: should be Relation.Unary.Properties!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice spot! Any chance of a quick PR?

Copy link
Contributor

@jamesmckinna jamesmckinna Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I have already fixed it on (a couple of ;-)) branches as part of merge conflict resolution for open PRs of mine (eg. on #2383 ), so the alternative would be to merge those... but if you want a cleaner fine-grained git history, happy to do so... #2474

```agda
map : P ≐ Q → Decidable P → Decidable Q
does-≐ : P ≐ Q → (P? : Decidable P) → (Q? : Decidable Q) → does ∘ P? ≗ does ∘ Q?
does-≡ : (P? P?′ : Decidable P) → does ∘ P? ≗ does ∘ P?′
```
7 changes: 7 additions & 0 deletions src/Relation/Nullary/Decidable.agda
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ dec-yes-irr a? irr a with a′ , eq ← dec-yes a? a rewrite irr a a′ = eq

⌊⌋-map′ : ∀ t f (a? : Dec A) → ⌊ map′ {B = B} t f a? ⌋ ≡ ⌊ a? ⌋
⌊⌋-map′ t f a? = trans (isYes≗does (map′ t f a?)) (sym (isYes≗does a?))

does-≡ : (a? b? : Dec A) → does a? ≡ does b?
does-≡ a? (yes a) = dec-true a? a
does-≡ a? (no ¬a) = dec-false a? ¬a

does-⇔ : A ⇔ B → (a? : Dec A) → (b? : Dec B) → does a? ≡ does b?
does-⇔ A⇔B a? = does-≡ (map A⇔B a?)
17 changes: 15 additions & 2 deletions src/Relation/Unary/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ open import Level using (Level)
open import Relation.Binary.Core as Binary
open import Relation.Binary.Definitions
hiding (Decidable; Universal; Irrelevant; Empty)
open import Relation.Binary.PropositionalEquality.Core using (refl)
open import Relation.Binary.PropositionalEquality.Core using (refl; _≗_)
open import Relation.Unary
open import Relation.Nullary.Decidable using (yes; no; _⊎-dec_; _×-dec_; ¬?)
open import Relation.Nullary.Decidable as Dec using (yes; no; _⊎-dec_; _×-dec_; ¬?; map′; does)
open import Function.Base using (id; _$_; _∘_)

private
Expand Down Expand Up @@ -200,6 +200,10 @@ U-Universal = λ _ → _
------------------------------------------------------------------------
-- Decidability properties

map : {P : Pred A ℓ₁} {Q : Pred A ℓ₂} →
P ≐ Q → Decidable P → Decidable Q
map (P⊆Q , Q⊆P) P? x = map′ P⊆Q Q⊆P (P? x)

∁? : {P : Pred A ℓ} → Decidable P → Decidable (∁ P)
∁? P? x = ¬? (P? x)

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

does-≡ : {P : Pred A ℓ} → (P? P?′ : Decidable P) →
does ∘ P? ≗ does ∘ P?′
does-≡ P? P?′ x = Dec.does-≡ (P? x) (P?′ x)

does-≐ : {P : Pred A ℓ₁} {Q : Pred A ℓ₂} → P ≐ Q →
(P? : Decidable P) → (Q? : Decidable Q) →
does ∘ P? ≗ does ∘ Q?
does-≐ P≐Q P? = does-≡ (map P≐Q P?)

------------------------------------------------------------------------
-- Irrelevant properties

Expand Down