SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Downloaden Sie, um offline zu lesen
The Future of DSLs:
Functions and Formal Methods
Markus Völter
voelter@acm.org
www.voelter.de
@markusvoelter
1
The Ancient Past.
2
The World as it is.
Precision
Programming
!=
{
Formulas, Rules
Data Structures
Tables
Values
}
Performance
Scalability
Robustness
Deployment
+ Tests
Data changes.
The Type System supports temporal data natively.
Law changes over the years.
The payroll calculations have to follow.
All languages shown in this talk
are built with the open source
JetBrains MPS language workbench.
MPS Language Workbench
Language Workbench
Open Source, by Jetbrains
Very Expressive
Used for years in industry
Vast Experience
MPS: Notational Freedom
100% crucial for acceptance in domain!
Rabbit Hole
Modeling is more than diagrams!
MPS: Language Composition
SPLE on Language Level!
Language Patterns
New Language
GPL Extension
Existing
Domain Notation
(Informal)
Formalization
Formalized
Language
Reuse GPL incl. Expressions and TS
Add/Embed DS-extensions
Compatible notational style
Reduce to GPL
Analyze Domain to find Abstractions
Define suitable, new notations
Rely on existing behavioral paradigm
Reuse standard expression language
Interpret/Generate to one or more GPLs
Use existing notation from domain
Clean up and formalize
Generate/Interpret
Often import existing „models“
Language Patterns
DSL Development
GPL Extension
Reuse GPL incl. Expressions and TS
Add/Embed DS-extensions
Compatible notational style
Reduce to GPL
An extensible set of integrated languages
for embedded software engineering.
Different kinds of languages, as
illustrated by the different
distributions of aspect code.
DSL Development
New Language
Analyze Domain to find Abstractions
Define suitable, new notations
Rely on existing behavioral paradigm
Reuse standard expression language
Interpret/Generate to one or more GPLs
KernelF
f f f f
f f f f
Specification: mbeddr contracts
Analysis:
Model
Checking
C Code
Specification: KernelF
Analysis: SMT Solving of Expressions
Specification: NuSMV extensions (Dan Ratiu)
Programming vs. MD: Traditionally
Programming vs. MD: What it can be
3
Is this good enough?
Notational Flexibility.
Language Modularity.
Collaboration.
In the Browser.
Semantics Definition.
KernelF
DSL
Java
SMT
Interpreter
*
Notational Flexibility.
Language Modularity.
Collaboration.
In the Browser.
Semantics Definition.
KernelF
DSL
Java
SMT
Interpreter
Not Incremental!
4
Where we go from here.
Shadow Models
Incremental, Realtime
Model Transformations
for MPS
User edits the input model
A delta is propagated into the
transformation engine
A change on the shadow model
is produced
This triggers analysis or update of
results in Shadow Model
Results/messages are lifted back to
input level
Results are annotated to the
input model
Mightbestacked
Shadow Models for DSL Development.
Run incrementally,
basically like in Excel.
Generate to (faster)
Java code
Verify properties
(SMT, Model Checking)
t=1 t=2
t=3 t=4
f f f f
f f f f
f f f f
f f f f
f f f f
f f f f
f f f f
f f f f
t= ...
Execution Paradigms
Functional / Spreadsheet Reactive/Imperative
t
<DEMO>
D
E
M
O
User Level
D
E
M
O
The next code snippet shows a selection of the KernelF2
base language concepts. We define a couple of values and
use various operators and types. Functions, generics and
algebraic data types are demonstrated as well.
D
E
M
O
Some of the expressions, such as true && true or 10 * 20
could be evaluated statically; and indeed, there is a
Shadow Models transformation for the KernelF2 base
language that performs such simplifications:
D
E
M
O
Now we demonstrate language extension and desugaring. This shows three of the
extension constructs defined in the kernelf2.sugar language: enums, alt
expressions and decision tables. These are not part of the core, but defined
in a modular extension; their semantics is defined through a reduction to the
base language. ?maybe? is a Boolean expression that we have added for demo
purposes to avoid making up arbitrary Boolean expressions all the time.
D
E
M
O
Below is the reduced version
of the previous code: enums
become constants that follow
a particular naming
convention, the alt
expression becomes nested
ifs, and the decision table
is translated to nested alt
expressions which are then in
turn reduced to ifs. Notice
how the reduced version
contains errors that are
produced by type checks of
the base language:
declarations must have unique
names and the <!> expression
must never show up. In this
case, <!> is produced by the
transformation because the
decision table has these
?maybe? expressions, so the
type system cannot statically
figure out whether the table
is complete and free from
overlaps.
D
E
M
O
Below we can see an error message in the source model
that is lifted from the shadow. No analysis happens on
the level of the enum declaration itself. Lifting errors
is a core use case for Shadow Models.
D
E
M
O
Implementation
[Simplifications]
D
E
M
O
Here is the entry point to the transformation; it contributes to a predefined
transformation that attaches the results of transformations to the shadow
repository, a Shadow-Models internal data structure that is also visualized
in the IDE. This contribution iterates over all the models in MPS that
contain a Module (the root concept of KernelF2, see examples above) and
transforms each of them through the fork moduleFork. It copies its input
while applying two transformations (declared elsewhere) to a fixpoint.
D
E
M
O
This screenshot shows the simplify transformation. The first entry
declares an abstract transformation from Expr to Expr; the other two
polymorphically override the declaration for the LogicalNotExpr and
the PlusExpr. The former transforms a !true to false and the second
one performs the static addition of number literals.
D
E
M
O
The concrete simplify transformations are defined in the
same language as its abstract declaration; this is not
the case for the desugar transformation. Only the
abstract declaration is specified in the kernelf.core
language, with language extensions expected to provide
the overrides:
D
E
M
O
Implementation
[Enums]
D
E
M
O
Let’s take a look at the reduction of enums to constants. The respective
transformation overrides the desugar transformation for EnumDecls. The
transformation iterates over the literals in the enum, and transforms each of
them into a Constant (note how the rule is allowed to create multiple outputs
as opposed to just one, as defined in the abstract declaration). The name and
the value properties of the created Constant are computed with Java
expressions that access the properties of the input node. The mapping between
the each EnumLiteral and the resulting Constant is stored in the enumLit-
ToConst mapping label.
D
E
M
O
We need two more transformations. First, we have to transform every
EnumType (as in val x: Color = …) into an IntType (val x: int = …),
because all enums are transformed to int constants. And whenever we
reference an enum literal using a EnumLitRef expression, we have to
transform it to a reference to the particular Constant that has been
created from the referenced literal; we can find it by querying the
previously populated label.
D
E
M
O
Implementation
[Error Lifting]
D
E
M
O
Error Lifing relies on detecting particular error messages on output nodes of
the transformation and, if one exists, back-propagating a new error to one or
more of the input nodes. To this end, transformation authors override a
predefined operation liftMessage “inside” the creator of the target node.
Here is the example for the enums:
The operation implementation, written inside the Constant, checks if the
error message(s) reported by MPS on this Constant contain the word
“duplicate”. If so, we propagate a message “this is the duplicate” to the
currently transformed literal, and another error “duplicate literal names” to
the input EnumDecl. The framework takes care automatically of removing the
lifted errors if their causes go away.
D
E
M
O
Implementation
[Alt Expressions]
D
E
M
O
A foldR function joins output for the n-th element of the list to
what has been constructed for the n-1-th list element. In this case,
we create a new if that reuses the condition of the current option
and puts its value into the then part. The else part of the currently
constructed if is whatever the previous iteration has created,
represented by the acc (short for accumulator) expression inside the
foldR. For the first entry in the alt’s list of options, we pass a
seed value to foldR; in our case it is the NeverLit, rendered as <!>.
D
E
M
O
This transformation will create a set of nested ifs, where the last one
always has an <!> in its else part. However, if we look above, the
transformation of the alt expression in the Extensions module did not include
an else <!> at the tail. Why is this? The reason is the otherwise in the last
option, it’s basically a catch-all clause. That last option will be
transformed to by the transformation above:
However, the set of base language simplifications defines one that transforms
an if true to the then part, because we know statically the else option will
never occur:
The case above thus simply becomes 3 and the else <!> goes away. As a
corollary, this means that whenever a <!> is created as the result of the
transformation of an alt expression (and survives simplification), then this
is an indication of an error in the alt expression; which is why we add a
corresponding lifter to the transformation, as can be seen above.
D
E
M
O
IDE Integrations
D
E
M
O
The Shadow Repository in the MPS project view that shows
the results of all transformations; double clicking any
root opens it in an editor, and the incremental
transformations can be observed in realtime.
D
E
M
O
The Fork Explorer shows the execution of the
transformations, including the inputs it processes and
the output nodes it creates.
</DEMO>
5
Status.
Basically works.
Performance Eval
outstanding.
Syntactic simplifications
necessary.
Syntactic
Improvements
„Just Work“ Needs
Research

