UNIT 05 • LOGIC & COGNITIVE ARCHITECTURES

Knowledge Representation & Reasoning

A comprehensive engineering treatment of symbolic AI: knowledge-based agent architectures, propositional calculus, resolution refutation proofs, first-order logic with unification and generalized modus ponens, forward and backward chaining on Horn clauses, semantic networks, frames, production rules, ontologies, and description logics.

📖 Standard: Russell & Norvig (AIMA 4th Edition)
⏱️ Study Depth: 6.5 Hours • Theory & Logic Engine
💻 Implementation: Python 3.12 (Forward & Backward Chaining, Resolution)
🎯 Verification: 100% Pure Natural English Language
01

What is Knowledge Representation & Reasoning?

In artificial intelligence, Knowledge Representation (KR) is the formal study of how an autonomous agent translates its understanding of the real physical world—including objects, facts, relationships, constraints, and causal rules—into structured, computer-tractable symbolic structures. Reasoning is the algorithmic manipulation of these symbolic structures to infer new, previously unstated facts and make provably sound decisions.

🧠 The Knowledge Representation Hypothesis (Brian Cantwell Smith, 1982)

"Any mechanically embodied intelligent process will be comprised of structural ingredients that we, as external observers, naturally take to represent a propositional account of the knowledge that the overall process exhibits, and independent of such external semantic attribution, play a formal, but causal, role in generating the behavior that manifests that knowledge."

In short: genuine intelligent action requires an explicit internal model of facts and rules that causally governs the agent's motor actions.

1. Representation vs. Data vs. Information
  • Data: Raw, uninterpreted symbols (e.g., number 38.5).
  • Information: Structured data with context (e.g., Patient temperature = 38.5 Celsius).
  • Knowledge: Contextual understanding coupled with actionable rules (e.g., IF temperature > 38.0 C AND symptoms include stiff neck THEN consider meningitis and alert physician).
2. Key Properties of a Good KR System
  • Representational Adequacy: Ability to express all types of knowledge required in the problem domain.
  • Inferential Adequacy: Ability to manipulate representational structures to derive all valid consequences.
  • Inferential Efficiency: Ability to guide the inference engine along promising deduction paths without combinatorial stall.
  • Acquisitional Efficiency: Ease with which new knowledge can be acquired, validated, and integrated.
02

Knowledge-Based Agents (The KB Architecture)

A Knowledge-Based Agent (KB Agent) maintains an explicit internal Knowledge Base (KB): a centralized repository of sentences expressed in a formal representation language.

System Architecture of a Knowledge-Based Agent
   +------------------+         Percepts          +---------------------+
   |   Environment    | ------------------------> | TELL(KB, Make-Percept-Sentence(percept, t))
   +------------------+                           +---------------------+
            ^                                                |
            |                                       Update Knowledge Base
            |                                                v
            | Action                              +---------------------+
            |                                     |    Knowledge Base   |
            |                                     |      (Sentences)    |
            |                                     +---------------------+
            |                                                |
            |                                                v
   +------------------+                           +---------------------+
   | Execute Action   | <------------------------ | ASK(KB, Make-Action-Query(t))
   +------------------+        Best Action        | (Inference Engine)  |
                                                  +---------------------+
🔄 The Two Fundamental Operations: TELL and ASK
  • TELL(KB, sentence): Adds new assertions or observed environmental facts into the Knowledge Base. Every TELL command modifies the agent's internal belief state.
  • ASK(KB, query): Queries the Knowledge Base to determine if a specific proposition logically follows from what has been asserted. ASK invokes an Inference Engine to compute answers.

Decoupled Architecture: A profound advantage of KB agents is the strict separation between the Knowledge Base (domain-specific facts) and the Inference Engine (domain-independent logical derivation algorithms). This allows developers to swap, scale, and update domain knowledge without rewriting algorithmic inference code.

