2009: j paul gibsont&msp-csc 4504 : langages formels et applicationsevent-b/famille.1 csc 4504 :...

43
2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille. 1 CSC 4504 : Langages formels et applications (La méthode Event-B) J Paul Gibson, A207 [email protected] ://www-public.it-sudparis.eu/~gibson/Teaching/Event Famille ://www-public.it-sudparis.eu/~gibson/Teaching/Event-B/Famille

Upload: internet

Post on 03-Apr-2015

114 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.1

CSC 4504 : Langages formels et applications

(La méthode Event-B)

J Paul Gibson, A207

[email protected]

http://www-public.it-sudparis.eu/~gibson/Teaching/Event-B/

Famille

http://www-public.it-sudparis.eu/~gibson/Teaching/Event-B/Famille.pdf

Page 2: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.2

Page 3: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.3

Page 4: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.4

Page 5: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.5

wizards

Page 6: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.6

ASCII

hommes <: P

Page 7: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.7

ASCII Representations of the Mathematical Symbols

Atomic Symbols

http://www.b-core.com/ONLINEDOC/ASCIISymbols.html

Page 8: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.8

ASCII Representations of the Mathematical Symbols

Unary Operators

Page 9: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.9

ASCII Representations of the Mathematical Symbols

Unary Operators

Assignment Operators

Page 10: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.10

ASCII Representations of the Mathematical Symbols

Binary Operators

Page 11: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.11

ASCII Representations of the Mathematical Symbols

Quantifiers

Page 12: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.12

Exemples

Page 13: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.13

Les relations:

Page 14: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.14

Exemples

Page 15: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.15

Les relations:

Page 16: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.16

Exemples

Page 17: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.17

Les fonctions:

Page 18: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.18

Bijection, injection and surjectionFrom Wikipedia, the free encyclopedia

Page 19: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.19

hommes femmes

P

Preuve d'un théorème

Page 20: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.20

Use the Event-B Keyboard (view) for editing complex expressions

! per. not ( per : P & not(per : hommes) & not (per : femmes))

Page 21: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.21

thm1 Proven Automatically √ Proving

Comment?

Page 22: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.22

Open perspective•Event-B•Proving•….Choose theorem

Page 23: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.23

hommes femmes

P

Partial injection

ASCII - epoux : femmes >+> hommes

Specification: Epoux

Page 24: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.24

hommes femmes

P

Partial injection

ASCII - epouse: hommes >+> femmes

Specification: Epouse

Page 25: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.25

hommes femmes

P

Partial injection

ASCII - epoux : femmes >+> hommes epouse: hommes >+> femmes

Epoux-Epouse: Attention!

Partial injection

Page 26: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.26

Problème: Theorem - epouse = epoux~ - n’est pas vrai

ASCII: epouse = epoux~ -1SYMBOL: epouse = epoux

Page 27: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.27

Le prouveur n’est pas content

Problème: Theorem - epouse = epoux~ - n’est pas vrai

Page 28: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.28

hommes femmes

P

Partial injection

ASCII - AXIOM epoux : femmes >+> hommes AXIOM epouse = epoux~

Specification: Epoux-Epouse - Corrigé

Page 29: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.29

Specification: Epoux/Epouse - Verification/Test

Page 30: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.30

Specification: Famille_ctx0 - Version finale

Pourquoi pas la transformer en pdf (en utilisant plugin B2latex)?

Page 31: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.31

Specification: Famille_ctx0 - Version finale

B2Latex

Page 32: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.32

Latex generated as

<contextnameDate>.tex

Convert to .pdf (using, eg, MiKTeX)

\documentclass[10pt,a4paper]{report}\usepackage[top=3cm, bottom=2.5cm, left=3cm, right=2.5cm] {geometry}\usepackage {bsymb,b2latex}\usepackage{fancyhdr,lastpage}\lhead{\rm An Event-B Specification of Famille\_ctx0}\rhead {\rm Page \thepage~of \pageref{LastPage}}\lfoot{}\cfoot{}\rfoot{}\pagestyle{fancy}%---------------------------------------------------------\begin{document}\thispagestyle{empty}\begin{description}\BTitle{Famille\_ctx0}{3 Mar 2009}{02:00:30 PM}\CONTEXT{Famille\_ctx0}\SETS

\begin{description}\Item{ P }

\end{description}\CONSTANTS

\begin{description}\Item{ hommes }\Item{ femmes }\Item{ epoux }\Item{ epouse }\Item{ f }\Item{ ff }\Item{ h }\Item{ hh }

\end{description}\AXIOMS

\begin{description}\nItem{ axm\_hommes }{ hommes \subseteq P }\nItem{ axm\_femmes }{ femmes = P\setminus hommes }\nItem{ axm\_epoux }{ epoux \in femmes \pinj hommes }\nItem{ axm\_epouse }{ epouse = epoux^{-1} }\nItem{ axm\_fhffhh }{ f\in femmes \land h\in hommes \land ff\in femmes \land hh\in

hommes }\end{description}

\THEOREMS\begin{description}

\nItem{ thm\_test\_axm\_femmes }{ \forall per\qdot \lnot ( per\in P \land \lnot (per \in hommes) \land \lnot (per \in femmes)) }

\nItem{ thm\_epouxepouse }{ epoux = epoux; epouse; epoux }\nItem{ thm\_test\_epouse1 }{ \lnot (hh=h) \land \lnot (ff=f) \land epoux = \{ f\mapsto h,

ff\mapsto hh\} \limp epouse(hh) = ff }\nItem{ thm\_test\_epouse2 }{ \lnot (hh=h) \land \lnot (ff=f) \land epoux = \{ f\mapsto h,

ff\mapsto hh\} \limp epouse(h) = f }\end{description}

\END\end{description}\end{document}

Page 33: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.33

Specification: Famille_ctx0.pdf

Page 34: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.34

Specification: Married - Famille_ctx1 extends Famille_ctx0

thm3 « married is a partial injection »

Prover cannot prove it automatically Should we add it as an axiom?

Page 35: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.35

Specification: Married - Famille_ctx1 extends Famille_ctx0

Page 36: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.36

Travaux Pratique (Context)– a completer (avant le 13)

Define:

•mere et pere•fille et fils•frere et soeur•cousin •oncle et tante

Validate Theorems, eg:

•oncle = cousin; pere•cousin = cousin~•pere; enfants = mere; enfants•pere; mere~ = {}•pere; frere; fille <: cousin

Before we look at the prover we first look (quickly) at Machines …

Page 37: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.37

Machine Famile_M0

Page 38: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.38

Machine Famile_M0

Page 39: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.39

Machine Famile_M0

event marry respects the invariant

Page 40: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.40

Machine Famile_M0

h1 h6 h7 h8 h9h4 h5h3h2

f1 f2 f3 f4 f5 f6 f7 f8

hommes

femmes

epoux

hms = {}

fms = {}

ep = {}

INITIALISATION: State0

add_h (h2)

hms = {h2}

fms = {}

ep = {}

State1

Page 41: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.41

Machine Famile_M0

h1 h6 h7 h8 h9h4 h5h3h2

f1 f2 f3 f4 f5 f6 f7 f8

hommes

femmes

epoux

add_f (f3)

hms = {h2}

fms = {f3}

ep = {}

State2

hms = {h2}

fms = {}

ep = {}

State1

Page 42: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.42

Machine Famile_M0

h1 h6 h7 h8 h9h4 h5h3h2

f1 f2 f3 f4 f5 f6 f7 f8

hommes

femmes

epoux

add_f (f2)

hms = {h2}

fms = {f3, f2}

ep = {}

State3

hms = {h2}

fms = {f3}

ep = {}

State2

Page 43: 2009: J Paul GibsonT&MSP-CSC 4504 : Langages formels et applicationsEvent-B/Famille.1 CSC 4504 : Langages formels et applications (La méthode Event-B)

2009: J Paul Gibson T&MSP-CSC 4504 : Langages formels et applications Event-B/Famille.43

Machine Famile_M0

h1 h6 h7 h8 h9h4 h5h3h2

f1 f2 f3 f4 f5 f6 f7 f8

hommes

femmes

epoux

hms = {h2}

fms = {f3, f2}

ep = { f3 |-> h2}State3

hms = {h2}

fms = {f3, f2}

ep = {}hms = {h2}

fms = {f3, f2}

ep = { f2 |-> h2}

marry(f3,h2)

marry(f2,h2)

X