Difference between pages "Extending the project explorer" and "Mathematical Extensions"

From Event-B
(Difference between pages)
Jump to navigationJump to search
imported>Renato
 
imported>Nicolas
m (→‎Example: Binary PLUS: corrected call to WDMediator for true WD)
 
Line 1: Line 1:
{{TOCright}}
+
Currently the operators and basic predicates of the Event-B mathematical language supported by Rodin are fixed.
= Introduction =
+
We propose to extend Rodin to define basic predicates, new operators or new algebraic types.
The purpose of this page is to describe how to extend the Event-B project explorer. It covers on the one hand, the definition of the extension, and on the other hand its implementation. The Event-B project explorer is itself an implementation of the extension-point <tt>org.eclipse.ui.views</tt>. The corresponding view id is '''fr.systerel.explorer.navigator.view''' which is defined as a subclass of <tt>org.eclipse.ui.navigator.CommonNavigator</tt> and it is over this view that we extend the project explorer. We will describe a simple implementation but the reader should be aware that the extension can have a more complex structure and consequently a more complex implementation.
 
  
[[Image:EventB project explorer.png]]
+
== Requirements ==
  
The useful extension points are listed below; they offer the possibility to contribute to the project explorer:
+
=== User Requirements ===
* <tt>org.eclipse.ui.navigator.navigatorContent</tt>
+
* Binary operators (prefix form, infix form or suffix form).
* <tt>org.eclipse.ui.navigator.viewer</tt>
+
* Operators on boolean expressions.
 +
* Unary operators, such as absolute values.
 +
: Note that the pipe, which is already used for set comprehension, cannot be used to enter absolute values (''in fact, as in the new design the pipe used in set comprehension is only a syntaxic sugar, the same symbol may be used for absolute value. To be confirmed with the prototyped parser. It may however be not allowed in a first time until backtracking is implemented, due to use of lookahead making assumptions on how the pipe symbol is used. -Mathieu ).
 +
* Basic predicates (e.g., the symmetry of relations <math>sym(R) \defi R=R^{-1}</math>).
 +
: Having a way to enter such predicates may be considered as syntactic sugar, because it is already possible to use sets (e.g., <math>R \in sym</math>, where <math>sym \defi \{R \mid R=R ^{-1}\}</math>) or functions (e.g., <math>sym(R) = \True</math>, where <math>sym \defi (\lambda R \qdot R \in A \rel B \mid \bool(R = R^{-1}))</math>).
 +
* Quantified expressions (e.g., <math>\sum x \qdot P \mid y</math>, <math>\prod x \qdot P \mid y</math>, <math>~\min(S)</math>, <math>~\max(S)</math>).
 +
* Types.
 +
** Enumerated types.
 +
** Scalar types.
  
= Before Starting =
+
=== User Input ===
 +
The end-user shall provide the following information:
 +
* keyboard input
 +
* Lexicon and Syntax. <br/>More precisely, it includes the symbols, the form (prefix, infix, postfix), the grammar, associativity (left-associative or right associative), commutativity, priority, the mode (flattened or not), ...
 +
* Pretty-print. <br/>Alternatively, the rendering may be determined from the notation parameters passed to the parser.
 +
* Typing rules.
 +
* Well-definedness.
  
It is necessary to define the elements and structure to be represented. We will use as an example the ''decompositionFile'' that is defined as follows:
+
=== Development Requirements ===
 +
* Scalability.
  
*decompositionFile
+
== Towards a generic AST ==
**decompositionRoot
 
***Component with the following attributes: ''machine'' (to be decomposed)
 
***Configuration with the following attributes: ''style'': shared event/shared variables; ''newProjectOption'': decompose in the same project/different projects; ''decomposeContextOption'': noDecomposition/minimal decomposition)
 
***SubComponent (resulting decomposed parts) with the following attributes: ''label''
 
****SubComponentElement (elements used to decompose:variables for shared event and events for shared variable) with the following attributes: '' element name/identifier''
 
  
[[Image:Decomp file pretty print.png]]
+
The following AST parts are to become generic, or at least parameterised:
 +
* [[Constrained_Dynamic_Lexer | Lexer]]
 +
* [[Constrained Dynamic Parser | Parser]]
 +
* Nodes ( Formula class hierarchy ): parameters needed for:
 +
** Type Solve (type rule needed to synthesize the type)
 +
** Type Check (type rule needed to verify constraints on children types)
 +
** WD (WD predicate)
 +
** PrettyPrint (tag image + notation (prefix, infix, postfix) + needs parentheses (deduced from compatibility graph))
 +
** Visit Formula (getting children + visitor callback mechanism)
 +
** Rewrite Formula (associative formulæ have a specific flattening treatment)
 +
* Types (Type class hierarchy): parameters needed for:
 +
** Building the type expression (type rule needed)
 +
** PrettyPrint (set operator image)
 +
** getting Base / Source / Target type (type rule needed)
 +
* Verification of preconditions (see for example <tt>AssociativeExpression.checkPreconditions</tt>)
  
= Navigator Content =
+
=== Vocabulary ===
  
A content extension provides a content and label provider that can be used by a navigator content service (in out case the ''Event-B project explorer''). The navigatorContent extension defines the specific classes for the content provider, label provider, and action provider in addition to the types of elements the extension knows about. To extend the project explorer, it is also required to add the following children of the navigatorContent:
+
An '''extension''' is to be understood as a single additional operator definition.  
  
* ''triggerPoints'': defines the nodes to be used when resolving the Common Navigator content provider's getElements() or getChildren(). This is also used to select the extension for providing labels, images, descriptions and for sorting.
+
=== Tags ===
*''possibleChildren'': defines the node to be used when resolving the Common Navigator content provider's getParent(). It is also used to help determine the parent when handling drop operations.
 
  
== Declaration ==
+
Every extension is associated with an integer tag, just like existing operators. Thus, questions arise about how to allocate new tags and how to deal with existing tags.<br />
 +
The solution proposed here consists in keeping existing tags 'as is'. They are already defined and hard coded in the <tt>Formula</tt> class, so this choice is made with backward compatibility in mind.
  
The navigatorContent extension-point allows tool writers to register their tool implementation under a symbolic name that is then used by the Rodin platform to find and run the tool. The symbolic name is the id of the tool extension. The declaration of this extension is defined as follows:
+
Now concerning extension tags, we will first introduce a few hypotheses:
 +
* Tags_Hyp1: tags are never persisted across sessions on a given platform
 +
* Tags_Hyp2: tags are never referenced for sharing purposes across various platforms
 +
