Back to Logical Agents Topics

First-Order Logic - Legal Expert System

Apply FOL to Legal Reasoning and Expert Systems

Exercise Overview

Legal Expert System Using First-Order Logic

Scenario: You are designing a legal expert system to assist in determining whether a person is liable for theft under certain conditions. The system's knowledge base (KB) must represent facts and rules using First-Order Logic (FOL) and perform reasoning to reach conclusions.

Skills Tested:

  • Knowledge Representation: Translating English legal statements into precise FOL syntax
  • Inference Mechanics: Applying Modus Ponens, Universal Instantiation, and Resolution
  • Unification: Recognizing variable bindings across clauses
  • Reasoning in Context: Connecting symbolic reasoning to a real-world expert system
Level: Advanced | Total Points: 35 | Estimated Time: 90-120 minutes

Predicates and Constants Reference

Use these predicates and constants throughout the exercise:

Predicates:
  • Takes(x, y, z) – person x takes item z from person y
  • WithoutPermission(x, y, z)x takes z from y without permission
  • CommitsTheft(x)x commits theft
  • Liable(x)x is liable under law
  • Minor(x)x is a minor (under 18 years old)
  • Prosecuted(x)x can be prosecuted
Constants:
  • Ahmed (أحمد) – A person involved in the case
  • Fatima (فاطمة) – Owner of the property
  • Car – The property in question

Part 1: English to FOL Translation

Points: 10 | Convert legal statements to First-Order Logic

Translation Task

Task: Translate the following legal statements into First-Order Logic (FOL):

Guidelines for Your Answer:
  • Use universal quantifiers (∀) for general rules (statements 1-3)
  • Use ground facts (no quantifiers) for specific observations (statements 4-5)
  • Use implications (→) for "if...then" rules
  • Use conjunction (∧) to combine multiple conditions
  • Use negation (¬) for "not"
Your Answer: ✓ Saved
Reasoning & Approach:
How to Translate Natural Language to FOL:

Think of FOL translation as building a precise mathematical representation:

  • Identify quantifiers: "Anyone", "all", "every" → use ∀ (for all). Specific names → no quantifier.
  • Identify conditions: "if...then" structures → use implication (→)
  • Combine conditions: Multiple requirements → use conjunction (∧)
  • Choose predicates carefully: Match the predicates given in the reference table
  • Order matters: In Takes(x, y, z), x is the taker, y is the owner, z is the item

Key Insight: General laws use ∀ (apply to everyone). Specific facts use constants (apply to specific individuals).

Complete Answer:
Statement 1: Theft Definition

English: "Anyone who takes someone else's property without permission commits theft."

FOL Translation:
∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]

Breakdown:

  • ∀x, y, z: For all persons x, y and all items z
  • Takes(x, y, z): x takes item z from y
  • ∧ WithoutPermission(x, y, z): AND x does this without y's permission
  • → CommitsTheft(x): THEN x commits theft
Statement 2: Liability Rule

English: "If a person commits theft, that person is liable."

FOL Translation:
∀x [CommitsTheft(x) → Liable(x)]

Breakdown:

  • ∀x: For all persons x
  • CommitsTheft(x): If x commits theft
  • → Liable(x): THEN x is liable
Statement 3: Minor Exception

English: "If a person is a minor, they are not liable."

FOL Translation:
∀x [Minor(x) → ¬Liable(x)]

Breakdown:

  • ∀x: For all persons x
  • Minor(x): If x is a minor
  • → ¬Liable(x): THEN x is NOT liable
Statement 4: Specific Fact about Ahmed

English: "Ahmed took Fatima's car without permission."

FOL Translation (two facts):
Takes(Ahmed, Fatima, Car)
WithoutPermission(Ahmed, Fatima, Car)

Breakdown:

  • No quantifier: This is a specific fact about Ahmed (a constant)
  • Takes(Ahmed, Fatima, Car): Ahmed took the car from Fatima
  • WithoutPermission(Ahmed, Fatima, Car): Ahmed did this without Fatima's permission
  • Why two formulas?: We need both conditions to satisfy rule 1
Statement 5: Ahmed's Age Status

English: "Ahmed is not a minor."

FOL Translation:
¬Minor(Ahmed)

