Back to Program Verification Index | Previous: (y-03) First-Order Logic | Next: (y-05) SMT-LIB

Mental Model for First-Order Theories

  • Pure FOL is too broad. It doesn’t know that or that unless we tell it.
  • A Theory () constrains the meaning of symbols (like ) using a specific Signature and a set of Axioms.
  • Instead of checking if a formula is “valid in all models,” we check if it is -valid (valid in all models that obey the theory’s rules).
  • This is how we bridge the gap between abstract logic and actual program variables (integers, arrays, bits).

What is a First-Order Theory?

A Theory () constrains the meaning of symbols (like ) using a specific Signature and a set of Axioms. This allows us to bridge the gap between abstract logic and actual program variables.

Formal Definition

A first-order theory consists of:

  1. Signature (): A set of constant, function, and predicate symbols.
  2. Axioms (): A set of closed -formulas.

-Models and -Validity

  • -Model: A model is a -model if it satisfies all axioms in .
  • -Satisfiable: A formula is -satisfiable if there exists a -model such that .
  • -Valid: A formula is -valid (denoted ) if every -model satisfies .
  • -Equivalent: and are -equivalent if is -valid.

Example: Rock-Paper-Scissors Theory ()

To define the game Rock-Paper-Scissors, we need a specific theory.

  • Signature:
  • Axioms:
    1. (Domain is restricted to these three)

🧠 Deep Dive: Reasoning in

Is the formula (no move wins against all others) -valid?

  • Yes. Because move would have to beat , and . But axioms 4, 6, and 8 state that no move beats itself. Is the formula (every move has something it beats) -valid?
  • Yes. beats , beats , and beats .

Theory of Equality ()

is the foundation of most SMT reasoning. Its signature includes and all other constant/function/predicate symbols.

Axioms

  1. Reflexivity:
  2. Symmetry:
  3. Transitivity:
  4. Function Congruence: For each -ary ,
  5. Predicate Congruence: For each -ary ,

🧠 Deep Dive: Axiom Schemata

Axioms like Function Congruence are actually Axiom Schemata. Since a signature can have infinitely many functions, we cannot list every axiom. Instead, we provide a “template.” For a binary function , the schema generates:


Arithmetic Theories

1. Peano Arithmetic ()

Theory of Natural Numbers () with addition and multiplication.

  • Signature:
  • Axioms: Successor rules, Plus/Times rules, and the Induction Schema:

🧠 Deep Dive: Expressiveness of

can express almost all of mathematics. Even exponentiation , which is not in the signature, can be encoded using a complex formula .

  • Gödel showed that for every recursive function , there is a formula such that .
  • This high expressiveness comes at a price: is undecidable.

2. Presburger Arithmetic ()

Natural numbers with addition only (no multiplication).

  • Signature:
  • Decidability: is decidable. It is the most common theory for loop bounds and simple offsets.

3. Theory of Integers ()

Integers () with .

🧠 Deep Dive: Transforming to

To decide -validity for a formula , we transform its negation into an equisatisfiable formula:

  1. Replace every integer variable with (where are natural numbers).
  2. Eliminate subtraction by moving terms to the other side of or .
  3. Replace with . If the resulting formula is unsatisfiable, then is -valid.

Theory of Arrays ()

Used to model computer memory and data structures. Unlike functions in FOL, arrays are “first-class objects” that can be modified.

  • Signature:
  • Axioms:
    1. Reflexivity, Symmetry, Transitivity of .
    2. Array Congruence:
    3. Read-over-Write 1:
    4. Read-over-Write 2:
    5. Extensionality:
      • Intuition: Two arrays are equal if and only if they have the same values at every index.

💡 Application: Modeling Memory

In a verifier, a pointer *ptr is modeled as select(mem, ptr), and an assignment *ptr = v becomes mem' = store(mem, ptr, v).


Summary of Decidability

Logic / TheorySatisfiabilityValidity
Propositional Logic (PL)DecidableDecidable
First-Order Logic (FOL)UndecidableSemi-decidable
Theory of Equality ()Undecidable (Decidable for QF)Undecidable
Presburger Arithmetic ()DecidableDecidable
Peano Arithmetic ()UndecidableUndecidable

In program verification, we usually care about -Satisfiability. If a “bad state” (like an assertion failure) is -satisfiable, it means there is a real execution that leads to a bug.


Summary

  1. Theories give specific meaning to symbols (e.g., how or `read` behave).
  2. (Equality) provides the foundation for all reasoning.
  3. Arithmetic theories range from easy (Presburger) to impossible (Peano).
  4. Array theory allows us to model computer memory.
  5. Verification tools combine these theories to reason about complex code.

Self-Check

  1. What two components define a first-order theory , and what does -validity mean?
  1. What are the five axioms of the theory of equality ?
  1. Why is Presburger arithmetic decidable while Peano arithmetic is not?
  1. State the two read-over-write axioms of and what they say in plain English.
  1. Why does verification usually care about -satisfiability of “bad states” rather than validity?

Back to Program Verification Index | Previous: (y-03) First-Order Logic | Next: (y-05) SMT-LIB | (y) Return to Notes | (y) Return to Home