📚 The Five Fundamental Types of Knowledge
Knowledge Type Definition & Characteristics Canonical Example
Declarative Knowledge Static facts, world concepts, and assertions about "WHAT" is true. Expressed as explicit statements that can be verified as true or false. Paris is the capital of France. or A triangle has three interior angles summing to 180 degrees.
Procedural Knowledge Operational rules, step-by-step algorithms, and recipes explaining "HOW" to accomplish a specific objective. To sort a list: select minimum element, swap with first unsorted slot, repeat until end.
Meta-Knowledge Knowledge ABOUT knowledge. Describes reliability, freshness, ownership, confidence, and scope of other knowledge items. This medical diagnosis rule has 94% statistical confidence and was verified in 2024 clinical trials.
Heuristic Knowledge Rules of thumb, expert insights, and practical intuitions that accelerate search without guaranteeing mathematical optimality. In chess, controlling the four center squares typically yields tactical superiority.
Structural Knowledge Taxonomies, object relationships, and part-whole aggregations connecting concepts hierarchically. An Engine is part-of a Car; a Car is a subtype-of MotorVehicle.
03

Propositional Logic: Syntax, Semantics & Truth Tables

Propositional Logic (Boolean Logic) is the simplest formal logic. Its primitive elements are atomic proposition symbols (e.g., P, Q, R) representing facts that can be either True or False.

🔣 Formal Connectives (Syntax & Semantics)
  • Negation (NOT, ~): ~P is True if and only if P is False.
  • Conjunction (AND, ^): P ^ Q is True if and only if both P and Q are True.
  • Disjunction (OR, v): P v Q is True if either P is True, Q is True, or both are True.
  • Implication (IMPLIES, →): P → Q is False only when P is True and Q is False; otherwise it is True. (Equivalent to ~P v Q). P is the antecedent; Q is the consequent.
  • Biconditional (IFF, ↔): P ↔ Q is True if and only if both P and Q have the exact same truth value. (Equivalent to (P → Q) ^ (Q → P)).
📊 Complete Master Truth Table
P Q NOT P (~P) P AND Q (P ^ Q) P OR Q (P v Q) P IMPLIES Q (P → Q) P IFF Q (P ↔ Q)
False False True False False True True
False True True False True True False
True False False False True False False
True True False True True True True
Validity (Tautology)

A sentence is valid (a tautology) if it evaluates to True in all possible models (under every possible truth assignment).

Example: P v ~P is always True regardless of P's value.

Satisfiability

A sentence is satisfiable if it evaluates to True in at least one model.

Example: P ^ Q is satisfiable because it is True when P = True and Q = True.

Unsatisfiability (Contradiction)

A sentence is unsatisfiable (a contradiction) if it evaluates to False in all models.

Example: P ^ ~P is always False.

⚖️ Canonical Logical Equivalences
Equivalence Law Logical Formulation Intuitive Meaning
Commutativity P ^ Q ≡ Q ^ P
P v Q ≡ Q v P
Order of operands does not change truth value.
Associativity (P ^ Q) ^ R ≡ P ^ (Q ^ R)
(P v Q) v R ≡ P v (Q v R)
Grouping of identical operators does not matter.
Double Negation Elimination ~(~P) ≡ P Two negatives make an affirmative.
De Morgan's Laws ~(P ^ Q) ≡ ~P v ~Q
~(P v Q) ≡ ~P ^ ~Q
Negating an AND yields an OR of negations; negating an OR yields an AND of negations.
Distributivity P ^ (Q v R) ≡ (P ^ Q) v (P ^ R)
P v (Q ^ R) ≡ (P v Q) ^ (P v R)
AND distributes over OR; OR distributes over AND.
Implication Elimination P → Q ≡ ~P v Q "P implies Q" means either P is false or Q is true.
Contraposition P → Q ≡ ~Q → ~P "If it rains then ground is wet" ≡ "If ground is not wet then it didn't rain".
04

Inference Rules & The Resolution Principle

Logical Entailment (KB |= α): A sentence α is entailed by KB if and only if in every model where KB is True, α is also True. An Inference Rule is a mechanical transformation pattern that derives new sentences from existing ones while guaranteeing Soundness (only deriving sentences that are genuinely entailed).

1. Modus Ponens (Affirming the Antecedent)
Premises: P → Q and P
Conclusion: Q

If it is known that "If it rains, the grass is wet" and it is known that "It is raining", we can soundly infer: "The grass is wet".

2. Modus Tollens (Denying the Consequent)
Premises: P → Q and ~Q
Conclusion: ~P

If "If John has the flu, he has a fever" and "John does NOT have a fever", we soundly infer: "John does not have the flu".

⚡ The Unit Resolution & Full Resolution Principle (Alan Robinson, 1965)

Resolution is a single, complete inference rule that operates on sentences expressed in Conjunctive Normal Form (CNF): a conjunction of clauses, where each clause is a disjunction of literals.

The Resolution Rule:
Clause 1: l1 v l2 v ... v lk v P
Clause 2: m1 v m2 v ... v mn v ~P
Resolvent: l1 v l2 v ... v lk v m1 v m2 v ... v mn

The literal P and its negation ~P are called complementary literals. They cancel out, leaving the remaining disjuncts as the newly derived clause (resolvent).

Proof by Refutation (Resolution Refutation)

To prove that KB |= α:

  1. Negate the goal sentence α to yield ~α.
  2. Convert KB and ~α into Conjunctive Normal Form (CNF clauses).
  3. Add ~α to the set of clauses.
  4. Repeatedly apply Resolution to resolve pairs of clauses containing complementary literals.
  5. If resolution resolves to the Empty Clause (contradiction / False), then KB ^ ~α is unsatisfiable! Therefore, the original hypothesis α is proven to be True!
Visual Trace of Resolution Refutation Proof
   Knowledge Base Clauses:
     (1) ~Rain v WetGrass     (Rain implies WetGrass)
     (2) Rain                 (It is raining)
   Query: Prove WetGrass

   Step 1: Negate query:
     (3) ~WetGrass            (Assumed contradiction)

   Step 2: Resolve Clause (1) and Clause (2) on complementary pair [Rain, ~Rain]:
     Resolvent (4): WetGrass

   Step 3: Resolve Clause (4) and Clause (3) on complementary pair [WetGrass, ~WetGrass]:
     Resolvent (5): [ ]  <-- EMPTY CLAUSE (Contradiction!)

   Conclusion: Since deriving False was inevitable, the assumption ~WetGrass is impossible.
               Therefore, WetGrass is mathematically PROVEN!
05

First-Order Logic (FOL): Predicates, Quantifiers & Unification

Propositional logic treats the world as a collection of atomic facts with zero internal structure. In propositional logic, to say "Every student is human", we would need a separate proposition for every individual student (StudentAlice → HumanAlice, StudentBob → HumanBob...), causing a catastrophic combinatorial explosion.

First-Order Logic (FOL / Predicate Calculus) introduces an ontological commitment to:

1. Universal Quantifier (FOR-ALL ∀)

Expresses that a property holds for all objects in the universe of discourse:

FOR-ALL x [ Human(x) → Mortal(x) ]
"For all x, if x is human, then x is mortal."
⚠️ Common Pitfall: FOR-ALL with AND

Writing FOR-ALL x [ Human(x) ^ Mortal(x) ] means: "Everything in the universe is human AND mortal" (including rocks, trees, and planets!). Always pair FOR-ALL with IMPLIES (→).

2. Existential Quantifier (THERE-EXISTS ∃)

Expresses that a property holds for at least one object in the universe:

THERE-EXISTS x [ Student(x) ^ Scored100(x) ]
"There exists at least one x such that x is a student AND x scored 100."
⚠️ Common Pitfall: THERE-EXISTS with IMPLIES

Writing THERE-EXISTS x [ Student(x) → Scored100(x) ] is trivially True if there exists ANY object that is NOT a student (because False implies anything is True!). Always pair THERE-EXISTS with AND (^).