Breakdown:

  • No quantifier: Specific fact about Ahmed
  • ¬Minor(Ahmed): Ahmed is NOT a minor (he's an adult)

Part 2: FOL Knowledge Base

Points: 5 | Construct the complete KB from translations

KB Construction Task

Task: From your translations in Part 1, write the complete FOL Knowledge Base (KB) as a numbered set of formulas.

Guidelines for Your Answer:
  • List all formulas from Part 1 in a clear, numbered format
  • Group rules (universal statements) separate from facts (ground statements)
  • Ensure the KB is complete and ready for inference
Your Answer: ✓ Saved
Reasoning & Approach:
How to Organize a Knowledge Base:

A well-organized KB makes reasoning easier:

  • Rules first: Universal statements (laws) that apply generally
  • Facts second: Specific observations about the case
  • Clear numbering: Makes it easy to reference formulas during inference
  • Consistency: All formulas use the same predicates and constants

Key Insight: Think of the KB as having two parts - the "laws" (rules) and the "evidence" (facts). Inference combines them.

Complete Knowledge Base:
Legal Expert System Knowledge Base (KB):

/* Rules (General Laws) */
1. ∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]
2. ∀x [CommitsTheft(x) → Liable(x)]
3. ∀x [Minor(x) → ¬Liable(x)]

/* Facts (Case-Specific Evidence) */
4. Takes(Ahmed, Fatima, Car)
5. WithoutPermission(Ahmed, Fatima, Car)
6. ¬Minor(Ahmed)
KB Structure Explanation:
  • Formulas 1-3: General legal rules that apply to anyone
  • Formulas 4-6: Specific facts about Ahmed's case
  • Total size: 6 formulas (3 rules + 3 facts)
  • Goal: Use inference to derive whether Ahmed is liable and can be prosecuted

Part 3: Inference Using Modus Ponens

Points: 5 | Derive conclusions step-by-step

Inference Task

Task: Using Modus Ponens, derive step-by-step whether:

  • CommitsTheft(Ahmed) can be inferred
  • Liable(Ahmed) can be inferred

You must clearly show the use of:

  • Universal Instantiation (UI)
  • Modus Ponens (MP)
Guidelines for Your Answer:
  • Start by instantiating universal rules with specific constants
  • Apply Modus Ponens: from α and α → β, infer β
  • Show the KB state after each inference
  • Number each step clearly
Your Answer: ✓ Saved
Reasoning & Approach:
How to Apply FOL Inference:

FOL inference requires two key steps:

  • Universal Instantiation (UI): Replace variables in ∀x formulas with specific constants
    • Example: From ∀x [P(x) → Q(x)], derive P(Ahmed) → Q(Ahmed)
  • Modus Ponens (MP): If you have α and α → β, infer β
    • Example: From P(Ahmed) and P(Ahmed) → Q(Ahmed), derive Q(Ahmed)
  • Chain inferences: Output of one step becomes input to the next
  • Track your KB: Show what's known after each step

Key Insight: Universal rules are templates. UI fills in the template with specific values. MP triggers the rule.

Complete Step-by-Step Derivation:
Starting KB:
1. ∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]
2. ∀x [CommitsTheft(x) → Liable(x)]
3. ∀x [Minor(x) → ¬Liable(x)]
4. Takes(Ahmed, Fatima, Car)
5. WithoutPermission(Ahmed, Fatima, Car)
6. ¬Minor(Ahmed)
1
Universal Instantiation (UI) on Formula 1:
Replace x with Ahmed, y with Fatima, z with Car

From: ∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]
Derive: Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car) → CommitsTheft(Ahmed)
KB₁ = KB₀ + {Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car) → CommitsTheft(Ahmed)}
2
Conjunction (∧ Introduction):
Combine formulas 4 and 5

From: Takes(Ahmed, Fatima, Car) AND WithoutPermission(Ahmed, Fatima, Car)
Derive: Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car)
KB₂ = KB₁ + {Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car)}
3
Modus Ponens (MP) - Derive CommitsTheft(Ahmed):
Apply MP using the conjunction from Step 2 and the implication from Step 1

