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)
Fromwhere a is any constant (denoting a specific domain element).
For example, from
we may infer
Existential Rule (ER)
From P(a)where a is a constant.
For example, if we know that
John takes CSE-113we 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)
Fromwhere a may be any constant.
Thus, if we know that
(1) Everyone taking CSE-113 satisfies the course prerequisites, andwe may infer that
(2) John takes CSE-113.
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.The input to a logic program is called a
Rules are universally quantified implications of a certain form.
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
Answer: yes (the goal occurs as fact).
Another goal: Mother(Joan,Sue)?
Answer: no (the program contains no such fact).
Another goal: ?
Answer: yes, x=Myrtle.
Rules in Logic Programs
Let us add some rules to the above facts:
Justification: We can obtain
by universal modus ponens from (2) and
The latter formula is a fact.
Another goal: ?
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:
Mother(Gene,Joan)We obtain two answers: x=Gene and x=Sue.
The GrandFather Clause
Let's add yet another rule:
(3)that defines the grandfather relationship. (For simplicity, we omit the universal quantifiers.)
(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.
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)and rules,
The next slide shows the computation tree for the goal
A Computation Tree
[F2] Parent(William,x)? [FAILS]