CS195Y Lecture 17

3/6/2017


Continuing with our city model

sig City{roads : set City }
pred someHub {
  some c : City | all c2 : City | c -> c2 in roads
}run someHub for exactly

On the whiteboard

City$0 City$2

Things that could be true or false about these:
C0 -> C1 in roads
C0 -> C0 in roads
C1 -> C0 in roads
C1 -> C1 in roads
How many possible rows in a binary relation? (#atoms)^(#cols)
"Herbrand Base" : all the things in a universe that are or are not the case.

(Less than) Fun Fact: Herbrand met a tragic end in a mountain climbing accident. Head over to Tim's hours sometime for storytime about Herbrand and all your other favorite logicians if you're curious.

How many things are in the Herbrand base for this universe?
The four we have above plus:
C0 in City
C1 in City
C0 in $somehub_c
C1 in $somehub_c
But in our run command we only have 6 primary variables?
Let's try taking out the exactly. And that does it! Now we have 8 primary variables.

We are moving towards boolean logic!

But what do the rest of these vars and clauses even mean?
How can we crunch our spec to be only in boolean logic?

We need to get rid of quantifiers. How can we remove the some from our predicate.
Given that I know either city1 and city2 needs to wor, I can use or to manipulate out the some in the someHub predicate.
This looks like :

(all c2 : City | c0 -> c2 in roads)
OR
(all c2 : City | c1 -> c2 in roads)
Note: this is regular or not exclusive or

Now I want to take out the all using and:
(c0 -> c1 in roads and c0 -> c0 in roads
OR
(c1 -> c0 in roads and c1 -> c1 in roads)
Simplify:
(c01 and c00) or (c10 and c11)
And what do you know it's a boolean formula!

Disjunctive Normal Form: (v1 and ... and vn) or ...
Conjunctive Normal Form: (+/- u1 or ... +/- un) and (+/- u1 or ... +/- um) and ...

What can we do with CNF?
If a formula's negation is satisfiable then that means there's a counterexample.
But wouldn't it be better to take DNF since it's easy to tell if it's satisfiable.
But it's also much easier to get to CNF then DNF so we need to make a tradeoff.

Getting something to CNF:
Use algebra! (This is really tedious to write out so I'm not going to do it, but Tim did it out in class so hopefully you have a sense)
We won't need to do this by hand again, since you're going to write a program to do it!