4 Knowledge Representation

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.

Knowledge Representation: notes

Knowledge definition and representation issues

Knowledge is information that is organized and understood so that it can be used to decide and act. Knowledge representation (KR) is the way we store knowledge in a computer. Reasoning is the process of drawing new conclusions from stored knowledge.

A good representation scheme has four properties:

  • Representational adequacy: it can represent all the kinds of knowledge needed.
  • Inferential adequacy: it can derive new knowledge from old.
  • Inferential efficiency: it can direct inference in useful directions quickly.
  • Acquisitional efficiency: it makes adding new knowledge easy.

Knowledge is of several kinds: declarative (facts), procedural (how to do things), and heuristic (rules of thumb).

Issues in knowledge representation:

  • Which attributes of objects are important, and are they basic enough to be shared?
  • How are relations between objects shown, such as "is-a" and "part-of"?
  • At what level of detail should knowledge be written?
  • How can a very large amount of knowledge be organized?
  • How should the correct piece of knowledge be found when needed?
  • How should incomplete, uncertain, or changing knowledge be handled?

Main approaches are logic, semantic networks, frames, scripts, and production rules.

Semantic networks

A semantic network is a graph. Nodes show objects or concepts. Labeled arcs show relations between them. Two common arcs are is-a (class membership or subclass) and has-part or other attributes. It supports inheritance: a node gets the properties of its parent class.

Example. Represent: "All animals and plants are living things. Rose is a plant. A rose is red. Tom is a cat. A cat is an animal."

Animal  --is-a--> Living thing
Plant   --is-a--> Living thing
Cat     --is-a--> Animal
Tom     --instance-of--> Cat
Rose    --instance-of--> Plant
Rose    --colour--> Red

From this, the system infers that Tom is an animal and a living thing, because the is-a links are followed upward.

Advantages: easy to read, natural for hierarchies, supports inheritance. Limits: no standard meaning for links, hard to represent negation and quantifiers, and exceptions are awkward.

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 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:

  1. If both expressions are constants or the same variable, they unify (empty substitution)
  2. If one is a variable, substitute it with the other term (occurs check: variable must not appear in the term)
  3. If both are compound expressions, unify functor/predicate names and then unify arguments recursively
  4. If none of the above, unification fails

Example:

Expression 1Expression 2MGU
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
StatementFOL 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:

  1. Eliminate implications (A → B becomes ¬A ∨ B)
  2. Move negations inward (De Morgan's laws)
  3. Standardize variables apart
  4. Skolemize (eliminate existential quantifiers)
  5. Drop universal quantifiers
  6. 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

#StatementCNF Clause
1All students are smart people¬S(x) ∨ Smart(x)
2All smart people are not intelligent¬Smart(x) ∨ ¬I(x)
3Somebody is intelligentI(c)
4Either 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.

Open this answer on its own page →

2080.2 · 5 marks

Explain about unification and lifting with example. [5]

Note: Reference notes were not available for this topic. The following answer is based on standard AI/FOL curriculum as taught in BSc CSIT. --- Unification is the process of finding a substitution (called a unifier) that makes two or more logical expressions identical. - It is a key operation in ...

Open this answer on its own page →

Scripts and conceptual dependency

2082 · 5 marks

How knowledge is represented using scripts? Support your answer with example. [3+2]

Show solved 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:

ComponentDescription
Entry ConditionsConditions that must be true before the script can begin
RolesPeople/agents involved in the situation
PropsObjects used during the events
TrackSpecific variation of the general script
ScenesSequence of events that occur
ResultsConditions 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

  1. Allows inference about unstated events
  2. Handles incomplete information effectively
  3. Represents real-world common sense knowledge
  4. Useful in natural language understanding systems

Limitations

  1. Scripts are rigid and do not handle unexpected events well
  2. Requires a large number of scripts to cover real-world situations
  3. 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.

Open this answer on its own page →

2079 · 5 marks

Illustrate your own scenario for shopping at my mall and represent those concepts using scripts. [5]

A script is a structured knowledge representation technique (proposed by Schank and Abelson) that captures a stereotyped sequence of events in a particular context. It represents common, predictable situations using: Component Description ------------------------ Entry Conditions What must be tru...

Open this answer on its own page →

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]

Conceptual Dependency (CD) is a theory proposed by Roger Schank for representing the meaning of natural language sentences in a language-independent, canonical form. It uses a set of primitive actions (ACTs) to represent any action or event. Primitive Meaning -------------------- PTRANS Physical ...

Open this answer on its own page →

2080.2 · 5 marks

How does script can be used in representing knowledge? Explain. [5]

A script is a structured knowledge representation technique introduced by Roger Schank and Robert Abelson (1977). It represents stereotyped sequences of events in a particular context -- essentially, it captures common, predictable patterns of human activity and world knowledge. A script is simil...

Open this answer on its own page →

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]

a. All animals and plants are living things. b. Rose is a plant. c. All plants prepare food using photosynthesis process. d. Carnivorous animals don't eat plants. e. Tiger is carnivorous. --- --- Node 1 (Subject) Relationship / Arc Node 2 (Object) --------- Animal is-a Living Thing Plant is-a Liv...

Open this answer on its own page →

0 · 5 marks

How do you express knowledge using semantic network? Describe with an example. [5]

A semantic network is a graph-based knowledge representation technique where: - Nodes represent objects, concepts, or events - Edges (arcs) represent relationships or associations between those nodes It provides a natural way to represent structured knowledge and supports inheritance through hier...

Open this answer on its own page →

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]

--- Knowledge refers to the information, facts, rules, and relationships about the world that an intelligent agent uses to make decisions and solve problems. It is the foundation of intelligent behavior in AI systems. - Example: "All humans are mortal" is a piece of knowledge. Knowledge Represent...

Open this answer on its own page →

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 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 fruit
  • Likes(x, y) : x likes y
  • Eats(x, y) : x eats y
  • Loves(x, y) : x loves y

Given Knowledge Base (Axioms)

No.StatementFOL Representation
F1Apple is a fruitFruit(Apple)
F2Watermelon is a fruitFruit(Watermelon)
F3Ava eats watermelonEats(Ava, Watermelon)
F4Ava loves watermelon so muchLoves(Ava, Watermelon)
F5Anything eaten by anybody and loved so much is a fruit∀x ∀y [Eats(x,y) ∧ Loves(x,y) → Fruit(y)]
F6Anyone 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:

ClauseCNF Form
C1Fruit(Apple)
C2Fruit(Watermelon)
C3Eats(Ava, Watermelon)
C4Loves(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.

Open this answer on its own page →

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]

--- CNF is necessary for resolution-based theorem proving for the following reasons: 1. Uniform Format: Resolution works on clauses (disjunctions of literals). CNF converts all formulas into a standard set of clauses, making the process mechanical and systematic. 2. Enables Unification: The resol...

Open this answer on its own page →