We have: Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car)
We have: Takes(Ahmed, Fatima, Car) ∧ WithoutPermission(Ahmed, Fatima, Car) → CommitsTheft(Ahmed)
By MP, derive: CommitsTheft(Ahmed)
KB₃ = KB₂ + {CommitsTheft(Ahmed)} ← FIRST GOAL REACHED!
4
Universal Instantiation (UI) on Formula 2:
Replace x with Ahmed

From: ∀x [CommitsTheft(x) → Liable(x)]
Derive: CommitsTheft(Ahmed) → Liable(Ahmed)
KB₄ = KB₃ + {CommitsTheft(Ahmed) → Liable(Ahmed)}
5
Modus Ponens (MP) - Derive Liable(Ahmed):
Apply MP using CommitsTheft(Ahmed) from Step 3 and the implication from Step 4

We have: CommitsTheft(Ahmed)
We have: CommitsTheft(Ahmed) → Liable(Ahmed)
By MP, derive: Liable(Ahmed)
KB₅ = KB₄ + {Liable(Ahmed)} ← SECOND GOAL REACHED!
Final Conclusions:
CommitsTheft(Ahmed) = TRUE (derived in Step 3)
Liable(Ahmed) = TRUE (derived in Step 5)
Inference Chain: Facts → Theft → Liability
Note: Formula 3 (Minor exception) doesn't apply because ¬Minor(Ahmed) is true

Part 4: Unification and Resolution

Points: 10 | Apply resolution to prove prosecution

Resolution Task

Additional Rule: The system now knows:

"If a person is liable, then they can be prosecuted."
∀x [Liable(x) → Prosecuted(x)]

Query (Goal): Prove that Ahmed can be prosecuted

⊢ Prosecuted(Ahmed)

Task: Use resolution to show whether Prosecuted(Ahmed) logically follows from the KB.

Steps to Follow:
  1. Convert all formulas to clausal form (CNF)
  2. Negate the goal (¬Prosecuted(Ahmed))
  3. Apply Unification and perform Resolution
  4. Continue until you derive the empty clause (⊥) or cannot proceed
Your Answer: ✓ Saved
Reasoning & Approach:
How Resolution Works in FOL:

Resolution is a proof by contradiction technique:

  • Goal: Prove KB ⊨ α (the KB entails α)
  • Method: Add ¬α to KB and try to derive a contradiction (empty clause)
  • CNF Conversion: Transform all formulas into clauses (disjunctions of literals)
  • Unification: Match predicates with different variables (e.g., Liable(x) matches Liable(Ahmed) with {x/Ahmed})
  • Resolution Rule: From {L ∨ α} and {¬L ∨ β}, derive {α ∨ β}
  • Success: If we derive {} (empty clause), the goal is proven!

Key Insight: Resolution chains backward from the goal to known facts, eliminating literals until nothing remains.

Complete Resolution Proof:
Step 1: Convert KB to Clausal Form (CNF)

Extended KB (adding prosecution rule):

1. ∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]
2. ∀x [CommitsTheft(x) → Liable(x)]
3. ∀x [Minor(x) → ¬Liable(x)]
4. Takes(Ahmed, Fatima, Car)
5. WithoutPermission(Ahmed, Fatima, Car)
6. ¬Minor(Ahmed)
7. ∀x [Liable(x) → Prosecuted(x)] ← NEW

Convert to CNF (eliminate →, convert to clauses):

C1: {¬Takes(x, y, z), ¬WithoutPermission(x, y, z), CommitsTheft(x)}
C2: {¬CommitsTheft(x), Liable(x)}
C3: {¬Minor(x), ¬Liable(x)}
C4: {Takes(Ahmed, Fatima, Car)}
C5: {WithoutPermission(Ahmed, Fatima, Car)}
C6: {¬Minor(Ahmed)}
C7: {¬Liable(x), Prosecuted(x)}
Step 2: Negate the Goal

Goal: Prove Prosecuted(Ahmed)

Negated Goal: ¬Prosecuted(Ahmed)

