Artificial Intelligence · Unit 4
Knowledge Representation
Exam-focused notes for Knowledge Representation (Artificial Intelligence, BIT252): what the TU syllabus asks and how it has actually been tested, with 11 solved past questions from this unit.
Knowledge Representation in short
An intelligent program needs knowledge in a form it can store and use. This chapter covers how knowledge is represented, from semantic networks and scripts to predicate logic, and how logic is prepared for automatic proof.
What this unit covers
- Knowledge definition and representation issues
- Semantic networks
- Scripts and conceptual dependency
- First order predicate logic
- Clausal normal form conversion
- Unification and lifting in predicate logic
Unification and lifting in predicate logic
2082 · 10 marks
How unification and lifting is done in predicate logic?Construct a knowledge base in first order predicate logic for following statements and convert them to CNF form: All students are smart people. All smart people are not intelligent. Someone is intelligent. Either all students are intelligent or all students are hardworking.[4+6]
Show solved answerHide answer
Unification, Lifting in Predicate Logic & Knowledge Base Construction
Part 1: Unification and Lifting [4 Marks]
Unification
Unification is the process of finding a substitution (called a unifier) that makes two or more logical expressions identical.
- A substitution θ is a set of bindings of the form {x/term, y/term, ...}
- The Most General Unifier (MGU) is the most general substitution that unifies two expressions
Unification Algorithm Steps:
- If both expressions are constants or the same variable, they unify (empty substitution)
- If one is a variable, substitute it with the other term (occurs check: variable must not appear in the term)
- If both are compound expressions, unify functor/predicate names and then unify arguments recursively
- If none of the above, unification fails
Example:
| Expression 1 | Expression 2 | MGU |
|---|---|---|
| P(x, y) | P(John, Mary) | {x/John, y/Mary} |
| Knows(John, x) | Knows(John, Jane) | {x/Jane} |
| P(x, f(x)) | P(a, f(a)) | {x/a} |
| P(x, x) | P(a, b) | Fails (a ≠ b) |
Lifting
Lifting refers to the process of generalizing inference rules from propositional logic to first-order predicate logic by incorporating unification.
The key idea: instead of applying rules to ground (fully instantiated) sentences only, we lift them to work with variables using unification.
Example - Lifted Modus Ponens (Generalized Modus Ponens):
If we have:
- P(x) → Q(x) (for all x)
- P(John)
Then by unification {x/John}, we derive: Q(John)
Lifted Resolution:
Standard resolution in propositional logic:
From (A ∨ B) and (¬B ∨ C), derive (A ∨ C)
Lifted resolution in FOL:
From (P(x) ∨ Q(x)) and (¬P(John) ∨ R(y)), unify P(x) with P(John) using {x/John}, derive (Q(John) ∨ R(y))
Benefits of Lifting:
- Avoids instantiating all possible ground instances
- Makes inference efficient and general
- Enables working directly with universally quantified statements
Part 2: Knowledge Base in FOL and CNF Conversion [6 Marks]
Step 1: Represent Statements in FOL
Let:
- S(x) = x is a student
- Smart(x) = x is a smart person
- I(x) = x is intelligent
- H(x) = x is hardworking
| Statement | FOL Representation |
|---|---|
| 1. All students are smart people | ∀x [S(x) → Smart(x)] |
| 2. All smart people are not intelligent | ∀x [Smart(x) → ¬I(x)] |
| 3. Someone is intelligent | ∃x [I(x)] |
| 4. Either all students are intelligent or all students are hardworking | [∀x (S(x) → I(x))] ∨ [∀x (S(x) → H(x))] |
Step 2: Convert Each Statement to CNF
CNF Conversion Steps:
- Eliminate implications (A → B becomes ¬A ∨ B)
- Move negations inward (De Morgan's laws)
- Standardize variables apart
- Skolemize (eliminate existential quantifiers)
- Drop universal quantifiers
- Distribute ∨ over ∧
Statement 1: ∀x [S(x) → Smart(x)]
- Eliminate implication: ∀x [¬S(x) ∨ Smart(x)]
- Drop universal quantifier:
CNF: ¬S(x) ∨ Smart(x)
Statement 2: ∀x [Smart(x) → ¬I(x)]
- Eliminate implication: ∀x [¬Smart(x) ∨ ¬I(x)]
- Drop universal quantifier:
CNF: ¬Smart(x) ∨ ¬I(x)
Statement 3: ∃x [I(x)]
- Skolemize: Replace ∃x with a Skolem constant c (since no universal quantifier wraps it)
- Result: I(c)
CNF: I(c)
Statement 4: [∀x (S(x) → I(x))] ∨ [∀x (S(x) → H(x))]
This is the most complex. First, standardize variables apart:
[∀x (S(x) → I(x))] ∨ [∀y (S(y) → H(y))]
- Eliminate implications:
[∀x (¬S(x) ∨ I(x))] ∨ [∀y (¬S(y) ∨ H(y))]
- Move quantifiers outward (prenex normal form):
∀x ∀y [(¬S(x) ∨ I(x)) ∨ (¬S(y) ∨ H(y))]
- Drop universal quantifiers:
(¬S(x) ∨ I(x) ∨ ¬S(y) ∨ H(y))
CNF: ¬S(x) ∨ I(x) ∨ ¬S(y) ∨ H(y)
Summary of CNF Clauses
| # | Statement | CNF Clause |
|---|---|---|
| 1 | All students are smart people | ¬S(x) ∨ Smart(x) |
| 2 | All smart people are not intelligent | ¬Smart(x) ∨ ¬I(x) |
| 3 | Somebody is intelligent | I(c) |
| 4 | Either all students are intelligent or all students are hardworking | ¬S(x) ∨ I(x) ∨ ¬S(y) ∨ H(y) |
Conclusion
Unification finds the substitution that makes two literals identical, and lifting is what allows the propositional inference rules to be applied directly to quantified first order sentences by using that substitution. Once every sentence of the knowledge base has been reduced to the four clauses above, resolution can be applied mechanically to them, since every clause is now a disjunction of literals with all quantifiers removed.
2080.2 · 5 marks
Explain about unification and lifting with example. [5]
Scripts and conceptual dependency
2082 · 5 marks
How knowledge is represented using scripts? Support your answer with example. [3+2]
Show solved answerHide answer
Knowledge Representation Using Scripts
What is a Script?
A script is a structured representation of knowledge about a stereotyped sequence of events in a particular context. Scripts were introduced by Roger Schank and Robert Abelson (1977) to represent common, everyday situations that follow a predictable pattern.
A script describes a causally ordered sequence of events that are expected to occur in a specific situation. It allows an AI system to make inferences about what happened even when information is incomplete.
Components of a Script
A script consists of the following components:
| Component | Description |
|---|---|
| Entry Conditions | Conditions that must be true before the script can begin |
| Roles | People/agents involved in the situation |
| Props | Objects used during the events |
| Track | Specific variation of the general script |
| Scenes | Sequence of events that occur |
| Results | Conditions that are true after the script ends |
Example: Restaurant Script
Script: RESTAURANT
Track: Coffee Shop
Entry Conditions:
- Customer is hungry
- Customer has money
Roles:
- Customer (C)
- Waiter (W)
- Cook (K)
- Cashier (Ca)
Props:
- Tables, Menu, Food, Bill, Money
Scene 1: ENTERING
- Customer enters restaurant
- Customer looks for a table
- Customer sits down
Scene 2: ORDERING
- Waiter brings menu
- Customer reads menu
- Customer orders food
- Waiter takes order to cook
Scene 3: EATING
- Cook prepares food
- Waiter brings food to customer
- Customer eats food
Scene 4: LEAVING
- Waiter brings bill
- Customer pays bill
- Customer leaves restaurant
Results:
- Customer is no longer hungry
- Customer has less money
- Restaurant has more money
How Scripts Help in Inference
Consider the following story:
"John went to a restaurant. He ordered a burger. He left a tip."
Using the restaurant script, the AI system can infer the following facts that were never explicitly stated:
- John sat at a table
- A waiter brought him a menu
- John paid the bill before leaving
- John was hungry when he entered
This ability to fill in missing information is called script-based inference.
Advantages of Scripts
- Allows inference about unstated events
- Handles incomplete information effectively
- Represents real-world common sense knowledge
- Useful in natural language understanding systems
Limitations
- Scripts are rigid and do not handle unexpected events well
- Requires a large number of scripts to cover real-world situations
- Difficult to handle novel situations not covered by existing scripts
Note: Scripts are a form of frame-based knowledge representation where knowledge is organized around a central concept or situation, making them suitable for AI systems dealing with natural language processing and story understanding.
2079 · 5 marks
Illustrate your own scenario for shopping at my mall and represent those concepts using scripts. [5]
2080.2 · 5 marks
Represent the following knowledge using conceptual dependency. a.) He opened the door b.) Ram gave rose to sita. c.) she is crying [5]
2080.2 · 5 marks
How does script can be used in representing knowledge? Explain. [5]
Semantic networks
2080 · 5 marks
Represent the following sentences into semantic network: a. All animals and plants are living things. b. Rose is a plant. c. All plant prepare food using photosynthesis process. d. Carnivorous animal don't eat plant. e. Tiger is carnivorous. [5]
0 · 5 marks
How do you express knowledge using semantic network? Describe with an example. [5]
Knowledge definition and representation issues
2079 · 10 marks
What is knowledge, representation and reasoning?When a machine is said to be passed Turing test?Give any two examples of constraint satisfaction problem.[3+5+2]
2080.2 · 10 marks
What are the issues in knowledge representation? Given the following knowledge base, using resolution show that a.) Ava likes watermelon b.) Apple and watermelon are fruits c.) Ava eats watermelon and love it so much d.)Anything eaten by anybody and love it so much if fruits[10]
Show solved answerHide answer
Issues in Knowledge Representation & Resolution
Part 1: Issues in Knowledge Representation (4 marks)
Knowledge representation deals with how knowledge about the world can be represented so that a computer system can use it to solve complex problems. The major issues are:
1. Representational Adequacy
The knowledge representation scheme must be able to represent all kinds of knowledge needed for the domain. It should handle facts, rules, relationships, and exceptions without loss of information.
2. Inferential Adequacy
The system must be able to derive new knowledge from existing knowledge. The representation must support valid inferences and reasoning mechanisms.
3. Inferential Efficiency
The system should be able to draw inferences quickly and efficiently. The representation should allow the inference engine to focus on relevant knowledge and avoid unnecessary search.
4. Acquisitional Efficiency
It should be easy to add new knowledge to the system without reorganizing the entire knowledge base. The representation should support incremental knowledge acquisition.
5. Expressiveness
The representation language must be expressive enough to capture complex relationships, uncertainty, time, and context in the real world.
6. Consistency and Completeness
The knowledge base should be free from contradictions (consistent) and should contain all necessary facts (complete) to answer queries correctly.
7. Handling Uncertainty
Real-world knowledge is often incomplete or uncertain. The representation must handle probabilistic or fuzzy information.
Part 2: Resolution Proof (6 marks)
Knowledge Base (Given Facts)
Let us define the predicates:
Fruit(x): x is a fruitLikes(x, y): x likes yEats(x, y): x eats yLoves(x, y): x loves y
Given Knowledge Base (Axioms)
| No. | Statement | FOL Representation |
|---|---|---|
| F1 | Apple is a fruit | Fruit(Apple) |
| F2 | Watermelon is a fruit | Fruit(Watermelon) |
| F3 | Ava eats watermelon | Eats(Ava, Watermelon) |
| F4 | Ava loves watermelon so much | Loves(Ava, Watermelon) |
| F5 | Anything eaten by anybody and loved so much is a fruit | ∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Fruit(y)] |
| F6 | Anyone who eats something and loves it, likes it | ∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Likes(x,y)] |
Convert to Conjunctive Normal Form (CNF) / Clausal Form
F5: ∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Fruit(y)]
= ∀x ∀y [¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Fruit(y)]
Clause C5: {¬Eats(x,y), ¬Loves(x,y), Fruit(y)}
F6: ∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Likes(x,y)]
= ∀x ∀y [¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Likes(x,y)]
Clause C6: {¬Eats(x,y), ¬Loves(x,y), Likes(x,y)}
All Clauses:
| Clause | CNF Form |
|---|---|
| C1 | Fruit(Apple) |
| C2 | Fruit(Watermelon) |
| C3 | Eats(Ava, Watermelon) |
| C4 | Loves(Ava, Watermelon) |
| C5 | ¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Fruit(y) |
| C6 | ¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Likes(x,y) |
a.) Prove: Ava likes watermelon → Likes(Ava, Watermelon)
Negate the goal: ¬Likes(Ava, Watermelon) → Clause C7
Resolution Steps:
Step 1: Resolve C6 and C3
C6: ¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Likes(x,y)
C3: Eats(Ava, Watermelon)
Unifier: {x=Ava, y=Watermelon}
Result C8: ¬Loves(Ava, Watermelon) ∨ Likes(Ava, Watermelon)
Step 2: Resolve C8 and C4
C8: ¬Loves(Ava, Watermelon) ∨ Likes(Ava, Watermelon)
C4: Loves(Ava, Watermelon)
Result C9: Likes(Ava, Watermelon)
Step 3: Resolve C9 and C7
C9: Likes(Ava, Watermelon)
C7: ¬Likes(Ava, Watermelon)
Result: □ (Empty Clause - Contradiction)
Proved: Ava likes watermelon ✓
b.) Prove: Apple and Watermelon are fruits
For Apple: Fruit(Apple) is already given as clause C1, so the proof is immediate.
Negate the goal: C7': ¬Fruit(Apple)
Step 1: Resolve C7' and C1
C1 : Fruit(Apple)
C7': ¬Fruit(Apple)
Result: □ (Empty Clause - Contradiction)
For Watermelon: Fruit(Watermelon) is given as C2, but it can also be derived from the rule C5, which is the more informative proof.
Negate the goal: C7'': ¬Fruit(Watermelon)
Step 1: Resolve C5 and C3
C5: ¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Fruit(y)
C3: Eats(Ava, Watermelon)
Unifier: {x=Ava, y=Watermelon}
Result C10: ¬Loves(Ava, Watermelon) ∨ Fruit(Watermelon)
Step 2: Resolve C10 and C4
C4: Loves(Ava, Watermelon)
Result C11: Fruit(Watermelon)
Step 3: Resolve C11 and C7''
Result: □ (Empty Clause - Contradiction)
Proved: Apple and Watermelon are fruits ✓
c.) Prove: Ava eats watermelon and loves it so much
The goal is the conjunction Eats(Ava, Watermelon) ∧ Loves(Ava, Watermelon). Negating a conjunction gives a single disjunctive clause.
Negate the goal: C12: ¬Eats(Ava, Watermelon) ∨ ¬Loves(Ava, Watermelon)
Step 1: Resolve C12 and C3
C3: Eats(Ava, Watermelon)
Result C13: ¬Loves(Ava, Watermelon)
Step 2: Resolve C13 and C4
C4: Loves(Ava, Watermelon)
Result: □ (Empty Clause - Contradiction)
Proved: Ava eats watermelon and loves it so much ✓
d.) Prove: Anything eaten by anybody and loved so much is a fruit
The goal is the universally quantified rule ∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Fruit(y)]. Its negation is existential, so the two existential variables are replaced by Skolem constants a and b, giving three unit clauses.
Negate the goal:
¬∀x ∀y [¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Fruit(y)]
= ∃x ∃y [Eats(x,y) ∧ Loves(x,y) ∧ ¬Fruit(y)]
Skolemize with constants a and b:
C14: Eats(a, b)
C15: Loves(a, b)
C16: ¬Fruit(b)
Step 1: Resolve C5 and C14
C5 : ¬Eats(x,y) ∨ ¬Loves(x,y) ∨ Fruit(y)
Unifier: {x=a, y=b}
Result C17: ¬Loves(a, b) ∨ Fruit(b)
Step 2: Resolve C17 and C15
Result C18: Fruit(b)
Step 3: Resolve C18 and C16
Result: □ (Empty Clause - Contradiction)
Proved: anything eaten by somebody and loved so much is a fruit ✓
Conclusion
Resolution refutation works the same way in all four parts: the knowledge base is converted to clausal form, the statement to be proved is negated and added to the clause set, and clauses are resolved with the most general unifier until the empty clause appears. Reaching the empty clause shows that the negated goal is inconsistent with the knowledge base, which means the original goal follows from it. Parts b and c resolve directly against the given facts, while parts a and d need the implication clauses C6 and C5 with the substitution {x = Ava, y = Watermelon} and the Skolem constants respectively.
Clausal normal form conversion
2079 · 10 marks
Why CNF is necessary? From the following facts, show that "Charlie is a mammal" using FOPL based resolution method. a.) ows, pigs and horses are mammals b.) The child of a horse is a horse c.) Bluebeard is a horse d.) Bluebeard is Charlie's father e.) Child and father are inverse relations f.) Every mammal has a father.[10]
Make Unit 4 stick
Practice BIT252 with flashcards & quizzes