• Non ci sono risultati.

An introduction to logic ∀∃ ¬

N/A
N/A
Protected

Academic year: 2021

Condividi "An introduction to logic ∀∃ ¬"

Copied!
35
0
0

Testo completo

(1)

An introduction to logic

Gabriele Puppis

¬ ∀∃

(2)

First and foremost: interrupt!

(3)

Logic as a formal language

(4)

What is “a logic”?

A formal language to express and reason about properties of objects (numbers, graphs, computations, etc)

! a crucial tool for verifying, validating, synthesising safety-critical systems

(5)

What is “a logic”?

A formal language to express and reason about properties of objects (numbers, graphs, computations, etc)

! a crucial tool for verifying, validating, synthesising safety-critical systems

Two (in)famous examples where logical formal methods would have saved $$$:

• Pentium I floating point division bug (loss @Intel > $475,000,000)

• Ariane 501 overflow bug: (loss @ESA > $500,000,000)

(6)

What is “a logic”?

(7)

What is “a logic”?

As a formal language, a logic requires:

a vocabulary: list of symbols we can use to denote objects and properties

a syntax: grammar for combining symbols into well-formed terms (formulas)

a semantics: way of assigning a meaning to symbols and terms

some algorithms: ways of reasoning automatically about the semantics (e.g. checking whether a given formula is valid)

(8)

Syntax and semantics

Q. “Are you two married?”

A. “Depends…”

(9)

Syntax and semantics

Q. “Are you two married?”

A. “Depends…”

Two possible relations:

unary relation R1(x) = “x is married with someone”

binary relation R2(x,y) = “x and y are married together”

(10)

Syntax and semantics

Q. “Are you two married?”

A. “Depends…”

Note:    R2(x,y) → R1(x) & R1(y) but not the converse!

Two possible relations:

unary relation R1(x) = “x is married with someone”

binary relation R2(x,y) = “x and y are married together”

(11)

Syntax and semantics

“All humans are mortal.

Socrates is human.

So Socrates is mortal.”

( (∀x A(x) → B(x)) ∧ A(y) ) → B(y)

(12)

Syntax and semantics

“All humans are mortal.

Socrates is human.

So Socrates is mortal.”

The above formula is valid (i.e. true in every model). We call it a tautology ( (∀x A(x) → B(x)) ∧ A(y) ) → B(y)

(13)

Syntax and semantics

“All humans are mortal.

Socrates is human.

So Socrates is mortal.”

The above formula is valid (i.e. true in every model). We call it a tautology

“All beatles have 6 legs.

John Lennon is a beatle.

So John Lennon has 6 legs.

( (∀x A(x) → B(x)) ∧ A(y) ) → B(y)

(14)

Syntax and semantics

“There is a barber who shaves all and only

those men who do not shave themselves.”

∃x ∀y C(x,y) ¬C(y,y)

(15)

Syntax and semantics

The formula is not satisfiable (i.e. false in every model). We call it a contradiction

“There is a barber who shaves all and only

those men who do not shave themselves.”

∃x ∀y C(x,y) ¬C(y,y)

(16)

Syntax and semantics

“There exists a set that contains all and only the sets that do not contain themselves.”

The formula is not satisfiable (i.e. false in every model). We call it a contradiction

“There is a barber who shaves all and only

those men who do not shave themselves.”

∃x ∀y C(x,y) ¬C(y,y)

(17)

Syntax and semantics

“Every incoming order is eventually processed.”

∀o ∀t    A(o,t) → ∃t’ t<t’ ∧ B(o,t’)

(18)

Syntax and semantics

“Every incoming order is eventually processed.”

The formula has variables of different sorts (representing objects of different types)

∀o ∀t    A(o,t) → ∃t’ t<t’ ∧ B(o,t’)

(19)

Syntax and semantics

“If a non-deterministic program

can reach infinitely many configurations, it has an infinite execution.”

(20)

Syntax and semantics

“If a finitely branching tree has infinitely many nodes, it contains an infinite path.”

“If a non-deterministic program

can reach infinitely many configurations, it has an infinite execution.”

(21)

Syntax and semantics

“If a finitely branching tree has infinitely many nodes, it contains an infinite path.”

“If a non-deterministic program

can reach infinitely many configurations, it has an infinite execution.”

∀x ∀y ∀z    A(y,x) ∧ A(z,x) → y=z ∨ A(y,z) ∨ A(z,y)  // structure is a tree

∧ ∀x ¬∃ y    A(x,y) ∧ ∀z A(x,z) → y=z ∨ A(y,z)        // is finitely branching

∧  ∃ x                                    // is infinite

→   // so

∃S ∃ x    x∈S                            // there is an infinite set

∧  ∀x ∀y    x∈S ∧ y∈S → x=y ∨ A(x,y) ∨ A(y,x)        // which is a path

(22)

Syntax and semantics

“If a finitely branching tree has infinitely many nodes, it contains an infinite path.”

The formula uses one relational symbol A (for the “ancestor-of ” relation) and different types of quantifiers (∀x, ∃x, ∃x, ∃S)

“If a non-deterministic program

can reach infinitely many configurations, it has an infinite execution.”

∀x ∀y ∀z    A(y,x) ∧ A(z,x) → y=z ∨ A(y,z) ∨ A(z,y)  // structure is a tree