C8: {¬Prosecuted(Ahmed)} ← Negated Goal
Step 3: Apply Resolution
1
Resolve C7 and C8:
C7: {¬Liable(x), Prosecuted(x)}
C8: {¬Prosecuted(Ahmed)}
Unify: x = Ahmed, Prosecuted(x) = Prosecuted(Ahmed)
Result: C9: {¬Liable(Ahmed)}
2
Resolve C2 and C9:
C2: {¬CommitsTheft(x), Liable(x)}
C9: {¬Liable(Ahmed)}
Unify: x = Ahmed, Liable(x) = Liable(Ahmed)
Result: C10: {¬CommitsTheft(Ahmed)}
3
Resolve C1 and C10:
C1: {¬Takes(x, y, z), ¬WithoutPermission(x, y, z), CommitsTheft(x)}
C10: {¬CommitsTheft(Ahmed)}
Unify: x = Ahmed, CommitsTheft(x) = CommitsTheft(Ahmed)
Result: C11: {¬Takes(Ahmed, y, z), ¬WithoutPermission(Ahmed, y, z)}
4
Resolve C4 and C11:
C4: {Takes(Ahmed, Fatima, Car)}
C11: {¬Takes(Ahmed, y, z), ¬WithoutPermission(Ahmed, y, z)}
Unify: y = Fatima, z = Car
Result: C12: {¬WithoutPermission(Ahmed, Fatima, Car)}
5
Resolve C5 and C12:
C5: {WithoutPermission(Ahmed, Fatima, Car)}
C12: {¬WithoutPermission(Ahmed, Fatima, Car)}
Result: C13: {} (EMPTY CLAUSE - CONTRADICTION!)
Conclusion:
• We derived the empty clause {} (contradiction)
• This means KB ∪ {¬Prosecuted(Ahmed)} is inconsistent
• Therefore: KB ⊨ Prosecuted(Ahmed)
Result: Ahmed CAN be prosecuted (proven by resolution)
Resolution Chain Summary:
¬Prosecuted(Ahmed) → ¬Liable(Ahmed) → ¬CommitsTheft(Ahmed) →
¬Takes(...) ∨ ¬WithoutPermission(...) → ¬WithoutPermission(Ahmed, Fatima, Car) →
Contradiction with WithoutPermission(Ahmed, Fatima, Car) →

Part 5: Interpretation and Expert System Insight

Points: 5 | Connect symbolic reasoning to real-world systems

Expert System Analysis

Task: Explain how this FOL reasoning process would operate in a legal expert system.

Address These Points:
  • How rules (laws) are encoded as logical implications
  • How facts (case data) are asserted into the KB
  • How the inference engine uses unification and resolution to reach decisions
  • Practical benefits and limitations of FOL-based legal reasoning
Your Answer: ✓ Saved
Reasoning & Approach:
How Expert Systems Work:

Think of expert systems as having three main components:

  • Knowledge Base: Contains domain expertise (laws, rules)
  • Fact Base: Contains case-specific data (evidence)
  • Inference Engine: Applies logical reasoning to derive conclusions

Key Insight: Expert systems separate knowledge (what) from reasoning (how), making them maintainable and explainable.

Complete Analysis:
1. Encoding Rules (Laws) as Logical Implications

Process:

  • Legal Rule: "Anyone who takes property without permission commits theft"
  • FOL Encoding: ∀x, y, z [Takes(x, y, z) ∧ WithoutPermission(x, y, z) → CommitsTheft(x)]

Benefits of this approach:

Precision: Eliminates ambiguity in legal language
Universality: ∀ quantifiers ensure rules apply to everyone
Modularity: Each rule is independent, can be added/removed
Transparency: Legal reasoning is explicit and traceable
Consistency: Contradictions can be detected formally

How rules are stored:

  • Rules are stored in clausal form (CNF) for efficient resolution
  • Each rule has conditions (antecedent) and conclusions (consequent)
  • Rules can reference other rules, forming chains of reasoning
2. Asserting Facts (Case Data) into the KB

Process:

  • Evidence Gathering: Collect facts about the case
    • Witness testimony: "Ahmed took Fatima's car"
    • Documentation: "No permission was given"
    • Records: "Ahmed is 25 years old (not a minor)"
  • FOL Encoding: Convert each fact to ground predicates
    • Takes(Ahmed, Fatima, Car)
    • WithoutPermission(Ahmed, Fatima, Car)
    • ¬Minor(Ahmed)
  • KB Update: Add facts to the knowledge base

