-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request adds a module `Haskell.Reasoning.Bool`. This modules adds lemmas that relate the operations `&&`, `||` and `not` on the `Bool` data type to the logical connectives `⋀`, `⋁`, and `¬` from the metatheory. This simplifies reasoning with predicates of the form `b ≡ True`, enabling proofs about Haskell functions such as `filter` or `any`. This pull request removes a couple of ad-hoc lemmas about logical connectives that are either obsolete or subsumed by the new module.
- Loading branch information
Showing
7 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
lib/customer-deposit-wallet-pure/agda/Haskell/Reasoning.agda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{-# OPTIONS --erasure #-} | ||
|
||
module Haskell.Reasoning where | ||
|
||
{- About | ||
See the Haskell.Reasoning.Core module | ||
for an extended description of how to use these modules. | ||
-} | ||
|
||
open import Haskell.Reasoning.Core public | ||
open import Haskell.Reasoning.Bool public |
61 changes: 61 additions & 0 deletions
61
lib/customer-deposit-wallet-pure/agda/Haskell/Reasoning/Bool.agda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{-# OPTIONS --erasure #-} | ||
|
||
module Haskell.Reasoning.Bool where | ||
|
||
open import Haskell.Prelude | ||
open import Haskell.Reasoning.Core | ||
|
||
{----------------------------------------------------------------------------- | ||
Relate (≡ True) to logical connectives | ||
------------------------------------------------------------------------------} | ||
|
||
-- Logical conjunction | ||
prop-&&-⋀ | ||
: ∀ {x y : Bool} | ||
→ (x && y) ≡ True | ||
→ (x ≡ True) ⋀ (y ≡ True) | ||
-- | ||
prop-&&-⋀ {True} {True} refl = refl `and` refl | ||
|
||
-- | ||
prop-⋀-&& | ||
: ∀ {x y : Bool} | ||
→ (x ≡ True) ⋀ (y ≡ True) | ||
→ (x && y) ≡ True | ||
-- | ||
prop-⋀-&& {True} {True} (refl `and` refl) = refl | ||
|
||
-- Logical disjunction | ||
prop-||-⋁ | ||
: ∀ {x y : Bool} | ||
→ (x || y) ≡ True | ||
→ (x ≡ True) ⋁ (y ≡ True) | ||
-- | ||
prop-||-⋁ {True} {y} refl = inl refl | ||
prop-||-⋁ {False} {True} refl = inr refl | ||
|
||
-- | ||
prop-⋁-|| | ||
: ∀ {x y : Bool} | ||
→ (x ≡ True) ⋁ (y ≡ True) | ||
→ (x || y) ≡ True | ||
-- | ||
prop-⋁-|| {True} (inl refl) = refl | ||
prop-⋁-|| {True} (inr refl) = refl | ||
prop-⋁-|| {False} (inr refl) = refl | ||
|
||
-- Logical negation | ||
prop-not-¬ | ||
: ∀ {x : Bool} | ||
→ (not x ≡ True) | ||
→ ¬ (x ≡ True) | ||
-- | ||
prop-not-¬ {True} () | ||
|
||
prop-¬-not | ||
: ∀ {x : Bool} | ||
→ ¬ (x ≡ True) | ||
→ (not x ≡ True) | ||
-- | ||
prop-¬-not {False} contra = refl | ||
prop-¬-not {True} contra = case contra refl of λ () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters