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 BasicsKnowledge 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraConditional StatementsDefining and Calling FunctionsFunctions: Decomposing ProblemsFunction Parameters and Argument PassingReturn ValuesVariable ScopeIntroduction to ClassesObjects and InstancesMethods and AttributesAlgorithm Design BasicsFirst-Order Logic for AI

Longest path: 83 steps · 398 total prerequisite topics

Prerequisites (1)

Leads To (3)