🤔Mathematical Logic Unit 4 – First–Order Logic (Predicate Logic)
First-order logic expands on propositional logic by introducing quantifiers, variables, and predicates. This powerful system allows for more nuanced expressions of relationships and properties, enabling precise formalization of complex statements in mathematics, computer science, and philosophy.
The syntax and semantics of first-order logic provide a framework for constructing and interpreting well-formed formulas. Key concepts include terms, atomic formulas, complex formulas, interpretations, and variable assignments, which together form the foundation for logical reasoning and formal proofs.
First-order logic (FOL) extends propositional logic by introducing quantifiers, variables, and predicates
Predicates are symbols that represent relations or properties of objects (e.g., P(x) could represent "x is prime")
Variables are symbols that stand for objects in the domain of discourse (e.g., x, y, z)
Constants are symbols that represent specific objects in the domain (e.g., a, b, c)
Functions are symbols that map objects to other objects (e.g., f(x) could represent "the father of x")
Terms are variables, constants, or functions applied to terms (e.g., x, a, f(x), g(a,f(y)))
Atomic formulas are predicates applied to terms (e.g., P(x), Q(a,f(y)))
Complex formulas are built from atomic formulas using logical connectives (¬, ∧, ∨, →, ↔) and quantifiers (∀, ∃)
Syntax of First-Order Logic
The syntax of FOL specifies the rules for constructing well-formed formulas (wffs)
Variables, constants, and predicates are chosen from disjoint sets of symbols
Terms are defined recursively:
Variables and constants are terms
If f is an n-ary function and t1,…,tn are terms, then f(t1,…,tn) is a term
Atomic formulas are of the form P(t1,…,tn), where P is an n-ary predicate and t1,…,tn are terms
Complex formulas are built using the following rules:
If ϕ is a formula, then ¬ϕ is a formula
If ϕ and ψ are formulas, then (ϕ∧ψ), (ϕ∨ψ), (ϕ→ψ), and (ϕ↔ψ) are formulas
If ϕ is a formula and x is a variable, then ∀xϕ and ∃xϕ are formulas
Parentheses are used to disambiguate the structure of formulas
Semantics and Interpretations
The semantics of FOL assigns meaning to the symbols and formulas
An interpretation I consists of a non-empty domain D and a function that maps:
Constants to elements of D
n-ary functions to functions from Dn to D
n-ary predicates to subsets of Dn
A variable assignment s is a function that maps variables to elements of D
The value of a term t under an interpretation I and assignment s, denoted Is(t), is defined recursively:
If t is a variable x, then Is(t)=s(x)
If t is a constant c, then Is(t)=I(c)
If t is f(t1,…,tn), then Is(t)=I(f)(Is(t1),…,Is(tn))
The truth value of a formula ϕ under an interpretation I and assignment s, denoted I⊨sϕ, is defined recursively:
I⊨sP(t1,…,tn) iff (Is(t1),…,Is(tn))∈I(P)
I⊨s¬ϕ iff I⊨sϕ
I⊨s(ϕ∧ψ) iff I⊨sϕ and I⊨sψ
I⊨s(ϕ∨ψ) iff I⊨sϕ or I⊨sψ
I⊨s(ϕ→ψ) iff I⊨sϕ or I⊨sψ
I⊨s(ϕ↔ψ) iff I⊨sϕ iff I⊨sψ
I⊨s∀xϕ iff for all d∈D, I⊨s[x↦d]ϕ
I⊨s∃xϕ iff there exists d∈D such that I⊨s[x↦d]ϕ
Quantifiers and Variables
Quantifiers are logical symbols that express the quantity of objects that satisfy a given formula
The universal quantifier ∀ ("for all") asserts that a formula holds for all objects in the domain
Example: ∀x(P(x)→Q(x)) means "for every x, if P(x) holds, then Q(x) holds"
The existential quantifier ∃ ("there exists") asserts that a formula holds for at least one object in the domain
Example: ∃x(P(x)∧Q(x)) means "there exists an x such that both P(x) and Q(x) hold"
Variables are symbols that stand for arbitrary objects in the domain
A variable is called free if it is not bound by a quantifier
Example: in ∀x(P(x)→Q(y)), x is bound, but y is free
A formula with no free variables is called a sentence
The scope of a quantifier is the formula it quantifies over
Example: in ∀x(P(x)→∃yQ(x,y)), the scope of ∀x is (P(x)→∃yQ(x,y)), and the scope of ∃y is Q(x,y)
Quantifiers can be nested, allowing for complex statements about objects and their relationships
Formal Proofs and Inference Rules
Formal proofs are sequences of formulas, each of which is either an axiom or derived from previous formulas using inference rules
Inference rules are syntactic rules that allow new formulas to be derived from existing ones
Some common inference rules in FOL include:
Modus ponens: from ϕ and ϕ→ψ, infer ψ
Universal instantiation: from ∀xϕ, infer ϕ[x↦t] for any term t
Existential generalization: from ϕ[x↦t], infer ∃xϕ
Conjunction introduction: from ϕ and ψ, infer ϕ∧ψ
Conjunction elimination: from ϕ∧ψ, infer ϕ (or ψ)
A proof system is sound if every formula derivable in the system is logically valid
A proof system is complete if every logically valid formula is derivable in the system
Gödel's completeness theorem states that FOL is complete: if a formula is logically valid, then it has a formal proof
Validity and Satisfiability
A formula ϕ is satisfiable if there exists an interpretation I and an assignment s such that I⊨sϕ
Example: ∃xP(x) is satisfiable, as there is an interpretation with a non-empty domain and an object that satisfies P
A formula ϕ is unsatisfiable if there is no interpretation I and assignment s such that I⊨sϕ
Example: ∀xP(x)∧∃x¬P(x) is unsatisfiable, as no object can both satisfy and not satisfy P
A formula ϕ is logically valid (or a tautology) if for every interpretation I and assignment s, I⊨sϕ
Example: ∀x(P(x)∨¬P(x)) is logically valid, as every object either satisfies P or does not satisfy P
A formula ϕ is logically invalid if there exists an interpretation I and an assignment s such that I⊨sϕ
Logical validity and satisfiability are related: a formula is logically valid iff its negation is unsatisfiable
Determining the satisfiability or validity of FOL formulas is an undecidable problem in general
Applications and Examples
FOL is used to formalize and reason about statements in various domains, such as mathematics, computer science, and philosophy
In mathematics, FOL can be used to define and prove theorems about structures like groups, rings, and fields
Example: the associativity of a binary operation ∗ can be expressed as ∀x∀y∀z((x∗y)∗z=x∗(y∗z))
In computer science, FOL is used in formal specification and verification of software and hardware systems
Example: the Hoare triple {P}C{Q} can be expressed in FOL as P→wp(C,Q), where wp is the weakest precondition predicate transformer
In database theory, FOL is used to define and query relational databases
Example: the query "find all employees who work in the sales department" can be expressed as ∃x(Employee(x)∧Department(x,"sales"))
FOL can be used to analyze and validate arguments in natural language
Example: the argument "all humans are mortal, Socrates is human, therefore Socrates is mortal" can be formalized as (∀x(Human(x)→Mortal(x))∧Human(Socrates))→Mortal(Socrates)
Many other logics, such as second-order logic, modal logic, and temporal logic, are extensions of FOL with additional expressive power
Common Pitfalls and Tips
Remember to use parentheses to disambiguate the structure of formulas, especially when using multiple connectives or quantifiers
Example: ∀xP(x)→Q(x) is different from ∀x(P(x)→Q(x))
Be careful with the order of quantifiers, as it can significantly change the meaning of a formula
Example: ∀x∃yP(x,y) is not equivalent to ∃y∀xP(x,y)
When using multiple quantifiers, ensure that each variable is bound by a quantifier before it is used
Example: ∀x∃yP(x,y,z) is not a well-formed formula if z is not bound by a quantifier
Keep in mind that the domain of discourse can affect the truth value of a formula
Example: ∀x∃y(x<y) is true in the domain of natural numbers but false in the domain of integers
Use the negation of quantifiers to express complex statements more concisely
Example: ¬∀xP(x) is equivalent to ∃x¬P(x), and ¬∃xP(x) is equivalent to ∀x¬P(x)
Break down complex formulas into smaller, more manageable parts when analyzing or proving them
Example: to prove ∀x(P(x)→(Q(x)∧R(x))), prove ∀x(P(x)→Q(x)) and ∀x(P(x)→R(x)) separately
Practice translating natural language statements into FOL and vice versa to develop a better understanding of the logic and its applications