Skip to content
Unit 3 Syllabus Note· Artificial Intelligence

Artificial Intelligence

Comprehensive exam revision notes for BCA-301N Unit 3 (Knowledge Representation & Classical Logic). Includes Section A (2M), Section B (5M), and Section C (15M) questions, answers, and diagrams.

Artificial Intelligence

Knowledge Representation & Classical Logic

Core Definitions & Key Concepts

What is the Knowledge Representation Hypothesis by Brian Smith

It asserts that any intelligent agent must contain an explicit internal representation of its knowledge expressed in symbols, and its behavior must be causally determined by manipulations of these symbolic structures.

Declarative Knowledge and Procedural Knowledge

Declarative Knowledge represents facts, concepts, and assertions ('knowing what', e.g., 'Bareilly is in UP', represented via logic or semantic networks). Procedural Knowledge represents operational rules, sequences, and procedures ('knowing how', e.g., code, production rules).

Modus Ponens and Modus Tollens

  • Modus Ponens: Given P \to Q and P, infer Q.
  • Modus Tollens: Given P \to Q and \neg Q, infer \neg P.

What is Conjunctive Normal Form (CNF)

A logical formula is in CNF if it is a conjunction (AND, \wedge) of one or more clauses, where each clause is a disjunction (OR, \vee) of literals (e.g., (A \vee B) \wedge (\neg B \vee C)).

What is the purpose of Skolemization in converting FOL to CNF

Skolemization eliminates existential quantifiers (\exists). If \exists x is within the scope of universal quantifiers \forall y, x is replaced by a Skolem function f(y). If not in any scope, it is replaced by a Skolem constant c.

Unification in First-Order Logic

Unification is the algorithmic process of finding a substitution \theta = \{x_1/t_1, x_2/t_2, \dots\} that makes two distinct logical expressions syntactically identical, i.e., UNIFY(p, q) = \theta such that SUBST(\theta, p) = SUBST(\theta, q).

What is the Most General Unifier (MGU)

An MGU is a substitution \theta that unifies two expressions while placing the minimum possible constraint on variables, meaning any other unifying substitution \sigma can be expressed as a composition \sigma = \theta \circ \gamma.

A Horn Clause and its importance in logic programming

A Horn Clause is a clause with at most one positive literal: e.g., \neg A \vee \neg B \vee C \equiv (A \wedge B) \to C. It is computationally tractable (O(N) linear inference time) and forms the foundation of Prolog.

Compare Forward Chaining and Backward Chaining

  • Forward Chaining (Data-driven): Starts with known facts and applies inference rules iteratively to derive new facts until a goal is reached.
  • Backward Chaining (Goal-driven): Starts with the hypothesized goal and searches backward through rules to find supporting known facts.

What is Resolution Refutation

A proof technique that proves formula \alpha follows from knowledge base KB by assuming \neg \alpha (the negated goal), adding it to KB in CNF, and applying resolution rules to derive a contradiction (the empty clause \Box).

Conceptual & Architectural Analysis

The 8-Step Procedure to Convert First-Order Logic Statements into CNF

