Introduction to First-Order Satisfiability IA085: Satisfiability and Automated Reasoning Martin Jonáš FI MUNI, Spring 2024 Where are we? Satisfiability modulo theories (SMT) • x = 1 ∧ x = y + y ∧ y > 0 • is it satisfiable over reals? • is it satisfiable over integers? • is it satisfiable over integers represented by 8 bits? • is it satisfiable over floating point numbers represented by 32 bits? For next four lectures, we will be dealing mostly with quantifier-free formulas. 1 / 36 Applications SMT solvers are widely used in practice • planning • scheduling • verification of hardware • compiler optimizations • verification of software • . . . 2 / 36 Applications 1 int x = read(); 2 int y = read(); 3 int z = read(); 4 if (x > 10 && y != 0) 5 { 6 print(z / (x + y)); 7 } Contains division by zero precisely if the formula x > 10 ∧ ¬(y = 0) ∧ x + y = 0 is satisfiable. 3 / 36 First-order logic First-Order Logic Propositional logic speaks only about atomic propositions • are true or false • have no internal structure First-order logic speaks about objects, their properties and relations among them. 4 / 36 First-Order Logic Propositional logic speaks only about atomic propositions • are true or false • have no internal structure First-order logic speaks about objects, their properties and relations among them. Examples • ∃s. Human(s) ∧ Mortal(s). • ∀s. Human(s) → Mortal(s). • ∃x∃y. x < 5 ∧ y < 3 ∧ 2 · (x + y) > 20. 4 / 36 First-Order Logic Propositional logic speaks only about atomic propositions • are true or false • have no internal structure First-order logic speaks about objects, their properties and relations among them. Examples • ∃s. Human(s) ∧ Mortal(s). • ∀s. Human(s) → Mortal(s). • ∃x∃y. x < 5 ∧ y < 3 ∧ 2 · (x + y) > 20. 4 / 36 First-Order Logic Propositional logic speaks only about atomic propositions • are true or false • have no internal structure First-order logic speaks about objects, their properties and relations among them. Examples • ∃s. Human(s) ∧ Mortal(s). • ∀s. Human(s) → Mortal(s). • ∃x∃y. x < 5 ∧ y < 3 ∧ 2 · (x + y) > 20. In addition to logical symbols, first-order formulas contain variables, constant symbols, function symbols, and predicate symbols. 4 / 36 First-Order Logic – Syntax Suppose we have • a set ΣF = {f, g, . . .} of function symbols and • a set ΣP = {R, S, . . .} of predicate symbols. Each function symbol f and predicate symbol P has its arity ar(f) and ar(P). Function symbols of arity 0 are called constants. The set Σ = ΣF ∪ ΣP is called a signature. Example • ΣF = {+, −, 0, 1} • ΣP = {=, ≤} 5 / 36 First-Order Logic – Syntax (Σ-)Term 1. a variable – x, y, z, . . . 2. a function symbol applied to ar(f) terms – f(x), g(f(x), y), … 6 / 36 First-Order Logic – Syntax (Σ-)Term 1. a variable – x, y, z, . . . 2. a function symbol applied to ar(f) terms – f(x), g(f(x), y), … (Σ)-Literal 1. a predicate symbol applied to ar(P) terms – R(x), S(f(x), y), . . . 2. a negation of predicate symbol applied to ar(P) terms – ¬R(x), ¬S(f(x), y), . . . 6 / 36 First-Order Logic – Syntax (Σ-)Term 1. a variable – x, y, z, . . . 2. a function symbol applied to ar(f) terms – f(x), g(f(x), y), … (Σ)-Literal 1. a predicate symbol applied to ar(P) terms – R(x), S(f(x), y), . . . 2. a negation of predicate symbol applied to ar(P) terms – ¬R(x), ¬S(f(x), y), . . . (Σ)-Formula 1. a Boolean combination of literals – (R(x) ∨ ¬R(y)) ∧ S(f(x), y), . . . 2. a quantifier applied to a formula – ∀x (R(x)) , . . .. 6 / 36 First-Order Logic – Syntactic Conventions and Terminology Notation • instead of +(r, s) write r + s (also for other infix function symbols) • instead of ≤ (r, s) write r ≤ s (also for other infix predicate symbols) • instead of 1() write 1 (also for other constants) • instead of ∀x∀y(φ ∧ ψ) write ∀x∀y. φ ∧ ψ Terminology • an occurrence of a variable is free if it is not bound by a quantifier • a formula without free occurrences of variables is closed or a sentence 7 / 36 First-Order Logic – Semantics Is the following formula true? ∀x∃y. x < y ∧ y < x + 1 8 / 36 First-Order Logic – Semantics Is the following formula true? ∀x∃y. x < y ∧ y < x + 1 It depends. 8 / 36 First-Order Logic – Semantics Is the following formula true? ∀x∃y. x < y ∧ y < x + 1 It depends. • What is the domain of x and y? • What does the function symbol + mean? • What does the predicate symbol < mean? 8 / 36 First-Order Logic – Semantics Is the following formula true? ∀x∃y. x < y ∧ y < x + 1 It depends. • What is the domain of x and y? • What does the function symbol + mean? • What does the predicate symbol < mean? 8 / 36 First-Order Logic – Semantics Is the following formula true? ∀x∃y. x < y ∧ y < x + 1 It depends. • What is the domain of x and y? • What does the function symbol + mean? • What does the predicate symbol < mean? Meaning of these three things is given by a Σ-structure. 8 / 36 First-Order Logic – Structures Σ-structure A • determines the set of objects and behavior of functions/predicates • a pair of 1. a non-empty set A called the universe, 2. a map (_)A that • to each f ∈ ΣF assigns a function fA : Aar(f) → A, • to each R ∈ ΣP \ {=} assigns a relation RA ⊆ Aar(R) , • we suppose that =A is the identity relation. 9 / 36 First-Order Logic – Structure Examples A = ( A, (_)A ) where A = Z +A (x, y) = x + y