CS345 PROBLEM SET #2

Due in class, Monday, October 14, 1996.

6 Questions, 100 pts.

### Problem 1 (25 pts.)

In this problem we will use two kinds of electronic gates, *NAND
gates* and *INVOR gates*.
A *NAND gate* has inputs X and Y; its output Z is F(alse) if
and only if both X and Y are T(rue).
In this problem the only *INVOR gate* has inputs X and Y; its
output Z is F(alse) if and only if X is T(rue) and Y is F(alse).
We can represents a circuit of NAND and INVOR gates by the EDB predicate
*wireT*(Z), meaning that wire Z is a circuit input set to
T(rue), *nandGate*(X,Y,Z) meaning that there is a NAND gate in
the circuit with input wires X and Y and with output wire Z, and
*invorGate*(X,Y,Z) meaning that there is an INVOR gate in the
circuit
with input wires X and Y and with output wire Z. The rules describing
a circuit are then the following.
```
```- t(Z) :- wireT(Z).
- t(Z) :- nandGate(X,Y,Z) & NOT t(X).
- t(Z) :- nandGate(X,Y,Z) & NOT t(Y).
- t(Z) :- invorGate(X,Y,Z) & NOT t(X).

```
t(Z) :- invorGate(X,Y,Z) & t(Y).
```

Here is a circuit of NAND and INVOR gates represented by the EDB:
wireT(1), nandGate(6,1,3), nandGate(1,2,4), nandGate(3,5,6),
nandGate(1,4,7), and invorGate(3,1,5).

For this EDB and the logic program above it, find the well-founded
model by repeatedly making positive inferences and looking for
unfounded sets.

### Problem 2 (15pts.)

For the same EDB and program as in Problem 1, find the well-founded
model by the alternating fixedpoint method.
### Problem 3 (20pts.)

For the EDB and program of Problem 1, find all the stable models. Is
there a stable semantics for this EDB and program?
### Problem 4 (15pts.)

Suppose we change the input of terminal 1 to be F(alse); i.e., the
relation *wireT* is made empty instead of {1}. Show that this
EDB plus the program from Problem 1 is modularly stratified. What are
the "modules"?
### Problem 5 (10pts.)

Is the program and EDB of Problem 4 locally stratified? Justify your
answer.
### Problem 6 (15pts.)

Compare the well-founded and stable approaches on the following rules
of propositional calculus.
```
```- p :- NOT q.
- q :- NOT r.
- r :- NOT s.

```
s :- NOT p.
```