The Use of Theories in Code Generation: Difference between revisions
imported>Andy |
imported>Andy |
||
Line 1: | Line 1: | ||
= The Theory Plug-in = | |||
The theory plug-in is used to add mathematical extensions to Rodin. The theories are created, and deployed, and can then be used in any models in the workspace. When dealing with implementation level models, such as in Tasking Event-B, we need to consider how to translate newly added types and operators into code. We have augmented the theory interface with a Translation Rules section. This enables a user to define translation rules that map Event-B formulas to code. | The theory plug-in is used to add mathematical extensions to Rodin. The theories are created, and deployed, and can then be used in any models in the workspace. When dealing with implementation level models, such as in Tasking Event-B, we need to consider how to translate newly added types and operators into code. We have augmented the theory interface with a Translation Rules section. This enables a user to define translation rules that map Event-B formulas to code. | ||
== Translation Rules== | |||
Figure 1 shows the interface, and some translations rules of the mapping to Ada. | Figure 1 shows the interface, and some translations rules of the mapping to Ada. | ||
Line 13: | Line 13: | ||
The translation rules are templates used for pattern matching. The meta-variables are defined and typed, and used in the rules. Event-B expressions and predicates are defined on the left hand side of the rule, and the code to be output (as text) appears on the right hand side of the matching rule. | The translation rules are templates used for pattern matching. The meta-variables are defined and typed, and used in the rules. Event-B expressions and predicates are defined on the left hand side of the rule, and the code to be output (as text) appears on the right hand side of the matching rule. | ||
== Type Rules == | |||
The type rules section, shown in Figure 1, is where the relationship is defined, between Event-B types and the type system of the implementation. | The type rules section, shown in Figure 1, is where the relationship is defined, between Event-B types and the type system of the implementation. |
Revision as of 08:43, 15 May 2012
The Theory Plug-in
The theory plug-in is used to add mathematical extensions to Rodin. The theories are created, and deployed, and can then be used in any models in the workspace. When dealing with implementation level models, such as in Tasking Event-B, we need to consider how to translate newly added types and operators into code. We have augmented the theory interface with a Translation Rules section. This enables a user to define translation rules that map Event-B formulas to code.
Translation Rules
Figure 1 shows the interface, and some translations rules of the mapping to Ada.
The translation rules are templates used for pattern matching. The meta-variables are defined and typed, and used in the rules. Event-B expressions and predicates are defined on the left hand side of the rule, and the code to be output (as text) appears on the right hand side of the matching rule.
Type Rules
The type rules section, shown in Figure 1, is where the relationship is defined, between Event-B types and the type system of the implementation.