In other words, cross-platform/session formula references are always made through their ''String'' representation. These assumptions, which were already made and verified for Rodin before extensions, lead us to restrict further considerations to the scope of a single session on a single platform.
  
<!ELEMENT navigatorContent ((enablement | (triggerPoints , possibleChildren)) , actionProvider* , commonSorter* , override? , dropAssistant* , commonWizard*)>
+
The following definitions hold at a given instant <math>t</math> and for the whole platform.<br />
  <!ATTLIST navigatorContent
+
Let <math>\mathit{EXTENSION}_t</math> be the set of extensions supported by the platform at instant <math>t</math>;<br /> let <math>\mathit{tag}_t</math> denote the affectation of tags to an extension at instant <math>t</math> (<math>\mathit{tag}_t \in \mathit{EXTENSION}_t \pfun \intg</math>);<br /> let <math>\mathit{COMMON}</math> be the set of existing tags defined by the <tt>Formula</tt> class (<math>\mathit{COMMON} \sub \intg</math>).<br /> The following requirements emerge:
  id                CDATA #REQUIRED
+
* Tags_Req1: <math>\forall t \qdot \mathit{tag}_t \in \mathit{EXTENSION}_t \tinj \intg</math>
  name              CDATA #REQUIRED
+
* Tags_Req2: <math>\forall e, t_1,t_2 \qdot \mathit{tag}_{t_1}(e)=\mathit{tag}_{t_2}(e)</math> where <math>t_1, t_2</math> are two instants during a given session
  priority          (lowest|lower|low|normal|high|higher|highest)
+
* Tags_Req3: <math>\forall t \qdot \ran(\mathit{tag}_t) \cap \mathit{COMMON} = \empty</math>
  contentProvider  CDATA #IMPLIED
 
  icon              CDATA #IMPLIED
 
  activeByDefault  (true | false)
 
  providesSaveables (true | false)
 
  labelProvider    CDATA #IMPLIED
 
>
 
  
A navigator content extension defines a content provider and label provider that can be used to provide children whenever an element matches the triggerPoints expression and also to provide a parent whenever an element matches the possibleChildren expression. Optionally, we may also provide an action provider which can provide menu contributions and action bar contributions when an element is selected that the extension contributed, or that matches the triggerPoints expression. It is possible to contribute with a sorter to sort elements that are contributed by the extension.
+
The above-mentioned scope-restricting hypothesis can be reformulated into: <math>\mathit{tag}</math> needs not be stable across sessions nor across platforms.
  
* id - A unique ID to identify this extension. Used for extension activation and by other extensions that would like to extend the defined extension (e.g. add another <tt>org.eclipse.ui.navigator.CommonActionProvider</tt>)
+
=== Formula Factory ===
* name - Specify a display name for the Content Extension. The display name is used in the activation dialog to allow clients to turn an extension on or off.
 
* priority - Indicates the relative priority of this extension to other extensions. Used by the Common Navigator to handle sorting and organization of the contributed content from this extension in relation to content from other extensions. Defaults to "normal"
 
* contentProvider - Supplies the name of a class which implements <tt>org.eclipse.jface.viewers.ITreeContentProvider</tt> or <tt>org.eclipse.ui.navigator.ICommonContentProvider</tt>. The content provider will be consulted when adding children to the tree. Use the enablement, triggerPoints, or possibleChildren clauses to indicate what kinds of content should trigger a request to your content provider. Elements contributed from the content provider are not guaranteed to appear in the tree in the same order. Clients should take advantage of the sorting extension (commonSorter) to ensure proper ordering of their elements. All elements contributed by this content provider are associated with this navigatorContent extension for the purposes of determining the label provider, action providers, sorters, drop assistants and common wizards.
 
* icon - A plugin-relative path to an icon for use when displaying the metadata about the content extension to the user.
 
* activeByDefault - Indicates whether the current extension will be active by default. Each content extension may be turned on or off by the user. The active state is differentiated from the visible state. See <tt>org.eclipse.ui.navigator.viewer/viewerContentBinding</tt> for more information on visibility
 
*labelProvider - Supplies the name of a class which implements <tt>org.eclipse.jface.viewers.ILabelProvider</tt> or for more advanced functionality, the <tt>org.eclipse.ui.navigator.ICommonLabelProvider</tt>. Clients may also implement <tt>org.eclipse.ui.navigator.IDescriptionProvider</tt> in order to add text to the status bar at the bottom of the Eclipse workbench based on the selection in the viewer. Since Eclipse 3.4, clients may also implement <tt>org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider</tt> to provide styled text labels. Note that the empty styled string signals that the label provider does not wish to render the label.
 
  
===Action Provider===
+
The requirements about tags give rise to a need for centralising the <math>\mathit{tag}</math> relation in order to enforce tag uniqueness.
 +
The Formula Factory appears to be a convenient and logical candidate for playing this role. Each time an extension is used to make a formula, the factory is called and it can check whether its associated tag exists, create it if needed, then return the new extended formula while maintaining tag consistency.
  
Still inside the navigatorContent, it is possible to add the following:
+
The factory can also provide API for requests about tags and extensions: getting the tag from an extension and conversely.
  
<!ELEMENT actionProvider (enablement?)>
+
We also need additional methods to create extended formulæ. A first problem to address is: which type should these methods return ?
  <!ATTLIST actionProvider
+
We could define as many extended types as the common AST API does, namely <tt>ExtendedUnaryPredicate</tt>, <tt>ExtendedAssociativeExpression</tt>, and so on, but this would lead to a large number of new types to deal with (in visitors, filters, …), together with a constraint about which types extensions would be forced to fit into. It is thus preferable to have as few extended types as possible, but with as much parameterisation as can be. Considering that the two basic types <tt>Expression</tt> and <tt>Predicate</tt> have to be extensible, we come to add two extended types <tt>ExtendedExpression</tt> and <tt>ExtendedPredicate</tt>.
  class        CDATA #REQUIRED
 
  id            CDATA #IMPLIED
 
  dependsOn    CDATA #IMPLIED
 
  overrides    CDATA #IMPLIED
 
  priority      (lowest|lower|low|normal|high|higher|highest)
 
  appearsBefore IDREF #IMPLIED
 
  >
 
  
A top level actionProvider is visible to an abstract viewer if there is a viewerActionBinding for that actionProvider. It is possible to provide actionProvider(s) under the root extension element (peer to other navigatorContent) in order to better control their enablement and viewer binding (see viewerActionBinding). Any items contributed to the toolbar or the view menu should be removed when the actionProviders is disposed. We described the two most used attributes of this element:
+
ExtendedExpression makeExtendedExpression( ? )
 +
ExtendedPredicate makeExtendedPredicate( ? )
  
