Skip to content

Commit

Permalink
Add Haskell.Reasoning.Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed May 7, 2024
1 parent edcece2 commit 8b2be4d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/customer-deposit-wallet-pure/agda/Haskell/Reasoning.agda
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 lib/customer-deposit-wallet-pure/agda/Haskell/Reasoning/Bool.agda
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 λ ()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```agda
{-# OPTIONS --erasure #-}
module Haskell.Reasoning where
module Haskell.Reasoning.Core where
```

This module bundles tools for reasoning about Haskell programs in [Agda][] and [Agda2hs][].
Expand Down

0 comments on commit 8b2be4d

Please sign in to comment.