University of Washington, Bothell
CSS 482: Expert Systems
Winter 2009
Expert System 1: A Circuit Simulation
Assigned: Wednesday, January 21, 2009
Due: Wednesday, January 28, 2009 at midnight

In your first expert system, you will develop a program that simulates logic circuits. A drawing of an example circuit might be:


PIC


In this case, we’re interested in circuits that include AND, OR, XOR, and NOT elements, plus connections (between element output and input), and input and output ports (A–C and D, E, respectively, in the figure). Your task is to develop an expert system in which the circuit structure (logic elements, connections, and ports) is represented as facts and a set of generic rules compute the output of each element or port, given its inputs.

Your approach should proceed in the following stages (we will discuss these in detail in class):

  1. Determine your fact representation. A logic element will at the least need a name (for the connections to refer to) and an output value (true, false, or unknown; the latter would be the initial value before a rule computes what it is). Connections will need to hold the name of the input element (or port) and the name of the output element (or port). Ports need to have names (again, for the connections to refer to) and values.
  2. Write your rules. Do this one at a time. What kind of rules will you need? Can you get a circuit with a single input port connected directly to a single output port to work? A single logic element? Will your rules work when the output of an element connects to multiple other elements’ inputs?
  3. Validate your expert system by simulating some simple circuits (the Rosen book from 342/3 has a number of simple circuits to try).
  4. When you change the circuit inputs by changing a port fact’s value, will running your system update the output port values correctly?
  5. Can you simulate a circuit with feedback connections (i.e., that has an internal state, like an S-R flip flop?

Deliverables

Please submit your program, with documentation (in which you outline your approach, ordered in the steps given above, with the answers to the questions above included) and example runs (which should demonstrate that your code works, using for example Rosen’s circuits “a circuit for a light controlled by two switches” and “the half adder”), to our CollectIt drop box. Your written documentation should be concise, but should allow the reader to understand your design without reference to the code.

Coding Standards

Your code should be easy to read and understand. Use consistent indentation. Each file should start with a comment that includes the file name, your name, the date and a summary of the file purpose/contents. Each deftemplate, defrule, etc. should have a useful comment string and comments indicating what each slot means. The gist of your written documentation should be included in comments in your file(s).