* ''class'' - Supplies the name of a class that implements <tt>org.eclipse.ui.navigator.CommonActionProvider</tt>. The action provider has an opportunity to contribute to the context menu and the retargetable actions defined in the IActionBars for the view that holds the navigator. It is also possible to contribute directly to the view menu through the IActionBars view menu.
+
Second problem to address: which arguments should these methods take ?
* ''id'' - Clients may optionally define an id to use for filtering purposes (either through activities or viewerContentBindings).
+
Other factory methods take the tag, a collection of children where applicable, and a source location. In order to discuss what can be passed as argument to make extended formulæ, we have to recall that the <tt>make…</tt> factory methods have various kinds of clients, namely:
 +
* parser
 +
* POG
 +
* provers
 +
(other factory clients use the parsing or identifier utility methods: SC modules, indexers, …)
  
To define when to enable this actionProvider, it is necessary to define the ''enablement'':
+
Thus, the arguments should be convenient for clients, depending on which information they have at hand.
 +
The source location does not obviously seem to require any adaptation and can be taken as argument the same way. Concerning the tag, it depends on whether clients have a tag or an extension at hand. Both are intended to be easily retrieved from the factory. As a preliminary choice, we can go for the tag and adjust this decision when we know more about client convenience.
  
<!ELEMENT enablement (not , and , or , instanceof , test , systemTest , equals , count , with , resolve , adapt , iterate , reference)*>
+
As for children, the problem is more about their types. We want to be able to handle as many children as needed, and of all possible types. Looking to existing formula children configurations, we can find:
 +
* expressions with predicate children: <math>\mathit{bool}(P)</math>
 +
* expressions with expression children: <math>E_1 + E_2</math>
 +
* predicates with predicate children: <math>P_1 \limp P_2</math>
 +
* predicates with expression children: <math>\mathit{partition}(S, E_1, E_2)</math>
 +
* mixed operators: <math>\{x \qdot P(x) \mid E(x)\}</math>, but it is worth noting that the possibility of introducing bound variables in extended formulæ is not established yet.
 +
Thus, for the sake of generality, children of both types should be supported for both extended predicates and extended expressions.
  
The enablement expression allows clients to specify the same expression for both triggerPoints and possibleChildren. In the case of actionProvider, clients must define an expression that will indicate to the framework when their <tt>org.eclipse.ui.navigator.CommonActionProvider</tt> should be invoked. Because of contributions to the ''IActionBars'', clients must be invoked whenever an object they are interested in is selected. Therefore, clients should use discretion in deciding when their extension should be enabled.
+
ExtendedExpression makeExtendedExpression(int tag, Expression[] expressions, Predicate[] predicates, SourceLocation location)
 +
ExtendedPredicate makeExtendedPredicate(int tag, Expression[] expressions, Predicate[] predicates, SourceLocation location)
  
== Programmatic usage ==
+
== Defining Extensions ==
  
In the java side, create 4 packages:
+
An extension is meant to contain every information and behaviour required by:
 +
* Keyboard
 +
* (Extensible Fonts ?)
 +
* Lexer
 +
* Parser
 +
* AST
 +
* Static Checker
 +
* Proof Obligation Generator
 +
* Provers
  
* *.*.editors.image: Where you have the class that handles the images to be used to display the elements in the project explorer (see for example: <tt>/org.eventb.ui/src/org/eventb/ui/IEventBSharedImages.java</tt>)
+
=== Keyboard requirements ===
  
* *.*.ui.explorer.contentProvider: contains the classes required in the extension point <tt>org.eclipse.ui.navigator.navigatorContent</tt>.
+
'''Kbd_req1''': an extension must provide an association combo/translation for every uncommon symbol involved in the notation.
  
* *.*.ui.explorer.actionProvider: contains the classes that handle the actions that can be originated by the added navigatorContent.
+
=== Lexer requirements ===
  
* *.*.ui.explorer.model: The content of the explorer is structured in classes called ''Models''. They all implement the interface <tt>fr.systerel.internal.explorer.model.IModelElement</tt>. The elements are structured in projects (''ModelProjects'') where the root file contains elements that can have proof obligations associated (in that case they should extends the abstract class <tt>fr.systerel.internal.explorer.model.ModelPOContainer</tt>). The elements of a root file are ''ModelElementNode'' similar to <tt>fr.systerel.internal.explorer.model.ModelElementNode</tt>. The models structure would look like this:
+
'''Lex_req1''': an extension must provide an association lexeme/token for every uncommon symbol involved in the notation.
  
  ModelProject
+
=== Parser requirements ===
    - ModelRoot1
 
        - ModelElementNode1
 
        - ModelElementNode2
 
        - ...
 
    - ModelRoot2
 
        - ModelElementNode3
 
        - ModelElementNode4
 
        - ...
 
       
 
Moreover, a class called ''ModelController'' defined as a singleton controls all the models and contains useful methods. It also implements the interface <tt>org.rodinp.core.IElementChangedListener</tt> that will be called whenever there is a change in one of the model elements. It will clean up the existing elements in the project explorer and reload with the recent changes through a class called ''DeltaProcessor'': processes an IRodinElementDelta for the ''ModelController''. It decides what needs to be refreshed in the model and the viewer and what needs to be removed from the model (see as an example the class <tt>fr.systerel.internal.explorer.model.DeltaProcessor</tt>). The ''ModelController'' instance should be called by implementing the method <tt>org.eclipse.jface.viewers.IContentProvider#inputChanged</tt> (required for classes that implement interface <tt>org.eclipse.jface.viewers.ITreeContentProvider</tt>). Usually an abstract class that implements ITreeContentProvider is created: ''AbstractContentProvider''.
 
  
public abstract class AbstractContentProvider implements ITreeContentProvider {
+
According to the [[Constrained_Dynamic_Parser| Parser]] page, the following informations are required by the parser in order to be able to parse a formula containing a given extension.
        protected static Object[] NO_OBJECT = new Object[0];
+
 
        protected IInternalElementType<?> type;
+
* symbol compatibility
        public AbstractContentProvider(IInternalElementType<?> type){this.type = type;}
+
* group compatibility
        public Object[] getChildren(Object parentElement) {
+
* symbol precedence
                IModelElement model = ModelControllerDecomposition.getModelElement(parentElement);
+
* group precedence
                if (model != null) {
+
* notation:
                      return model.getChildren(type, false);
+
** prefix, infix, …
                }
+
** configuration (sub-parsers, symbols and their relative position, child types)
                return NO_OBJECT;
+
 
        }
+
=== AST requirements ===
        public Object getParent(Object element) {
+
 
                IModelElement model = ModelControllerDecomposition.getModelElement(element);
+
==== Extended Formulæ ====
                if (model != null) {
+
 
                        return model.getParent(true);
+
[[Image:AST_Formulae.png]]
                }
+
 
                return null;
+
==== Operator Properties API ====
      }
+
 
      public boolean hasChildren(Object element) {
+
Operator properties are reified through the following interfaces and enumerated:
              return getChildren(element).length>0;
+
 
      }
+
[[Image:AST_OperProps.png]]
      public Object[] getElements(Object inputElement) {
+
 
            return getChildren(inputElement);
+
==== Extension API ====
      }
+
 
      public void dispose() {}
+
Extensions are required to implement the following APIs in order to be supported in the AST. It is the expression of the missing information for a <tt>ExtendedExpression</tt> (resp. <tt>ExtendedPredicate</tt>) to behave as a <tt>Expression</tt> (resp. <tt>Predicate</tt>). It can also be viewed as the parametrization of the AST.
      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
 
              if (viewer instanceof CommonViewer) {
+
[[Image:AST_Extensions.png]]
                    ModelControllerDecomposition.createInstance((CommonViewer)viewer);
+
 
              }
+
==== Mediator API ====
      }
+
 
 +
The mediators provided as arguments to these APIs have the following specification:
 +
 
 +
[[Image:AST_Mediators.png]]
 +
 
 +
==== Example: Binary PLUS ====
 +
 
 +
public class BinaryPlus implements IExpressionExtension {
 +
 +
public Type getType(ITypeMediator mediator, ExtendedExpression expression) {
 +
final Type resultType = mediator.makeIntegerType();
 +
for (Expression child : expression.getChildExpressions()) {
 +
final Type childType = child.getType();
 +
if (!childType.equals(resultType)) {
 +
return null;
 +
}
 +
}
 +
return resultType;
 +
}
 +
 +
public Type typeCheck(ITypeCheckMediator mediator,
 +
ExtendedExpression expression) {
 +
final Type resultType = mediator.makeIntegerType();
 +
for (Expression child : expression.getChildExpressions()) {
 +
mediator.sameType(child.getType(), resultType);
 +
}
 +
return resultType;
 +
}
 +
 +
public String getSyntaxSymbol() {
 +
return "+";
 +
}
 +
 +
public Predicate getWDPredicate(IWDMediator mediator,
 +
IExtendedFormula formula) {
 +
return mediator.makeTrueWD();
 +
}
 +
 +
public void addCompatibilities(ICompatibilityMediator mediator) {
 +
mediator.addCompatibility(getId(), getId());
 +
}
 +
 +
public void addPriorities(IPriorityMediator mediator) {
 +
// no priorities to set
 +
}
 +
 +
public String getGroupId() {
 +
return "arithmetic";
 +
}
 +
 +
public String getId() {
 +
return "binary plus";
 +
}
 +
 +
public ExtensionKind getKind() {
 +
return ExtensionKind.BINARY_INFIX_EXPRESSION;
 +
}
 +
 
  }
 
  }
  
This class is extended by the respective ''contentProviders''. For instance:
+
=== Static Checker requirements ===
 +
 
 +
The static checker is involved in:
 +
* static checking an extension definition (pre deployment)
 +
: {{TODO}}
 +
* static checking a model that uses extensions (post deployment);
 +
: to that purpose, (deployed) extensions need to be placed in the build dependency graph before models that use them
 +
: it must check that referenced (deployed) extensions are present in the project
 +
: it needs to get the appropriate FormulaFactory for parsing (with referenced extensions enabled)
 +
: it must be aware of extensions being added/deleted/replaced to reprocess dependent models
 +
 
 +
=== Proof Obligation Generator requirements ===
 +
 
 +
Likewise, the POG may run on
 +
* an extension definition (pre deployment)
 +
: {{TODO}}
 +
* a model that uses extensions (post deployment)
 +
: nothing to do for WD POs (relies on the fact that extension WD is transmitted to the AST)
 +
 
 +
=== Prover requirements ===
 +
 
 +
Theorems about extensions must be converted to additional inference rules.
 +
 
 +
{{TODO}}
 +
 
 +
=== Extension compatibility issues ===
 +
{{TODO}}
 +
 
 +
== User Input Summarization ==
 +
 
 +
Identified required data entail the following user input:
 +
 
 +
* '''id''':
 +
:a String id
 +
 
 +
* '''group id''':
 +
:an identifier of a existing group a new group id
  
public class DecompositionContentProvider extends AbstractContentProvider{...}
+
* '''kind''' (determines both the type and the notation):
 +
:a choice between
 +
::* PARENTHESIZED_PREFIX_PREDICATE: <math>\operatorname{op}(a,b,c)</math>
 +
::* PARENTHESIZED_PREFIX_EXPRESSION: ''idem''
 +
::* BINARY_INFIX_EXPRESSION: <math>a ~ \lozenge ~ b</math>
 +
::* ASSOCIATIVE_INFIX_EXPRESSION: <math>a ~ \lozenge ~ b ~ \lozenge ~ c</math>
 +
As a first step we may restrict the choice to the above list. For all these kinds, all children are expressions.
  
== Example ==
+
* '''syntax symbol''':
 +
:a String equal to the operator to be parsed in formulæ (for instance ''"<math>\lozenge</math>"'' or ''"myOperator"'' or ''"\u03d5"'')
  
An example of the implementation of this extension-point is defined below:
+
* '''keyboard''':
 +
:a list of associations 'symbol <-> ASCII shortcut' for uncommon symbols
  
<extension
+
* '''parsing''':
        point="org.eclipse.ui.navigator.navigatorContent">
+
:compatibility:
      <navigatorContent
+
:* a list of operator ids of the same group, that are compatible with the defined operator
            contentProvider="ch.ethz.eventb.decomposition.ui.explorer.contentProvider.DecompositionContentProvider"
+
: in particular, if the id of the defined operator is included, it means it is compatible with itself
            id="ch.ethz.eventb.decomposition.ui.navigator.explorer.decomposition"
 
            labelProvider="ch.ethz.eventb.decomposition.ui.explorer.contentProvider.DecompositionLabelProvider"
 
            name="Decomposition Root"
 
            priority="highest">
 
        <triggerPoints>
 
            <or>
 
              <instanceof
 
                    value="org.eclipse.core.resources.IProject">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IDecompositionRoot">
 
              </instanceof>
 
            </or></triggerPoints>
 
        <possibleChildren>
 
            <instanceof
 
                  value="ch.ethz.eventb.decomposition.core.IDecompositionRoot">
 
            </instanceof>
 
        </possibleChildren>
 
      </navigatorContent>
 
      <navigatorContent
 
            contentProvider="ch.ethz.eventb.decomposition.ui.explorer.contentProvider.ComponentContentProvider"
 
            id="ch.ethz.eventb.decomposition.ui.navigator.explorer.component"
 
            labelProvider="ch.ethz.eventb.decomposition.ui.explorer.contentProvider.DecompositionLabelProvider"
 
            name="Decomposition Component"
 
            priority="higher">
 
        <triggerPoints>
 
            <or>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IDecompositionRoot">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IComponent">
 
              </instanceof>
 
            </or>
 
        </triggerPoints>
 
        <possibleChildren>
 
            <instanceof
 
                  value="ch.ethz.eventb.decomposition.core.IComponent">
 
            </instanceof>
 
        </possibleChildren>
 
