Skip to content

Instantly share code, notes, and snippets.

@lgcantarelli
Created June 13, 2016 19:46
Show Gist options
  • Save lgcantarelli/090362fd9dc90afd47787748182047c4 to your computer and use it in GitHub Desktop.
Save lgcantarelli/090362fd9dc90afd47787748182047c4 to your computer and use it in GitHub Desktop.
data B = T | F | NOT B | AND B B | OR B B
deriving(Eq, Show)
prog :: B
prog = OR (AND F (NOT T)) (NOT F)
smallStepB :: B -> B
smallStepB (NOT T) = F
smallStepB (NOT F) = T
smallStepB (NOT b) = (NOT (smallStepB b))
smallStepB (OR F b) = b
smallStepB (OR T b) = T
smallStepB (OR b1 b2) = (OR (smallStepB b1) b2)
smallStepB (AND F b) = F
smallStepB (AND T b) = b
smallStepB (AND b1 b2) = (AND (smallStepB b1) b2)
ssInterpreterB :: B -> B
ssInterpreterB b = if (isFinalB b) then b else (ssInterpreterB (smallStepB b))
isFinalB :: B -> Bool
isFinalB T = True
isFinalB F = True
isFinalB _ = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment