You are on page 1of 39

Knowledge

Representation
LOGIC
Knowledge representation

 Objective: express the knowledge about the


world in a computer-tractable form
 Key aspects: –
 Syntax: describes how sentences are formed in the
language
 Semantics: describes the meaning of sentences, what is
it the sentence refers to in the real world
logic

 Is one of the earliest formalisms for the representation of


knowledge
 propositional logic
 first-order predicate logic.
Propositional logic

 representation language which allows us to express and


reason with statements that are either true or False
 Statements are called propositions
 Simple propositions are called atoms or atomic
propositions
Propositional logic

 EXAMPLES. The following are propositions: –


 It is raining today
 Dr Hatem is the dean.
 whereas the following are not:
 are you going out somewhere?
 2+x=13
Propositional logic

 Atoms can be combined with logical connectives


Priority of the connectives
Truth table
Truth table: Logical implication

 If q -> p
• If p, then q
 Ex: “If I study Hard, then I will pass .”

If I study Hard -- then I will pass == Satisfied with result 


If I study Hard -- then I don't pass == not satisfied with result 
If I don't study hard -- then I pass == I am satisfied 
if don't study hard -- then I don't pass == I am satisfied with results 
Truth table: Biconditional

• P if and only if q
Composite sentences:

 Constructed from valid sentences via logical


connectives
Example: Truth table
Interpretation

 w(P) = true: the atom P has the truth value true

 w(P) = false: the atom P has the truth value


false
w is called an interpretation function
Equivalence

 Two formulas F and G are called equivalent,


written as F ≡ G,
 if the truth values of F and G are the same under all
possible interpretations.
 i.e, their truth tables are identical.
EXAMPLE
Laws of equivalence
Example

 It is not sunny this afternoon and it is colder than yesterday.


Propositional logic

 Propositional logic has very limited expressive power


 propositional logic assumes the world contains facts,

 How to represent this sentence using propositional logic?


 Some humans are intelligent
 so, we required some more powerful logic, such as first-order
logic.
first-order logic

 It is an extension to propositional logic.


 first-order logic (like natural language) assumes the world
contains
 Objects

 Relations

 Functions
Symbols
Symbols

 function symbols:
 write in uncapitalized mixed case (e.g., bestFriend)
 predicate symbols:
 write in capitalized mixed case, (e.g., OlderThan)
 Arity: a nonnegative integer indicating how many “arguments” of nonlogical
symbols
 Constants : function of arity 0
 Propositional: Predicate of arity 0
Atomic sentences:

• Atomic sentences are the most basic sentences of first-order logic.


• These sentences are formed from a predicate symbol followed by a
parenthesis with a sequence of terms.
• Predicate (term1, term2, ......, term n).
 Example:
 Ravi and Ajay are brothers Brothers(Ravi, Ajay).
 Chinky is a cat cat (Chinky).
Complex Sentences:

 Complex sentences are made by combining atomic sentences


using connectives.
Example
Example
Function

 First-order logic allows functions that return objects


associated with other objects.
 Examples:
 MedianOf(x, y, z)
 As with predicates, functions can take in any number of
arguments, but always return a single value
The Existential Quantifier
The Existential Quantifier
The Existential Quantifier
The Existential Quantifier
The Existential Quantifier
How to express this

Some muggle is intelligent.


How to express this

Some muggle is intelligent.


The Universal Quantifier

 “For any natural number n, n is even if and only if n 2 is even”


The Universal Quantifier
The Universal Quantifier
Variables and Quantifiers
Translate the following sentences into
FOL.
1. Everything is bitter or sweet
2. Either everything is bitter or everything is sweet
3. There is somebody who is loved by everyone
4. Nobody is loved by no one
5. If someone is noisy, everybody is annoyed 1
6. Frogs are green.
7. Frogs are not green.
8. No frog is green.
9. Some frogs are not green.
10. A mechanic likes Bob.
11. A mechanic likes herself.
12. Every mechanic likes Bob.
13. Some mechanic likes every nurse.
14. There is a mechanic who is liked by every nurse.

You might also like