</extension>
 
  
Above we defined two navigatorContent elements (''DecompositionContentProvider'' and ''ComponentContentProvider'') using the same class as labelProvider (''DecompositionLabelProvider''). The first is triggered by instances of ''IProject'' and ''IDecompositionRoot'' and the possible children of this element are ''IDecompositionRoot'' as well.
+
:priority:
 +
:* a list of other operator ids of the same group with higher priority than this operator
 +
:* a list of other operator ids of the same group with lower priority than this operator
  
An actionProvider example is described below:
+
:additionally, if a new group is defined, it shall be given
 +
:* the id of another group with lower priority
 +
:* the id of another group with higher priority
  
      <actionProvider
+
:As these informations have a global scope, we may think about more convenient ways to input/review them, avoiding a manual scanning of all individual extensions.
            class="ch.ethz.eventb.decomposition.ui.explorer.actionProvider.DecompositionRootActionProvider"
 
            id="ch.ethz.eventb.decomposition.ui.DecompositionRootActionProvider">
 
        <enablement>
 
            <or>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IDecompositionRoot">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IDecompositionConfiguration">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.ISubComponent">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.ISubComponentElement">
 
              </instanceof>
 
              <instanceof
 
                    value="ch.ethz.eventb.decomposition.core.IComponent">
 
              </instanceof>
 
            </or>
 
        </enablement>
 
      </actionProvider>
 
  
This actionProvider, described by the class <tt>ch.ethz.eventb.decomposition.ui.explorer.actionProvider.DecompositionRootActionProvider</tt> is enabled by instances of IDecompositionRoot, IDecompositionConfiguration, ISubComponent, ISubComponentElement and IComponent.
+
* '''type rule''':
 +
:* the type of every child
 +
:as a first step we may restrict children to all bear the same type, for instance <math>\Z</math> or <math>\pow(\alpha \cprod \beta)</math>.
 +
:* (for expressions) the resulting type, which may depend on the type of the children
 +
: for instance <math>T_1 \cprod T_2</math> where <math>T_i</math> stands for the type of the i-th child.
 +
 +
* '''well-definedness''':
 +
:as a first step we will only provide a pre-defined WD condition: 'children WD conjunction', so as long as it remains so, nothing needs to be input by the user concerning WD.
  
= Navigator Viewer =
+
== Impact on other tools ==
  
The viewer element defines the configuration for a common viewer. We define two children of this extension point:
+
Impacted plug-ins (use a factory to build formulæ):
 +
* <tt>org.eventb.core</tt>
 +
: In particular, the static checker and proof obligation generator are impacted.
 +
* <tt>org.eventb.core.seqprover</tt>
 +
* <tt>org.eventb.pp</tt>
 +
* <tt>org.eventb.pptrans</tt>
 +
* <tt>org.eventb.ui</tt>
  
* ''viewerContentBinding'': to define the visibility of ''contentProviders''.
+
== Identified Problems ==
* ''viewerActionBinding'': to define the visibility of ''actionProviders''.
+
The static checker shall enforce verifications to detect the following situations:
 +
* Two mathematical extensions are not compatible (the extensions define symbols with the same name but with a different semantics).
 +
* A mathematical extension is added to a model and there is a conflict between a symbol and an identifier.
 +
* An identifier which conflicts with a symbol of a visible mathematical extension is added to a model.
  
== Declaration ==
+
Beyond that, the following situations are problematic:
 +
* A formula has been written with a given parser configuration and is read with another parser configuration.
 +
: As a consequence, it appears as necessary to remember the parser configuration.
 +
: The static checker will then have a way to invalid the sources of conflicts (e.g., priority of operators, etc).
 +
:: ''The static checker will then have a way to invalid the formula upon detecting a conflict (name clash, associativity change, semantic change...) [[User:Mathieu|mathieu]]
  
<!ELEMENT viewerContentBinding (includes? , excludes?)>
 
  <!ATTLIST viewerContentBinding
 
  viewerId CDATA #REQUIRED
 
  >
 
  
Clients must define one or more viewerContentBinding elements to describe which content extensions, common filters, and link helpers are visible to the viewer. A content extension or common filter is visible if the id of the content extension or common filter matches an includes statement under a viewerContentBinding and is not excluded by an excludes statement. If a content extension or common filter is not visible to a viewer, then the extension will never be asked for content by a content service for that viewer or be presented to the user in the available filters dialog. Clients may define an includes element to select which extensions are visible to the viewer, and similarly an excludes element for extensions that should not be made visible to the viewer. Clients may further define the extensions that should be explicitly queried for root elements (through ITreeContentProvider.getElements()) by the "isRoot" attribute. If one or more contentExtension elements have "isRoot" set to true within the includes statement, only those extensions will be queried for root elements. The "isRoot" attribute has no effect for exclusions. A viewer may have multiple viewerContentBindings defined, and their includes/excludes statements will be aggregated to produce the final behavior.
+
* A proof may free a quantified expression which is in conflict with a mathematical extension.
 +
: SOLUTION #1: Renaming the conflicting identifiers in proofs?
  
* viewerId - The id of the common viewer. If the viewer is in a common navigator then the id must match the navigator's id defined in its org.eclipse.ui.views extension.
+
* A theorem library changes: all proofs made using this library are potentially invalidated
 +
: it is just as when a reasoner version changes, proof status should be updated to show broken proofs
  
<!ELEMENT viewerActionBinding (includes? , excludes?)>
+
== Open Questions ==
  <!ATTLIST viewerActionBinding
 
  viewerId CDATA #REQUIRED
 
  >
 
  
Clients must define which action providers are visible to their viewer. Clients may define an includes element to select which extensions are visible to the viewer, and similarly an excludes element for extensions that should not be made visible to the viewer. A viewer may have multiple viewerActionBindings defined, and their includes/excludes statements will be aggregated to produce the final behavior.
+
=== New types ===
 +
Which option should we prefer for new types?
 +
* OPTION #1: Transparent mode.
 +
:In transparent mode, it is always referred to the base type. As a consequence, the type conversion is implicitly supported (weak typing).  
 +
:For example, it is possible to define the <tt>DISTANCE</tt> and <tt>SPEED</tt> types, which are both derived from the <math>\intg</math> base type, and to multiply a value of the former type with a value of the latter type.
  
== Example ==
+
* OPTION #2: Opaque mode.
 +
:In opaque mode, it is never referred to the base type. As a consequence, values of one type cannot be converted to another type (strong typing).
 +
:Thus, the above multiplication is not allowed.
 +
:This approach has at least two advantages:
 +
:* Stronger type checking.
 +
:* Better prover performances.
 +
:It also has some disadvantages:
 +
:* need of ''extractors'' to convert back to base types.
 +
:* need of extra circuitry to allow things like <math>x:=d*2</math> where <math>x, d</math> are of type <tt>DISTANCE</tt>
  
An example of the use of this extension point is defined below:
+
* OPTION #3: Mixed mode.
 +
:In mixed mode, the transparent mode is applied to scalar types and the opaque mode is applied to other types.
  
<extension
+
=== Scope of the mathematical extensions ===
        point="org.eclipse.ui.navigator.viewer">
+
* OPTION #1: Project scope.
      <viewerContentBinding
+
:The mathematical extensions are implicitly visible to all components of the project that has imported them.
            viewerId="fr.systerel.explorer.navigator.view">
+
* OPTION #2: Component scope.
        <includes>
+
:The mathematical extensions are only visible to the components that have explicitly imported them. However, note that this visibility is propagated through the hierarchy of contexts and machines (<tt>EXTENDS</tt>, <tt>SEES</tt> and <tt>REFINES</tt> clauses).
            <contentExtension
+
:An issue has been identified. Suppose that <tt>ext1</tt> extension is visible to component <tt>C1</tt> and <tt>ext2</tt> is visible to component <tt>C2</tt>, and there is no compatibility issue between <tt>ext1</tt> and <tt>ext2</tt>. It is not excluded that an identifier declared in <tt>C1</tt> conflict with a symbol in <tt>ext2</tt>. As a consequence, a global verification is required when adding a new mathematical extension.
                  pattern="ch.ethz.eventb.decomposition.ui.navigator.explorer.decomposition">
+
* OPTION #3: Workspace scope.
            </contentExtension>
+
:The mathematical extensions are visible to the whole workspace.
            <contentExtension
 
                  pattern="ch.ethz.eventb.decomposition.ui.navigator.explorer.component">
 
          </contentExtension>
 
            <contentExtension
 
                  pattern="ch.ethz.eventb.decomposition.ui.navigator.explorer.configuration">
 
            </contentExtension>
 
            <contentExtension
 
                  pattern="ch.ethz.eventb.decomposition.ui.navigator.explorer.subComponent">
 
            </contentExtension>
 
            <contentExtension
 
                  pattern="ch.ethz.eventb.decomposition.ui.navigator.explorer.subComponentElement">
 
            </contentExtension>
 
        </includes>
 
      </viewerContentBinding>
 
      <viewerActionBinding
 
            viewerId="fr.systerel.explorer.navigator.view">
 
        <includes>
 
            <actionExtension
 
                  pattern="ch.ethz.eventb.decomposition.ui.DecompositionRootActionProvider">
 
            </actionExtension>
 
        </includes>
 
      </viewerActionBinding>
 
  </extension>
 
  
The contentExtension patterns correspond to the ids in the contentProvider and actionProvider extension-points defined above (see the navigatorContent example section).
+
== Bibliography ==
 +
