Artificial Intelligence
Artificial Intelligence
Logic
Representation of knowledge and the reasoning process are central to the entire field of artificial
intelligence. The primary component of a knowledge-based agent is its knowledge-base. A knowledge-
base is a set of sentences. Each sentence is expressed in a language called the knowledge representation
language. Sentences represent some assertions about the world. There must mechanisms to derive new
sentences from old ones. This process is known as inferencing or reasoning. Inference must obey the
primary requirement that the new sentences should follow logically from the previous ones. Logic is the
primary vehicle for representing and reasoning about knowledge. Specifically, we will be dealing with
formal logic. The advantage of using formal logic as a language of AI is that it is precise and definite.
This allows programs to be written which are declarative - they describe what is true and not how to solve
problems. This also allows for automated reasoning techniques for general purpose inferencing.
Knowledge base = set of sentences in a formal language
A logic consists of two parts, a language and a method of reasoning. The logical language, in turn, has
two aspects, syntax and semantics. Thus, to specify or define a particular logic, one needs to specify three
things:
Syntax: The atomic symbols of the logical language, and the rules for constructing well-formed, non-
atomic expressions (symbol structures) of the logic. Syntax specifies the symbols in the language and
how they can be combined to form sentences. Hence facts about the world are represented as sentences in
logic.
Semantics: The meanings of the atomic symbols of the logic, and the rules for determining the meanings
of non-atomic expressions of the logic. It specifies what facts in the world a sentence refers to. Hence,
also specifies how you assign a truth value to a sentence based on its meaning in the world. A fact is a
claim about the world, and may be true or false.
Syntactic Inference Method: The rules for determining a subset of logical expressions, called theorems
of the logic. It refers to mechanical method for computing (deriving) new (true) sentences from existing
sentences.
Entailment:
• Entailment means that one thing follows from another:
KB ╞ α
• Knowledge base KB entails sentence α if and only if α is true in all worlds where KB is true
– E.g., x+y = 4 entails 4 = x+y
Entailment is a relationship between sentences (i.e., syntax) that is based on semantics
Reasoning Patterns in propositional logic
First Order Logic
•In propositional logic, each possible atomic fact requires a separate unique propositional symbol.
•If there are n people and m locations, representing the fact that some person moved from one location to
another requires nm2 separate symbols.
•Predicate logic includes a richer ontology:
-objects (terms)
-properties (unary predicates on terms)
-relations (n-ary predicates on terms)
-functions (mappings from terms to other terms)
Syntax for First-Order Logic
Sentence → AtomicSentence | Sentence Connective Sentence | Quantifier Variable Sentence |
⇁Sentence | (Sentence)
AtomicSentence → Predicate(Term, Term, ...) | Term=Term
Term → Function(Term,Term,...) | Constant | Variable
Connective → V | ∧ |⇒ | ⇔
Quanitfier → ∀ | ∃
Constant → A | John | Car1
Variable →x | y | z |...
Predicate → Brother | mother | ...
Function → father-of | plus | Owns...
Terms and Predicates
•Objects are represented by terms:
-Constants: Block1, John
-Function symbols: father-of, successor, plus An n-ary function maps a tuple of n terms to another term:
father-of(John), succesor(0), plus(plus(1,1),2)
•Terms are simply names for objects. Logical functions are not procedural as in programming languages.
They do not need to be defined, and do not really return a value. Allows for the representation of an
infinite number of terms.
•Propositions are represented by a predicate applied to a tuple of terms. A predicate represents a property
of or
relation between terms that can be true or false: Brother(John, Fred), Left-of(Square1, Square2)
GreaterThan(plus(1,1), plus(0,1))
•In a given interpretation, an n-ary predicate can defined as a function from tuples of n terms to {True,
False} or
equivalently, a set tuples that satisfy the predicate: {<John, Fred>, <John, Tom>, <Bill, Roger>, ...}
Sentences in First-Order Logic
An atomic sentence is simply a predicate applied to a set of terms. An atomic sentence is true in a given
model, under a given interpretation, if the relation referred to by the predicate symbol holds among the
objects referred to by the arguments
Owns(John,Car1)
Sold(John,Car1,Fred)
Semantics is True or False depending on the interpretation, i.e. is the predicate true of these arguments.
•The standard propositional connectives (V ∧⇒⇔ ∀ ∃) can be used to construct complex sentences:
Owns(John,Car1) V Owns(Fred, Car1)
Sold(John,Car1,Fred) ⇁Owns(John, Car1)
Semantics same as in propositional logic.
Two sentences are equivalent if they hold in exactly the same models.
Quantifiers
Once we have a logic that allows objects, it is only natural to want to express properties of entire
collections of objects, instead of enumerating the objects by name. Quantifiers let us do this. First-order
logic contains two standard quantifiers, called Universal nd existential
The order of quantification is therefore very important. It becomes clearer if we insert parentheses.
∀x (∃y Loves (x, y)) says that everyone has a particular property, namely, the property that they love
someone. On the other hand, ∃y (∀x Loves(x, y)) says that someone in the world has a particular
property, namely the property of being loved by everybody.
Some confusion can arise when two quantifiers are used with the same variable name.
Consider the sentence
∀x [Crown( x )V (∃x Brother (Richard,x ))] .
Here the x in Brother(Richard, x) is existentially quantified. The rule is that the variable belongs to the
innermost quantifier that mentions it; then it will not be subject to any other quantification. Another way
to think of it is this: ∃x Brother(Richard, x) is a sentence about Richard (that he has a brother), not about
x; so putting a ∀x outside it has no effect. It could equally well have been written ∃z Brother (Richard,
z). Because this can be a source of confusion, we will always use different variables.
Connections between ∀and ∃
The two quantifiers are actually intimately connected with each other, through negation. Asserting
that everyone dislikes parsnips is the same as asserting there does not exist someone who likes them,
and vice versa:
∀x ⇁Likes(x, coffee) is equivalent to ⇁∃x Likes(x, coffee) .
We can go one step further: "Everyone likes ice cream" means that there is no one who does not like ice
cream:
∀x Likes (x, IceCream) is equivalent to ⇁∃x ⇁Likes(x, IceCream) .
Because ∀is really a conjunction over the universe of objects and ∃is a disjunction, it should not be
surprising that they obey De Morgan's rules. The De Morgan rules for quantified and unquantified
sentences are as follows:
Equality
First-order logic includes one more way to make atomic sentences, other than using a predicate and terms
as described earlier. We can use the equality symbol to make statements to the effect that two terms
refer to the same object. For example,
Father( John) = Henry
says that the object referred to by Father(John) and the object referred to by Henry are the same.
Because an interpretation fixes the referent of any term, determining the truth of an equality sentence is
simply a matter of seeing that the referents of the two terms are the same object.
The equality symbol can be used to state facts about a given function, as we just did for the Father
symbol. It can also be used with negation to insist that two terms are not the same object. To say that
Richard has at least two brothers, we would write
∃ x, y Brother(x,Richard) A Brother(y, Richard) A⇁(x=y)
The sentence
∃ x, y Brother(x,Richard) A Brother(y,Richard) ,
does not have the intended meaning. In particular, it is true in a model where Richard has only one
brother. To see this, consider the extended interpretation in which both x and y are assigned to King John.
The addition of ⇁(x=y) rules out such models. The notation x ≠y is sometimes used as an abbreviation far
⇁(x=y).