Skip to content

Commit 3941b39

Browse files
MatthewDaggittandreasabel
authored andcommitted
Move T? to Relation.Nullary.Decidable.Core (#2189)
* Move `T?` to `Relation.Nullary.Decidable.Core` * Var name fix * Some refactoring * Fix failing tests and address remaining comments * Fix style-guide
1 parent 67ff824 commit 3941b39

File tree

12 files changed

+67
-57
lines changed

12 files changed

+67
-57
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ Non-backwards compatible changes
838838

839839
4. The modules `Relation.Nullary.(Product/Sum/Implication)` have been deprecated
840840
and their contents moved to `Relation.Nullary.(Negation/Reflects/Decidable)`.
841+
842+
5. The proof `T?` has been moved from `Data.Bool.Properties` to `Relation.Nullary.Decidable.Core`
843+
(but is still re-exported by the former).
841844

842845
as well as the following breaking changes:
843846

@@ -3563,6 +3566,12 @@ Additions to existing modules
35633566
poset : Set a → Poset _ _ _
35643567
```
35653568

3569+
* Added new proof in `Relation.Nullary.Reflects`:
3570+
```agda
3571+
T-reflects : Reflects (T b) b
3572+
T-reflects-elim : Reflects (T a) b → b ≡ a
3573+
```
3574+
35663575
* Added new operations in `System.Exit`:
35673576
```
35683577
isSuccess : ExitCode → Bool

README/Design/Hierarchies.agda

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ record Semigroup : Set (suc (a ⊔ ℓ)) where
265265
-- IsA A
266266
-- / || \ / || \
267267
-- IsB IsC IsD B C D
268-
268+
269269
-- The procedure for re-exports in the bundles is as follows:
270270

271271
-- 1. `open IsA isA public using (IsC, M)` where `M` is everything
@@ -280,7 +280,7 @@ record Semigroup : Set (suc (a ⊔ ℓ)) where
280280

281281
-- 5. `open B b public using (O)` where `O` is everything exported
282282
-- by `B` but not exported by `IsA`.
283-
283+
284284
-- 6. Construct `d : D` via the `isC` obtained in step 1.
285285

286286
-- 7. `open D d public using (P)` where `P` is everything exported

notes/style-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ word within a compound word is capitalized except for the first word.
402402

403403
* Rational variables are named `p`, `q`, `r`, ... (default `p`)
404404

405-
* All other variables tend to be named `x`, `y`, `z`.
405+
* All other variables should be named `x`, `y`, `z`.
406406

407407
* Collections of elements are usually indicated by appending an `s`
408408
(e.g. if you are naming your variables `x` and `y` then lists

src/Data/Bool.agda

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
module Data.Bool where
1010

11-
open import Relation.Nullary
12-
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)
13-
1411
------------------------------------------------------------------------
1512
-- The boolean type and some operations
1613

src/Data/Bool/Base.agda

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,19 @@ true xor b = not b
5757
false xor b = b
5858

5959
------------------------------------------------------------------------
60-
-- Other operations
61-
62-
infix 0 if_then_else_
63-
64-
if_then_else_ : Bool A A A
65-
if true then t else f = t
66-
if false then t else f = f
60+
-- Conversion to Set
6761

6862
-- A function mapping true to an inhabited type and false to an empty
6963
-- type.
70-
7164
T : Bool Set
7265
T true =
7366
T false =
67+
68+
------------------------------------------------------------------------
69+
-- Other operations
70+
71+
infix 0 if_then_else_
72+
73+
if_then_else_ : Bool A A A
74+
if true then t else f = t
75+
if false then t else f = f

src/Data/Bool/Properties.agda

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ open import Relation.Binary.Definitions
2828
using (Decidable; Reflexive; Transitive; Antisymmetric; Minimum; Maximum; Total; Irrelevant; Irreflexive; Asymmetric; Trans; Trichotomous; tri≈; tri<; tri>; _Respects₂_)
2929
open import Relation.Binary.PropositionalEquality.Core
3030
open import Relation.Binary.PropositionalEquality.Properties
31-
open import Relation.Nullary.Reflects using (ofʸ; ofⁿ)
32-
open import Relation.Nullary.Decidable.Core using (True; does; proof; yes; no)
31+
open import Relation.Nullary.Decidable.Core using (True; yes; no; fromWitness)
3332
import Relation.Unary as U
3433

3534
open import Algebra.Definitions {A = Bool} _≡_
@@ -726,15 +725,17 @@ xor-∧-commutativeRing = ⊕-∧-commutativeRing
726725
open XorRing _xor_ xor-is-ok
727726

728727
------------------------------------------------------------------------
729-
-- Miscellaneous other properties
728+
-- Properties of if_then_else_
730729

731-
⇔→≡ : {x y z : Bool} x ≡ z ⇔ y ≡ z x ≡ y
732-
⇔→≡ {true } {true } hyp = refl
733-
⇔→≡ {true } {false} {true } hyp = sym (Equivalence.to hyp refl)
734-
⇔→≡ {true } {false} {false} hyp = Equivalence.from hyp refl
735-
⇔→≡ {false} {true } {true } hyp = Equivalence.from hyp refl
736-
⇔→≡ {false} {true } {false} hyp = sym (Equivalence.to hyp refl)
737-
⇔→≡ {false} {false} hyp = refl
730+
if-float : (f : A B) b {x y}
731+
f (if b then x else y) ≡ (if b then f x else f y)
732+
if-float _ true = refl
733+
if-float _ false = refl
734+
735+
------------------------------------------------------------------------
736+
-- Properties of T
737+
738+
open Relation.Nullary.Decidable.Core public using (T?)
738739

739740
T-≡ : {x} T x ⇔ x ≡ true
740741
T-≡ {false} = mk⇔ (λ ()) (λ ())
@@ -757,18 +758,20 @@ T-∨ {false} {false} = mk⇔ inj₁ [ id , id ]
757758
T-irrelevant : U.Irrelevant T
758759
T-irrelevant {true} _ _ = refl
759760

760-
T? : U.Decidable T
761-
does (T? b) = b
762-
proof (T? true ) = ofʸ _
763-
proof (T? false) = ofⁿ λ()
764-
765761
T?-diag : b T b True (T? b)
766-
T?-diag true _ = _
762+
T?-diag b = fromWitness
763+
764+
------------------------------------------------------------------------
765+
-- Miscellaneous other properties
766+
767+
⇔→≡ : {x y z : Bool} x ≡ z ⇔ y ≡ z x ≡ y
768+
⇔→≡ {true } {true } hyp = refl
769+
⇔→≡ {true } {false} {true } hyp = sym (Equivalence.to hyp refl)
770+
⇔→≡ {true } {false} {false} hyp = Equivalence.from hyp refl
771+
⇔→≡ {false} {true } {true } hyp = Equivalence.from hyp refl
772+
⇔→≡ {false} {true } {false} hyp = sym (Equivalence.to hyp refl)
773+
⇔→≡ {false} {false} hyp = refl
767774

768-
if-float : (f : A B) b {x y}
769-
f (if b then x else y) ≡ (if b then f x else f y)
770-
if-float _ true = refl
771-
if-float _ false = refl
772775

773776
------------------------------------------------------------------------
774777
-- DEPRECATED NAMES

src/Data/List/Relation/Binary/BagAndSetEquality.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import Relation.Binary.Reasoning.Preorder as PreorderReasoning
4444
open import Relation.Binary.PropositionalEquality as P
4545
using (_≡_; _≢_; _≗_; refl)
4646
open import Relation.Binary.Reasoning.Syntax
47-
open import Relation.Nullary
47+
open import Relation.Nullary.Negation using (¬_)
4848
open import Data.List.Membership.Propositional.Properties
4949

5050
private

src/Effect/Applicative.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ record RawApplicative (F : Set f → Set g) : Set (suc f ⊔ g) where
5656
-- Haskell-style alternative name for pure
5757
return : A F A
5858
return = pure
59-
59+
6060
-- backwards compatibility: unicode variants
6161
_⊛_ : F (A B) F A F B
6262
_⊛_ = _<*>_

src/Function/Bundles.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ module _ (From : Setoid a ℓ₁) (To : Setoid b ℓ₂) where
380380
-- For further background on (split) surjections, one may consult any
381381
-- general mathematical references which work without the principle
382382
-- of choice. For example:
383-
--
383+
--
384384
-- https://ncatlab.org/nlab/show/split+epimorphism.
385385
--
386386
-- The connection to set-theoretic notions with the same names is

src/Relation/Nullary.agda

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,9 @@ open import Agda.Builtin.Equality
1515
------------------------------------------------------------------------
1616
-- Re-exports
1717

18-
open import Relation.Nullary.Negation.Core public using
19-
( ¬_; _¬-⊎_
20-
; contradiction; contradiction₂; contraposition
21-
)
22-
23-
open import Relation.Nullary.Reflects public using
24-
( Reflects; ofʸ; ofⁿ
25-
; _×-reflects_; _⊎-reflects_; _→-reflects_
26-
)
27-
28-
open import Relation.Nullary.Decidable.Core public using
29-
( Dec; does; proof; yes; no; _because_; recompute
30-
; ¬?; _×-dec_; _⊎-dec_; _→-dec_
31-
)
18+
open import Relation.Nullary.Negation.Core public
19+
open import Relation.Nullary.Reflects public
20+
open import Relation.Nullary.Decidable.Core public
3221

3322
------------------------------------------------------------------------
3423
-- Irrelevant types

0 commit comments

Comments
 (0)