Systematic FOL to CNF Conversion Algorithm

  1. Eliminate Implications: Replace P \to Q with \neg P \vee Q, and P ≤ftrightarrow Q with (\neg P \vee Q) \wedge (\neg Q \vee P).
  2. Move Negation Inward (De Morgan's Laws):
  • \neg (P \wedge Q) \equiv \neg P \vee \neg Q
  • \neg (P \vee Q) \equiv \neg P \wedge \neg Q
  • \neg \forall x P \equiv \exists x \neg P
  • \neg \exists x P \equiv \forall x \neg P
  1. Standardize Variables: Rename variables so each quantifier binds a unique variable: \forall x P(x) \vee \forall x Q(x) \to \forall x P(x) \vee \forall y Q(y).
  2. Skolemize (Eliminate $\exists$): Replace existentially quantified variables with Skolem constants or functions depending on outer universal quantifiers.
  3. Drop Universal Quantifiers: Since all remaining variables are universally quantified, omit \forall.
  4. Distribute $\vee$ over $\wedge$: Convert into clauses using A \vee (B \wedge C) \equiv (A \vee B) \wedge (A \vee C).
  5. Flatten and Separate Clauses: Treat each conjunct as an independent clause.
  6. Standardize Variables Apart: Rename variables across separate clauses so no variable name is shared.

Compare Forward Chaining vs Backward Chaining with an Architecture Diagram

System Architecture / Concept DiagramHorizontal Scroll Enabled
[ FORWARD CHAINING : Data-Driven ]        [ BACKWARD CHAINING : Goal-Driven ]
  Known Facts (Database)                   Hypothesized Goal
          |\                                        |
          v                                        v
  Fire Matching Rules                     Find Rules that Conclude Goal
          |                                        |
          v                                        v
  Derive New Facts                        Sub-goals to be Verified
          |                                        |
          v                                        v
  Stop when Goal is Generated             Stop when Base Facts Support Sub-goals
CriteriaForward ChainingBackward Chaining
Search DirectionBottom-up (Facts \to Conclusions)Top-down (Hypothesis \to Supporting Evidence)
Best Used WhenLots of data available, open-ended outcomesSpecific query needs verification (e.g., Medical diagnosis)
Control MechanismMatch-Resolve-Act cycleRecursive depth-first stack search
Computational CostCan generate many irrelevant factsFocused strictly on goal-relevant clauses

The Unification Algorithm with Worked Examples

Unification Step-by-Step

To unify two atomic sentences P(x, f(y)) and P(a, f(b)):

  1. Check predicate symbols: Both are P (Match).
  2. First arguments: x (variable) and a (constant). Substitute \theta_1 = \{x / a\}.
  3. Apply \theta_1 to expressions.
  4. Second arguments: f(y) and f(b). Predicates match (f). Inner arguments y and b unify with \theta_2 = \{y / b\}.
  5. Compose substitutions: \theta = \{x / a, y / b\}.

Occurs Check: A variable x cannot be unified with a term containing x (e.g., UNIFY(x, f(x)) must fail), preventing infinite recursive structures.

Discuss Wumpus World as a Knowledge-Based Agent Environment

The Wumpus World is a 4 × 4 grid game illustrating logical reasoning under partial observability:

  • Percepts: [Stench, Breeze, Glitter, Bump, Scream]
  • Stench: In rooms adjacent to Wumpus.
  • Breeze: In rooms adjacent to a Pit.
  • Glitter: In room containing Gold.
  • Propositional Reasoning: An agent in [1,1] detects no breeze \implies \neg P_{1,2} \wedge \neg P_{2,1}. Moving to [2,1], it detects breeze \implies P_{2,2} \vee P_{3,1}. Combining knowledge, the agent safely deduces [1,2] is safe!

What is the Resolution Principle in Propositional Logic

Given two parent clauses containing complementary literals L and \neg L: $C_1 = A \vee L \quad and \quad C_2 = B \vee \neg L The **Resolvent** is: C = A \vee B If the resolvent produces an empty clause \Box (from resolving P and \neg P$), a logical contradiction is proven.

In-Depth Analysis & Implementation

Prove the Classic Socratic Syllogism Using Resolution Refutation in First-Order Logic

Resolution Refutation Proof for 'Socrates is Mortal'

Problem Formulation:

  1. Statement 1: All men are mortal.

$\forall x (Man(x) \to Mortal(x))$

  1. Statement 2: Socrates is a man.

$Man(Socrates)$

  1. Goal Query: Prove that Socrates is mortal.

$Mortal(Socrates)$

Step 1: Negate the Goal Query

$\neg Mortal(Socrates)$

Step 2: Convert All Statements into Clause Normal Form (CNF)

  • From Statement 1:

$\forall x (\neg Man(x) \vee Mortal(x)) \implies \neg Man(x) \vee Mortal(x) \quad [Clause 1]$

  • From Statement 2:

$Man(Socrates) \quad [Clause 2]$

  • From Negated Goal:

$\neg Mortal(Socrates) \quad [Clause 3]$

Step 3: Resolution Graph (Derivation of Contradiction)

System Architecture / Concept DiagramHorizontal Scroll Enabled
   Clause 1: ~Man(x) v Mortal(x)       Clause 2: Man(Socrates)
                 \                           /
                  \                         /
                   \    theta = {x/Socrates}
                    \                     /
                     v                   v
                  Clause 4: Mortal(Socrates)     Clause 3: ~Mortal(Socrates)
                                \                       /
                                 \                     /
                                  v                   v
                                   +-----------------+
                                   |   Empty Clause  |
                                   |      ( # )      |
                                   |  CONTRADICTION  |
                                   +-----------------+

Step 4: Resolution Steps:

  1. Resolve Clause 1 and Clause 2 with substitution \theta = \{x / Socrates\}. The complementary literals \neg Man(Socrates) and Man(Socrates) cancel out, yielding Clause 4: Mortal(Socrates).
  2. Resolve Clause 4 with Clause 3 (Negated Goal). The complementary literals Mortal(Socrates) and \neg Mortal(Socrates) cancel out, producing the Empty Clause ($\Box$).
  3. Conclusion: The derivation of the empty clause proves that assuming Socrates is not mortal leads to an impossible logical contradiction. Therefore, by refutation, Socrates is Mortal is proved true! \blacksquare

Detail Knowledge Representation Schemes: Semantic Networks, Frames, and Conceptual Dependency (CD) with Comparative Analysis

Structured Knowledge Representation Paradigms

System Architecture / Concept DiagramHorizontal Scroll Enabled
1. SEMANTIC NETWORKS              2. FRAMES                          3. CONCEPTUAL DEPENDENCY
+--------+      is-a       +-------+    Frame: BIRD                        [John] <=> ATRANS
| Canary | --------------> | Bird  |    - superclass: ANIMAL                  <- (object) -> [Money]
+--------+                 +-------+    - can_fly: True (default)             <- (recipient) -> [Mary]
    |                          |        - legs: 2                             <- (donor) -> [John]
    | color                    | covers - wings: 2
    v                          v        - if_needed: check_species_slot
[Yellow]                   [Feathers]

1. Semantic Networks (Quillian):

  • Graph-based representation where nodes represent concepts/objects and directed edges represent semantic relations (is-a, has-a, part-of).
  • Inference Mechanism: Inheritance through transitive closure along is-a taxonomies.

2. Frames (Marvin Minsky):

  • Object-oriented record structures consisting of a collection of named Slots and associated Values or default values.
  • Supports Demons (procedural attachments like if-added, if-removed, if-needed) for active computation when slot values change.

3. Conceptual Dependency Theory (Roger Schank):

  • Models the meaning of natural language sentences independent of grammatical surface structures using a set of 11 primitive actions (e.g., ATRANS - transfer of possession, PTRANS - transfer of physical location, MTRANS - transfer of mental info).

Comparative Evaluation Matrix:

FeatureSemantic NetworksFramesConceptual Dependency
Primary RepresentationGraph (Nodes & Links)Slotted Record / ObjectsPrimitive ACT Graphs
Inference TypeInheritance traversalDefault values & DemonsSemantic slot filling
Expressive PowerModerateHigh (Procedural hooks)Very High (for NLP)
Computational CostFast graph traversalModerateComplex parsing required

Write a Complete Python Resolution Theorem Prover for Propositional Clauses

System Architecture / Concept DiagramHorizontal Scroll Enabled
def resolve(ci, cj):
    """Resolves two propositional clauses (sets of literals)."""
    resolvents = set()
    for di in ci:
        # Look for complementary literal
        neg_di = di[1:] if di.startswith('~') else '~' + di
        if neg_di in cj:
            # Form new clause by removing di and neg_di
            new_clause = (ci - {di}) | (cj - {neg_di})
            resolvents.add(frozenset(new_clause))
    return resolvents

def pl_resolution(clauses, query):
    """
    Propositional Logic Resolution Refutation.
    Proves query follows from clauses if contradiction (empty set) is derived.
    """
    # Add negated query to KB clauses
    neg_query = query[1:] if query.startswith('~') else '~' + query
    clause_set = set(frozenset(c) for c in clauses)
    clause_set.add(frozenset([neg_query]))

    new = set()
    step = 1
    print(f"Initial Clause Set with Negated Query: {clause_set}")

    while True:
        pairs = [(ci, cj) for ci in clause_set for cj in clause_set if ci != cj]
        for (ci, cj) in pairs:
            resolvents = resolve(ci, cj)
            if frozenset() in resolvents: # Empty clause derived
                print(f"\n[SUCCESS] Empty clause derived at step {step} from {set(ci)} and {set(cj)}!")
                return True # Query is provably TRUE
            new.update(resolvents)

        if new.issubset(clause_set):
            print("\n[FAILURE] No new clauses derived. Query cannot be proved.")
            return False
        clause_set.update(new)
        step += 1

# Verification: A v B, ~A v C, ~B -> Prove C
kb = [{'A', 'B'}, {'~A', 'C'}, {'~B'}]
query_literal = 'C'
print("Proof Result:", pl_resolution(kb, query_literal))

Important Exam Points & Quick Revision

Examiners frequently ask for: Resolution Refutation of a logical argument (guaranteed 10/15 marks Section C), FOL to CNF 8 steps, and Forward vs Backward Chaining.

Your reading progress
0%

100% left on this page — finishing it closes the gap for Knowledge Representation & Classical Logic.

Weak topic hint

Knowledge Representation & Classical Logic still counts as a weak topic until you finish this note and answer its questions.

Practise this unit
What Should You Do Next?

Test Your Understanding

Now that you've read through these notes, practice unit MCQs to identify weak points and solidify your learning before exams.