🧬 Unification & The Most General Unifier (MGU)

In first-order inference, we frequently need to make two predicate sentences look identical by finding a substitution dictionary θ for their variables. This process is called Unification:

UNIFY(Sentence1, Sentence2) = θ such that SUBST(θ, Sentence1) == SUBST(θ, Sentence2)

Examples of Unification:

  • UNIFY(Knows(John, x), Knows(John, Jane)) → θ = { x: Jane }
  • UNIFY(Knows(John, x), Knows(y, Bill)) → θ = { x: Bill, y: John }
  • UNIFY(Knows(John, x), Knows(x, Bill)) → FAILS! (x cannot simultaneously be John and Bill).

Occurs Check: A variable cannot be unified with a term containing that same variable (e.g., unifying x with Father(x) would cause an infinite recursive loop: Father(Father(Father(...)))).

06

Forward & Backward Chaining on Horn Clauses

Full first-order theorem proving with resolution is semi-decidable (if a query is not entailed, the algorithm may run forever). To guarantee polynomial-time inference in production systems, AI uses a restricted subset of logic called Horn Clauses.

Definition: Definite Clause (Horn Clause)
A disjunction of literals with at most one positive literal:
~P v ~Q v R ≡ (P ^ Q) → R
The positive literal R is the Head (consequent); the conjunction of negative literals (P ^ Q) is the Body (antecedents). Facts are clauses with zero negative literals (e.g., P).
1. Forward Chaining (Data-Driven / Bottom-Up)

Starts with the known atomic facts in the KB. Fires rules whose premises are completely satisfied. The conclusions of fired rules are added to the KB as new facts. This cycle repeats until the query is derived or no new facts can be added.

  • Direction: From data → to conclusions.
  • Best For: Event monitoring, sensory data interpretation, real-time control, diagnostics.
  • Property: May compute many facts that are irrelevant to the specific target query.
2. Backward Chaining (Goal-Driven / Top-Down)

Starts from the target query goal. Works backward by locating rules whose head (consequent) matches the goal, then recursively establishes whether all premises in that rule's body can be proven as subgoals.

  • Direction: From query → back to base facts.
  • Best For: Medical diagnosis, legal reasoning, automated question answering, Prolog engines.
  • Property: Highly focused: only explores rules relevant to the goal. Avoids computing irrelevant consequences.
Forward vs. Backward Chaining Inference Flow
   Knowledge Base Rules:
     Rule 1: A ^ B -> C
     Rule 2: C ^ D -> E
     Rule 3: E -> Goal

   Known Facts: A, B, D

   FORWARD CHAINING (Bottom-Up):
     [A, B, D] ---> Fires Rule 1: derives C
     [A, B, C, D] -> Fires Rule 2: derives E
     [A, B, C, D, E] -> Fires Rule 3: derives Goal! (Proven)

   BACKWARD CHAINING (Top-Down):
     Goal? -> Look for head: Rule 3 needs E.
     Subgoal E? -> Look for head: Rule 2 needs C and D.
     Is D a known fact? Yes!
     Subgoal C? -> Look for head: Rule 1 needs A and B.
     Are A and B known facts? Yes! -> Base reached, Goal Proven!
07

Structured Knowledge Representations: Networks, Frames & Rules

1. Semantic Networks

Developed by Allan Collins and Ross Quillian (1968). Represents knowledge as a directed graph where:

  • Nodes: Concepts, categories, or individual instances.
  • Edges: Labeled relationships between nodes.

Key power: Property Inheritance along is-a (subclass) and instance-of edges. If Canary is-a Bird and Bird can-fly, then Canary inherits the ability to fly automatically!

2. Frames (Marvin Minsky, 1974)

Precursor to Object-Oriented Programming (OOP). A Frame is a collection of named slots and associated values representing stereotypical entities:

  • Slots: Attributes (e.g., color, doors).
  • Facets: Constraints on slots (type, range).
  • Default Values: Assumed values in absence of contrary evidence.
  • Demons (Procedural Attachments): Scripts executed automatically when a slot is accessed (e.g., if-needed, if-added).
