Skip to content

Instantly share code, notes, and snippets.

@qoelet
Last active December 23, 2015 04:09
Show Gist options
  • Save qoelet/6578793 to your computer and use it in GitHub Desktop.
Save qoelet/6578793 to your computer and use it in GitHub Desktop.
import Data.List
import Control.Applicative
main :: IO ()
main = do
let tt = [True, True]
ff = [False, False]
tf = head perms_tf
ft = reverse (head perms_tf)
perms_tf = permutations [True, False]
perms_tbl = tt:tf:ft:[ff]
putStrLn "Negation"
putStrLn $ show([True, not True])
putStrLn "Conjunction"
fmap putStrLn show(map and perms_tbl)
putStrLn "Disjunction"
fmap putStrLn show(map or perms_tbl)
putStrLn "Implication"
fmap putStrLn show ([(<=) x (head y) | (x:y) <- perms_tbl])
putStrLn "Equivalence"
-- thanks to ion on IRC, who answered my query with
-- (P -> Q, Q -> P)?
fmap putStrLn show ([((<=) x (head y)) && ((<=) (head y) x) | (x:y) <- perms_tbl])
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment