Skip to content

Commit ef6d78c

Browse files
committed
Module with properties of Bool was moved from contrib to base.
1 parent 21434e0 commit ef6d78c

File tree

6 files changed

+92
-83
lines changed

6 files changed

+92
-83
lines changed

libs/base/Data/Bool.idr

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
module Data.Bool
2+
3+
%access public export
4+
%default total
5+
6+
notInvolutive : (x : Bool) -> not (not x) = x
7+
notInvolutive True = Refl
8+
notInvolutive False = Refl
9+
10+
-- AND
11+
12+
andSameNeutral : (x : Bool) -> x && x = x
13+
andSameNeutral False = Refl
14+
andSameNeutral True = Refl
15+
16+
andFalseFalse : (x : Bool) -> x && False = False
17+
andFalseFalse False = Refl
18+
andFalseFalse True = Refl
19+
20+
andTrueNeutral : (x : Bool) -> x && True = x
21+
andTrueNeutral False = Refl
22+
andTrueNeutral True = Refl
23+
24+
andAssociative : (x, y, z : Bool) -> x && (y && z) = (x && y) && z
25+
andAssociative True _ _ = Refl
26+
andAssociative False _ _ = Refl
27+
28+
andCommutative : (x, y : Bool) -> x && y = y && x
29+
andCommutative x True = andTrueNeutral x
30+
andCommutative x False = andFalseFalse x
31+
32+
andNotFalse : (x : Bool) -> x && not x = False
33+
andNotFalse False = Refl
34+
andNotFalse True = Refl
35+
36+
-- OR
37+
38+
orSameNeutral : (x : Bool) -> x || x = x
39+
orSameNeutral False = Refl
40+
orSameNeutral True = Refl
41+
42+
orFalseNeutral : (x : Bool) -> x || False = x
43+
orFalseNeutral False = Refl
44+
orFalseNeutral True = Refl
45+
46+
orTrueTrue : (x : Bool) -> x || True = True
47+
orTrueTrue False = Refl
48+
orTrueTrue True = Refl
49+
50+
orAssociative : (x, y, z : Bool) -> x || (y || z) = (x || y) || z
51+
orAssociative True _ _ = Refl
52+
orAssociative False _ _ = Refl
53+
54+
orCommutative : (x, y : Bool) -> x || y = y || x
55+
orCommutative x True = orTrueTrue x
56+
orCommutative x False = orFalseNeutral x
57+
58+
orNotTrue : (x : Bool) -> x || not x = True
59+
orNotTrue False = Refl
60+
orNotTrue True = Refl
61+
62+
-- interaction & De Morgan's laws
63+
64+
orSameAndRightNeutral : (x, y : Bool) -> x || (x && y) = x
65+
orSameAndRightNeutral False _ = Refl
66+
orSameAndRightNeutral True _ = Refl
67+
68+
andDistribOrR : (x, y, z : Bool) -> x && (y || z) = (x && y) || (x && z)
69+
andDistribOrR False _ _ = Refl
70+
andDistribOrR True _ _ = Refl
71+
72+
orDistribAndR : (x, y, z : Bool) -> x || (y && z) = (x || y) && (x || z)
73+
orDistribAndR False _ _ = Refl
74+
orDistribAndR True _ _ = Refl
75+
76+
notAndIsOr : (x, y : Bool) -> not (x && y) = not x || not y
77+
notAndIsOr False _ = Refl
78+
notAndIsOr True _ = Refl
79+
80+
notOrIsAnd : (x, y : Bool) -> not (x || y) = not x && not y
81+
notOrIsAnd False _ = Refl
82+
notOrIsAnd True _ = Refl

libs/base/base.ipkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ modules = Control.Arrow
1616
, Control.Monad.Writer
1717

1818
, Data.Bits
19+
, Data.Bool
1920
, Data.Buffer
2021
, Data.Complex
2122
, Data.Erased

libs/contrib/Data/Bool/Extra.idr

Lines changed: 6 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,8 @@
1+
||| This is a backward-compatibility module.
2+
|||
3+
||| This module's original contents were moved to `Data.Bool`.
4+
||| It's okay to add something new to this module but it seems to be good
5+
||| to leave a public import of the `Data.Bool` module.
16
module Data.Bool.Extra
27