3. Production Rules

Used in classical Expert Systems (e.g., MYCIN, CLIPS). Consists of a working memory and a rule base structured as:

IF <condition> THEN <action>

RETE Algorithm: A pattern-matching algorithm that eliminates re-evaluating rules whose conditions have not changed.
Conflict Resolution: When multiple rules match, pick using recency, specificity, or priority weights.

08

Ontologies & Description Logics (DL)

In modern computer science and knowledge graphs, an Ontology is a formal, explicit specification of a shared conceptualization. It defines the formal vocabulary of concepts, classes, attributes, and relationships governing a specific domain (e.g., Gene Ontology, SNOMED CT for medicine, Schema.org for web semantics).

🏛️ Description Logic (DL): The Foundation of the Semantic Web (OWL)

Description Logics are a family of decidable fragments of First-Order Logic specifically engineered to balance expressive power with computational tractability. Description logics provide the formal logical foundation for the W3C standard OWL (Web Ontology Language).

TBox (Terminological Knowledge)

The schema or vocabulary of the domain. Defines concepts (classes) and roles (binary relations) and axioms describing their relationships.

Woman ≡ Person AND Female
Mother ≡ Woman AND (HAS-CHILD SOME Person)
ABox (Assertional Knowledge)

The instance data of the domain. Asserts facts about specific named individual entities.

Mother(Mary)
ChildOf(John, Mary)

Core Reasoning Services in Description Logic:

  • Subsumption: Determine whether concept C is more general than concept D (i.e., whether every instance of D must necessarily be an instance of C).
  • Consistency / Satisfiability: Check if a concept definition or KB contains logical contradictions (e.g., a person who is simultaneously living and dead when classes are disjoint).
  • Classification: Automatically placing new concept definitions into their mathematically correct location in the inheritance hierarchy.
09

Complete Python Implementations: Inference Engines

Below is an executable Python implementation demonstrating: 1. A Forward Chaining Engine on Horn Clauses. 2. A Backward Chaining Engine proving subgoals recursively. 3. A Propositional Resolution Prover demonstrating proof by refutation.

logic_reasoning_engine.py — Forward/Backward Chaining & Resolution
"""
AI Track Unit 5: Knowledge Representation & Logical Inference Engine
Forward Chaining, Backward Chaining, and Resolution Refutation
Author: DevAscent Engineering Team
"""

from typing import List, Set, Dict, Optional, Tuple

# =====================================================================
# 1. HORN CLAUSE KNOWLEDGE BASE & CHAINING ENGINES
# =====================================================================
class HornClause:
    def __init__(self, premises: List[str], conclusion: str):
        self.premises: List[str] = premises
        self.conclusion: str = conclusion

    def __repr__(self):
        if not self.premises:
            return f"Fact({self.conclusion})"
        return f"{' ^ '.join(self.premises)} -> {self.conclusion}"

