May 16, 2017
B Method
Proof assistants Lucas Franceschino
B Method Proof assistants May 16, 2017 Lucas Franceschino What is - - PowerPoint PPT Presentation
B Method Proof assistants May 16, 2017 Lucas Franceschino What is B method? B-method goal Actual Specifications program 3 B-method goal Actual Specifications program Machine 3 B-method goal Actual Specifications
May 16, 2017
Proof assistants Lucas Franceschino
Specifications Actual program
3
Specifications Actual program
Machine
3
Specifications Actual program
Machine Refinement 1
3
Specifications Actual program
Machine Refinement 1 Refinement 2
3
Specifications Actual program
Machine Refinement 1 Refinement 2 Refinement 3
3
Specifications Actual program
Machine Refinement 1 C / ada Refinement 2 Refinement 3
3
Specifications Actual program
Machine Refinement 1 C / ada Refinement 2 Refinement 3
3
Specifications Actual program
3
Jean-Raymond Abrial
1970
Specification of data structures and programs Initiated the Z-Notation (in Oxford)
B4free, Bart, ABTools…
4
Jean-Raymond Abrial
1970
Specification of data structures and programs Initiated the Z-Notation (in Oxford)
Good for formal specifications, not for development
4
Jean-Raymond Abrial
1970
Specification of data structures and programs Initiated the Z-Notation (in Oxford)
Good for formal specifications, not for development
1996
Published “The B Book” Atelier B
B4free, Bart, ABTools…
4
Jean-Raymond Abrial
1970
Specification of data structures and programs Initiated the Z-Notation (in Oxford)
Good for formal specifications, not for development
1996
Published “The B Book” Atelier B
2010
Published “Modeling in Event-B : system and software engineering” Rodin platform
B4free, Bart, ABTools…
4
Jean-Raymond Abrial
1970
Specification of data structures and programs Initiated the Z-Notation (in Oxford)
Good for formal specifications, not for development
1996
Published “The B Book” Atelier B Was in the development team of Ada
2010
Published “Modeling in Event-B : system and software engineering” Rodin platform
B4free, Bart, ABTools…
4
Braking system, platform screen doors…
6
110 000 lines of B 87 000 lines of Ada 29 000 lemmas
7
Driverless trains Extension in 2003 80 million passengers in 2009
110 000 lines of B 87 000 lines of Ada 29 000 lemmas
7
9.2 km . October 1998 Driverless trains Extension in 2003 80 million passengers in 2009
110 000 lines of B 87 000 lines of Ada 29 000 lemmas
7
9.2 km . October 1998 No bugs discovered yet! Still in version 1.0 Driverless trains Extension in 2003 80 million passengers in 2009
110 000 lines of B 87 000 lines of Ada 29 000 lemmas
7
airbags, motor) to help building diagnostic tools
stage separations of Ariane rocket
Java runtime for smartcard
Provide safe: authentication, data storage, application processing
8
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Specification
Integration tests
Conception
Unit tests
Code Validation
10
Module: modelling of a sub system
Component
11
Module: modelling of a sub system
Component Static part Static part Definition of: Variables, constants, sets List of invariants Dynamic part Dynamic part Initialize variables Define operations on variables Pr Proo
Static part coherence Initializing preserve invariants Operations preserve invariants
11
Module: modelling of a sub system Abstract machine
Component Static part Static part Definition of: Variables, constants, sets List of invariants Dynamic part Dynamic part Initialize variables Define operations on variables Pr Proo
Static part coherence Initializing preserve invariants Operations preserve invariants
11
Module: modelling of a sub system Abstract machine Refinements
Component Static part Static part Definition of: Variables, constants, sets List of invariants Dynamic part Dynamic part Initialize variables Define operations on variables Pr Proo
Static part coherence Initializing preserve invariants Operations preserve invariants
11
Module: modelling of a sub system Abstract machine Refinements
Component Static part Static part Definition of: Variables, constants, sets List of invariants Dynamic part Dynamic part Initialize variables Define operations on variables Pr Proo
Static part coherence Initializing preserve invariants Operations preserve invariants
Implementation
11
Module: modelling of a sub system Abstract machine Refinements
Component Static part Static part Definition of: Variables, constants, sets List of invariants Dynamic part Dynamic part Initialize variables Define operations on variables Pr Proo
Static part coherence Initializing preserve invariants Operations preserve invariants
Implementation
We refine a previous component: we make it more precise and specific
11
Abstract machine Refinements Implementation
Substitutions
12
Abstract machine Refinements Implementation
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1 x : (x ∈ INT ∧ x < 20) not deterministic
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1 a := 1 || || b := 1 b := 1 || || a := 1 x : (x ∈ INT ∧ x < 20) not deterministic
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Let bindings Become such that Simultaneous operations Sequencing While loop Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1 a := 1 || || b := 1 b := 1 || || a := 1 x : (x ∈ INT ∧ x < 20) not deterministic
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Let bindings Become such that Simultaneous operations Sequencing While loop Precondition Choice Let bindings Become such that Simultaneous operations Sequencing While loop Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1 a := 1 || || b := 1 b := 1 || || a := 1 x : (x ∈ INT ∧ x < 20) not deterministic
Substitutions
12
Abstract machine Refinements Implementation
Precondition Choice Let bindings Become such that Simultaneous operations Sequencing While loop Precondition Choice Let bindings Become such that Simultaneous operations Sequencing While loop Precondition Choice Become such that Simultaneous operations Sequencing While loop Let bindings
Predicated-based IF ANY x WHERE x ∈ S a := 1 ; ; b := 1 a := 1 || || b := 1 b := 1 || || a := 1 x : (x ∈ INT ∧ x < 20) not deterministic M a k i n g p r
r a m m
e c
c r e t e
Substitutions
12
Machine Refinement Implementation Block Y Y Y Identical Y Y Y Becomes Equal Y Y Y Precondition Y Y N Assertion Y Y Y Bounded choice Y Y N IF conditional Y Y Y Conditional Bounded choice Y Y N Case Conditional Y Y Y Unbounded choice Y Y N Local Definition Y Y N Becomes Element of Y Y N Becomes such that Y Y N Local Variable N Y Y Sequencing N Y Y Operation Call Y Y Y While Loop N N Y Simultaneous Y Y N
13
14
State oriented
S1 S2
14
State oriented
S1 S2
Hoare logic
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4 / ≔
ASSIGNMENT
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4 / ≔
ASSIGNMENT
, ;
COMPOSITION
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4 / ≔
ASSIGNMENT
, ;
COMPOSITION
∧ , ∧ if then else end
CONDITIONAL
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4 / ≔
ASSIGNMENT
, ;
COMPOSITION
∧ , ∧ if then else end
CONDITIONAL
∧ while do done ∧
WHILE
14
State oriented
S1 S2
Hoare logic
2 x := x*x 4 / ≔
ASSIGNMENT
, ;
COMPOSITION
∧ , ∧ if then else end
CONDITIONAL
∧ while do done ∧
WHILE
→ , , →
CONSEQUENCE
14
15
Arithmetic
15
Arithmetic
15
Arithmetic
15
∏ ∑ Arithmetic
15
Functions and relations ∏ ∑ Arithmetic
15
Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Set comprehension, generalized union & intersections Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Records Set comprehension, generalized union & intersections Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Trees Records Set comprehension, generalized union & intersections Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Sequences Trees Records Set comprehension, generalized union & intersections Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
No algebraic data types Sequences Trees Records Set comprehension, generalized union & intersections Sets Partial / total functions, surjections, lambda, domain/range manipulations, closure, inversions… Functions and relations ∏ ∑ Arithmetic
15
Component
Abstract machine Refinements Implementation 17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...)
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ...
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ...
Prove all predicates
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ... INITIALISATION var1 := expr || var2 := expr
Prove all predicates
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ... INITIALISATION var1 := expr || var2 := expr
Prove all predicates For each initialization, prove invariant conservations
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ... INITIALISATION var1 := expr || var2 := expr OPERATIONS varOutput1 ← fun1(i1, i2, ...) = ... varOutput2 ← fun2(i1, i2, ...) = ...
Prove all predicates For each initialization, prove invariant conservations
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ... INITIALISATION var1 := expr || var2 := expr OPERATIONS varOutput1 ← fun1(i1, i2, ...) = ... varOutput2 ← fun2(i1, i2, ...) = ...
Prove all predicates For each initialization, prove invariant conservations Show each operation conserve invariants
17
Component
Abstract machine Refinements Implementation
MACHINE Name(input1, input2, ...) CONSTRAINTS input1 ∈ INT ∧ input2 ∈ INT ... CONSTANTS cst1, cst2, ... VARIABLES var1, var2, ... INVARIANT var1 + var2 ∈ {x . X**(1/2) ∈ } ∧ ... ASSERTIONS predicate1 ∧ predicate2 ∧ ... INITIALISATION var1 := expr || var2 := expr OPERATIONS varOutput1 ← fun1(i1, i2, ...) = ... varOutput2 ← fun2(i1, i2, ...) = ...
Prove all predicates For each initialization, prove invariant conservations Show each operation conserve invariants
Proof Obligations
17
18
18
18
18
18
18
18
First, expressions are normalized
19
First, expressions are normalized
1
19
First, expressions are normalized
1 S ⊆ 1,2,3 ∈ 1 ∪ 2 ∪ 3
19
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) => #x.(a & b) == (#x.a & b) THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ;
Theory files: list of rules
20
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) => #x.(a & b) == (#x.a & b) THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ;
Theory files: list of rules 10.000 lines of rules
20
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) => #x.(a & b) == (#x.a & b) THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ;
Theory files: list of rules 10.000 lines of rules User can add rules No safe core
20
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) => #x.(a & b) == (#x.a & b) THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ;
Theory files: list of rules 10.000 lines of rules User can add rules No safe core
Still, we can prove a rule before adding it
20
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ; P == btrue ;
Theory files: list of rules 10.000 lines of rules User can add rules No safe core
Still, we can prove a rule before adding it
20
Theory files: list of rules No safe core 10.000 lines of rules User can add rules
THEORY SimplifyX IS (i => (j => k)) == (i & j => k) ; (a => bfalse) == not(a) ; (bfalse => a) == btrue ; (a => btrue) == btrue ;
Automatic prover
(btrue => a) == a ; (bvrb(x)) & (x\a) => #x.a == a ; (bvrb(x)) & (x\b) P == btrue ; Still, we can prove a rule before adding it
21
Proof construction Search information Browsing proof obligations Command repetition
22
Proof construction Search information Browsing proof obligations Command repetition Repeat (rr), loop (bb)…
22
Proof construction Search information Browsing proof obligations Command repetition Back (ba), Reset (re), Next (ne), Previous (pv), Goto (go)… Repeat (rr), loop (bb)…
22
Proof construction Search information Browsing proof obligations Command repetition Back (ba), Reset (re), Next (ne), Previous (pv), Goto (go)… Repeat (rr), loop (bb)… Search rule / hypothesis / goal, show proof, reduce PO…
22
Proof construction
23
Proof construction Prover call automatic proofs & simplification
23
Proof construction Prover call automatic proofs & simplification pr
23
Proof construction Prover call automatic proofs & simplification pr ss
23
Proof construction Prover call automatic proofs & simplification Rule applications pr ss
23
Proof construction Prover call automatic proofs & simplification Rule applications pr ss ar
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms pr ss ar
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms pr ss ar eh
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms pr ss ar eh ae
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms pr ss ar eh ae 3 ∧ 3 ∈ ∧ ∈ ⇒
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms pr ss ar eh ae
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate pr ss ar eh ae
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate pr ss ar eh ae ct
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate pr ss ar eh ae ct fh
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate pr ss ar eh ae ct fh dc
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate pr ss ar eh ae ct fh dc se
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate Operations on hypothesis deduction, add hypothesis… pr ss ar eh ae ct fh dc se
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate Operations on hypothesis deduction, add hypothesis… pr ss ar eh ae ct fh dc se dd
23
Proof construction Prover call automatic proofs & simplification Rule applications Rewrite equality applications, abstract terms Inference rules contradiction, false hypothesis, cases, instantiate Operations on hypothesis deduction, add hypothesis… pr ss ar eh ae ct fh dc se dd ah
23
Two operations: reserve a seat or free a seat Data : set of seats and sub set of taken seats
25