Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 5 Lab: First-Order Logic

Lab Overview

Implement first-order reasoning:

  1. Term and predicate representation

  2. Unification and substitution

  3. Forward chaining with FOL

  4. Backward chaining with FOL

  5. Prolog-style queries

Exercise 1: Term Representation and Substitution

Implement data structures for FOL terms.

Exercise 2: Unification Algorithm

Implement the unification algorithm.

Exercise 3: Knowledge Base and Queries

Implement a first-order knowledge base.

Exercise 4: Forward Chaining with FOL

Implement forward chaining for first-order logic.

Exercise 5: Prolog-Style Interpreter

Build a simple Prolog interpreter.

Challenge: Resolution with Skolemization

Implement full FOL resolution.

Lab Report

Deliverables

  • Unification implementation

  • FOL knowledge base

  • Forward/backward chaining

  • Query system

Discussion

  1. How does unification differ from matching?

  2. Compare expressiveness of FOL vs propositional logic

  3. What is the computational complexity of FOL inference?

  4. When should you use FOL vs other representations?