class KnowledgeBase:
    def __init__(self):
        self.clauses: List[HornClause] = []
        self.facts: Set[str] = set()

    def tell_fact(self, fact: str):
        self.facts.add(fact)

    def tell_rule(self, premises: List[str], conclusion: str):
        self.clauses.append(HornClause(premises, conclusion))

    # -----------------------------------------------------------------
    # Forward Chaining Algorithm
    # -----------------------------------------------------------------
    def forward_chain(self, query: str) -> Tuple[bool, List[str]]:
        """
        Data-driven bottom-up inference.
        Returns (is_entailed, derivation_order).
        """
        known_facts = set(self.facts)
        if query in known_facts:
            return True, [query]

        # Count of unsatisfied premises for each clause
        count = {clause: len(clause.premises) for clause in self.clauses}
        agenda = list(self.facts)
        derivation_order = []

        while agenda:
            p = agenda.pop(0)
            derivation_order.append(p)

            for clause in self.clauses:
                if p in clause.premises:
                    count[clause] -= 1
                    # If all premises satisfied, fire rule
                    if count[clause] == 0:
                        concl = clause.conclusion
                        if concl == query:
                            derivation_order.append(concl)
                            return True, derivation_order
                        if concl not in known_facts:
                            known_facts.add(concl)
                            agenda.append(concl)

        return False, derivation_order

    # -----------------------------------------------------------------
    # Backward Chaining Algorithm
    # -----------------------------------------------------------------
    def backward_chain(self, query: str, visited: Optional[Set[str]] = None) -> bool:
        """
        Goal-driven top-down recursive inference.
        """
        if visited is None:
            visited = set()

        # If already known as base fact, base case succeeded
        if query in self.facts:
            return True

        if query in visited:
            return False  # Prevent infinite loops in circular rules
        visited.add(query)

        # Find all rules concluding this query
        for clause in self.clauses:
            if clause.conclusion == query:
                # All premises must recursively be proven True
                all_premises_proven = True
                for premise in clause.premises:
                    if not self.backward_chain(premise, visited.copy()):
                        all_premises_proven = False
                        break
                if all_premises_proven:
                    return True

        return False

# =====================================================================
# 2. PROPOSITIONAL RESOLUTION PROVER (CNF Refutation)
# =====================================================================
Clause = frozenset

def resolve_pair(ci: Clause, cj: Clause) -> Set[Clause]:
    """Resolve two clauses on any complementary literal pair."""
    resolvents = set()
    for literal in ci:
        complement = literal[1:] if literal.startswith('~') else '~' + literal
        if complement in cj:
            # Combine remaining literals
            new_clause = (ci - {literal}) | (cj - {complement})
            resolvents.add(new_clause)
    return resolvents

def pl_resolution(clauses_input: List[List[str]], negated_query: List[str]) -> bool:
    """
    Propositional Resolution Refutation Theorem Prover.
    Returns True if KB |= Query (empty clause derived).
    """
    clauses: Set[Clause] = {frozenset(c) for c in clauses_input}
    clauses.add(frozenset(negated_query))

    new_derived = set()
    step = 0

    while True:
        step += 1
        clause_list = list(clauses)
        pairs = [(clause_list[i], clause_list[j]) 
                 for i in range(len(clause_list)) 
                 for j in range(i + 1, len(clause_list))]

        for ci, cj in pairs:
            resolvents = resolve_pair(ci, cj)
            if frozenset() in resolvents:
                print(f"[Resolution Refutation] Contradiction (Empty Clause derived at step {step})!")
                return True
            new_derived.update(resolvents)

        if new_derived.issubset(clauses):
            return False  # No new clauses can be derived; query not entailed

        clauses.update(new_derived)

# =====================================================================
# DEMONSTRATION HARNESS
# =====================================================================
if __name__ == "__main__":
    print("=" * 68)
    print("DEMO 1: HORN CLAUSE INFERENCE (FORWARD & BACKWARD CHAINING)")
    print("=" * 68)

    kb = KnowledgeBase()
    # Facts
    kb.tell_fact("Colleague(John)")
    kb.tell_fact("HasFever(John)")
    kb.tell_fact("Coughing(John)")

    # Rules
    kb.tell_rule(["HasFever(John)", "Coughing(John)"], "Infected(John)")
    kb.tell_rule(["Infected(John)", "Colleague(John)"], "NeedsQuarantine(John)")
    kb.tell_rule(["NeedsQuarantine(John)"], "AlertManager(John)")

    target = "AlertManager(John)"

    # Forward Chaining
    fc_result, derivation_path = kb.forward_chain(target)
    print(f"Forward Chaining Result for '{target}': {fc_result}")
    print(f"Facts Derivation Sequence: {' -> '.join(derivation_path)}")

    # Backward Chaining
    bc_result = kb.backward_chain(target)
    print(f"Backward Chaining Result for '{target}': {bc_result}\n")

    print("=" * 68)
    print("DEMO 2: PROPOSITIONAL RESOLUTION REFUTATION")
    print("Rules: (P implies Q) and (Q implies R) and P. Query: Prove R.")
    print("=" * 68)

    # KB in CNF:
    # (~P v Q), (~Q v R), (P)
    # Negated query: (~R)
    cnf_kb = [
        ["~P", "Q"],
        ["~Q", "R"],
        ["P"]
    ]
    query_negated = ["~R"]

    proof_success = pl_resolution(cnf_kb, query_negated)
    print(f"Resolution Proof of R: {'SUCCESSFULLY PROVEN' if proof_success else 'FAILED'}")
