First-order logic

Also known as: FOL · predicate logic · first-order predicate calculus

On this page 7

First-order logic (FOL), also called predicate logic or the first-order predicate calculus, is a formal language for stating facts about objects, their properties and their relations, using variables that range over objects and the quantifiers “for all” and “there exists”. In the field of Symbolic AI & reasoning, it serves as the reference formalism for knowledge representation and automated inference, the standard against which more restricted or more expressive logics are measured.

Its importance comes from a rare balance: it is expressive enough to describe most of mathematics and everyday domain knowledge, yet it has a sound and complete proof theory, so every logically valid conclusion can in principle be derived mechanically. That combination made first-order logic the backbone of expert systems, theorem provers, logic programming and ontology languages in artificial intelligence.

Building blocks of first-order logic

A first-order language is defined by a signature: a set of constant symbols, function symbols and predicate symbols, each with a fixed arity. From these, terms and formulas are built recursively, and the logical connectives and quantifiers are shared by every first-order language.

The table below lists the syntactic elements and the role each one plays in a knowledge base.

ElementExampleRole
Constantalice, parisNames one specific object
Variablex, yStands for any object in the domain
Function symbolmotherOf(x)Maps objects to another object
Predicate symbolParent(x, y)States a property or relation that is true or false
Connectiveand, or, not, impliesCombines formulas
Quantifierfor all x, there exists yBinds a variable over the whole domain
Equalityx = yAsserts that two terms denote the same object
Syntactic elements of first-order logic

A term denotes an object, while an atomic formula applies a predicate to terms and yields a truth value. A sentence such as “for all x, Human(x) implies Mortal(x)” contains no free variables, so it can be stored in a knowledge base and evaluated in any interpretation.

Semantics: interpretations, models and entailment

The meaning of a first-order sentence is fixed by an interpretation, which chooses a non-empty domain of objects and assigns each constant an object, each function a mapping and each predicate a relation over that domain. A sentence is true in an interpretation when the relations hold as the formula states.

An interpretation that makes every sentence of a knowledge base true is a model of it. A knowledge base entails a conclusion when the conclusion is true in every model of the knowledge base, not merely in the intended one. This model-theoretic definition is what makes inference trustworthy: a sound procedure never derives a sentence that some model contradicts.

Classical first-order logic is monotonic: adding new sentences can never invalidate an earlier conclusion. It also makes no closed-world assumption, so a fact that is absent from the knowledge base is unknown rather than false, a point that separates it from databases and Datalog.

How first-order logic compares with other logics

First-order logic sits in the middle of a spectrum between decidable but limited logics and highly expressive but intractable ones. The comparison shows why practical systems often choose a fragment instead of full FOL.

LogicQuantifies overValidity checkTypical AI use
Propositional logicNothing; only atomic propositionsDecidable, NP-complete satisfiabilitySAT solving, hardware verification
Description logicIndividuals via restricted rolesDecidable for most variantsOntologies, Web Ontology Language
Horn-clause fragmentObjects, in restricted rule formEfficient for definite queriesProlog, Datalog, rule engines
First-order logicObjects in the domainSemi-decidableTheorem proving, formal specification
Second-order logicObjects, sets and relationsNo complete proof systemMathematical foundations, rarely automated
Modal logicPossible worlds via operatorsOften decidableKnowledge, belief, time
First-order logic and neighboring formalisms

The key result is that FOL validity is semi-decidable: if a sentence is entailed, a complete prover will eventually find a proof, but if it is not, the search may run forever. Church and Turing proved in 1936 that no general algorithm decides validity, which is why engineers trade expressiveness for decidability.

Inference methods for first-order logic

Automated reasoning in first-order logic relies on unification, the algorithm that finds a substitution making two terms identical, such as binding x to alice so that Parent(x, bob) matches Parent(alice, bob). Almost every practical inference rule is built on top of it.

MethodHow it worksCompletenessWhere it is used
ResolutionRefutes the negated goal in clausal formRefutation-completeTheorem provers such as Vampire and E
Forward chainingApplies rules to known facts until no new facts appearComplete for definite clausesProduction systems, Datalog engines
Backward chainingWorks from the goal back to supporting factsComplete for definite clauses with fair searchProlog, diagnostic expert systems
TableauxExpands formulas into branches and closes contradictionsCompleteDescription logic reasoners
SMT solvingCombines SAT search with theory solversComplete for decidable theoriesSoftware verification
Main inference strategies

Before resolution, formulas are converted to conjunctive normal form, and existential quantifiers are removed through Skolemization, which replaces an existential variable with a new function of the universal variables in scope. This step preserves satisfiability, not equivalence, a subtlety that often confuses newcomers.

Limitations and common misconceptions

First-order logic is precise, but it has well-known limits that shape how it is deployed in practice. Most of them concern computational cost and the rigidity of classical truth values.

ProblemCauseCommon remedy
Non-terminating proofsSemi-decidability of validityTime limits, decidable fragments
Brittle with exceptionsMonotonic reasoningNon-monotonic logics, default rules
No graded beliefOnly true or falseProbabilistic logic, Markov logic networks
Cannot express finitenessCompactness theoremSecond-order or specialized theories
Costly knowledge engineeringManual axiom writingOntology reuse, learned rules
Typical problems and their remedies
  • “First-order” does not mean simple: the word refers to quantifying over objects only, not over predicates or sets.
  • Completeness is not decidability: Gödel’s completeness theorem guarantees proofs exist for valid sentences, not that non-valid ones can be recognized.
  • A missing fact is not a false fact: unlike in databases, absent information stays unknown under the open-world reading.

In everyday language

First-order logic is a strict way of writing down facts so that a computer can reason with them. It talks about things, such as people or cities. It also talks about how those things relate, such as who is the parent of whom.

Its special power is the pair of words “every” and “some”. You can write “every human is mortal” and “Socrates is a human”. A machine can then conclude that Socrates is mortal. The conclusion is guaranteed to follow, with no guessing involved.

The price is speed. For some questions, the computer may search for a very long time without finding an answer.

Seen in the real world

A hardware company verifying a floating-point division unit writes the design rules and the arithmetic specification as first-order axioms. Engineers then ask an automated theorem prover to show that, for every pair of valid inputs, the circuit returns the correctly rounded result defined by the IEEE 754 standard.

The prover combines resolution with arithmetic decision procedures and handles thousands of lemmas over several days of computation. When a proof attempt fails, the prover returns a concrete counterexample input, which points the team to the faulty lookup-table entry. After the fix, every lemma is proved, and the chip ships with a machine-checked guarantee of correctness that no amount of random testing could provide.