| |
Due on Tuesday September 18
Semantics of Predicate Logic
- State the following propositions in predicate logic:
 | p is a prime number. |
 | a is the greatest common divisor of b and c. |
 | Fermat's Last Theorem.
|
Learn to run GHCi (the GHC Haskell interpreter) by running the Predicate Logic
Interpreter, which you can find here. The best way to do this
is to save the file as "PredicateLogic.lhs" (it is currently a
.txt file) and then load it from
the command line in GHCi. Read through the program and make sure that you understand
all parts of it. Try running a few of the examples at the command
line
to familiarize yourself with GHCi.
Create a new file called "PS1.lhs" (in the same folder in which you saved
PredicateLogic.lhs), whose first two lines of code should be:
> module PS1 where
> import PredicateLogic
In this file, add your solutions to problem 1 above, and try running them in
GHCi.
Make the following extensions to the language of predicate logic:
 | Add an exclusive or operator to the assertion language. |
 | Add an exponentiation operator to the integer expression
language. |
 | Add integer expressions of the form:
sum <var>: <intexp> to <intexp> .
<intexp>
such that, for example, "sum x: 1 to 5 . x+1"
will evaluate to 20. |
For each of these extensions, provide the following:
 | an abstract grammar rule, |
 | a denotational semantics equation, |
 | a definition of the set of free variables, and |
 | a substitution rule
(the propositions regarding binding and substitution for for the predicate
calculus should not change) |
Finally, modify the Predicate Logic Interpreter to implement these
extensions, and test your code.
Solutions:
PS1Soln.txt
PS1Test.txt
|