A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

First-Order Logic for AI

Graduate Depth 82 in the knowledge graph ☐ I know this ☆ Set as goal
42topics build on this
398prerequisites beneath it
See this on the map →
Algorithm Design Basics→→Knowledge GraphsLogic Programming Basics (Prolog)+1 more
logic knowledge-representation reasoning formal-systems

Core Idea

First-order logic (FOL) extends propositional logic with predicates, quantifiers, and variables to represent complex domains formally and expressively. FOL serves as a foundation for logical inference, planning, and knowledge representation; however, automated reasoning in FOL is computationally expensive (semi-decidable) and even for restricted fragments can be intractable.

How It's Best Learned

Practice translating English statements into FOL formulas, then use a theorem prover (e.g., Prolog or DPLL-based solvers) to prove simple theorems.

Explainer

If you have worked with propositional logic (Boolean variables, AND, OR, NOT, implications), you know its power and its limitation. You can express statements like "if it rains, the ground is wet" as R → W, and chain such rules together for inference. But propositional logic cannot express "every student who studies passes the exam" because it has no way to talk about objects, their properties, or quantification over collections. First-order logic (FOL) extends propositional logic with exactly these capabilities.

FOL introduces three key elements. Predicates are functions that return true or false for specific objects: Student(alice), Passes(bob, math). Variables stand in for unspecified objects: Student(x). Quantifiers bind variables to make general claims: ∀x (Student(x) ∧ Studies(x) → Passes(x)) says "for all x, if x is a student and x studies, then x passes." The existential quantifier ∃x says "there exists at least one x such that..." — for example, ∃x (Student(x) ∧ Passes(x, philosophy)) means "some student passes philosophy." With predicates, variables, quantifiers, and the logical connectives you already know (∧, ∨, ¬, →), FOL can represent a vast range of real-world knowledge in a form that supports automated reasoning.

In AI, FOL serves as the foundation for knowledge representation and reasoning. A knowledge base is a set of FOL sentences describing what is known about a domain. An inference engine applies rules of deduction — modus ponens (from P and P → Q, conclude Q), universal instantiation (from ∀x P(x), conclude P(alice) for any specific alice), and resolution (a general-purpose rule that combines clauses to derive new conclusions) — to answer queries. For example, given the knowledge base {∀x (Bird(x) ∧ ¬Penguin(x) → Flies(x)), Bird(tweety), ¬Penguin(tweety)}, the inference engine can derive Flies(tweety). This is the basis for logic programming languages like Prolog, expert systems, and semantic web technologies.

The computational cost of FOL reasoning is the central practical challenge. While propositional logic is decidable (you can always determine if a formula is satisfiable, though it may take exponential time), FOL is only semi-decidable: if a conclusion follows from the premises, an algorithm will eventually find the proof, but if it does not follow, the algorithm may run forever without halting. This is not a theoretical curiosity — it is a fundamental limit proved by Church and Turing. In practice, this means FOL theorem provers can handle moderately sized knowledge bases but struggle with the scale of real-world knowledge. Restricted fragments of FOL — such as Horn clauses (the basis of Prolog) or description logics (the basis of OWL and the semantic web) — trade expressiveness for decidability, giving guaranteed termination at the cost of being unable to represent certain kinds of knowledge.

Despite competition from statistical and neural approaches, FOL remains essential in AI for domains requiring provably correct reasoning: formal verification of software, planning systems that must guarantee safety properties, legal and regulatory reasoning, and knowledge graph construction. Its value lies not in processing noisy, uncertain data (where machine learning excels) but in maintaining logical consistency and supporting explanations — if the system concludes something, it can show you the chain of deductive steps that led there.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → Defining and Calling Functions → Functions: Decomposing Problems → Function Parameters and Argument Passing → Return Values → Variable Scope → Introduction to Classes → Objects and Instances → Methods and Attributes → Algorithm Design Basics → First-Order Logic for AI

Longest path: 83 steps · 398 total prerequisite topics

Prerequisites (1)

Leads To (3)