Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 2

Microproject

Write a Clojure program using at least one higher order function (e.g., map, filter, reduce, some, …) to symbolically simplify non-nested boolean nand relations of arbitrary length >= 1 represented as unevaluated lists. For example, in each of the below, given a list representation of the item on the left (you should quote the list), the result should be the item on the right. Some example rules for simplification are provided below.

You should generalize for any length expression based on these patterns. Your program must work for any arbitrary variables used.

Main Project

In this project you will convert logical expressions which consist of “and”, “or”, and “not” connectives to ones which only use the “nand” connective. “not” will be assumed to take one argument, while “and” and “or” will take one or more. Then, you will symbolically simplify the resulting expression.

Expressions are created as unevaluated lists. For example:

Conversion from and/or/not logic to nand logic is done using the following patterns:

You should generalize for any number of arguments based on the patterns.

Simplification consists of replacing particular forms with equivalent forms or symbols. Use the patterns from the microproject, but here the simplification must be recursive.

The main entry point to the program, “evalexp”, calls functions that simplify, nand-convert, and bind these expressions.

Binding consists of replacing some or all of the variables in expressions with constants (true or false), and then returning the partially evaluated form.

The evalexp function should take a symbolic expression and a binding map and return the simplest form (that might just be a constant). One way to define this is

Example:

binds x and z (but not y) in p1, leading to

Then the conversion to nand occurs resulting in:

and then further simplifies to just false.

Suggested Development Environment

Either: