À la chasse aux bugs

avec le Laboratoire d'informatique formelle
Les mathématiques au service
de l'assurance-qualité
NSERC
CRSNG

Fonds de recherche
Nature et
technologies
Ariane V
1996
Ariane V
1996
6 rappels
en 2010
400 000 rappels
59 500 000 000 $
M. Gauche

M. Droit
M. Gauche

M. Droit
ATELIERS

GAU
?

!
Votre code

?

!
Librairie
Service web
Module
Votre code

?

!
b

c
a
b

Plan
Devis
Contrat
...

c
a
b

c
a
b

c
a

b

c
a
b

?

c
a

b

c
a

?
b

?

c
a

b

c
a

?
TESTING
T

ES

T
M.
?

Pas exhaustif

T

ES

T
M.
?

Pas exhaustif

T

ES

T
M.

Long…
?

Basé sur la
compréhension
du testeur

Pas exhaustif

?

T

ES

T
M.

Long…
ATELIERS
ATELIERS
ATELIERS
ATEL

GAU
X

ATEL

GAU
X
ATELIERS

GAU
X
ATELIERS

GAU

?

?
Programmation

Tests
unitaires

Tests
fonctionnels

Tests
système

Après
sortie
% de bugs introduits

85%

Programmation

Tests
unitaires

Tests
fonctionnels

Tests
système

Après
sortie
% de bugs introduits
% de bugs trouvés

85%

Programmation

Tests
unitaires

Tests
fonctionnels

Tests
système

Après
sortie
% de bugs introduits
% de bugs trouvés
coût de réparation

16 000$
85%
1000$

25$
Programmation

100$
Tests
unitaires

250$

Tests
fonctionnels

Tests
système

Après
sortie
1. jlq
ie
2. fjf
...
p. 3

p. 8
Toutes les
histoires
possibles
Toutes les
histoires
possibles

Toutes les
histoires
du livre
Toutes les
histoires
possibles

Toutes les
histoires
plausibles

Toutes les
histoires
du livre
Toutes les
histoires
possibles

Toutes les
histoires
plausibles

Toutes les
histoires
du livre
Combien d'histoires possibles ?
Combien d'histoires possibles ?
1

2
Combien d'histoires possibles ?
1

2

2

1
Combien d'histoires possibles ?
1

2

2

1

1

2

3
Combien d'histoires possibles ?
1

2

1

2

3

2

1

1

3

2
Combien d'histoires possibles ?
1

2

1

2

3

2

1

1

3

2

2

1

3
Combien d'histoires possibles ?
1

2

1

2

3

2

1

1

3

2

2

1

3

2

3

1
Combien d'histoires possibles ?
1

2

1

2

3

2

1

1

3

2

2

1

3

2

3

1

3

1

2
Combien d'histoires possibles ?
1

2

1

2

3

2

1

1

3

2

2

1

3

2

3

1

3

1

2

3

2

1
Histoires

Combien d'histoires possibles ?

1

2

3
Pages

4

5
Histoires

Combien d'histoires possibles ?

1

1

2

3
Pages

4

5
Histoires

Combien d'histoires possibles ?

1

1

2

2

3
Pages

4

5
Histoires

Combien d'histoires possibles ?

6
1

1

2

2

3
Pages

4

5
Histoires

Combien d'histoires possibles ?

6
1

1

24

2

2

3
Pages

4

5
Histoires

Combien d'histoires possibles ?

6
1

1

24

120

4

5

2

2

3
Pages
Histoires

Combien d'histoires possibles ?

6
1

1

24

120

4

5

2

2

3
Pages
LEM
7500 lignes
LEM
7500 lignes

Chevy Volt
10 000 000 lignes
LEM
7500 lignes
Windows 7
50 000 000 lignes

Chevy Volt
10 000 000 lignes
Windows 7
50 000 000 lignes

Chevy Volt
10 000 000 lignes
Windows 7
50 000 000 lignes
10 km
1 km/h

10 km

1 km/h
1 km/h

10 km

2 km/h

1 km/h
1 km/h

10 km

2 km/h

1 km/h
2M$
ains @
1 km/h 2 tr
10 km
2 km/h

1 km/h
2M$
ains @
1 km/h 2 tr
10 km
20M$
rails @
2 km/h

1 km/h
2M$
ains @
1 km/h 2 tr
10 km
20M$
rails @
3.90$
rgot @
esca
2 km/h

1 km/h
2M$
ains @
1 km/h 2 tr
10 km
20M$
rails @
. _ 0$
3_9___
rg_ot _@__
esca _ __ __
____ 2 km/h 0$
003.9
4 000
2

1 km/h
Position train 1 = 1 x t
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Moment de l'impact ?
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Moment de l'impact ?
1 x t = 10 - (1 x t)
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Moment de l'impact ?
1 x t = 10 - (1 x t)
2 x t = 10
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Moment de l'impact ?
1 x t = 10 - (1 x t)
2 x t = 10
t=5
Position train 1 = 1 x t
Position train 2 = 10 - (1 x t)
Moment de l'impact ?
1 x t = 10 - (1 x t)
2 x t = 10
t=5
Distance escargot: 2 x 5 = 10 km
MATH

S
E

E
Logique
mathematique

E

E
Logique
mathematique

E

E

Combinatoire
des mots
Logique
mathematique

E

E

Combinatoire
des mots
Theorie des
graphes
Un jeu mathématique

On vous po
se le problè
me suivant:
Si le train a
rrive en ret
ard et qu'il
pas de taxis
n'y a
à la gare, a
lors Jean ar
en retard à
rive
son rendezvous.
Jean n'est p
as en retard
à son rende
vous.
zLe train est
arrivé en re
tard.

?

Y avait-il d
es taxis
à la gare?

Sylvain Hallé - 8INF958 Spécification, test et vérification
Le 'calculus ratiocinator'
Dès 1665, Leibniz imagine un langage universel, la
lingua characteristica universalis, qui vise à...
Représenter toutes les
choses sujettes au
raisonnement
Établir des liens entre elles
au moyen d'un calcul de la
raison

Gottfried Wilhelm
Leibniz
(1646-1716)
Sylvain Hallé - 8INF958 Spécification, test et vérification
Le 'calculus ratiocinator'
« Alors, il ne sera plus
besoin entre deux
philosophes de discussions
plus longues qu'entre deux
mathématiciens, puisqu'il
suffira qu'ils saisissent leur
plume, qu'ils s'asseyent à
leur table de calcul (en
faisant appel, s'ils le
souhaitent, à un ami) et
qu'ils se disent l'un à
l'autre : « Calculons ! »

Gottfried Wilhelm
Leibniz
(1646-1716)

Sylvain Hallé - 8INF958 Spécification, test et vérification
Quelques définitions
Donnons à chaque affirmation élémentaire un symbole:

p
q
r

Le train est en retard
Il y a des taxis à la gare
Jean arrive en retard à son rendez-vous
Variables propositionnelles

Chacune de ces variables peut prendre l'une ou l'autre
de deux valeurs possibles:
Vrai (aussi noté V, 1, ⊤)
Faux (aussi noté F, 0, ⊥)

Sylvain Hallé - 8INF958 Spécification, test et vérification
Quelques définitions
Chacune des données du problème est un énoncé liant
certaines affirmations élémentaires au moyen de
connecteurs logiques
∧
∨
→
↔
¬

Conjonction (et)
Disjonction (ou)
Implication (si ... alors ...)
Équivalence (... si et seulement si ...)
Négation (non)

Sylvain Hallé - 8INF958 Spécification, test et vérification
Quelques définitions
On peut donc écrire symboliquement chacun des
énoncés de l'énigme:
Si l'avion arrive en retard et qu'il n'y a pas de taxis à
la gare, alors Jean arrive en retard à son rendez-vous
(p ∧ ¬q) → r
Jean n'est pas arrivé en retard à son rendez-vous
¬r
L'avion est arrivé en retard
p

Sylvain Hallé - 8INF958 Spécification, test et vérification
Comment résoudre le problème?
L'énigme a été réduite au problème symbolique suivant:
Étant donné que...
(p ∧ ¬q) → r
¬r
p
...sont vraies, peut-on conclure que q est vraie?
Comment peut-on le trouver?

Sylvain Hallé - 8INF958 Spécification, test et vérification
Valuation
Une valuation est une fonction ν qui affecte exactement
une valeur à chaque variable propositionnelle
Exemple: ν(p) = ⊤, ν(q) = ⊤, ν(r) = ⊥
On peut calculer la valuation d'une expression composée
à partir de la valuation de ses opérandes. Si φ et ψ sont
des expressions dont la valuation est connue, alors...
ν(φ ∧ ψ) = ⊤ lorsque ν(φ) = ν(ψ) = ⊤, sinon ⊥
ν(φ ∨ ψ) = ⊥ lorsque ν(φ) = ν(ψ) = ⊥, sinon ⊤
ν(φ → ψ) = ⊥ lorsque ν(φ) = ⊤ et ν(ψ) = ⊥, sinon ⊤
ν(φ ↔ ψ) = ⊤ lorsque ν(φ) = ν(ψ), sinon ⊥
ν(¬φ) = ⊤ lorsque ν(φ) = ⊥, et vice versa

Sylvain Hallé - 8INF958 Spécification, test et vérification
Modèle
Si φ est une expression et ν une valuation telle que
ν(φ) = ⊤, on dit que ν satisfait φ, ce que l'on peut écrire
ν⊨φ
Dans ce cas, on dit aussi que ν est un modèle de φ.
Exercice
1. Si l'on utilise n variables propositionnelles,
combien de valuations différentes peut-on créer?
2. Combien y a-t-il de modèles des expressions...
a) p ∨ q
b) (p ∧ q) → ¬p
Sylvain Hallé - 8INF958 Spécification, test et vérification
Table de vérité
On peut calculer la valeur d'une expression pour toutes
les valuations possibles au moyen d'une table de vérité

p q (p ∧ q) → ¬p
⊥
⊥
⊤
⊤

⊥
⊤
⊥
⊤

Sylvain Hallé - 8INF958 Spécification, test et vérification
Table de vérité
On peut calculer la valeur d'une expression pour toutes
les valuations possibles au moyen d'une table de vérité

p q (p ∧ q) → ¬p
⊥
⊥
⊤
⊤

⊥
⊤
⊥
⊤

⊥
⊥
⊥
⊤

Sylvain Hallé - 8INF958 Spécification, test et vérification
Table de vérité
On peut calculer la valeur d'une expression pour toutes
les valuations possibles au moyen d'une table de vérité

p q (p ∧ q) → ¬p
⊥
⊥
⊤
⊤

⊥
⊤
⊥
⊤

⊥
⊥
⊥
⊤

⊤
⊤
⊥
⊥

Sylvain Hallé - 8INF958 Spécification, test et vérification
Table de vérité
On peut calculer la valeur d'une expression pour toutes
les valuations possibles au moyen d'une table de vérité

p q (p ∧ q) → ¬p
⊥
⊥
⊤
⊤

⊥
⊤
⊥
⊤

⊥
⊥
⊥
⊤

⊥
⊥
⊥
⊥

⊤
⊤
⊥
⊥

Sylvain Hallé - 8INF958 Spécification, test et vérification
Conséquence logique
Pour résumer:
1. Les énoncés du problème
original ont été
formalisés en un ensemble
d'énoncés logiques

On vous po
se le problè
me suivant:
Si le train ar
rive en reta
rd et qu'il n'
pas de taxis
ya
à la gare, al
ors Jean arri
en retard à
ve
son rendez-v
ous.
Jean n'est pa
s en retard
à son rendez
vous.
Le train est
arrivé en re
tard.
Y avait-il de
s taxis
?
à la gare?

A = {(p ∧ ¬q) → r, ¬r, p}
2. On cherche maintenant à déterminer si la question
posée (q) est une conséquence logique de A, ou
autrement dit, à savoir si...
A⊨q

Sylvain Hallé - 8INF958 Spécification, test et vérification
Satisfaisabilité
Une expression φ est dite satisfaisable lorsque qu'il
existe au moins une valuation ν telle que ν ⊨ φ
...autrement dit, il existe un "monde" dans lequel
φ est vraie
On peut se convaincre que φ est satisfaisable si et
seulement si ¬φ n'est pas une tautologie
Problème de la satisfaisabilité (SAT)
Étant donné une expression φ, trouver une valuation
ν telle que ν ⊨ φ

Sylvain Hallé - 8INF958 Spécification, test et vérification
Qui a tué tante Agatha?
Quelqu'un vivant au Manoir a tué tante Agatha.
Agatha, le maître d'hôtel et Charles sont les seuls à
vivre au Manoir.
Un tueur déteste toujours sa victime, et n'est jamais
plus riche que celle-ci.
Charles ne déteste personne que tante Agatha déteste.
Agatha déteste tout le monde sauf le maître d'hôtel.
Le maître d'hôtel déteste tous ceux qui ne sont pas
plus riches que tante Agatha.
Le maître d'hôtel déteste tous ceux que tante Agatha
déteste.
Personne ne déteste tout le monde.

Sylvain Hallé - 8INF958 Spécification, test et vérification
Modélisation propositionnelle
Une modélisation du problème en logique
propositionnelle est peu commode
Beaucoup de variables
Beaucoup de formules répétées pour chaque variable
Et si on ajoute un individu au Manoir?
Peut-on faire mieux?

Sylvain Hallé - 8INF958 Spécification, test et vérification
Éléments
Le problème précédent concerne un certain nombre
d'éléments...
E = {Agatha, Maître d'hôtel, Charles}
...et donne une liste de faits à propos de ces éléments.
Par exemple:
"Tante Agatha est la victime"
"Tante Agatha déteste tout le monde, sauf le maître
d'hôtel"

Sylvain Hallé - 8INF958 Spécification, test et vérification
Prédicat
Un prédicat p est une fonction prenant des éléments en
entrée et retournant ⊤ ou ⊥. Formellement, on écrit:
n

arité du prédicat

p : E → {⊤,⊥}
Exemples:
prédicat d'arité 1 (unaire)
victime(__)
assassin(__)
prédicats d'arité 2 (binaires)
déteste(__, __)
plusRicheQue(__, __)

Intuitivement, un prédicat est une affirmation à propos
d'un ou plusieurs éléments

Sylvain Hallé - 8INF958 Spécification, test et vérification
Prédicat
Puisqu'un prédicat retourne toujours ⊤ ou ⊥, on peut
combiner les prédicats en utilisant les connecteurs de la
logique propositionnelle:
victime(Agatha)
assassin(Charles) → plusRicheQue(Agatha, Charles)
déteste(Agatha, Maître d'hôtel) ∨ assassin(Agatha)
Problème: que fait-on d'une affirmation comme
"Un assassin déteste toujours sa victime" ?

Sylvain Hallé - 8INF958 Spécification, test et vérification
Prédicat
Méthode #1 (façon propositionnelle): énumérer les cas
possibles
((assassin(Agatha) ∧ victime(Charles))
→ déteste(Agatha, Charles))
∧
((assassin(Charles) ∧ victime(Agatha))
→ déteste(Charles, Agatha))
∧
...
Peu commode...

Sylvain Hallé - 8INF958 Spécification, test et vérification
Quantificateurs
Méthode #2: utiliser des quantificateurs
∀x : ∀y : (assassin(x) ∧ victime(y)) → déteste(x,y)
"pour tout x (pris dans l'ensemble E)"

Intuitivement, si E = {a, b, c, ..., k}, alors
∀x : φ ≡ φ[x/a] ∧ φ[x/b] ∧ ... ∧ φ[x/k]
où φ[x/a] est l'expression φ dans laquelle on a remplacé
tous les x par a
Ex.: ∀x : assassin(x) ≡ assassin(Agatha) ∧
assassin(Charles) ∧ assassin(Maître d'hôtel)
Sylvain Hallé - 8INF958 Spécification, test et vérification
Vérification
automatique
Exemple 1
Gestion des réseaux
Ne pas appuyer
sur
si
est allumé
Ne pas appuyer
sur
si
est allumé

Actionner en même
temps
et
Ne pas appuyer
sur
si
est allumé

Actionner en même
temps
et

Actionner seulement
si
indique 2
NON
Un
seul!

Tjrs
>2
X
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...

ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.6 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.4 remote-as 100
...
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...

ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.6 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.4 remote-as 100
...
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...

ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.6 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.4 remote-as 100
...
ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.4 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.6 remote-as 100
...

ip vrf Customer_A
rd 100:110
route-target export 100:1000
route-target import 100:1000
!
ip vrf Customer_B
rd 100:120
route-target export 100:2000
route-target import 100:2000
!
interface Loopback0
ip address 10.10.10.6 255.255.255.255
ip router isis
!
interface Loopback101
ip vrf forwarding Customer_A
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
interface Loopback102
ip vrf forwarding Customer_B
ip address 200.0.4.1 255.255.255.0
no ip directed-broadcast
!
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.4 remote-as 100
...
∀s₁ ∈ /DeviceName :
∀s₂ ∈ /DeviceName :
∀v₁ ∈ /DeviceName/s₁/ip-vrf :
∀v₂ ∈ /DeviceName/s₂/ip-vrf :
v₁=v₂ → (
∃r₁ ∈ /DeviceName/s₁/ip-vrf/v₁/rd :
∃r₂ ∈ /DeviceName/s₁/ip-vrf/v₂/rd :
r₁=r₂)
1
438

2
1
438

2
329 = 17
√
329 = 17
√
17
x 17
329 = 17
√
17
x 17
329 = 17
√
4

17
x 17
9
329 = 17
√
4

17
x 17
9
329 = 17
√
4

17
x 17
119
329 = 17
√
17
x 17
119
329 = 17
√
17
x 17
119
7
329 = 17
√
17
x 17
119
7
329 = 17
√
17
x 17
119
17
329 = 17
√
17
x 17
119
+17
329 = 17
√
17
x 17
119
+17
9
329 = 17
√
17
x 17
119
+17
9
329 = 17
√
17
x 17
119
+17
89
329 = 17
√
17
x 17
119
+17
89
329 = 17
√
17
x 17
119
+17
289
329 = 17
X
√
17
x 17
119
+17
289
?
√329 = 17
?
√329 = 17
19 étapes
?
√329 = 17
19 étapes

√329

=?
?
√329 = 17
19 étapes

√329

=?
64 étapes
|
|
|
|

Nombre d'étapes

80
60
40
20
0

0

|
|
|
|
|
200 400 600 800 1000
Nombre à calculer

?
√329 = 17
19 étapes

√329

=?
64 étapes
|
|
|

Vérifier

|

Nombre d'étapes

80
60
40
20
0

0

|
|
|
|
|
200 400 600 800 1000
Nombre à calculer

?
√329 = 17
19 étapes

√329

=?
64 étapes
|
|
|

80
60
40
20
0

Vérifier

|

Nombre d'étapes

Calculer

0

|
|
|
|
|
200 400 600 800 1000
Nombre à calculer

?
√329 = 17
19 étapes

√329

=?
64 étapes
|
|
|

80
60
40
20
0

0

}

4x

Vérifier

|

Nombre d'étapes

Calculer

|
|
|
|
|
200 400 600 800 1000
Nombre à calculer

?
√329 = 17
19 étapes

√329

=?
64 étapes
|
|

Vérifier

|

Complexité

|

Calculer

|

|

|

|

Taille du problème

|
|
|

Vérifier

|

Complexité

|

Calculer

|

|

|

|

Taille du problème

|
|
|
|

Vérifier

|

Complexité

}

Calculer

|

|

|

|

Taille du problème

|

!!!
Complexité
Étant donné une expression à n variables, toutes les
méthodes vues jusqu'ici ont une complexité en pire cas
de l'ordre de 2n
Théorème (Cook, 1971)
Le problème SAT est un problème
NP-complet.
Conséquence: on ne sait pas
à l'heure actuelle s'il existe un
algorithme SAT dont le pire
cas serait inférieur à O(2n )
Si oui, alors P=NP !

Stephen A. Cook
(1939-)

Sylvain Hallé - 8INF958 Spécification, test et vérification
Ajax web application
Cloud computing

Sylvain Hallé
Ajax web application
Cloud computing

JavaScript

Sylvain Hallé
Ajax web application
Cloud computing

eG
Be es
atl
Be el
am n
C
va
ara
C

Sylvain Hallé
Ajax web application
Cloud computing

<a onclick="javascript:
findBand(’Beatles’)">

eG
Be es
atl
Be el
am n
C
va
ara
C

Sylvain Hallé
Ajax web application
Cloud computing

findBand(’Beatles’)

Sylvain Hallé
Ajax web application
Cloud computing

findBand(’Beatles’)

Sylvain Hallé
Ajax web application
Cloud computing

artist
=beatles

findBand(’Beatles’)

Sylvain Hallé
Ajax web application
Cloud computing

artist
=beatles

findBand(’Beatles’)

Sylvain Hallé
Ajax web application
Cloud computing

artist
=beatles

document.innerHTML =

Sylvain Hallé

findBand(’Beatles’)
Ajax web application
Cloud computing

artist
=beatles

document.innerHTML =

C
Page is updated,
not reloaded

Sylvain Hallé

findBand(’Beatles’)
Ajax web application
Cloud computing

artist
=beatles

document.innerHTML =

C
Server response only provides
updated contents

Sylvain Hallé

findBand(’Beatles’)
Ajax web application
Cloud computing

<Search>
<Artist>
beatles
</Artist>
</Search>

Does not need
to be a URL
Does not need
to be HTML

<SearchResults>
<Item>
<Artist>
The Beatles
</Artist>
<Title>
Rubber Soul
</Title>
</Item>
...
</SearchResults>
Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing

Sylvain Hallé
Conceptually...
Cloud computing
Web service

Sylvain Hallé

Web client
Main issue
Not like traditional programming: all
input-output is exchanged unverified!

Possible mismatch
between messages sent
and messages expected
Sylvain Hallé
Interface contracts
All possible sequences
of all possibles messages
with all possible values

Sylvain Hallé
Interface contracts

Constraints
on individual
messages

Sylvain Hallé
Interface contracts

Constraints
on individual
messages

Sylvain Hallé

Constraints
on sequences
Interface contracts

Data-aware
sequential constraints

Constraints
on individual
messages

Sylvain Hallé

Constraints
on sequences
Interface contracts
Interface contract =
valid (error-free) interactions
Data-aware
sequential constraints

Constraints
on individual
messages

Sylvain Hallé

Constraints
on sequences
Three types of constraints (I)
Constraints on individual messages
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

Examples:

Sylvain Hallé
Three types of constraints (I)
Constraints on individual messages
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

Examples:

1. The element Page must be an integer between 1 and 20."
/M

Sylvain Hallé
Three types of constraints (I)
Constraints on individual messages
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

Examples:

1. The element Page must be an integer between 1 and 20."
/M
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.
Sylvain Hallé
Expressing data constraints
Simple XPath
Fetches portions of an XML document according to a
query path = sequence of tags

V

pM ®
: Q ´2
Examples:
p ’’, m) = {1,2,4}
(‘‘/a/b/c
p ’’, m) = Æ
(‘‘/a/b/d
Sylvain Hallé

{

M: set of messages
Q: set of XML query paths
V: set of atomic values

<a>
<b>
<c>1</c>
<c>2</c>
</b>
<d>
<c>9</c>
</d>
<b>
<c>3</c>
</b>
</a>

m
Expressing data constraints
XPath term
Expresses properties over values fetched by XPath expressions

p
"Û v Î
(x)
j
(q,m)
q x : j (v) for every
p
$ Û vÎ
(x)
j
(q,m)
q x : j (v) for some
Examples:
"x < 5
/a/b/c x :
$
/a/b x :
$ : "y £
x
/a/b/c x
/a/b/c y :
Sylvain Hallé

<a>
<b>
<c>1</c>
<c>2</c>
</b>
<d>
<c>9</c>
</d>
<b>
<c>3</c>
</b>
</a>

{

Q,
M, path
For some message m Î q Î

m

2
Expressing data constraints
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

1. The element Page must be an integer between 1 and 20."
/M
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.
Sylvain Hallé

2
Expressing data constraints
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

1. " x : x > 0 Ù
x < 21
/Message/Page
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.
Sylvain Hallé

2
Expressing data constraints
<Message>
<Action>ItemSearch</Action>
<Results>5</Results>
<Keyword>beatles</Keyword>
<Page>1</Page>
</Message>

1. " x : x > 0 Ù
x < 21
/Message/Page
2. $
/Message/Page x :

Sylvain Hallé

Û
$
/Message/Results y :

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Examples:

Sylvain Hallé

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Examples:
3. The Login request cannot be resent if its response is"
/
successful."
/
.

Sylvain Hallé

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Examples:
3. The Login request cannot be resent if its response is"
/
successful."
/
.

4. CartCreate must follow a successful LoginResponse."
/
Sylvain Hallé

2
Linear Temporal Logic

Alphabet (A)
Set of possible messages

Trace (A*)
Sequence of messages

Sylvain Hallé
Linear Temporal Logic
LTL formula
Ga
Xa
Fa
aWb

= assertion on the sequence of states in a trace
"always a"
"a in the next"
"eventually a"
"a until b"

A B A C D C B E

G (a ®
X b) FALSE
Sylvain Hallé

...

ØW c
(d Ú
e)

TRUE
Linear Temporal Logic
Well-known results:

1. For every LTL formula jexists a Büchi automaton A j
, there
such that for every (infinite) trace s
:

s sj
| j L(A )
= Û
Î
-regular
i.e. LTL describes w languages
2. The alphabet symbols can be generalized to finite sets of
Boolean propositions
Þ
Let’s use XPath terms as our Boolean propositions

Sylvain Hallé
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Examples:
3. The Login request cannot be resent if its response is"
/
successful."
/
.

4. CartCreate must follow a successful LoginResponse."
/
Sylvain Hallé

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Examples:
3. G ("
/Message/Action a : a = LoginResponse ®
(X G "
Login))
/Message/Action a’ : a’ ¹
.

4. CartCreate must follow a successful LoginResponse."
/
Sylvain Hallé

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

Examples:

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Xpath terms

3. G ("
/Message/Action a : a = LoginResponse ®
(X G "
Login))
/Message/Action a’ : a’ ¹
.

4. CartCreate must follow a successful LoginResponse."
/
Sylvain Hallé

2
Three types of constraints (II)
Constraints on message sequences
<Message>
<Action>
LoginResponse
</Action>
...
</Message>

Examples:

X

<Message>
<Action>
Login
</Action>
...
</Message>

<Message>
<Action>
CartCreate
</Action>
...
</Message>

Xpath terms

3. G ("
/Message/Action a : a = LoginResponse ®
(X G "
Login))
/Message/Action a’ : a’ ¹
.

4. ("
CartCreate)
/Message/Action a : a ¹
W ("
LoginResponse)
/Message/Action a’ : a’ =
Sylvain Hallé

2
Three types of constraints (III)
Data-aware sequential constraints
<Message>
<SessionKey>123</SessionKey>
<CartId>789</CartId>
...
</Message>

<Message>
<SessionKey>123</SessionKey>
<CartId>789</CartId>
...
</Message>

Examples:

5. There can be at most one active cart ID per session key."
/

Sylvain Hallé

2
Three types of constraints (III)
Data-aware sequential constraints
<Message>
<SessionKey>123</SessionKey>
<CartId>789</CartId>
...
</Message>

<Message>
<SessionKey>123</SessionKey>
<CartId>789</CartId>
...
</Message>

Examples:
5. G ("
/Message/SessionKey k : "
/Message/CartId c :
G ("
/Message/SessionKey k’ : "
/Message/CartId c’ :
k = k’ ®
c = c’))

Sylvain Hallé

2
Three types of constraints (III)
Data-aware sequential constraints
<Message>
<Action>CartAdd</Action>
<Items>
<Item>
<ItemId>567</ItemId>
...

Examples:

<Message>
<Action>CartAdd</Action>
<Items>
<Item>
<ItemId>567</ItemId>
...

X

6. You cannot add the same item twice to the shopping cart."
/

Sylvain Hallé

2
Three types of constraints (III)
Data-aware sequential constraints
<Message>
<Action>CartAdd</Action>
<Items>
<Item>
<ItemId>567</ItemId>
...

Examples:

<Message>
<Action>CartAdd</Action>
<Items>
<Item>
<ItemId>567</ItemId>
...

X

6. G ("
/Message/Action a : a = CartAdd ®
"
/Message/ItemId i : X G ("
/Message/Action a’ :
a’ = CartAdd ® i’ : i ¹
"
i’ ))
/Message/ItemId
Sylvain Hallé

2
Six constraints for the Beep Store

Constraints on individual messages

Constraints on message sequences

Data-aware constraints

Sylvain Hallé
Six constraints for the Beep Store
1. The element Page must be an integer between 1 and 20.
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.

Constraints on message sequences

Data-aware constraints

Sylvain Hallé
Six constraints for the Beep Store
1. The element Page must be an integer between 1 and 20.
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.
3. The Login request cannot be resent if its response is
successful.
4. CartCreate must follow a successful LoginResponse.

Data-aware constraints

Sylvain Hallé
Six constraints for the Beep Store
1. The element Page must be an integer between 1 and 20.
2. The element Page is mandatory only if Results is present,
otherwise it is forbidden.
3. The Login request cannot be resent if its response is
successful.
4. CartCreate must follow a successful LoginResponse.
5. There can be at most one active cart ID per session key.
6. You cannot add the same item twice to the shopping cart.
Sylvain Hallé
System
System
Instrumentation

System
Instrumentation

System
Instrumentation
Trace

System
Instrumentation
Trace

Events

System
Instrumentation
Trace

Events

System
Trace
validation

Instrumentation
Trace

Events

System
Instrumentation

System
Instrumentation

Runtime monitoring

System
Instrumentation

Runtime monitoring

System
Instrumentation

Runtime monitoring

Overhead

System
Définition
Runtime monitoring
Étude du design d'outils pour observer et analyser un
système pendant son exécution.
Usages possibles:
Testing/débogage
Sécurité et détection d'intrusions
Protection contre les fautes/pannes
Compréhension de programmes
Plusieurs noms: runtime verification, runtime checking,
dynamic analysis, trace analysis, fault protection, ...

Sylvain Hallé - 8INF958 Spécification, test et vérification
Composantes
Structure de base d'un système de runtime monitoring:

Spécification
Système cible

Événement

État
interne

Moniteur
Senseur

Verdict
Réaction
(facultatif)
Sylvain Hallé - 8INF958 Spécification, test et vérification
Enforcing interface contracts at runtime

XMLHttpRequest

·
JavaScript object
·
Provided by the browser
·
All communications to monitor
already centralized: ‘‘no’’
instrumentation
Sylvain Hallé
Enforcing interface contracts at runtime
XMLHttpRequestBB

Sylvain Hallé
Enforcing interface contracts at runtime
XMLHttpRequestBB

XMLHttpRequest

· around original
Wrapper
· same methods
Provides
· messages before
Checks
relaying them
Sylvain Hallé

LTL-FO+
algorithm
Add BeepBeep to an application
Copy BeepBeep
? in the application's directory
http://beepbeep.sourceforge.net

Include BeepBeep

myapplication.html
<html>
<head>
<title>My Application
</title>
<script type="text/javascript"
href="myapplication.js"/>
</head>
<body>
...
</body>
</html>

Sylvain Hallé
Add BeepBeep to an application
Copy BeepBeep
? in the application's directory
http://beepbeep.sourceforge.net

Include BeepBeep

myapplication.html
<html>
<head>
<title>My Application
</title>
<script type="text/javascript"
href="myapplication.js"/>
<script type="text/javascript"
href="beepbeep.js"/>
</head>
<body>
...
</body>
</html>

Sylvain Hallé
Add BeepBeep to an application
Copy BeepBeep
? in the application's directory
http://beepbeep.sourceforge.net

Include BeepBeep

myapplication.html
<html>
<head>
<title>My Application
</title>
<script type="text/javascript"
href="myapplication.js"/>
<script type="text/javascript"
href="beepbeep.js"/>
</head>
<body>
...
</body>
</html>

Sylvain Hallé

myapplication.js
// Initializations
...
req = new XMLHttpRequest();
...
function abc()
{
...
req.send(some_message);
}
Add BeepBeep to an application
Copy BeepBeep
? in the application's directory
http://beepbeep.sourceforge.net

Include BeepBeep

beepstore.html
<html>
<head>
<title>My Application
</title>
<script type="text/javascript"
href="myapplication.js"/>
<script type="text/javascript"
href="beepbeep.js"/>
</head>
<body>
...
</body>
</html>

Sylvain Hallé

beepstore.js
// Initializations
...
req = new XMLHttpRequestBB();
...
function abc()
{
...
req.send(some_message);
}
Add BeepBeep to an application
Create a contract
? file with LTL-FO+ formulas
# ------------------------------------------------------# BeepBeep contract file for the Beep Store
# ------------------------------------------------------% The element Page must be an integer between 1 and 20.
; G ([p /Message/Page] (((p) > ({0})) & ((p) < ({21}))))
% The element Page is mandatory only if Results is
present, otherwise it is forbidden.
; G ([a /Message/Action] (((a) = ({ItemSearch})) -> (
((<r /Message/Results> ({TRUE})) ->
(<p /Message/Page> ({TRUE}))) &
((<p /Message/Page> ({TRUE})) -> (
<r /Message/Results> ({TRUE}))))))
% The Login request cannot be resent if its response
is successful.
; G ([a /Message/Action] (((a) = ({LoginResponse})) ->
(X (G ([b /Message/Action] (!((b) = ({Login}))))))))

Sylvain Hallé

}

Caption: used
when violations
are discovered
Plain-text
LTL-FO+
(automatically
parsed)
Add BeepBeep to an application
When loading
 the application, BeepBeep starts as a small
Java applet inside the page
The
Beep
Store

Sign in or register
Search:

Search results for ‘Beatles’

What is this?
Login

Rubber Soul
The Beatles

Ask for account
Contact us
Fault parameters

Yellow Submarine
The Beatles

?/?/?/?/?/?:0:0

Sylvain Hallé

GO

Your Cart
Add BeepBeep to an application
When loading
 the application, BeepBeep starts as a small
Java applet inside the page
The
Beep
Store

Sign in or register
Search:

Search results for ‘Beatles’

What is this?
Login

Rubber Soul
The Beatles

Ask for account
Contact us
Fault parameters

?/?/?/?/?/?:0:0

Sylvain Hallé

Yellow Submarine
The Beatles

GO

Your Cart
BeepBeep’s visible interface

?/?/?/?/?/?:0:0
Current state of monitor
for each property
T:
t:
F:
f:
?:

last message made it true
is true
last message made it false
is false
not yet true/false

Sylvain Hallé

Number of
messages
processed

Cumulative
processing
time (in ms)
On ne peut réussir un niveau sans sauter au moins
une fois
F action = jump
20
Mario ne peut jamais sauter d'une hauteur
supérieure à 20
G (action = jump → height < 20)
X
Si Mario se penche, il ne peut pas sauter tout de
suite après
G (action = crouch → X action ≠ jump)
X
Mario ne peut jamais entrer en collision avec un
ennemi lorsqu'il tient une carapace
G (action = haveShell → X action ≠ collision)
ou mieux
G (action = haveShell →
(action ≠ collision U action = dropShell))
Deux derniers événements
État des moniteurs
Surcharge CPU
COVERSTORY

Verified software
My computer won’t fail me
Web-browser crashes are annoying, but as far as software malfunctions go, the
consequences are mild. With a plane’s autopilot or the control room of a nuclear power
station, it’s another matter. As our lives become ever more saturated with computers,
how can we know they won’t fail? Currently, we systematically test all conceivable
scenarios under which they might. A better insurance might be logic. [...]

32 | New Scientist | 16 October 2010

À la chasse aux bugs avec la Laboratoire d'informatique formelle

  • 1.
    À la chasseaux bugs avec le Laboratoire d'informatique formelle Les mathématiques au service de l'assurance-qualité
  • 2.
  • 8.
  • 9.
  • 11.
  • 13.
  • 15.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
    ? Basé sur la compréhension dutesteur Pas exhaustif ? T ES T M. Long…
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
    % de bugsintroduits 85% Programmation Tests unitaires Tests fonctionnels Tests système Après sortie
  • 43.
    % de bugsintroduits % de bugs trouvés 85% Programmation Tests unitaires Tests fonctionnels Tests système Après sortie
  • 44.
    % de bugsintroduits % de bugs trouvés coût de réparation 16 000$ 85% 1000$ 25$ Programmation 100$ Tests unitaires 250$ Tests fonctionnels Tests système Après sortie
  • 46.
  • 48.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
    Combien d'histoires possibles? 1 2 1 2 3 2 1 1 3 2
  • 59.
    Combien d'histoires possibles? 1 2 1 2 3 2 1 1 3 2 2 1 3
  • 60.
    Combien d'histoires possibles? 1 2 1 2 3 2 1 1 3 2 2 1 3 2 3 1
  • 61.
    Combien d'histoires possibles? 1 2 1 2 3 2 1 1 3 2 2 1 3 2 3 1 3 1 2
  • 62.
    Combien d'histoires possibles? 1 2 1 2 3 2 1 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
    Histoires Combien d'histoires possibles? 6 1 1 24 2 2 3 Pages 4 5
  • 68.
    Histoires Combien d'histoires possibles? 6 1 1 24 120 4 5 2 2 3 Pages
  • 69.
    Histoires Combien d'histoires possibles? 6 1 1 24 120 4 5 2 2 3 Pages
  • 71.
  • 72.
  • 73.
    LEM 7500 lignes Windows 7 50000 000 lignes Chevy Volt 10 000 000 lignes
  • 74.
    Windows 7 50 000000 lignes Chevy Volt 10 000 000 lignes
  • 75.
    Windows 7 50 000000 lignes
  • 80.
  • 81.
  • 82.
    1 km/h 10 km 2km/h 1 km/h
  • 83.
    1 km/h 10 km 2km/h 1 km/h
  • 84.
    2M$ ains @ 1 km/h2 tr 10 km 2 km/h 1 km/h
  • 85.
    2M$ ains @ 1 km/h2 tr 10 km 20M$ rails @ 2 km/h 1 km/h
  • 86.
    2M$ ains @ 1 km/h2 tr 10 km 20M$ rails @ 3.90$ rgot @ esca 2 km/h 1 km/h
  • 87.
    2M$ ains @ 1 km/h2 tr 10 km 20M$ rails @ . _ 0$ 3_9___ rg_ot _@__ esca _ __ __ ____ 2 km/h 0$ 003.9 4 000 2 1 km/h
  • 89.
  • 90.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t)
  • 91.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t) Moment de l'impact ?
  • 92.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t) Moment de l'impact ? 1 x t = 10 - (1 x t)
  • 93.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t) Moment de l'impact ? 1 x t = 10 - (1 x t) 2 x t = 10
  • 94.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t) Moment de l'impact ? 1 x t = 10 - (1 x t) 2 x t = 10 t=5
  • 95.
    Position train 1= 1 x t Position train 2 = 10 - (1 x t) Moment de l'impact ? 1 x t = 10 - (1 x t) 2 x t = 10 t=5 Distance escargot: 2 x 5 = 10 km
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
    Un jeu mathématique Onvous po se le problè me suivant: Si le train a rrive en ret ard et qu'il pas de taxis n'y a à la gare, a lors Jean ar en retard à rive son rendezvous. Jean n'est p as en retard à son rende vous. zLe train est arrivé en re tard. ? Y avait-il d es taxis à la gare? Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 102.
    Le 'calculus ratiocinator' Dès1665, Leibniz imagine un langage universel, la lingua characteristica universalis, qui vise à... Représenter toutes les choses sujettes au raisonnement Établir des liens entre elles au moyen d'un calcul de la raison Gottfried Wilhelm Leibniz (1646-1716) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 103.
    Le 'calculus ratiocinator' «Alors, il ne sera plus besoin entre deux philosophes de discussions plus longues qu'entre deux mathématiciens, puisqu'il suffira qu'ils saisissent leur plume, qu'ils s'asseyent à leur table de calcul (en faisant appel, s'ils le souhaitent, à un ami) et qu'ils se disent l'un à l'autre : « Calculons ! » Gottfried Wilhelm Leibniz (1646-1716) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 104.
    Quelques définitions Donnons àchaque affirmation élémentaire un symbole: p q r Le train est en retard Il y a des taxis à la gare Jean arrive en retard à son rendez-vous Variables propositionnelles Chacune de ces variables peut prendre l'une ou l'autre de deux valeurs possibles: Vrai (aussi noté V, 1, ⊤) Faux (aussi noté F, 0, ⊥) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 105.
    Quelques définitions Chacune desdonnées du problème est un énoncé liant certaines affirmations élémentaires au moyen de connecteurs logiques ∧ ∨ → ↔ ¬ Conjonction (et) Disjonction (ou) Implication (si ... alors ...) Équivalence (... si et seulement si ...) Négation (non) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 106.
    Quelques définitions On peutdonc écrire symboliquement chacun des énoncés de l'énigme: Si l'avion arrive en retard et qu'il n'y a pas de taxis à la gare, alors Jean arrive en retard à son rendez-vous (p ∧ ¬q) → r Jean n'est pas arrivé en retard à son rendez-vous ¬r L'avion est arrivé en retard p Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 107.
    Comment résoudre leproblème? L'énigme a été réduite au problème symbolique suivant: Étant donné que... (p ∧ ¬q) → r ¬r p ...sont vraies, peut-on conclure que q est vraie? Comment peut-on le trouver? Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 108.
    Valuation Une valuation estune fonction ν qui affecte exactement une valeur à chaque variable propositionnelle Exemple: ν(p) = ⊤, ν(q) = ⊤, ν(r) = ⊥ On peut calculer la valuation d'une expression composée à partir de la valuation de ses opérandes. Si φ et ψ sont des expressions dont la valuation est connue, alors... ν(φ ∧ ψ) = ⊤ lorsque ν(φ) = ν(ψ) = ⊤, sinon ⊥ ν(φ ∨ ψ) = ⊥ lorsque ν(φ) = ν(ψ) = ⊥, sinon ⊤ ν(φ → ψ) = ⊥ lorsque ν(φ) = ⊤ et ν(ψ) = ⊥, sinon ⊤ ν(φ ↔ ψ) = ⊤ lorsque ν(φ) = ν(ψ), sinon ⊥ ν(¬φ) = ⊤ lorsque ν(φ) = ⊥, et vice versa Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 109.
    Modèle Si φ estune expression et ν une valuation telle que ν(φ) = ⊤, on dit que ν satisfait φ, ce que l'on peut écrire ν⊨φ Dans ce cas, on dit aussi que ν est un modèle de φ. Exercice 1. Si l'on utilise n variables propositionnelles, combien de valuations différentes peut-on créer? 2. Combien y a-t-il de modèles des expressions... a) p ∨ q b) (p ∧ q) → ¬p Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 110.
    Table de vérité Onpeut calculer la valeur d'une expression pour toutes les valuations possibles au moyen d'une table de vérité p q (p ∧ q) → ¬p ⊥ ⊥ ⊤ ⊤ ⊥ ⊤ ⊥ ⊤ Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 111.
    Table de vérité Onpeut calculer la valeur d'une expression pour toutes les valuations possibles au moyen d'une table de vérité p q (p ∧ q) → ¬p ⊥ ⊥ ⊤ ⊤ ⊥ ⊤ ⊥ ⊤ ⊥ ⊥ ⊥ ⊤ Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 112.
    Table de vérité Onpeut calculer la valeur d'une expression pour toutes les valuations possibles au moyen d'une table de vérité p q (p ∧ q) → ¬p ⊥ ⊥ ⊤ ⊤ ⊥ ⊤ ⊥ ⊤ ⊥ ⊥ ⊥ ⊤ ⊤ ⊤ ⊥ ⊥ Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 113.
    Table de vérité Onpeut calculer la valeur d'une expression pour toutes les valuations possibles au moyen d'une table de vérité p q (p ∧ q) → ¬p ⊥ ⊥ ⊤ ⊤ ⊥ ⊤ ⊥ ⊤ ⊥ ⊥ ⊥ ⊤ ⊥ ⊥ ⊥ ⊥ ⊤ ⊤ ⊥ ⊥ Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 114.
    Conséquence logique Pour résumer: 1.Les énoncés du problème original ont été formalisés en un ensemble d'énoncés logiques On vous po se le problè me suivant: Si le train ar rive en reta rd et qu'il n' pas de taxis ya à la gare, al ors Jean arri en retard à ve son rendez-v ous. Jean n'est pa s en retard à son rendez vous. Le train est arrivé en re tard. Y avait-il de s taxis ? à la gare? A = {(p ∧ ¬q) → r, ¬r, p} 2. On cherche maintenant à déterminer si la question posée (q) est une conséquence logique de A, ou autrement dit, à savoir si... A⊨q Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 115.
    Satisfaisabilité Une expression φest dite satisfaisable lorsque qu'il existe au moins une valuation ν telle que ν ⊨ φ ...autrement dit, il existe un "monde" dans lequel φ est vraie On peut se convaincre que φ est satisfaisable si et seulement si ¬φ n'est pas une tautologie Problème de la satisfaisabilité (SAT) Étant donné une expression φ, trouver une valuation ν telle que ν ⊨ φ Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 116.
    Qui a tuétante Agatha? Quelqu'un vivant au Manoir a tué tante Agatha. Agatha, le maître d'hôtel et Charles sont les seuls à vivre au Manoir. Un tueur déteste toujours sa victime, et n'est jamais plus riche que celle-ci. Charles ne déteste personne que tante Agatha déteste. Agatha déteste tout le monde sauf le maître d'hôtel. Le maître d'hôtel déteste tous ceux qui ne sont pas plus riches que tante Agatha. Le maître d'hôtel déteste tous ceux que tante Agatha déteste. Personne ne déteste tout le monde. Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 117.
    Modélisation propositionnelle Une modélisationdu problème en logique propositionnelle est peu commode Beaucoup de variables Beaucoup de formules répétées pour chaque variable Et si on ajoute un individu au Manoir? Peut-on faire mieux? Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 118.
    Éléments Le problème précédentconcerne un certain nombre d'éléments... E = {Agatha, Maître d'hôtel, Charles} ...et donne une liste de faits à propos de ces éléments. Par exemple: "Tante Agatha est la victime" "Tante Agatha déteste tout le monde, sauf le maître d'hôtel" Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 119.
    Prédicat Un prédicat pest une fonction prenant des éléments en entrée et retournant ⊤ ou ⊥. Formellement, on écrit: n arité du prédicat p : E → {⊤,⊥} Exemples: prédicat d'arité 1 (unaire) victime(__) assassin(__) prédicats d'arité 2 (binaires) déteste(__, __) plusRicheQue(__, __) Intuitivement, un prédicat est une affirmation à propos d'un ou plusieurs éléments Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 120.
    Prédicat Puisqu'un prédicat retournetoujours ⊤ ou ⊥, on peut combiner les prédicats en utilisant les connecteurs de la logique propositionnelle: victime(Agatha) assassin(Charles) → plusRicheQue(Agatha, Charles) déteste(Agatha, Maître d'hôtel) ∨ assassin(Agatha) Problème: que fait-on d'une affirmation comme "Un assassin déteste toujours sa victime" ? Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 121.
    Prédicat Méthode #1 (façonpropositionnelle): énumérer les cas possibles ((assassin(Agatha) ∧ victime(Charles)) → déteste(Agatha, Charles)) ∧ ((assassin(Charles) ∧ victime(Agatha)) → déteste(Charles, Agatha)) ∧ ... Peu commode... Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 122.
    Quantificateurs Méthode #2: utiliserdes quantificateurs ∀x : ∀y : (assassin(x) ∧ victime(y)) → déteste(x,y) "pour tout x (pris dans l'ensemble E)" Intuitivement, si E = {a, b, c, ..., k}, alors ∀x : φ ≡ φ[x/a] ∧ φ[x/b] ∧ ... ∧ φ[x/k] où φ[x/a] est l'expression φ dans laquelle on a remplacé tous les x par a Ex.: ∀x : assassin(x) ≡ assassin(Agatha) ∧ assassin(Charles) ∧ assassin(Maître d'hôtel) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 123.
  • 124.
  • 126.
  • 127.
    Ne pas appuyer sur si estallumé Actionner en même temps et
  • 128.
    Ne pas appuyer sur si estallumé Actionner en même temps et Actionner seulement si indique 2
  • 131.
  • 133.
  • 136.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ...
  • 137.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ...
  • 138.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ... ip vrf Customer_A rd 100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.6 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.4 remote-as 100 ...
  • 139.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ... ip vrf Customer_A rd 100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.6 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.4 remote-as 100 ...
  • 140.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ... ip vrf Customer_A rd 100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.6 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.4 remote-as 100 ...
  • 141.
    ip vrf Customer_A rd100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.4 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.6 remote-as 100 ... ip vrf Customer_A rd 100:110 route-target export 100:1000 route-target import 100:1000 ! ip vrf Customer_B rd 100:120 route-target export 100:2000 route-target import 100:2000 ! interface Loopback0 ip address 10.10.10.6 255.255.255.255 ip router isis ! interface Loopback101 ip vrf forwarding Customer_A ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! interface Loopback102 ip vrf forwarding Customer_B ip address 200.0.4.1 255.255.255.0 no ip directed-broadcast ! router bgp 100 bgp log-neighbor-changes neighbor 10.10.10.4 remote-as 100 ...
  • 142.
    ∀s₁ ∈ /DeviceName: ∀s₂ ∈ /DeviceName : ∀v₁ ∈ /DeviceName/s₁/ip-vrf : ∀v₂ ∈ /DeviceName/s₂/ip-vrf : v₁=v₂ → ( ∃r₁ ∈ /DeviceName/s₁/ip-vrf/v₁/rd : ∃r₂ ∈ /DeviceName/s₁/ip-vrf/v₂/rd : r₁=r₂)
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
    329 = 17 √ 17 x17 119 +17 9
  • 158.
    329 = 17 √ 17 x17 119 +17 9
  • 159.
    329 = 17 √ 17 x17 119 +17 89
  • 160.
    329 = 17 √ 17 x17 119 +17 89
  • 161.
    329 = 17 √ 17 x17 119 +17 289
  • 162.
    329 = 17 X √ 17 x17 119 +17 289
  • 163.
  • 164.
  • 165.
    ? √329 = 17 19étapes √329 =?
  • 166.
    ? √329 = 17 19étapes √329 =? 64 étapes
  • 167.
    | | | | Nombre d'étapes 80 60 40 20 0 0 | | | | | 200 400600 800 1000 Nombre à calculer ? √329 = 17 19 étapes √329 =? 64 étapes
  • 168.
    | | | Vérifier | Nombre d'étapes 80 60 40 20 0 0 | | | | | 200 400600 800 1000 Nombre à calculer ? √329 = 17 19 étapes √329 =? 64 étapes
  • 169.
    | | | 80 60 40 20 0 Vérifier | Nombre d'étapes Calculer 0 | | | | | 200 400600 800 1000 Nombre à calculer ? √329 = 17 19 étapes √329 =? 64 étapes
  • 170.
    | | | 80 60 40 20 0 0 } 4x Vérifier | Nombre d'étapes Calculer | | | | | 200 400600 800 1000 Nombre à calculer ? √329 = 17 19 étapes √329 =? 64 étapes
  • 171.
  • 172.
  • 173.
  • 174.
    Complexité Étant donné uneexpression à n variables, toutes les méthodes vues jusqu'ici ont une complexité en pire cas de l'ordre de 2n Théorème (Cook, 1971) Le problème SAT est un problème NP-complet. Conséquence: on ne sait pas à l'heure actuelle s'il existe un algorithme SAT dont le pire cas serait inférieur à O(2n ) Si oui, alors P=NP ! Stephen A. Cook (1939-) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 175.
    Ajax web application Cloudcomputing Sylvain Hallé
  • 176.
    Ajax web application Cloudcomputing JavaScript Sylvain Hallé
  • 177.
    Ajax web application Cloudcomputing eG Be es atl Be el am n C va ara C Sylvain Hallé
  • 178.
    Ajax web application Cloudcomputing <a onclick="javascript: findBand(’Beatles’)"> eG Be es atl Be el am n C va ara C Sylvain Hallé
  • 179.
    Ajax web application Cloudcomputing findBand(’Beatles’) Sylvain Hallé
  • 180.
    Ajax web application Cloudcomputing findBand(’Beatles’) Sylvain Hallé
  • 181.
    Ajax web application Cloudcomputing artist =beatles findBand(’Beatles’) Sylvain Hallé
  • 182.
    Ajax web application Cloudcomputing artist =beatles findBand(’Beatles’) Sylvain Hallé
  • 183.
    Ajax web application Cloudcomputing artist =beatles document.innerHTML = Sylvain Hallé findBand(’Beatles’)
  • 184.
    Ajax web application Cloudcomputing artist =beatles document.innerHTML = C Page is updated, not reloaded Sylvain Hallé findBand(’Beatles’)
  • 185.
    Ajax web application Cloudcomputing artist =beatles document.innerHTML = C Server response only provides updated contents Sylvain Hallé findBand(’Beatles’)
  • 186.
    Ajax web application Cloudcomputing <Search> <Artist> beatles </Artist> </Search> Does not need to be a URL Does not need to be HTML <SearchResults> <Item> <Artist> The Beatles </Artist> <Title> Rubber Soul </Title> </Item> ... </SearchResults> Sylvain Hallé
  • 187.
  • 188.
  • 189.
  • 190.
  • 191.
  • 192.
  • 193.
  • 194.
    Main issue Not liketraditional programming: all input-output is exchanged unverified! Possible mismatch between messages sent and messages expected Sylvain Hallé
  • 195.
    Interface contracts All possiblesequences of all possibles messages with all possible values Sylvain Hallé
  • 196.
  • 197.
  • 198.
    Interface contracts Data-aware sequential constraints Constraints onindividual messages Sylvain Hallé Constraints on sequences
  • 199.
    Interface contracts Interface contract= valid (error-free) interactions Data-aware sequential constraints Constraints on individual messages Sylvain Hallé Constraints on sequences
  • 200.
    Three types ofconstraints (I) Constraints on individual messages <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> Examples: Sylvain Hallé
  • 201.
    Three types ofconstraints (I) Constraints on individual messages <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> Examples: 1. The element Page must be an integer between 1 and 20." /M Sylvain Hallé
  • 202.
    Three types ofconstraints (I) Constraints on individual messages <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> Examples: 1. The element Page must be an integer between 1 and 20." /M 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. Sylvain Hallé
  • 203.
    Expressing data constraints SimpleXPath Fetches portions of an XML document according to a query path = sequence of tags V pM ® : Q ´2 Examples: p ’’, m) = {1,2,4} (‘‘/a/b/c p ’’, m) = Æ (‘‘/a/b/d Sylvain Hallé { M: set of messages Q: set of XML query paths V: set of atomic values <a> <b> <c>1</c> <c>2</c> </b> <d> <c>9</c> </d> <b> <c>3</c> </b> </a> m
  • 204.
    Expressing data constraints XPathterm Expresses properties over values fetched by XPath expressions p "Û v Î (x) j (q,m) q x : j (v) for every p $ Û vÎ (x) j (q,m) q x : j (v) for some Examples: "x < 5 /a/b/c x : $ /a/b x : $ : "y £ x /a/b/c x /a/b/c y : Sylvain Hallé <a> <b> <c>1</c> <c>2</c> </b> <d> <c>9</c> </d> <b> <c>3</c> </b> </a> { Q, M, path For some message m Î q Î m 2
  • 205.
    Expressing data constraints <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> 1.The element Page must be an integer between 1 and 20." /M 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. Sylvain Hallé 2
  • 206.
    Expressing data constraints <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> 1." x : x > 0 Ù x < 21 /Message/Page 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. Sylvain Hallé 2
  • 207.
    Expressing data constraints <Message> <Action>ItemSearch</Action> <Results>5</Results> <Keyword>beatles</Keyword> <Page>1</Page> </Message> 1." x : x > 0 Ù x < 21 /Message/Page 2. $ /Message/Page x : Sylvain Hallé Û $ /Message/Results y : 2
  • 208.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Examples: Sylvain Hallé 2
  • 209.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Examples: 3. The Login request cannot be resent if its response is" / successful." / . Sylvain Hallé 2
  • 210.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Examples: 3. The Login request cannot be resent if its response is" / successful." / . 4. CartCreate must follow a successful LoginResponse." / Sylvain Hallé 2
  • 211.
    Linear Temporal Logic Alphabet(A) Set of possible messages Trace (A*) Sequence of messages Sylvain Hallé
  • 212.
    Linear Temporal Logic LTLformula Ga Xa Fa aWb = assertion on the sequence of states in a trace "always a" "a in the next" "eventually a" "a until b" A B A C D C B E G (a ® X b) FALSE Sylvain Hallé ... ØW c (d Ú e) TRUE
  • 213.
    Linear Temporal Logic Well-knownresults: 1. For every LTL formula jexists a Büchi automaton A j , there such that for every (infinite) trace s : s sj | j L(A ) = Û Î -regular i.e. LTL describes w languages 2. The alphabet symbols can be generalized to finite sets of Boolean propositions Þ Let’s use XPath terms as our Boolean propositions Sylvain Hallé
  • 214.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Examples: 3. The Login request cannot be resent if its response is" / successful." / . 4. CartCreate must follow a successful LoginResponse." / Sylvain Hallé 2
  • 215.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Examples: 3. G (" /Message/Action a : a = LoginResponse ® (X G " Login)) /Message/Action a’ : a’ ¹ . 4. CartCreate must follow a successful LoginResponse." / Sylvain Hallé 2
  • 216.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> Examples: X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Xpath terms 3. G (" /Message/Action a : a = LoginResponse ® (X G " Login)) /Message/Action a’ : a’ ¹ . 4. CartCreate must follow a successful LoginResponse." / Sylvain Hallé 2
  • 217.
    Three types ofconstraints (II) Constraints on message sequences <Message> <Action> LoginResponse </Action> ... </Message> Examples: X <Message> <Action> Login </Action> ... </Message> <Message> <Action> CartCreate </Action> ... </Message> Xpath terms 3. G (" /Message/Action a : a = LoginResponse ® (X G " Login)) /Message/Action a’ : a’ ¹ . 4. (" CartCreate) /Message/Action a : a ¹ W (" LoginResponse) /Message/Action a’ : a’ = Sylvain Hallé 2
  • 218.
    Three types ofconstraints (III) Data-aware sequential constraints <Message> <SessionKey>123</SessionKey> <CartId>789</CartId> ... </Message> <Message> <SessionKey>123</SessionKey> <CartId>789</CartId> ... </Message> Examples: 5. There can be at most one active cart ID per session key." / Sylvain Hallé 2
  • 219.
    Three types ofconstraints (III) Data-aware sequential constraints <Message> <SessionKey>123</SessionKey> <CartId>789</CartId> ... </Message> <Message> <SessionKey>123</SessionKey> <CartId>789</CartId> ... </Message> Examples: 5. G (" /Message/SessionKey k : " /Message/CartId c : G (" /Message/SessionKey k’ : " /Message/CartId c’ : k = k’ ® c = c’)) Sylvain Hallé 2
  • 220.
    Three types ofconstraints (III) Data-aware sequential constraints <Message> <Action>CartAdd</Action> <Items> <Item> <ItemId>567</ItemId> ... Examples: <Message> <Action>CartAdd</Action> <Items> <Item> <ItemId>567</ItemId> ... X 6. You cannot add the same item twice to the shopping cart." / Sylvain Hallé 2
  • 221.
    Three types ofconstraints (III) Data-aware sequential constraints <Message> <Action>CartAdd</Action> <Items> <Item> <ItemId>567</ItemId> ... Examples: <Message> <Action>CartAdd</Action> <Items> <Item> <ItemId>567</ItemId> ... X 6. G (" /Message/Action a : a = CartAdd ® " /Message/ItemId i : X G (" /Message/Action a’ : a’ = CartAdd ® i’ : i ¹ " i’ )) /Message/ItemId Sylvain Hallé 2
  • 222.
    Six constraints forthe Beep Store Constraints on individual messages Constraints on message sequences Data-aware constraints Sylvain Hallé
  • 223.
    Six constraints forthe Beep Store 1. The element Page must be an integer between 1 and 20. 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. Constraints on message sequences Data-aware constraints Sylvain Hallé
  • 224.
    Six constraints forthe Beep Store 1. The element Page must be an integer between 1 and 20. 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. 3. The Login request cannot be resent if its response is successful. 4. CartCreate must follow a successful LoginResponse. Data-aware constraints Sylvain Hallé
  • 225.
    Six constraints forthe Beep Store 1. The element Page must be an integer between 1 and 20. 2. The element Page is mandatory only if Results is present, otherwise it is forbidden. 3. The Login request cannot be resent if its response is successful. 4. CartCreate must follow a successful LoginResponse. 5. There can be at most one active cart ID per session key. 6. You cannot add the same item twice to the shopping cart. Sylvain Hallé
  • 227.
  • 228.
  • 229.
  • 230.
  • 231.
  • 232.
  • 233.
  • 234.
  • 235.
  • 236.
  • 237.
  • 238.
  • 239.
    Définition Runtime monitoring Étude dudesign d'outils pour observer et analyser un système pendant son exécution. Usages possibles: Testing/débogage Sécurité et détection d'intrusions Protection contre les fautes/pannes Compréhension de programmes Plusieurs noms: runtime verification, runtime checking, dynamic analysis, trace analysis, fault protection, ... Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 240.
    Composantes Structure de based'un système de runtime monitoring: Spécification Système cible Événement État interne Moniteur Senseur Verdict Réaction (facultatif) Sylvain Hallé - 8INF958 Spécification, test et vérification
  • 241.
    Enforcing interface contractsat runtime XMLHttpRequest · JavaScript object · Provided by the browser · All communications to monitor already centralized: ‘‘no’’ instrumentation Sylvain Hallé
  • 242.
    Enforcing interface contractsat runtime XMLHttpRequestBB Sylvain Hallé
  • 243.
    Enforcing interface contractsat runtime XMLHttpRequestBB XMLHttpRequest · around original Wrapper · same methods Provides · messages before Checks relaying them Sylvain Hallé LTL-FO+ algorithm
  • 244.
    Add BeepBeep toan application Copy BeepBeep ? in the application's directory http://beepbeep.sourceforge.net Include BeepBeep  myapplication.html <html> <head> <title>My Application </title> <script type="text/javascript" href="myapplication.js"/> </head> <body> ... </body> </html> Sylvain Hallé
  • 245.
    Add BeepBeep toan application Copy BeepBeep ? in the application's directory http://beepbeep.sourceforge.net Include BeepBeep  myapplication.html <html> <head> <title>My Application </title> <script type="text/javascript" href="myapplication.js"/> <script type="text/javascript" href="beepbeep.js"/> </head> <body> ... </body> </html> Sylvain Hallé
  • 246.
    Add BeepBeep toan application Copy BeepBeep ? in the application's directory http://beepbeep.sourceforge.net Include BeepBeep  myapplication.html <html> <head> <title>My Application </title> <script type="text/javascript" href="myapplication.js"/> <script type="text/javascript" href="beepbeep.js"/> </head> <body> ... </body> </html> Sylvain Hallé myapplication.js // Initializations ... req = new XMLHttpRequest(); ... function abc() { ... req.send(some_message); }
  • 247.
    Add BeepBeep toan application Copy BeepBeep ? in the application's directory http://beepbeep.sourceforge.net Include BeepBeep  beepstore.html <html> <head> <title>My Application </title> <script type="text/javascript" href="myapplication.js"/> <script type="text/javascript" href="beepbeep.js"/> </head> <body> ... </body> </html> Sylvain Hallé beepstore.js // Initializations ... req = new XMLHttpRequestBB(); ... function abc() { ... req.send(some_message); }
  • 248.
    Add BeepBeep toan application Create a contract ? file with LTL-FO+ formulas # ------------------------------------------------------# BeepBeep contract file for the Beep Store # ------------------------------------------------------% The element Page must be an integer between 1 and 20. ; G ([p /Message/Page] (((p) > ({0})) & ((p) < ({21})))) % The element Page is mandatory only if Results is present, otherwise it is forbidden. ; G ([a /Message/Action] (((a) = ({ItemSearch})) -> ( ((<r /Message/Results> ({TRUE})) -> (<p /Message/Page> ({TRUE}))) & ((<p /Message/Page> ({TRUE})) -> ( <r /Message/Results> ({TRUE})))))) % The Login request cannot be resent if its response is successful. ; G ([a /Message/Action] (((a) = ({LoginResponse})) -> (X (G ([b /Message/Action] (!((b) = ({Login})))))))) Sylvain Hallé } Caption: used when violations are discovered Plain-text LTL-FO+ (automatically parsed)
  • 249.
    Add BeepBeep toan application When loading  the application, BeepBeep starts as a small Java applet inside the page The Beep Store Sign in or register Search: Search results for ‘Beatles’ What is this? Login Rubber Soul The Beatles Ask for account Contact us Fault parameters Yellow Submarine The Beatles ?/?/?/?/?/?:0:0 Sylvain Hallé GO Your Cart
  • 250.
    Add BeepBeep toan application When loading  the application, BeepBeep starts as a small Java applet inside the page The Beep Store Sign in or register Search: Search results for ‘Beatles’ What is this? Login Rubber Soul The Beatles Ask for account Contact us Fault parameters ?/?/?/?/?/?:0:0 Sylvain Hallé Yellow Submarine The Beatles GO Your Cart
  • 251.
    BeepBeep’s visible interface ?/?/?/?/?/?:0:0 Currentstate of monitor for each property T: t: F: f: ?: last message made it true is true last message made it false is false not yet true/false Sylvain Hallé Number of messages processed Cumulative processing time (in ms)
  • 253.
    On ne peutréussir un niveau sans sauter au moins une fois F action = jump
  • 254.
    20 Mario ne peutjamais sauter d'une hauteur supérieure à 20 G (action = jump → height < 20)
  • 255.
    X Si Mario sepenche, il ne peut pas sauter tout de suite après G (action = crouch → X action ≠ jump)
  • 256.
    X Mario ne peutjamais entrer en collision avec un ennemi lorsqu'il tient une carapace G (action = haveShell → X action ≠ collision) ou mieux G (action = haveShell → (action ≠ collision U action = dropShell))
  • 258.
  • 259.
  • 260.
  • 262.
    COVERSTORY Verified software My computerwon’t fail me Web-browser crashes are annoying, but as far as software malfunctions go, the consequences are mild. With a plane’s autopilot or the control room of a nuclear power station, it’s another matter. As our lives become ever more saturated with computers, how can we know they won’t fail? Currently, we systematically test all conceivable scenarios under which they might. A better insurance might be logic. [...] 32 | New Scientist | 16 October 2010