Hi There!

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

Assignment 2

Microproject

Examine the below main project. Write one or more Clojure functions which perform symbolic simplification on (un-nested) expressions using the and logical connective. Be sure to generalize to all possible variables and valid numbers of arguments to and. For example: 

Main Project

Write a set of Clojure functions that perform symbolic simplification and evaluation of boolean expressions using and, or, and not. not will be assumed to take one argument, while and and or will take one or more. You should use false for False and true for True.

Expressions are created as unevaluated lists. Three sample expressions could be defined as follows:

You could also define functions to build unevaluated lists for for you, such as:

Using these, p3 could have been created using

If you wish to use these in your project, you will need to modify andexp and orexp to allow for one or more arguments.

The main function to write, evalexp, entails calling functions that simplify, bind, and evaluate these expressions.

Simplification consists of replacing particular forms with equivalent functions, including the following:

You should generalize for any length expression based on these patterns. Your program must work for any arbitrary variables used. As in the microproject, you may wish to write functions to handle certain kinds of cases, and handle the non-recursive case before you handle the recursive one.

Binding consists of replacing some or all of the variables in expressions with provided 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 (and false (or false (and y (not true)))) and then further simplifies to just false.