next up previous
Next: About this document Up: My Home Page

Midterm 1 Rules

Anything we have covered thus far is fair game, particularly propositional logic, digital logic, and predicate logic.

Problems will be similar to the homeworks.

Check out the practice exam on the WWW - I am using it as a model for the exam length and topic distribution.

Come early to the exam so you can find your assigned seat!

Bring your ID card and leave it out on your desk so we can check!

All exams must be completed using an indelible ink pen only. Components of an exam completed using any other writing instrument will receive a grade of zero.

Material on the Exam

Predicate logic: logical forms, connectives, truth tables, logical equivalence, logical inference.

Digital logic: logic circuits, building circuits from truth tables, binary numbers and arithmetic.

Predicate logic: translating sentences into predicates, quantifiers, truth evaluation and logical equivalence of predicate logic formulas.

It is also fair to have related, but non-logical mathematical problems such as we did on the homework, as this course is designed to develop problem solving skills.

Rules of Inference

Rule of Universal Instantiation (UI)

From tex2html_wrap_inline366
infer P(a)
where a is any constant (denoting a specific domain element).

For example, from


we may infer


Existential Rule (ER)

From P(a)
infer tex2html_wrap_inline374
where a is a constant.

For example, if we know that

John takes CSE-113
we may infer
Somebody takes CSE-113.

Derived Inference Rules

Universal instantiation is often combined with modus ponens in the following inference rule.

Universal Modus Ponens (UMP)

From tex2html_wrap_inline378
and P(a)
infer Q(a)
where a may be any constant.

Thus, if we know that

(1) Everyone taking CSE-113 satisfies the course prerequisites, and
(2) John takes CSE-113.
we may infer that
John satisfies the course prerequisites.

Forward versus Backward Reasoning

Inference rules can be applied to derive new conclusions from given assumptions. This is sometimes called forward reasoning or forward chaining.

But inference rules can also be used in the opposite direction to determine under which conditions a given goal can be derived. This is called backward reasoning or backward chaining.

For example, suppose we want to answer the question

Does John satisfy the CSE-113 prerequisites?

If we know that

everyone taking CSE-113 satisfies the course prerequisites,
then it is sufficient to check that
John takes CSE-113.

Note that the condition is sufficient, but not necessary, as there are of course other ways to verify that John satsifies the CSE-113 prerequisites.

Programming in Logic

Predicate logic formulas can be used to write programs in a programming language called Prolog.

A logic program consists of two kinds of formulas:

Facts are atomic formulas without variables.

Rules are universally quantified implications of a certain form.

The input to a logic program is called a
Goal, an existentially quantified atomic formula, usually with variables.
Inference rules similar to universal modus ponens and the existential rule are used in backward chaining mode to determine whether a (instance of the) goal can be derived from the given facts via the given rules.

A Logic Program



Goal: Mother(Sue,Joan)?

Answer: yes (the goal occurs as fact).

Another goal: Mother(Joan,Sue)?

Answer: no (the program contains no such fact).

Another goal: tex2html_wrap_inline404 ?

Answer: yes, x=Myrtle.

Rules in Logic Programs

Let us add some rules to the above facts:

(1) tex2html_wrap_inline408
(2) tex2html_wrap_inline410

Goal: Parent(Gene,Joan)?

Answer: yes.

Justification: We can obtain


by universal modus ponens from (2) and


The latter formula is a fact.

Another goal: tex2html_wrap_inline418 ?

Read: A parent of whom is Joan?

Answer: By (2) it is sufficient to look for answers to Mother(x,Joan)? For the latter, there are two relevant facts:

We obtain two answers: x=Gene and x=Sue.

The GrandFather Clause

Let's add yet another rule:

(3) tex2html_wrap_inline430
that defines the grandfather relationship. (For simplicity, we omit the universal quantifiers.)

Goal: Grandfather(Gene,z)?

(We also omit the existential quantifier for simplicity.)

By (3) we can look for answers to


The conjunction can be interepreted as two subgoals, Parent(Gene,y) and Father(y,z).

Two facts are relevant to the first subgoal:
Parent(Gene,Joan) and Parent(Gene,William).

Trying the first fact, we get y=Joan as solution for the first subgoal and then have to solve the now partially instantiated second subgoal Father(Joan,z).

The relevant fact for the latter subgoal is

At this point all subgoals have been solved and we get the answer z=Ormonde to the initial goal.

If we had tried Parent(Gene,William) instead, the second subgoal would have become Father(William,z).

Then the computation would have failed, as the program contains no facts relevant to Father(William,z).

Prolog and Proofs

The result of a computation with a logic program is a proof that the goal is a logical consequence of the facts and rules.

Here is a proof corresponding to the last computation.

  1. Mother(Gene,Joan) (fact)
  2. tex2html_wrap_inline458 (rule)
  3. tex2html_wrap_inline460 (by UI)
  4. Parent(Gene,Joan) (by UMP)
  5. Father(Joan,Ormonde) (fact)
  6. tex2html_wrap_inline466
    tex2html_wrap_inline468 (rule)
  7. tex2html_wrap_inline470
    tex2html_wrap_inline472 (by repeated UI)
  8. Grandfather(Gene,Ormonde) (by generalized MP)
  9. tex2html_wrap_inline476 (by ER)


When executing a logic program one has to explore all possible backward chains. These can be represented by a tree.

Consider a logic program with facts,

F1: Parent(Gene,William)
F2: Parent(Gene,Joan)
F3: Parent(Sue,William)
F4: Parent(Joan,Ormonde)
and rules,
C1: tex2html_wrap_inline486
C2: tex2html_wrap_inline488

The next slide shows the computation tree for the goal


A Computation Tree

tex2html_wrap_inline492 Ancestor(Gene,x)?

tex2html_wrap_inline496 [C1] Parent(Gene,x)?

tex2html_wrap_inline500 [F1] tex2html_wrap536

tex2html_wrap_inline504 [F2] tex2html_wrap538

tex2html_wrap_inline508 [C2] tex2html_wrap_inline510 ?

tex2html_wrap_inline512 [F1] Ancestor(William,x)?

tex2html_wrap_inline516 [F2] Parent(William,x)? [FAILS]


tex2html_wrap_inline522 [F2] Ancestor(Joan,x)?

tex2html_wrap_inline526 [C1] Parent(Joan,x)?

tex2html_wrap_inline530 [F4] tex2html_wrap540


next up previous
Next: About this document Up: My Home Page

Steve Skiena
Tue Aug 24 23:51:31 EDT 1999