(La méthode Event-B) Famille CSC 4504 : Langages formels et applications

Download Report

Transcript (La méthode Event-B) Famille CSC 4504 : Langages formels et applications

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
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.1
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.2
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.3
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.4
wizards
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.5
ASCII
hommes <: P
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.6
ASCII Representations of the Mathematical Symbols
http://www.b-core.com/ONLINEDOC/ASCIISymbols.html
Atomic Symbols
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.7
ASCII Representations of the Mathematical Symbols
Unary Operators
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.8
ASCII Representations of the Mathematical Symbols
Unary Operators
Assignment Operators
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.9
ASCII Representations of the Mathematical Symbols
Binary Operators
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.10
ASCII Representations of the Mathematical Symbols
Quantifiers
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.11
Exemples
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.12
Les relations:
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.13
Exemples
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.14
Les relations:
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.15
Exemples
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.16
Les fonctions:
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.17
Bijection, injection and surjection
From Wikipedia, the free encyclopedia
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.18
P
hommes
femmes
Preuve d'un théorème
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.19
Use the Event-B Keyboard (view) for editing complex expressions
! per. not ( per : P & not(per : hommes) & not (per : femmes))
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.20
Comment?
thm1 Proven Automatically
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
√
Proving
Event-B/Famille.21
Open
perspective
•Event-B
•Proving
•….
Choose theorem
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.22
Specification: Epoux
P
hommes
femmes
Partial injection
ASCII 2009: J Paul Gibson
epoux : femmes >+> hommes
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.23
Specification: Epouse
P
hommes
femmes
Partial injection
ASCII 2009: J Paul Gibson
epouse: hommes >+> femmes
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.24
Epoux-Epouse: Attention!
P
hommes
Partial injection
ASCII 2009: J Paul Gibson
femmes
Partial injection
epoux : femmes >+> hommes
epouse: hommes >+> femmes
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.25
Problème: Theorem - epouse = epoux~ - n’est pas vrai
ASCII:
2009: J Paul Gibson
epouse = epoux~
SYMBOL:
epouse = epoux -1
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.26
Problème: Theorem - epouse = epoux~ - n’est pas vrai
Le prouveur n’est pas content
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.27
Specification: Epoux-Epouse - Corrigé
P
hommes
femmes
Partial injection
ASCII 2009: J Paul Gibson
AXIOM epoux : femmes >+> hommes
AXIOM epouse = epoux~
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.28
Specification: Epoux/Epouse - Verification/Test
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.29
Specification: Famille_ctx0 - Version finale
Pourquoi pas la transformer en pdf (en utilisant plugin B2latex)?
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.30
Specification: Famille_ctx0 - Version finale
B2Latex
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.31
\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}
Latex generated as
<contextnameDate>.tex
Convert to .pdf (using, eg, MiKTeX)
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.32
Specification: Famille_ctx0.pdf
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.33
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?
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.34
Specification: Married - Famille_ctx1 extends Famille_ctx0
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.35
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:
Before we look at the prover
we first look (quickly) at
Machines …
•oncle = cousin; pere
•cousin = cousin~
•pere; enfants = mere; enfants
•pere; mere~ = {}
•pere; frere; fille <: cousin
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.36
Machine Famile_M0
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.37
Machine Famile_M0
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.38
Machine Famile_M0
event marry
respects the
invariant
2009: J Paul Gibson
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.39
Machine Famile_M0
hommes
h1
h2
h3
h4
h5
h6
h7
h8
…
epoux
f1
…
h9
f2
f3
f4
f5
f6
f8 …
f7
femmes
State1
INITIALISATION: State0
hms = {}
fms = {}
hms = {h2}
add_h (h2)
ep = {}
ep = {}
2009: J Paul Gibson
fms = {}
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.40
Machine Famile_M0
hommes
h1
h2
h3
h4
h5
h6
h7
h8
…
h9
…
epoux
f2
f1
f3
f4
f5
f6
f8 …
f7
femmes
State2
State1
hms = {h2}
hms = {h2}
fms = {}
add_f (f3)
ep = {}
ep = {}
2009: J Paul Gibson
fms = {f3}
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.41
Machine Famile_M0
hommes
h1
h2
h3
h4
h5
h6
h7
h8
h9
…
…
epoux
f2
f1
f3
f4
f5
f6
f8 …
f7
femmes
State3
State2
hms = {h2}
hms = {h2}
fms = {f3}
fms = {f3, f2}
ep = {}
2009: J Paul Gibson
add_f (f2)
ep = {}
T&MSP-CSC 4504 : Langages formels et applications
Event-B/Famille.42
Machine Famile_M0
hommes
h1
h2
h3
h4
h5
h6
h7
h8
h9
…
epoux
f2
f1
f3
f4
f5
femmes
State3
hms = {h2}
f6
f8 …
f7
hms = {h2}
marry(f3,h2)
fms = {f3, f2}
X
fms = {f3, f2}
ep = { f3 |-> h2}
hms = {h2}
ep = {}
marry(f2,h2)
2009: J Paul Gibson
…
fms = {f3, f2}
ep = { f2 |-> h2}
T&MSP-CSC 4504 : Langages formels et applications
√
Event-B/Famille.43