3-
%access public export
4-
%default total
5-
6-
notInvolutive : (x : Bool) -> not (not x) = x
7-
notInvolutive True = Refl
8-
notInvolutive False = Refl
9-
10-
-- AND
11-
12-
andSameNeutral : (x : Bool) -> x && x = x
13-
andSameNeutral False = Refl
14-
andSameNeutral True = Refl
15-
16-
andFalseFalse : (x : Bool) -> x && False = False
17-
andFalseFalse False = Refl
18-
andFalseFalse True = Refl
19-
20-
andTrueNeutral : (x : Bool) -> x && True = x
21-
andTrueNeutral False = Refl
22-
andTrueNeutral True = Refl
23-
24-
andAssociative : (x, y, z : Bool) -> x && (y && z) = (x && y) && z
25-
andAssociative True _ _ = Refl
26-
andAssociative False _ _ = Refl
27-
28-
andCommutative : (x, y : Bool) -> x && y = y && x
29-
andCommutative x True = andTrueNeutral x
30-
andCommutative x False = andFalseFalse x
31-
32-
andNotFalse : (x : Bool) -> x && not x = False
33-
andNotFalse False = Refl
34-
andNotFalse True = Refl
35-
36-
-- OR
37-
38-
orSameNeutral : (x : Bool) -> x || x = x
39-
orSameNeutral False = Refl
40-
orSameNeutral True = Refl
41-
42-
orFalseNeutral : (x : Bool) -> x || False = x
43-
orFalseNeutral False = Refl
44-
orFalseNeutral True = Refl
45-
46-
orTrueTrue : (x : Bool) -> x || True = True
47-
orTrueTrue False = Refl
48-
orTrueTrue True = Refl
49-
50-
orAssociative : (x, y, z : Bool) -> x || (y || z) = (x || y) || z
51-
orAssociative True _ _ = Refl
52-
orAssociative False _ _ = Refl
53-
54-
orCommutative : (x, y : Bool) -> x || y = y || x
55-
orCommutative x True = orTrueTrue x
56-
orCommutative x False = orFalseNeutral x
57-
58-
orNotTrue : (x : Bool) -> x || not x = True
59-
orNotTrue False = Refl
60-
orNotTrue True = Refl
61-
62-
-- interaction & De Morgan's laws
63-
64-
orSameAndRightNeutral : (x, y : Bool) -> x || (x && y) = x
65-
orSameAndRightNeutral False _ = Refl
66-
orSameAndRightNeutral True _ = Refl
67-
68-
andDistribOrR : (x, y, z : Bool) -> x && (y || z) = (x && y) || (x && z)
69-
andDistribOrR False _ _ = Refl
70-
andDistribOrR True _ _ = Refl
71-
72-
orDistribAndR : (x, y, z : Bool) -> x || (y && z) = (x || y) && (x || z)
73-
orDistribAndR False _ _ = Refl
74-
orDistribAndR True _ _ = Refl
75-
76-
notAndIsOr : (x, y : Bool) -> not (x && y) = not x || not y
77-
notAndIsOr False _ = Refl
78-
notAndIsOr True _ = Refl
79-
80-
notOrIsAnd : (x, y : Bool) -> not (x || y) = not x && not y
81-
notOrIsAnd False _ = Refl
82-
notOrIsAnd True _ = Refl
8+
import public Data.Bool

libs/contrib/Interfaces/Verified.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Control.Algebra.NumericImplementations
66
import Control.Algebra.VectorSpace
77
import Data.Vect
88
import Data.ZZ
9-
import Data.Bool.Extra
9+
import Data.Bool
1010

1111
%default total
1212
%access public export

libs/contrib/Text/Lexer.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Text.Lexer
22

3-
import Data.Bool.Extra
3+
import Data.Bool
44

55
import public Text.Lexer.Core
66
import public Text.Quantity

libs/contrib/Text/Lexer/Core.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Text.Lexer.Core
22

3-
import Data.Bool.Extra
3+
import Data.Bool
44

55
import public Control.Delayed
66

0 commit comments

Comments
 (0)