Skip to content
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

Additions to Haskell.Law.Bool #389

Merged
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Haskell
_build
dist
dist-newstyle
Expand All @@ -7,6 +8,9 @@ docs/build/
*.hi
*.o

# Agda
*.agdai

# For nix users
.direnv/**
.envrc
Expand Down
178 changes: 178 additions & 0 deletions lib/Haskell/Law/Bool.agda
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,184 @@ open import Haskell.Prim.Bool

open import Haskell.Law.Equality

{-----------------------------------------------------------------------------
Properties
Logical operations and constants
------------------------------------------------------------------------------}
--
prop-x-&&-True
: ∀ (x : Bool)
→ (x && True) ≡ x
--
prop-x-&&-True True = refl
prop-x-&&-True False = refl

--
prop-x-&&-False
: ∀ (x : Bool)
→ (x && False) ≡ False
--
prop-x-&&-False True = refl
prop-x-&&-False False = refl

--
prop-x-||-True
: ∀ (x : Bool)
→ (x || True) ≡ True
--
prop-x-||-True True = refl
prop-x-||-True False = refl

--
prop-x-||-False
: ∀ (x : Bool)
→ (x || False) ≡ x
--
prop-x-||-False True = refl
prop-x-||-False False = refl

{-----------------------------------------------------------------------------
Properties
Boolean algebra
https://en.wikipedia.org/wiki/Boolean_algebra_(structure)
------------------------------------------------------------------------------}
--
prop-||-idem
: ∀ (a : Bool)
→ (a || a) ≡ a
--
prop-||-idem False = refl
prop-||-idem True = refl

--
prop-||-assoc
: ∀ (a b c : Bool)
→ ((a || b) || c) ≡ (a || (b || c))
--
prop-||-assoc False b c = refl
prop-||-assoc True b c = refl

--
prop-||-sym
: ∀ (a b : Bool)
→ (a || b) ≡ (b || a)
--
prop-||-sym False False = refl
prop-||-sym False True = refl
prop-||-sym True False = refl
prop-||-sym True True = refl

--
prop-||-absorb
: ∀ (a b : Bool)
→ (a || (a && b)) ≡ a
--
prop-||-absorb False b = refl
prop-||-absorb True b = refl

--
prop-||-identity
: ∀ (a : Bool)
→ (a || False) ≡ a
--
prop-||-identity False = refl
prop-||-identity True = refl

--
prop-||-&&-distribute
: ∀ (a b c : Bool)
→ (a || (b && c)) ≡ ((a || b) && (a || c))
--
prop-||-&&-distribute False b c = refl
prop-||-&&-distribute True b c = refl

--
prop-||-complement
: ∀ (a : Bool)
→ (a || not a) ≡ True
--
prop-||-complement False = refl
prop-||-complement True = refl

--
prop-&&-idem
: ∀ (a : Bool)
→ (a && a) ≡ a
--
prop-&&-idem False = refl
prop-&&-idem True = refl

--
prop-&&-assoc
: ∀ (a b c : Bool)
→ ((a && b) && c) ≡ (a && (b && c))
--
prop-&&-assoc False b c = refl
prop-&&-assoc True b c = refl

--
prop-&&-sym
: ∀ (a b : Bool)
→ (a && b) ≡ (b && a)
--
prop-&&-sym False False = refl
prop-&&-sym False True = refl
prop-&&-sym True False = refl
prop-&&-sym True True = refl

--
prop-&&-absorb
: ∀ (a b : Bool)
→ (a && (a || b)) ≡ a
--
prop-&&-absorb False b = refl
prop-&&-absorb True b = refl

--
prop-&&-identity
: ∀ (a : Bool)
→ (a && True) ≡ a
--
prop-&&-identity False = refl
prop-&&-identity True = refl

--
prop-&&-||-distribute
: ∀ (a b c : Bool)
→ (a && (b || c)) ≡ ((a && b) || (a && c))
--
prop-&&-||-distribute False b c = refl
prop-&&-||-distribute True b c = refl

--
prop-&&-complement
: ∀ (a : Bool)
→ (a && not a) ≡ False
--
prop-&&-complement False = refl
prop-&&-complement True = refl

--
prop-deMorgan-not-&&
: ∀ (a b : Bool)
→ not (a && b) ≡ (not a || not b)
--
prop-deMorgan-not-&& False b = refl
prop-deMorgan-not-&& True b = refl

--
prop-deMorgan-not-||
: ∀ (a b : Bool)
→ not (a || b) ≡ (not a && not b)
--
prop-deMorgan-not-|| False b = refl
prop-deMorgan-not-|| True b = refl

{-----------------------------------------------------------------------------
Properties
Other
------------------------------------------------------------------------------}

--------------------------------------------------
-- &&

Expand Down
Loading