Weitere ähnliche Inhalte

Was ist angesagt?

C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
Tareq Hasan
 

Was ist angesagt? (20)

C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
C programming interview questions
C programming interview questionsC programming interview questions
C programming interview questions
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
Fortran 95
Fortran 95Fortran 95
Fortran 95
 
Fortran compiling 2
Fortran compiling 2Fortran compiling 2
Fortran compiling 2
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
01 c++ Intro.ppt
01 c++ Intro.ppt01 c++ Intro.ppt
01 c++ Intro.ppt
 
What's New In Python 2.5
What's New In Python 2.5What's New In Python 2.5
What's New In Python 2.5
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
Doppl development iteration #1
Doppl development   iteration #1Doppl development   iteration #1
Doppl development iteration #1
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
OOP Poster Presentation
OOP Poster PresentationOOP Poster Presentation
OOP Poster Presentation
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
 
C fundamental
C fundamentalC fundamental
C fundamental
 
c# at f#
c# at f#c# at f#
c# at f#
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
Features of c
Features of cFeatures of c
Features of c
 

Ähnlich wie The future of DSLs - functions and formal methods

C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
Rajeshkumar Reddy
 

Ähnlich wie The future of DSLs - functions and formal methods (20)

Opps concept
Opps conceptOpps concept
Opps concept
 
COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis: COMPILER DESIGN- Introduction & Lexical Analysis:
COMPILER DESIGN- Introduction & Lexical Analysis:
 
Sprouting into the world of Elm
Sprouting into the world of ElmSprouting into the world of Elm
Sprouting into the world of Elm
 
Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
 
Embedded c
Embedded cEmbedded c
Embedded c
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)MDE=Model Driven Everything (Spanish Eclipse Day 2009)
MDE=Model Driven Everything (Spanish Eclipse Day 2009)
 
F# 101
F# 101F# 101
F# 101
 
JavaScript: Core Part
JavaScript: Core PartJavaScript: Core Part
JavaScript: Core Part
 
Matlab for diploma students(1)
Matlab for diploma students(1)Matlab for diploma students(1)
Matlab for diploma students(1)
 
C Language Presentation.pptx
C Language Presentation.pptxC Language Presentation.pptx
C Language Presentation.pptx
 
Data services-functions
Data services-functionsData services-functions
Data services-functions
 
Final requirement
Final requirementFinal requirement
Final requirement
 
1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf1588147798Begining_ABUAD1.pdf
1588147798Begining_ABUAD1.pdf
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
Epsilon
EpsilonEpsilon
Epsilon
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScript
 
Operators
OperatorsOperators
Operators
 

Mehr von Markus Voelter

Deklarative Smart Contracts
Deklarative Smart ContractsDeklarative Smart Contracts
Deklarative Smart Contracts
Markus Voelter
 
Generic Tools, Specific Laguages
Generic Tools, Specific LaguagesGeneric Tools, Specific Laguages
Generic Tools, Specific Laguages
Markus Voelter
 
Domain Specific Language Design
Domain Specific Language DesignDomain Specific Language Design
Domain Specific Language Design
Markus Voelter
 

Mehr von Markus Voelter (20)

Consulting
ConsultingConsulting
Consulting
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?
 
Deklarative Smart Contracts
Deklarative Smart ContractsDeklarative Smart Contracts
Deklarative Smart Contracts
 
Using language workbenches and domain-specific languages for safety-critical ...
Using language workbenches and domain-specific languages for safety-critical ...Using language workbenches and domain-specific languages for safety-critical ...
Using language workbenches and domain-specific languages for safety-critical ...
 
What's Missing in Language Workbenches
What's Missing in Language WorkbenchesWhat's Missing in Language Workbenches
What's Missing in Language Workbenches
 
How Domains Shape Languages
 How Domains Shape Languages How Domains Shape Languages
How Domains Shape Languages
 
Why Modeling Suck Sucks
Why Modeling Suck SucksWhy Modeling Suck Sucks
Why Modeling Suck Sucks
 
Fusing Modeling and Programming into Language-Oriented Programming
Fusing Modeling and Programming into Language-Oriented ProgrammingFusing Modeling and Programming into Language-Oriented Programming
Fusing Modeling and Programming into Language-Oriented Programming
 
Lessons Learned from building mbeddr
Lessons Learned from building mbeddrLessons Learned from building mbeddr
Lessons Learned from building mbeddr
 
The Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelFThe Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelF
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language Workbenches
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific Languages
 
Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)Generic Tools - Specific Languages (PhD Defense Slides)
Generic Tools - Specific Languages (PhD Defense Slides)
 
Language-Oriented Business Applications
Language-Oriented Business ApplicationsLanguage-Oriented Business Applications
Language-Oriented Business Applications
 
Generic Tools, Specific Laguages
Generic Tools, Specific LaguagesGeneric Tools, Specific Laguages
Generic Tools, Specific Laguages
 
Domain Specific Language Design
Domain Specific Language DesignDomain Specific Language Design
Domain Specific Language Design
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back Again
 
Faszination Segelfliegen
Faszination SegelfliegenFaszination Segelfliegen
Faszination Segelfliegen
 
Introduction To MDD
Introduction To MDDIntroduction To MDD
Introduction To MDD
 
Professional Podcasting Guide
Professional Podcasting GuideProfessional Podcasting Guide
Professional Podcasting Guide
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 

The future of DSLs - functions and formal methods

  • 1. The Future of DSLs: Functions and Formal Methods Markus Völter voelter@acm.org www.voelter.de @markusvoelter
  • 3. 2 The World as it is.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Data changes. The Type System supports temporal data natively.
  • 14.
  • 15. Law changes over the years. The payroll calculations have to follow.
  • 16.
  • 17. All languages shown in this talk are built with the open source JetBrains MPS language workbench.
  • 18. MPS Language Workbench Language Workbench Open Source, by Jetbrains Very Expressive Used for years in industry Vast Experience
  • 19. MPS: Notational Freedom 100% crucial for acceptance in domain! Rabbit Hole Modeling is more than diagrams!
  • 20. MPS: Language Composition SPLE on Language Level!
  • 21.
  • 22. Language Patterns New Language GPL Extension Existing Domain Notation (Informal) Formalization Formalized Language Reuse GPL incl. Expressions and TS Add/Embed DS-extensions Compatible notational style Reduce to GPL Analyze Domain to find Abstractions Define suitable, new notations Rely on existing behavioral paradigm Reuse standard expression language Interpret/Generate to one or more GPLs Use existing notation from domain Clean up and formalize Generate/Interpret Often import existing „models“ Language Patterns
  • 23.
  • 24. DSL Development GPL Extension Reuse GPL incl. Expressions and TS Add/Embed DS-extensions Compatible notational style Reduce to GPL
  • 25. An extensible set of integrated languages for embedded software engineering.
  • 26. Different kinds of languages, as illustrated by the different distributions of aspect code.
  • 27. DSL Development New Language Analyze Domain to find Abstractions Define suitable, new notations Rely on existing behavioral paradigm Reuse standard expression language Interpret/Generate to one or more GPLs KernelF f f f f f f f f
  • 28.
  • 29.
  • 30.
  • 32. Specification: KernelF Analysis: SMT Solving of Expressions
  • 34.
  • 35. Programming vs. MD: Traditionally
  • 36. Programming vs. MD: What it can be
  • 37.
  • 38. 3 Is this good enough?
  • 39. Notational Flexibility. Language Modularity. Collaboration. In the Browser. Semantics Definition. KernelF DSL Java SMT Interpreter *
  • 40. Notational Flexibility. Language Modularity. Collaboration. In the Browser. Semantics Definition. KernelF DSL Java SMT Interpreter Not Incremental!
  • 41. 4 Where we go from here.
  • 42. Shadow Models Incremental, Realtime Model Transformations for MPS
  • 43. User edits the input model A delta is propagated into the transformation engine A change on the shadow model is produced This triggers analysis or update of results in Shadow Model Results/messages are lifted back to input level Results are annotated to the input model Mightbestacked
  • 44. Shadow Models for DSL Development. Run incrementally, basically like in Excel. Generate to (faster) Java code Verify properties (SMT, Model Checking)
  • 45. t=1 t=2 t=3 t=4 f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f t= ... Execution Paradigms Functional / Spreadsheet Reactive/Imperative t
  • 48. D E M O The next code snippet shows a selection of the KernelF2 base language concepts. We define a couple of values and use various operators and types. Functions, generics and algebraic data types are demonstrated as well.
  • 49. D E M O Some of the expressions, such as true && true or 10 * 20 could be evaluated statically; and indeed, there is a Shadow Models transformation for the KernelF2 base language that performs such simplifications:
  • 50. D E M O Now we demonstrate language extension and desugaring. This shows three of the extension constructs defined in the kernelf2.sugar language: enums, alt expressions and decision tables. These are not part of the core, but defined in a modular extension; their semantics is defined through a reduction to the base language. ?maybe? is a Boolean expression that we have added for demo purposes to avoid making up arbitrary Boolean expressions all the time.
  • 51. D E M O Below is the reduced version of the previous code: enums become constants that follow a particular naming convention, the alt expression becomes nested ifs, and the decision table is translated to nested alt expressions which are then in turn reduced to ifs. Notice how the reduced version contains errors that are produced by type checks of the base language: declarations must have unique names and the <!> expression must never show up. In this case, <!> is produced by the transformation because the decision table has these ?maybe? expressions, so the type system cannot statically figure out whether the table is complete and free from overlaps.
  • 52. D E M O Below we can see an error message in the source model that is lifted from the shadow. No analysis happens on the level of the enum declaration itself. Lifting errors is a core use case for Shadow Models.
  • 54. D E M O Here is the entry point to the transformation; it contributes to a predefined transformation that attaches the results of transformations to the shadow repository, a Shadow-Models internal data structure that is also visualized in the IDE. This contribution iterates over all the models in MPS that contain a Module (the root concept of KernelF2, see examples above) and transforms each of them through the fork moduleFork. It copies its input while applying two transformations (declared elsewhere) to a fixpoint.
  • 55. D E M O This screenshot shows the simplify transformation. The first entry declares an abstract transformation from Expr to Expr; the other two polymorphically override the declaration for the LogicalNotExpr and the PlusExpr. The former transforms a !true to false and the second one performs the static addition of number literals.
  • 56. D E M O The concrete simplify transformations are defined in the same language as its abstract declaration; this is not the case for the desugar transformation. Only the abstract declaration is specified in the kernelf.core language, with language extensions expected to provide the overrides:
  • 58. D E M O Let’s take a look at the reduction of enums to constants. The respective transformation overrides the desugar transformation for EnumDecls. The transformation iterates over the literals in the enum, and transforms each of them into a Constant (note how the rule is allowed to create multiple outputs as opposed to just one, as defined in the abstract declaration). The name and the value properties of the created Constant are computed with Java expressions that access the properties of the input node. The mapping between the each EnumLiteral and the resulting Constant is stored in the enumLit- ToConst mapping label.
  • 59. D E M O We need two more transformations. First, we have to transform every EnumType (as in val x: Color = …) into an IntType (val x: int = …), because all enums are transformed to int constants. And whenever we reference an enum literal using a EnumLitRef expression, we have to transform it to a reference to the particular Constant that has been created from the referenced literal; we can find it by querying the previously populated label.
  • 61. D E M O Error Lifing relies on detecting particular error messages on output nodes of the transformation and, if one exists, back-propagating a new error to one or more of the input nodes. To this end, transformation authors override a predefined operation liftMessage “inside” the creator of the target node. Here is the example for the enums: The operation implementation, written inside the Constant, checks if the error message(s) reported by MPS on this Constant contain the word “duplicate”. If so, we propagate a message “this is the duplicate” to the currently transformed literal, and another error “duplicate literal names” to the input EnumDecl. The framework takes care automatically of removing the lifted errors if their causes go away.
  • 63. D E M O A foldR function joins output for the n-th element of the list to what has been constructed for the n-1-th list element. In this case, we create a new if that reuses the condition of the current option and puts its value into the then part. The else part of the currently constructed if is whatever the previous iteration has created, represented by the acc (short for accumulator) expression inside the foldR. For the first entry in the alt’s list of options, we pass a seed value to foldR; in our case it is the NeverLit, rendered as <!>.
  • 64. D E M O This transformation will create a set of nested ifs, where the last one always has an <!> in its else part. However, if we look above, the transformation of the alt expression in the Extensions module did not include an else <!> at the tail. Why is this? The reason is the otherwise in the last option, it’s basically a catch-all clause. That last option will be transformed to by the transformation above: However, the set of base language simplifications defines one that transforms an if true to the then part, because we know statically the else option will never occur: The case above thus simply becomes 3 and the else <!> goes away. As a corollary, this means that whenever a <!> is created as the result of the transformation of an alt expression (and survives simplification), then this is an indication of an error in the alt expression; which is why we add a corresponding lifter to the transformation, as can be seen above.
  • 66. D E M O The Shadow Repository in the MPS project view that shows the results of all transformations; double clicking any root opens it in an editor, and the incremental transformations can be observed in realtime.
  • 67. D E M O The Fork Explorer shows the execution of the transformations, including the inputs it processes and the output nodes it creates.