∧ ∀x ¬∃ y    A(x,y) ∧ ∀z A(x,z) → y=z ∨ A(y,z)        // is finitely branching

∧  ∃ x                                    // is infinite

→   // so

∃S ∃ x    x∈S                            // there is an infinite set

∧  ∀x ∀y    x∈S ∧ y∈S → x=y ∨ A(x,y) ∨ A(y,x)        // which is a path

(23)

Algorithms

How hard is it to mechanise? ⤳ complexity classes Evaluation of a formula

Validity / satisfiability Logical equivalence Logical consequence

Definability in a logical fragment

What can be mechanized? ⤳ decidable/undecidable

(24)

Algorithms

How hard is it to mechanise? ⤳ complexity classes

usage of resources: • time

• memory

PCP K H’s 10th

Domino

. . . Evaluation of a formula

Validity / satisfiability Logical equivalence Logical consequence

Definability in a logical fragment

What can be mechanized? ⤳ decidable/undecidable

(25)

Algorithms

Alg f

time

input size

How hard is it to mechanise? ⤳ complexity classes

What can be mechanized? ⤳ decidable/undecidable

usage of resources: • time

• memory

PCP K H’s 10th

Domino

. . .

(26)

Algorithms

Alg f

time

input size

Algorithm Alg is TIME-bounded by a function f : ℕ ⟶ ℕ if

Alg(input) uses less than f (|input|) units of TIME.

How hard is it to mechanise? ⤳ complexity classes

What can be mechanized? ⤳ decidable/undecidable

usage of resources: • time

• memory

PCP K H’s 10th

Domino

. . .

(27)

Algorithms

Alg f

time

input size

Algorithm Alg is TIME-bounded by a function f : ℕ ⟶ ℕ if

Alg(input) uses less than f (|input|) units of TIME.SPACE.

SPACE

How hard is it to mechanise? ⤳ complexity classes

What can be mechanized? ⤳ decidable/undecidable

usage of resources: • time

• memory

PCP K H’s 10th

Domino

. . .

(28)

Algorithms

P ⊆ NP ⊆ PSPACE ⊆ EXP ⊆ · · ·

Alg f

time

input size

Algorithm Alg is TIME-bounded by a function f : ℕ ⟶ ℕ if

Alg(input) uses less than f (|input|) units of TIME.

Deterministic and TIME-bounded by a polynomial

SPACE-bounded by a polynomial

Non-deterministic and TIME-bounded by a polynomial SPACE.

SPACE

How hard is it to mechanise? ⤳ complexity classes

What can be mechanized? ⤳ decidable/undecidable

usage of resources: • time

• memory

PCP K H’s 10th

Domino

. . .

(29)

Algorithms

φ

M

yes/no

Model-checking problem

input: formula φ + model M

output:   yes iff φ holds on M (M ⊨ φ)

(30)

Algorithms

φ

M

yes/no

Variant:   sometimes M is fixed (e.g. when M is infinite), and the only input is φ Model-checking problem

input: formula φ + model M

output:   yes iff φ holds on M (M ⊨ φ)

(31)

Algorithms

φ

yes/no M

Validity problem input: formula φ

output:   yes iff φ holds on every model M

(32)

Algorithms

φ

yes/no M

Variant:   sometimes M is restricted to range over specific class (e.g. finite models) Validity problem

input: formula φ

output:   yes iff φ holds on every model M

(33)

Algorithms

φ

yes/no

Validity problem

input: formula φ

output:   yes iff φ holds on every model M B or not B?

Yes, Dave, that’s valid

(34)

Algorithms

φ

yes/no

Variant:   sometimes M is restricted to range over specific class (e.g. finite models) Satisfiability problem

input: formula φ

output:   yes iff φ holds on some model M B and not B?

No, Dave,

that’s not possible

(35)

Algorithms …but not only

expressiveness decidability

succinctness efficiency

When studying logics, algorithms are not the only interesting part:

Expressive power

Which kinds of properties can be expressed in a given logic?

Is this logic more/less expressive than this other logic?

Does it express undecidable properties?

Succinctness

How complex it is to express a family of properties?

Which logic is more succinct?

Which logic has more efficient algorithms?

Normal forms, algebraic representations, …

Riferimenti

Documenti correlati

We considered three social robots named Teo, Sam, and Paro. Teo [2] and Sam [5] are research products from our lab. They have been designed in cooperation with NDD specialists

The model run using the parameters suggested by stakeholders creating plausible scenarios (like the use of different extraction techniques) and incorporating the observation

(See Mirabel &amp; Rodr´ıguex 1998, Belloni 2001, and Zdziarski &amp; Grandi 2001 for discussions of the theoretical models.) The observed time lag between the minimum in the

In adult zebrafish, bdnf expression has a similar distribution as in the larvae with the most prominent staining in dorsal telencephalon, preoptic area, dorsal thalamus,

This article reports the experience performed by GETS in developing its own modeling standard through customizing the MAAB rules for the railway signaling domain and shows the result

Quando il testo si avvia verso l’epilogo, compare un tratto che man- ca sia nella versione raccolta da Briz sia in quella di Capmany: tra gli oggetti mostrati per attivare

This difference between West Flemish and German follows, if we assume, as I have argued in chapter 3, that in West Flemish only finite verbs can move to the head of AspP.. Else

In this paper, we have shown the undecidability of model checking of the fragment of Brane Logic without quantifiers and adjoints, in presence of the replication (either on systems