Extra Credit Assignment
CS 550 Programming Languages
Instructor: Jeremy Johnson
Due date: Wed. June 3 at midnight (no late submissions will be accepted)
Scheme and the Scheme Interpreter (50 points)
This extra credit assignment asks students to write an interpreter for
propositional calculus and to use this interpreter to write a theorem
prover (using truth tables) for statements in the propositional calculus.
The extra credit assignment must be done individually, though questions may
be posted or emailed to the instructor. Students should not post solutions
or code that is part of a solution.
Background Information
Background information is obtained in
lecture 4 on functional programming and
the operational semantics of scheme (scheme interpreter).
As always refer to the documentation for
MIT/GNU Scheme as needed.
What to do
- Implement an interpreter for the proposition calculus using scheme.
You should use the following syntax
- < boolexp > &rarr #t | #f [boolean constants]
- < boolexp > &rarr variable [boolean variables]
- < boolexp > &rarr (and boolexp ... boolexp)
- < boolexp > &rarr (or boolexp ... boolexp)
- < boolexp > &rarr (not boolexp)
- < boolexp > &rarr (implies boolexp boolexp) [P => Q,
where P is the first argument and Q is the second argument]
- < boolexp > &rarr (equiv boolexp boolexp) [P <=> Q,
where P is the first argument and Q is the second argument]
Your interpreter should take a boolean expression and an environment
and return #t or #f. If an undefined variable is encountered then
return the symbol error. Your interpreter should first transform
boolean operators (and and or) with more than two
arguments to nested operators with just two arguments (similar to the
way cond is handled in the scheme interpreter).
- Use your boolean expression interpreter from question 1 to prove
tautologies. I.E. a boolean expression that is true for all possible
values of the variables. E.G. (or P (not P)), (equiv (or P Q) (or Q P)),
(equiv (or P Q) (or P (and (not P) Q))). Your prover should generate
all possible values for the variables occuring in the boolean expression
[all possible bindings], and using your interpreter, check to verify that
the expression is true for all possible variable bindings.
How to submit
Students should submit their solution electronically using webct.
Submit a gzipped tar file, called Ae.tar.gz. The tar file should
contain source code, instructions how to run your programs, sample input
and output files, and a README file. The README file should describe all
files that are included, contain instructions how to build and use the
code, and outline how the code works.
All scheme functions should be written in scheme and must work with
MIT-Scheme. Code should be documented (clear specifications and comments
for any tricky parts of the code).