How this works in practice:

User Interface: Lawyer enters case details via forms
Validation: System checks facts are well-formed
Integration: Facts added to inference engine's working memory
Query: System asks "What can we conclude about Ahmed?"
3. Inference Engine: Unification and Resolution

How the Inference Engine Operates:

1
Goal-Driven Reasoning:
• User asks: "Can Ahmed be prosecuted?"
• System translates to query: Prosecuted(Ahmed)?
• Resolution starts by negating goal: ¬Prosecuted(Ahmed)
2
Backward Chaining:
• To prove Prosecuted(Ahmed), system looks for rule:
  ∀x [Liable(x) → Prosecuted(x)]
• Unifies: x = Ahmed
• New subgoal: Liable(Ahmed)?
3
Chain of Reasoning:
• To prove Liable(Ahmed), needs CommitsTheft(Ahmed)
• To prove CommitsTheft(Ahmed), needs Takes(...) ∧ WithoutPermission(...)
• These facts exist in KB!
• Resolution derives contradiction with ¬Prosecuted(Ahmed)
• Therefore: Prosecuted(Ahmed) is TRUE

Unification in Action:

Pattern Matching: System matches abstract rules with specific facts
Variable Binding: x in ∀x [Liable(x)...] binds to Ahmed
Substitution: Variables replaced with constants throughout chain
Efficiency: Only relevant facts and rules are considered
4. Benefits and Limitations

✅ Benefits of FOL-Based Legal Expert Systems:

  • Explainability: System can show its reasoning chain
    • "Ahmed is liable because he took Fatima's car without permission, which constitutes theft under Rule 1."
  • Consistency: Same facts always lead to same conclusions
  • Scalability: Can handle complex multi-rule scenarios
  • Knowledge Reuse: Rules apply to all similar cases
  • Audit Trail: Every inference step is recorded
  • What-If Analysis: Change facts and re-run inference
    • "What if Ahmed were a minor?" → System shows he wouldn't be liable

⚠️ Limitations:

  • Black-and-White Logic: Real law involves nuance, interpretation
    • FOL can't handle "reasonable doubt" or "probable cause" naturally
  • Knowledge Acquisition Bottleneck: Encoding all laws is labor-intensive
  • Brittleness: Missing rules lead to incorrect conclusions
  • No Learning: System doesn't improve from experience (unlike ML)
  • Context Sensitivity: Difficult to encode contextual factors
  • Conflict Resolution: When laws contradict, system may not know which takes precedence

🔄 Modern Hybrid Approaches:

• Combine FOL with probabilistic reasoning (Bayesian networks)
• Use fuzzy logic for degrees of certainty
• Integrate with machine learning for case outcome prediction
• Apply natural language processing to extract facts from documents
• Leverage LLMs to assist in legal research and reasoning
Key Takeaways:
FOL provides structure: Makes legal reasoning explicit and traceable
Expert systems democratize expertise: Non-lawyers can get basic legal guidance
Not a replacement: Augments human legal professionals, doesn't replace them
Best for: Routine cases with clear-cut rules (e.g., eligibility checks)
Future: Integration with AI/ML creates more robust legal reasoning systems

Exercise Summary

What you've learned from this exercise

Learning Outcomes Achieved:
Technical Skills:
  • Translating English to FOL
  • Building FOL knowledge bases
  • Applying Universal Instantiation
  • Using Modus Ponens for inference
  • CNF conversion
  • Resolution theorem proving
  • Unification of FOL terms
Conceptual Understanding:
  • Knowledge representation
  • Symbolic reasoning
  • Expert system architecture
  • Inference engine operation
  • Real-world AI applications
  • Benefits and limitations of FOL
Congratulations! You've completed an advanced FOL expert system exercise!

Manage Your Answers

Your answers are automatically saved in your browser's local storage. Use the buttons below to manage all your answers at once:

Important Notes:
  • Auto-save: Your answers are saved automatically as you type (after 500ms)
  • Browser Storage: Answers are stored locally in your browser
  • Privacy: Your answers are NOT sent to any server
  • Persistence: Answers persist across browser sessions
  • Limitations: Clearing browser data will delete your answers
  • Export: Download your answers as a text file for backup