21
CSC4504 - Formal Languages 2016: J Paul Gibson 1 Event-B (Using RODIN): First Example /~gibson/Teaching/CSC4504/Event-B-FirstExample.pdf

Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 1

Event-B (Using RODIN): First Example

/~gibson/Teaching/CSC4504/Event-B-FirstExample.pdf

Page 2: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 2

After installing RODIN and checking for updates you should have a clean workspace, which looks something like this:

A CLEAN WORKSPACE

Page 3: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 3

A NEW PROJECT

Now we wish to create a new project; and there are multiple ways of doing this (as there always is in RODIN – and Eclipse):

Here: using shortcut

New Event-B project

New Event-B project

TO DO - make a new Event-B project called “FirstExample”

Page 4: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 4

A NEW PROJECT

Page 5: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 5

Now add an Event-B Context component – SomeSets - to our project (in order to do some mathematics using set notation)

Page 6: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 6

Check that the SomeSets context is empty

Page 7: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 7

Now, try and write the following context specification … how intuitive is the RODIN user interface for beginners?

Can you explain what it means (in English)?

Use the wizards

You may need some help with the ASCII editing: http://wiki.event-b.org/images/EventB-Summary.pdf

Page 8: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 8

There is a second kind of editor/view that is popular

Right click SomeSets and select Open With Event-B context editor

This is the pretty print view of the Event-B context editor

Page 9: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 9

Use the edit view to add English comments documenting the specification

Page 10: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 10

Use the editor view to add English comments documenting the specification

NOTE: Both the different editor views get updated

Page 11: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 11

Now, can you specify that if you are male then you cannot be female

There are lots of different axioms that you could write.

Can you find one that you think is correct?

But, our specification is incomplete: it allows male and female sets to overlap

Page 12: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 12

Male ∩ Female = ∅

Female = PERSON ∖ Male

Male = PERSON \ Female

QUESTION: Are these axioms equivalent?

Let’s see using RODIN: Does Male ∩ Female = ∅ imply Female = PERSON ∖ Male

Page 13: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 13

Add Male ∩ Female = ∅ as an axiom (non theorem) Add Female = PERSON ∖ Male as a theorem

QUESTION: What do you notice about the SomeSets context properties ?

Page 14: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 14

We may have some proof obligations to discharge with the prover

If you have a theorem that is not proved you need to launch the prover view in order to discharge it.

Page 15: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 15

We can open the Proving perspective to try to prove axm5

Page 16: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 16

This shouldnt be so hard for a prover to Prove automatically

Launch PP (with all hypotheses)

Page 17: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 17

Don’t forget to save the proof

Page 18: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 18

Can you use RODIN to check equivalence of these axioms?

1. Male ∩ Female = ∅

2. Female = PERSON ∖ Male

3. Male = PERSON \ Female

We have already proven that 1 => 2

Question: what else do we need to prove?

Page 19: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 19

Let’s add some more sets to our context.

Imagine that we wish to build a context that models family relations

The types of concepts that we need are:

•Mother, •Father, •Parent, •Child, •Brother, •Sister, •Sibling, •Ancestor, •Descendant

TO DO: See how many of these you can model using just sets

Page 20: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 20

Parents – the set of people who are mothers or fathers is pretty easy, eg:

But, it is not clear how to model the other concepts (if it is indeed possible) without introducing relations between sets

Page 21: Event-B (Using RODIN): First Example - Télécom SudParisgibson/Teaching/CSC4504/... · After installing RODIN and checking for updates you should have a clean workspace, which looks

CSC4504 - Formal Languages 2016: J Paul Gibson 21

Let us return to the family in RODIN to try and model the relationships