* J.R. Abrial, M.Butler, M.Schmalz, S.Hallerstede, L.Voisin, [http://deploy-eprints.ecs.soton.ac.uk/80 ''Proposals for Mathematical Extensions for Event-B''], 2009.
 +
:This proposal consists in considering three kinds of extension:
 +
# Extensions of set-theoretic expressions or predicates: example extensions of this kind consist in adding the transitive closure of relations or various ordered relations.
 +
# Extensions of the library of theorems for predicates and operators.
 +
# Extensions of the Set Theory itself through the definition of algebraic types such as  lists or ordered trees using new set constructors.
  
[[Category:Developer documentation]]
+
[[Category:Design proposal]]
[[Category:Rodin Platform]]
 

Revision as of 13:55, 17 June 2010

Currently the operators and basic predicates of the Event-B mathematical language supported by Rodin are fixed. We propose to extend Rodin to define basic predicates, new operators or new algebraic types.

Requirements

User Requirements

  • Binary operators (prefix form, infix form or suffix form).
  • Operators on boolean expressions.
  • Unary operators, such as absolute values.
Note that the pipe, which is already used for set comprehension, cannot be used to enter absolute values (in fact, as in the new design the pipe used in set comprehension is only a syntaxic sugar, the same symbol may be used for absolute value. To be confirmed with the prototyped parser. It may however be not allowed in a first time until backtracking is implemented, due to use of lookahead making assumptions on how the pipe symbol is used. -Mathieu ).
  • Basic predicates (e.g., the symmetry of relations sym(R) \defi R=R^{-1}).
Having a way to enter such predicates may be considered as syntactic sugar, because it is already possible to use sets (e.g., R \in sym, where sym \defi \{R \mid R=R ^{-1}\}) or functions (e.g., sym(R) = \True, where sym \defi (\lambda R \qdot R \in A \rel B \mid \bool(R = R^{-1}))).
  • Quantified expressions (e.g., \sum x \qdot P \mid y, \prod x \qdot P \mid y, ~\min(S), ~\max(S)).
  • Types.
    • Enumerated types.
    • Scalar types.

User Input

The end-user shall provide the following information:

  • keyboard input
  • Lexicon and Syntax.
    More precisely, it includes the symbols, the form (prefix, infix, postfix), the grammar, associativity (left-associative or right associative), commutativity, priority, the mode (flattened or not), ...
  • Pretty-print.
    Alternatively, the rendering may be determined from the notation parameters passed to the parser.
  • Typing rules.
  • Well-definedness.

Development Requirements

  • Scalability.

Towards a generic AST

The following AST parts are to become generic, or at least parameterised:

  • Lexer
  • Parser
  • Nodes ( Formula class hierarchy ): parameters needed for:
    • Type Solve (type rule needed to synthesize the type)
    • Type Check (type rule needed to verify constraints on children types)
    • WD (WD predicate)
    • PrettyPrint (tag image + notation (prefix, infix, postfix) + needs parentheses (deduced from compatibility graph))
    • Visit Formula (getting children + visitor callback mechanism)
    • Rewrite Formula (associative formulæ have a specific flattening treatment)
  • Types (Type class hierarchy): parameters needed for:
    • Building the type expression (type rule needed)
    • PrettyPrint (set operator image)
    • getting Base / Source / Target type (type rule needed)
  • Verification of preconditions (see for example AssociativeExpression.checkPreconditions)

Vocabulary

An extension is to be understood as a single additional operator definition.

Tags

Every extension is associated with an integer tag, just like existing operators. Thus, questions arise about how to allocate new tags and how to deal with existing tags.
The solution proposed here consists in keeping existing tags 'as is'. They are already defined and hard coded in the Formula class, so this choice is made with backward compatibility in mind.

Now concerning extension tags, we will first introduce a few hypotheses:

  • Tags_Hyp1: tags are never persisted across sessions on a given platform
  • Tags_Hyp2: tags are never referenced for sharing purposes across various platforms

In other words, cross-platform/session formula references are always made through their String representation. These assumptions, which were already made and verified for Rodin before extensions, lead us to restrict further considerations to the scope of a single session on a single platform.

The following definitions hold at a given instant t and for the whole platform.
Let \mathit{EXTENSION}_t be the set of extensions supported by the platform at instant t;
let \mathit{tag}_t denote the affectation of tags to an extension at instant t (\mathit{tag}_t \in \mathit{EXTENSION}_t \pfun \intg);
let \mathit{COMMON} be the set of existing tags defined by the Formula class (\mathit{COMMON} \sub \intg).
The following requirements emerge:

  • Tags_Req1: \forall t \qdot \mathit{tag}_t \in \mathit{EXTENSION}_t \tinj \intg
  • Tags_Req2: \forall e, t_1,t_2 \qdot \mathit{tag}_{t_1}(e)=\mathit{tag}_{t_2}(e) where t_1, t_2 are two instants during a given session
  • Tags_Req3: \forall t \qdot \ran(\mathit{tag}_t) \cap \mathit{COMMON} = \empty

The above-mentioned scope-restricting hypothesis can be reformulated into: \mathit{tag} needs not be stable across sessions nor across platforms.

Formula Factory

The requirements about tags give rise to a need for centralising the \mathit{tag} relation in order to enforce tag uniqueness. The Formula Factory appears to be a convenient and logical candidate for playing this role. Each time an extension is used to make a formula, the factory is called and it can check whether its associated tag exists, create it if needed, then return the new extended formula while maintaining tag consistency.

The factory can also provide API for requests about tags and extensions: getting the tag from an extension and conversely.

We also need additional methods to create extended formulæ. A first problem to address is: which type should these methods return ? We could define as many extended types as the common AST API does, namely ExtendedUnaryPredicate, ExtendedAssociativeExpression, and so on, but this would lead to a large number of new types to deal with (in visitors, filters, …), together with a constraint about which types extensions would be forced to fit into. It is thus preferable to have as few extended types as possible, but with as much parameterisation as can be. Considering that the two basic types Expression and Predicate have to be extensible, we come to add two extended types ExtendedExpression and ExtendedPredicate.

ExtendedExpression makeExtendedExpression( ? )
ExtendedPredicate makeExtendedPredicate( ? )

Second problem to address: which arguments should these methods take ? Other factory methods take the tag, a collection of children where applicable, and a source location. In order to discuss what can be passed as argument to make extended formulæ, we have to recall that the make… factory methods have various kinds of clients, namely:

  • parser
  • POG
  • provers

(other factory clients use the parsing or identifier utility methods: SC modules, indexers, …)

Thus, the arguments should be convenient for clients, depending on which information they have at hand. The source location does not obviously seem to require any adaptation and can be taken as argument the same way. Concerning the tag, it depends on whether clients have a tag or an extension at hand. Both are intended to be easily retrieved from the factory. As a preliminary choice, we can go for the tag and adjust this decision when we know more about client convenience.

As for children, the problem is more about their types. We want to be able to handle as many children as needed, and of all possible types. Looking to existing formula children configurations, we can find:

  • expressions with predicate children: \mathit{bool}(P)
  • expressions with expression children: E_1 + E_2
  • predicates with predicate children: P_1 \limp P_2
  • predicates with expression children: \mathit{partition}(S, E_1, E_2)
  • mixed operators: \{x \qdot P(x) \mid E(x)\}, but it is worth noting that the possibility of introducing bound variables in extended formulæ is not established yet.

Thus, for the sake of generality, children of both types should be supported for both extended predicates and extended expressions.

ExtendedExpression makeExtendedExpression(int tag, Expression[] expressions, Predicate[] predicates, SourceLocation location)
ExtendedPredicate makeExtendedPredicate(int tag, Expression[] expressions, Predicate[] predicates, SourceLocation location)

Defining Extensions

An extension is meant to contain every information and behaviour required by:

  • Keyboard
  • (Extensible Fonts ?)
  • Lexer
  • Parser
  • AST
  • Static Checker
  • Proof Obligation Generator
  • Provers

Keyboard requirements

Kbd_req1: an extension must provide an association combo/translation for every uncommon symbol involved in the notation.

Lexer requirements

Lex_req1: an extension must provide an association lexeme/token for every uncommon symbol involved in the notation.

Parser requirements

According to the Parser page, the following informations are required by the parser in order to be able to parse a formula containing a given extension.

  • symbol compatibility
  • group compatibility
  • symbol precedence
  • group precedence
  • notation:
    • prefix, infix, …
    • configuration (sub-parsers, symbols and their relative position, child types)

AST requirements

Extended Formulæ

AST Formulae.png

Operator Properties API

Operator properties are reified through the following interfaces and enumerated:

AST OperProps.png

Extension API

Extensions are required to implement the following APIs in order to be supported in the AST. It is the expression of the missing information for a ExtendedExpression (resp. ExtendedPredicate) to behave as a Expression (resp. Predicate). It can also be viewed as the parametrization of the AST.

AST Extensions.png

Mediator API

The mediators provided as arguments to these APIs have the following specification:

AST Mediators.png

Example: Binary PLUS

public class BinaryPlus implements IExpressionExtension {

	public Type getType(ITypeMediator mediator, ExtendedExpression expression) {
		final Type resultType = mediator.makeIntegerType();
		for (Expression child : expression.getChildExpressions()) {
			final Type childType = child.getType();
			if (!childType.equals(resultType)) {
				return null;
			}
		}
		return resultType;
	}

	public Type typeCheck(ITypeCheckMediator mediator,
			ExtendedExpression expression) {
		final Type resultType = mediator.makeIntegerType();
		for (Expression child : expression.getChildExpressions()) {
			mediator.sameType(child.getType(), resultType);
		}
		return resultType;
	}

	public String getSyntaxSymbol() {
		return "+";
	}

	public Predicate getWDPredicate(IWDMediator mediator,
			IExtendedFormula formula) {
		return mediator.makeTrueWD();
	}

	public void addCompatibilities(ICompatibilityMediator mediator) {
		mediator.addCompatibility(getId(), getId());
	}

	public void addPriorities(IPriorityMediator mediator) {
		// no priorities to set
	}

	public String getGroupId() {
		return "arithmetic";
	}

	public String getId() {
		return "binary plus";
	}

	public ExtensionKind getKind() {
		return ExtensionKind.BINARY_INFIX_EXPRESSION;
	}

}

Static Checker requirements

The static checker is involved in:

  • static checking an extension definition (pre deployment)
TODO
  • static checking a model that uses extensions (post deployment);
to that purpose, (deployed) extensions need to be placed in the build dependency graph before models that use them
it must check that referenced (deployed) extensions are present in the project
it needs to get the appropriate FormulaFactory for parsing (with referenced extensions enabled)
it must be aware of extensions being added/deleted/replaced to reprocess dependent models

Proof Obligation Generator requirements

Likewise, the POG may run on

  • an extension definition (pre deployment)
TODO
  • a model that uses extensions (post deployment)
nothing to do for WD POs (relies on the fact that extension WD is transmitted to the AST)

Prover requirements

Theorems about extensions must be converted to additional inference rules.

TODO

Extension compatibility issues

TODO

User Input Summarization

Identified required data entail the following user input:

  • id:
a String id
  • group id:
an identifier of a existing group a new group id
  • kind (determines both the type and the notation):
a choice between
  • PARENTHESIZED_PREFIX_PREDICATE: \operatorname{op}(a,b,c)
  • PARENTHESIZED_PREFIX_EXPRESSION: idem
  • BINARY_INFIX_EXPRESSION: a ~ \lozenge ~ b
  • ASSOCIATIVE_INFIX_EXPRESSION: a ~ \lozenge ~ b ~ \lozenge ~ c

As a first step we may restrict the choice to the above list. For all these kinds, all children are expressions.

  • syntax symbol:
a String equal to the operator to be parsed in formulæ (for instance "\lozenge" or "myOperator" or "\u03d5")
  • keyboard:
a list of associations 'symbol <-> ASCII shortcut' for uncommon symbols
  • parsing:
compatibility:
  • a list of operator ids of the same group, that are compatible with the defined operator
in particular, if the id of the defined operator is included, it means it is compatible with itself
priority:
  • a list of other operator ids of the same group with higher priority than this operator
  • a list of other operator ids of the same group with lower priority than this operator
additionally, if a new group is defined, it shall be given
  • the id of another group with lower priority
  • the id of another group with higher priority
As these informations have a global scope, we may think about more convenient ways to input/review them, avoiding a manual scanning of all individual extensions.
  • type rule:
  • the type of every child
as a first step we may restrict children to all bear the same type, for instance \Z or \pow(\alpha \cprod \beta).
  • (for expressions) the resulting type, which may depend on the type of the children
for instance T_1 \cprod T_2 where T_i stands for the type of the i-th child.
  • well-definedness:
as a first step we will only provide a pre-defined WD condition: 'children WD conjunction', so as long as it remains so, nothing needs to be input by the user concerning WD.

Impact on other tools

Impacted plug-ins (use a factory to build formulæ):

  • org.eventb.core
In particular, the static checker and proof obligation generator are impacted.
  • org.eventb.core.seqprover
  • org.eventb.pp
  • org.eventb.pptrans
  • org.eventb.ui

Identified Problems

The static checker shall enforce verifications to detect the following situations:

  • Two mathematical extensions are not compatible (the extensions define symbols with the same name but with a different semantics).
  • A mathematical extension is added to a model and there is a conflict between a symbol and an identifier.
  • An identifier which conflicts with a symbol of a visible mathematical extension is added to a model.

Beyond that, the following situations are problematic:

  • A formula has been written with a given parser configuration and is read with another parser configuration.
As a consequence, it appears as necessary to remember the parser configuration.
The static checker will then have a way to invalid the sources of conflicts (e.g., priority of operators, etc).
The static checker will then have a way to invalid the formula upon detecting a conflict (name clash, associativity change, semantic change...) mathieu


  • A proof may free a quantified expression which is in conflict with a mathematical extension.
SOLUTION #1: Renaming the conflicting identifiers in proofs?
  • A theorem library changes: all proofs made using this library are potentially invalidated
it is just as when a reasoner version changes, proof status should be updated to show broken proofs

Open Questions

New types

Which option should we prefer for new types?

  • OPTION #1: Transparent mode.
In transparent mode, it is always referred to the base type. As a consequence, the type conversion is implicitly supported (weak typing).
For example, it is possible to define the DISTANCE and SPEED types, which are both derived from the \intg base type, and to multiply a value of the former type with a value of the latter type.
  • OPTION #2: Opaque mode.
In opaque mode, it is never referred to the base type. As a consequence, values of one type cannot be converted to another type (strong typing).
Thus, the above multiplication is not allowed.
This approach has at least two advantages:
  • Stronger type checking.
  • Better prover performances.
It also has some disadvantages:
  • need of extractors to convert back to base types.
  • need of extra circuitry to allow things like x:=d*2 where x, d are of type DISTANCE
  • OPTION #3: Mixed mode.
In mixed mode, the transparent mode is applied to scalar types and the opaque mode is applied to other types.

Scope of the mathematical extensions

  • OPTION #1: Project scope.
The mathematical extensions are implicitly visible to all components of the project that has imported them.
  • OPTION #2: Component scope.
The mathematical extensions are only visible to the components that have explicitly imported them. However, note that this visibility is propagated through the hierarchy of contexts and machines (EXTENDS, SEES and REFINES clauses).
An issue has been identified. Suppose that ext1 extension is visible to component C1 and ext2 is visible to component C2, and there is no compatibility issue between ext1 and ext2. It is not excluded that an identifier declared in C1 conflict with a symbol in ext2. As a consequence, a global verification is required when adding a new mathematical extension.
  • OPTION #3: Workspace scope.
The mathematical extensions are visible to the whole workspace.

Bibliography

This proposal consists in considering three kinds of extension:
  1. Extensions of set-theoretic expressions or predicates: example extensions of this kind consist in adding the transitive closure of relations or various ordered relations.
  2. Extensions of the library of theorems for predicates and operators.
  3. Extensions of the Set Theory itself through the definition of algebraic types such as lists or ordered trees using new set constructors.