Difference between pages "Single View Design" and "TextEditor EBNF"

From Event-B
(Difference between pages)
Jump to navigationJump to search
imported>Maria
 
imported>PMatos
m (Note on incorrect EBNF with regards to implementation?)
 
Line 1: Line 1:
==Purpose==
+
{| align="right"
The purpose of the Single View Design is to present everything in a single view in Rodin.
+
| __TOC__
 +
|}
 +
This page describes the text syntax for Event-B models in the TextEditor. It shows its EBNF, [[#Explanation|explains]] some details and design decisions and gives some [[#Examples|examples]].
  
==Specification==
+
See the [[Text_Editor]] page for details of the editor and the usage of the text syntax.
The Single View Design uses the [http://wiki.eclipse.org/index.php/Common_Navigator_Framework Common Navigator Framework] that is provided by Eclipse.
 
  
[[Image:MasterDetails.jpg]]
+
Screenshots which give an impression of the syntax in the text editor are shown on the [[TextEditor_Screenshots| screenshot page]].
  
===The Navigator===
 
The navigator is the part on the left that contains a tree. It presents all projects and their contents. The users can choose between to ways how the machines and contexts will be presented:
 
*A simple structure where all machines and contexts are presented on the same level
 
*A complex structure where the machines and contexts are presented as a tree. Thus dependencies between machines and contexts (like ''refines'' or ''sees'') are made visible.
 
  
  
===The Details===
+
===EBNF for the TextEditor's syntax ===
The details part is situated on the right and may contain several tabs. The content of each tab may depend on the selection in the navigator. Currently the only tab that exists is the statistics tab. It is possible to add new custom tabs.
 
  
====Statistics====
+
parse_unit =
The statistics tab presents information about the state of the proof obligations of the selected node in the navigator.
+
    'machine' identifier_literal comment*
 +
    ('refines' identifier_literal (',' identifier_literal)*)?
 +
    ('sees' identifier_literal (',' identifier_literal)*)?
 +
    ('variables' identifier_list)?
 +
    ('invariants' labeled_predicate_with_theorem+)?
 +
    ('variant' variant)?
 +
    ('events' event+)?
 +
    end |
 +
   
 +
    'context' identifier_literal comment*
 +
    ('extends' identifier_literal (',' identifier_literal)*)?
 +
    ('sets' identifier_list)?
 +
    ('constants' identifier_list)?
 +
    ('axioms' labeled_predicate_with_theorem+)?
 +
    end ;
 +
 +
variant = expression comment*;
 +
 +
event =
 +
    convergence? 'event' identifier_literal comment*
 +
    event_refinement?
 +
    ('any' identifier_list)?
 +
    ('where' labeled_predicate+)?
 +
    ('with' labeled_predicate+)?
 +
    ('then' labeled_action+)? ;
 +
 +
convergence = 'ordinary' | 'convergent' | 'anticipated' ;
 +
 +
event_refinement =
 +
    'refines' identifier_literal (',' identifier_literal)* |
 +
    'extends' identifier_literal ;
 +
 +
labeled_action = '@' label action comment*;
 +
 +
labeled_predicate = '@' label predicate comment*;
 +
 +
labeled_predicate_with_theorem =
 +
    '@' label predicate comment*|
 +
    'theorem' '@' identifier_literal predicate comment*;
 +
 +
identifier = identifier_literal comment*;
 +
 +
identifier_list = identifier identifier* ;
 +
 +
comment =
 +
    '//' string-to-next-linebreak |
 +
    '/*' string '*/' ;
  
==User guide==
 
===Customizing the Navigator===
 
Click on the little triangle in the upper right corner of the navigator view and select ''Customize View''. This opens a dialog that allows you to choose ''Filters'' and ''Content''.
 
  
[[Image:Customize.jpg]]
+
'''NOTE: the EBNF above for Contexts specifies that constants come after sets. It seems to be the other way around in RODIN.'''
  
====Content====
+
===Explanation ===
Here you can choose what content should be shown in the navigator.
+
====Formulas ====
*'''Resources''': All projects, files and folder (keep this one checked!).
+
As you might notice the grammar only describes the structure of machines and contexts. For the terminals ''predicate'', ''expression'' and ''action'' you can use the syntax for formulas which you already know from editing models with the graphical Event-B editor. You can use the ASCII representation of mathematical symbols or their unicode. See the Rodin help for details about the mathematical symbols and their ASCII counterparts.
*'''Working Sets''': Allows you to see the working sets as top level elements. If you're not familiar with working sets, consult [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/cworkset.htm eclipse help].
 
*'''Simple Context Structure''': Lists all contexts of a project.
 
*'''Complex Context Structure''': Lists all contexts of a project. Contexts that extend another context are attached to it as children in the tree. Contexts that are seen by a machine are attached to the machine as children. Choose either the complex or the simple structure. It is not recommended to have both active at the same time.
 
*'''Simple Machines Structure''': Lists all machines of a project.
 
*'''Complex Context Structure''': Lists all machines of a project. Machines that refine another machine are attached to it as children in the tree. Choose either the complex or the simple structure. It is not recommended to have both active at the same time.
 
*'''Carrier Sets'''
 
*'''Constants'''
 
*'''Variables'''
 
*'''Axioms'''
 
*'''Invariants'''
 
*'''Theorems'''
 
*'''Events'''
 
*'''Proof Obligations''': All proof obligations of a machine, context, axiom, invariant, theorem or event.
 
  
Here's an example of what the same projects looks like once using the complex machine and context structure (left) and once using the simple version (right).
+
====Comments ====
 +
Also note that the rather strict position for comments is necessary. In the RodinDB most elements can be commented. That means if you comment an element this comment is attached to the element. To reflect this in a text syntax we need to exactly specify to which textual element a comment belongs. Therefore we decided to always associate a comment to the previous element.
 +
Additionally database only allows one comment per element. The grammar allows multiple comments, but to reflect the database restriction to one internally multiple comments are concatenated to one with linebreaks between the separate comments.
  
[[Image:Complex.jpg]][[Image:Simple.jpg]]
+
====Labels ====
 +
The syntax doesn't allow whitespaces within labels. It assumes that all characters following an '@' belong to the label until the next whitespace character is found.
  
====Filters====
 
The filters let you choose what to hide in the navigator.
 
*'''File extensions''': There are various filters to hide certain types of files.
 
*'''All files and folders''': Hides all files and subfolders.
 
*'''Non Rodin Projects''': Hides all non Rodin projects. Also hides closed Rodin Projects.
 
*'''Closed Projects''': Hides all closed projects.
 
  
There are some additional filters that can be found on top of the navigator:
+
===Examples ===
 +
''Feel free to add own examples!''
  
[[Image:PoFilters.JPG]]
+
=====Machine 'm0' from example 'maximum' =====
  
Enter a text into the field and only proof obligations containing the string will be shown. If you push the green button, all discharged proof obligations will be hidden.
+
See the [[TextEditor_Screenshots#Machine_.27m0.27_from_example_.27maximum.27|screenshot]] of this example or download the [http://deploy-eprints.ecs.soton.ac.uk/56/4/maximum.zip project].
  
===Statistics===
+
machine m0 sees array
The content displayed in the statistics tab depends on the selection in the navigator. Generally it shows an overview of the status of all proof obligations of the selected elements and a more detailed view below (if available). If a project is selected this means that in the overview the statistics for all proof obligations of that project are shown. In the detailed viewed each machine and context is listed with their own statistics. If you double click on an element in the detailed view, the corresponding element will be selected in the navigator.
+
 +
variables i
 +
 +
invariants
 +
  @inv1 i ∈ ℕ
 +
 +
events
 +
  event INITIALISATION
 +
    then
 +
      @act1 i :∈ ℕ
 +
  end
 +
 +
  event find_max
 +
    any j
 +
    where
 +
      @grd1 j ∈ 1‥n
 +
      @grd2 ∀k·k∈1‥n ⇒ a(k) a(j)
 +
    then
 +
      @act1 i ≔ j
 +
  end
 +
end
  
It is possible to select multiple elements in the navigator and get a combined statistics. But the selected elements must be on the same level (e.g. projects, machines/contexts). This mean if you select both machines and projects at the same time, you won't get any statistics.
+
=====Context 'array' from example 'maximum' =====
  
==Developer guide==
+
See the [[TextEditor_Screenshots#Context_.27array.27_from_example_.27maximum.27|screenshot]] of this example or download the [http://deploy-eprints.ecs.soton.ac.uk/56/4/maximum.zip project].
===Extending Single View Design===
 
Single View Design uses the [http://wiki.eclipse.org/index.php/Common_Navigator_Framework Common Navigator Framework] and [http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/forms_master_details.htm the Master/Details pattern]. The part on the left (the navigator) is the master part. You can add custom filters, content providers and action providers in a plug-in of your own. Add the extension <code>org.eclipse.ui.navigator.viewer</code>. There you can add viewerContentBindings and viewerActionBindings with viewerId <code>fr.systerel.explorer.navigator.view</code>. This binds your custom content, actions and filters to the navigator. The part on the right is the details part. You can add tabs of your own by extending <code>fr.systerel.explorer.masterDetails</code>.
 
  
In the picture you can see what types the nodes in the navigator have.
+
context array
 
+
[[Image:Tree.jpg]]
+
constants n a  
 
+
====Adding a content provider to the navigator====
+
axioms
To add a custom content provider you have to use the <code>org.eclipse.ui.navigator.navigatorContent</code> extension. There you add a new navigatorContent. Example: You want to add a new child under the IMachineFile nodes. Define a navigatorContent and add triggerPoints. There you add a new <code>instanceof</code> with value <code>org.eventb.core.IMachineFile</code>. The priority of the navigatorContent decides in what order the content is shown with respect to other content providers. (For example the content provider for the variables has a higher priority than the one for invariants, that's why the variables appear before the invariants in the tree.) You need to provide a contentProvider and a labelProvider class. For more information read the extension point description of [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_navigator_navigatorContent.html navigatorContent]. Finally include your navigatorContent in your viewerContentBindings.
+
   @axm1 n ∈ ℕ1
 
+
   @axm2 a ∈ 1‥n → ℤ
<code>
+
  end
  <extension
 
        point="org.eclipse.ui.navigator.navigatorContent">
 
      <navigatorContent
 
            contentProvider="example.ContentProvider"
 
            id="example.navigatorContent"
 
            labelProvider="example.LabelProvider"
 
            name="Example Content">
 
        <triggerPoints>
 
            <instanceof
 
                  value="org.eventb.core.IMachineFile">
 
            </instanceof>
 
        </triggerPoints>
 
      </navigatorContent>
 
  </extension>
 
</code>
 
 
 
<code>
 
   <extension
 
        point="org.eclipse.ui.navigator.viewer">
 
      <viewerContentBinding
 
            viewerId="fr.systerel.explorer.navigator.view">
 
        <includes>
 
            <contentExtension
 
                  pattern="example.navigatorContent">
 
            </contentExtension>
 
        </includes>
 
      </viewerContentBinding>
 
   </extension>
 
</code>
 
 
 
 
 
====Adding a filter to the navigator====
 
To add a custom filter you have to use the <code>org.eclipse.ui.navigator.navigatorContent</code> extension. There you add a new commonFilter. You can either provide an implementation for <code>ViewerFilter</code> or use xml filterExpressions. For more information read the extension point description of [http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_navigator_navigatorContent.html navigatorContent]. Finally include your commonFilter in your viewerContentBindings.
 
 
 
====Adding an action provider to the navigator====
 
To add a custom filter you use again the <code>org.eclipse.ui.navigator.navigatorContent</code> extension. There you add a new actionProvider. You have to provide an implementation for <code>org.eclipse.ui.navigator.CommonActionProvider</code>. To decide on what nodes in the tree your action provider should be invoked, use the enablement expression. Finally include your commonFilter in your viewerActionBindings.
 
 
 
====Adding a tab with custom content to the details part====
 
To add a custom tab use the <code>fr.systerel.explorer.masterDetails</code> extension. Add a new detailsTab and provide a class that implements <code>INavigatorDetailsTab</code>.
 
 
 
[[Category:Work in progress]]
 

Revision as of 13:42, 7 July 2009

This page describes the text syntax for Event-B models in the TextEditor. It shows its EBNF, explains some details and design decisions and gives some examples.

See the Text_Editor page for details of the editor and the usage of the text syntax.

Screenshots which give an impression of the syntax in the text editor are shown on the screenshot page.


EBNF for the TextEditor's syntax

parse_unit =
   'machine' identifier_literal comment*
   ('refines' identifier_literal (',' identifier_literal)*)?
   ('sees' identifier_literal (',' identifier_literal)*)?
   ('variables' identifier_list)?
   ('invariants' labeled_predicate_with_theorem+)?
   ('variant' variant)?
   ('events' event+)?
   end |
   
   'context' identifier_literal comment*
   ('extends' identifier_literal (',' identifier_literal)*)?
   ('sets' identifier_list)?
   ('constants' identifier_list)?
   ('axioms' labeled_predicate_with_theorem+)?
   end ;

variant = expression comment*;

event =
   convergence? 'event' identifier_literal comment*
   event_refinement?
   ('any' identifier_list)?
   ('where' labeled_predicate+)?
   ('with' labeled_predicate+)?
   ('then' labeled_action+)? ;

convergence = 'ordinary' | 'convergent' | 'anticipated' ;

event_refinement =
   'refines' identifier_literal (',' identifier_literal)* |
   'extends' identifier_literal ;

labeled_action = '@' label action comment*;

labeled_predicate = '@' label predicate comment*;

labeled_predicate_with_theorem =
   '@' label predicate comment*|
   'theorem' '@' identifier_literal predicate comment*;

identifier = identifier_literal comment*;

identifier_list = identifier identifier* ;

comment =
   '//' string-to-next-linebreak |
   '/*' string '*/' ;


NOTE: the EBNF above for Contexts specifies that constants come after sets. It seems to be the other way around in RODIN.

Explanation

Formulas

As you might notice the grammar only describes the structure of machines and contexts. For the terminals predicate, expression and action you can use the syntax for formulas which you already know from editing models with the graphical Event-B editor. You can use the ASCII representation of mathematical symbols or their unicode. See the Rodin help for details about the mathematical symbols and their ASCII counterparts.

Comments

Also note that the rather strict position for comments is necessary. In the RodinDB most elements can be commented. That means if you comment an element this comment is attached to the element. To reflect this in a text syntax we need to exactly specify to which textual element a comment belongs. Therefore we decided to always associate a comment to the previous element. Additionally database only allows one comment per element. The grammar allows multiple comments, but to reflect the database restriction to one internally multiple comments are concatenated to one with linebreaks between the separate comments.

Labels

The syntax doesn't allow whitespaces within labels. It assumes that all characters following an '@' belong to the label until the next whitespace character is found.


Examples

Feel free to add own examples!

Machine 'm0' from example 'maximum'

See the screenshot of this example or download the project.

machine m0 sees array

variables i

invariants
  @inv1 i ∈ ℕ

events
  event INITIALISATION
    then
      @act1 i :∈ ℕ
  end

  event find_max
    any j
    where
      @grd1 j ∈ 1‥n
      @grd2 ∀k·k∈1‥n ⇒ a(k) ≤ a(j)
    then
      @act1 i ≔ j
  end
end
Context 'array' from example 'maximum'

See the screenshot of this example or download the project.

context array

constants n a 

axioms
  @axm1 n ∈ ℕ1
  @axm2 a ∈ 1‥n → ℤ
end