10

Viva Voce & Engineering Interview Questions

Q1: Why is Propositional Logic insufficient for modeling real-world AI domains, and how does First-Order Logic solve this?

Answer: Propositional logic has zero structural representation: it can only express that an entire statement is True or False. To express a generalized principle across a universe of N entities (e.g., "All humans are mortal"), propositional logic requires N individual duplicate propositions (Human1 → Mortal1, Human2 → Mortal2...). It has no mechanism to quantify over objects. First-Order Logic (FOL) solves this by introducing predicates, functions, objects, and quantifiers (FOR-ALL ∀ and THERE-EXISTS ∃), allowing infinite generalizations in a single expressive sentence: FOR-ALL x [ Human(x) → Mortal(x) ].

Q2: Distinguish between Soundness and Completeness in logical inference engines.

Answer:
Soundness: An inference engine is sound if it derives only true consequences. If KB derives α, then KB |= α (no false derivations).
Completeness: An inference engine is complete if it can derive every sentence that is logically entailed. If KB |= α, then the algorithm is guaranteed to find a proof. Soundness guarantees mathematical truthfulness; completeness guarantees that no valid answers are missed.

Q3: How does the Resolution Refutation algorithm prove that KB entails a query sentence α?

Answer: Instead of attempting to prove α directly, Resolution uses proof by contradiction. It asserts the negation of the query (~α) into the Knowledge Base (all converted to Conjunctive Normal Form). It then repeatedly resolves clauses containing complementary literals (e.g., P and ~P). If the empty clause [ ] (False) is derived, it proves that KB ^ ~α is mathematically unsatisfiable. Because assuming ~α causes an unavoidable contradiction, the original query α must be True.

Q4: What is Unification, and why is the "Occurs Check" mandatory?

Answer: Unification is the algorithmic procedure of finding a substitution dictionary θ for variables that makes two distinct first-order expressions syntactically identical. The Occurs Check prevents a variable from being unified with a compound term that contains that same variable (e.g., unifying x with f(x)). If the occurs check were omitted, x would expand into an infinite cyclic expression f(f(f(...))), causing infinite loops and generating mathematically unsound derivations.

Q5: Compare Forward Chaining with Backward Chaining. When should an engineer choose one over the other?

Answer: Forward Chaining is data-driven (bottom-up): it starts with known facts and fires rules to derive all possible consequences. It is ideal for monitoring, event processing, automated synthesis, and reactive control. However, it can derive many facts irrelevant to a specific question. Backward Chaining is goal-driven (top-down): it starts with a specific target query and recursively works backwards to see if base facts support the required premises. It is ideal for question answering, medical diagnosis, and legal verification where the system only needs to evaluate facts directly relevant to the target query.

Q6: What are the TBox and ABox in Description Logic, and how do they map to modern Knowledge Graphs?

Answer: In Description Logic (the formal underpinning of OWL ontologies):
TBox (Terminological Box): Defines the schema, classes, roles, and structural constraints of the domain (e.g., Professor is-a AcademicStaff).
ABox (Assertional Box): Contains instance data and facts about specific named individuals (e.g., Professor(DrAlanSmith)). In modern enterprise knowledge graphs, the TBox corresponds to the ontology / graph schema, while the ABox corresponds to the actual nodes and edges instantiated in the graph database.