You are on page 1of 17

Introduction to Propositional Logic

Albert Oliveras and Enric Rodrguez-Carbonell and Javier Larrosa

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 1

Overview of the session


Definition of Propositional Logic
Syntax
Semantics
Parenthesis removal
Usual Queries
Satisfiability, tautology, logical consequence,...
Logical equivalences
Basic proving

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 2

What is a Logic?
A logic is a formal language for representing information such
that conclusions can be drawn.
Logic = syntax + semantics (+ inference)
When defining a logic we have to define:
Syntax: the valid formulas in the language
Semantics: the meaning of formulas (i.e. when a formula
is true)
Inference algorithms allows to extract conclusions about the
satisfiability of formulas and about the relationship between
formulas.
Lots of different logics, but here only propositional logic
Other logics: first-order, temporal, fuzzy, ...
Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 3

Definition of Propositional Logic


SYNTAX (what is a formula (a.k.a. sentence) ?):
Vocabulary consists of a set P of propositional variables,
usually denoted by (subscripted) p, q, r, . . .
The set of propositional formulas over P is defined as:
Every propositional variable is a formula
If F is a formula, F is also a formula
If F and G are formulas, (F G) is also a formula
If F and G are formulas, (F G) is also a formula
Nothing else is a formula
Formulas are usually denoted by (subscripted) F, G, H, . . .
Examples:
p
( p (p q))

p
(( p q) (r q))

( p q)
...

( p q)

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 4

Definition of Propositional Logic (2)


SEMANTICS :
Propositional variables are boolean (i.e, 0 or 1)
An interpretation (a.k.a. world, truth assignment) I over P is a
0, 1 assignment to each variable in P
I satisfies F (written I |= F) if and only if the evaluation of F
under I is 1.
The boolean operators (, , ) are specified with their
corresponding truth tables, or, equivalently,
p =de f 1 p
p q =de f max{p, q}
p q =de f min{p, q}
If I |= F we say that I is a model of F (also, F is true in I, or I
entails F)
Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 5

Example
Consider formula ( p q) (r q)
Interpretation I = {p := 0, q := 1, r := 0}
... is NOT a model of the formula.
Excercise:
Consider formula ( p q) ( p q)
Find a satisfying and a non-satisfying interpretation

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 6

Small Syntax Extension


We will write (F G) as an abbreviation for (F G)
Similarly, (F G) is an abbreviation of ((F G) (G F ))
They both capture very intuitive concepts, which ones?

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 7

Removing parenthesis
From most to least priority:
All connectives are left-associative
EXAMPLES:
F1 F2 F3 F4 is

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 8

Removing parenthesis
From most to least priority:
All connectives are left-associative
EXAMPLES:
F1 F2 F3 F4 is

( ( ( ( F1 ) F2 ) F3 ) (F4 ) )

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 8

Removing parenthesis
From most to least priority:
All connectives are left-associative
EXAMPLES:
F1 F2 F3 F4 is

( ( ( ( F1 ) F2 ) F3 ) (F4 ) )

F1 F2 F3 F4 F5 is

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 8

Removing parenthesis
From most to least priority:
All connectives are left-associative
EXAMPLES:
F1 F2 F3 F4 is

( ( ( ( F1 ) F2 ) F3 ) (F4 ) )

F1 F2 F3 F4 F5 is

( ( ( (F1 F2 ) F3 ) (F4 ) ) F5 )

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 8

Example
EXAMPLE
We have 3 pigeons and 2 holes. If each hole can hold at most
one pigeon, is it possible to place all pigeons in the holes?
Vocabulary: pi, j means i-th pigeon is in j-th hole
Each pigeon is placed in at least one hole:

( p1,1 p1,2 ) ( p2,1 p2,2 ) ( p3,1 p3,2 )


Each hole can hold at most one pigeon:
( p1,1 p2,1 ) ( p1,1 p3,1 ) ( p2,1 p3,1 )
( p1,2 p2,2 ) ( p1,2 p3,2 ) ( p2,2 p3,2 )
Resulting formula has no model

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 9

Usual Queries
Let F and G be arbitrary formulas. Then:
F is satisfiable (also consistent) if it has at least one model
F is unsatisfiable (also a contradiction) if it has no model
F is a tautology if every interpretation is a model of F
G is a logical consequence of F (F entails G), denoted F |= G,
if every model of F is a model of G
F and G are logically equivalent, denoted F G, if F and G
have the same models

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 10

Proving by truth tables


( p q) (r q) is satisfiable?
(p q) (p q) ( p q) ( p q) is unsatisfiable?
( p q) p q is a tautology?
p q is a logical consequence of p q?
( p q) and p q are logically equivalent?

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 11

Proving by truth tables: cost


Constructing the truth tables is time and space O(2n )
Satisfiability
Unsatisfiability
Tautology
Entailment
Logical equivalence

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 12

Logical Equivalences
F F
F F
F G
F G
F
(F G) H
(F G) H
F (G H )
F (G H )

F
(F G) F G
F
(F G) F G
GF
If F is a tautology then
GF
F G

G
F
F G

F
F (G H )
If F is unsatisfiable then
F (G H )
F G

F
(F G) (F H )
F G

G
(F G) (F H )

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 13

Exercise: Prove that (F G) F G


We have to prove that an interpretation I is a model of the left-hand
expression iff is a model of the right-hand expression

Departament de Llenguatges i Sistemes Informatics

UPC

UNIVERSITAT POLITECNICA
DE CATALUNYA

Introduction to Propositional Logic p. 14

You might also like