Model-Based Methods
and
Automation of Software Production
Jussi Rintanen
Department of Computer Science, Aalto University
December 13, 2018
The Problem
• Massive programmer shortage:
• Finland: 7000+
• USA: 200000+
• Programmer productivity too low
• Programming is a craft industry
Completely new kind of solutions are needed!
How do we program computers?
mov ax,@data
mov ds,ax
mov bx,si_ze
dec bx
xx:
mov cx,bx
mov si,0
yy:
mov al,a[si]
inc si
cmp al,a[si]
jb zz
xchg al,a[si]
mov a[si-1],al
zz:
loop yy
dec bx
jnz xx
How do we program computers?
40 N = N - 1
70 ISCAN = 1
IOK = 1
ISTOP = N
IF(ISTART - ISTOP) 50, 110, 110
50 IF(NUMS(ISCAN) - NUMS(ISCAN+1)) 90,90,60
60 J = NUMS(ISCAN)
NUMS(ISCAN) = NUMS(ISCAN+1)
NUMS(ISCAN+1) = J
IOK = 0
90 IF(ISCAN - (ISTOP - 1)) 80,100,100
80 ISCAN = ISCAN + 1
GOTO 50
100 IF(IOK) 105,105,110
105 ISTOP = ISTOP - 1
GOTO 70
110 DO 120 I=1, N
120 PRINT 130, NUMS(I)
130 FORMAT(I10)
STOP
END
How do we program computers?
for (c = 0; c < n; c++)
scanf("%d", &array[c]);
for (c = 0 ; c < n - 1; c++)
{
for (d = 0 ; d < n - c - 1; d++)
{
if (array[d] > array[d+1]) /* For decreasing order use < */
{
swap = array[d];
array[d] = array[d+1];
array[d+1] = swap;
}
}
}
What are programs good for?
• Easy to compile to machine code
• Easy to execute
• Easy to understand what it really does, in terms of
machine code
What are programs not so good for?
• Difficult to prove correct
• Difficult to analyze and reason about
• Difficult to use for other purposes than execute
(This is why testing beats correctness proofs)
• Difficult to understand (by programmer, other people)
Model-Based Approach to Software
SW for managing electricity networks
Model of a network:
• power lines
(topology)
• switches
• protection devices
• transformers
• customer
connections
Functionalities:
• Monitoring and diagnosis
• Control and reconfiguration
• Management of maintenance
crews
• Medium and long-term planning
of network maintenance,
modifications, extensions
Model-Based Approach to Software
SW for data-intensive applications
Model of an application:
• Data model
• Rules governing change of data
• Permissions to access, modify
(who? when?)
Functionalities:
• Analyze the model
• Implement the model
(code)
• Automate tasks (A.I.)
Our Goals
• Make (some of) SW development engineering
• Systematic process to develop SW specifications
• “AI” to do (almost) all of the routine coding
• Lift the abstraction level of code written by programmers
• Shift focus from code to business/organizational processes
• Result:
• Decreased development effort
• Easier testing and validation
• More modifiable and extendible SW
• Independence from execution environment (PL, OS, DBMS, UI)
Our Goals: Longer Term
• Intelligent agents (A.I.) supporting (and replacing) humans
in organizational roles
• Networks of interacting and inter-operating SW systems
• Fully automated companies, agencies, services, ...
• Integration with physical assets and infrastructure
• management of primary industries, energy, manufacturing,
transportation and logistics, services, ...
EIAI / aitocode: Software Production
users
HTML/HTTP
mobile apps
email/messaging
SW
DBMS
cloud storage
external SW
How Is Software Produced?
1 Precisely specify what the software is to do
2 Analyze software specification (automatic)
3 Choose:
• Programming language
• Database system(s)
• Operating system / execution environment
4 Synthesize software system (automatic)
5 Deploy software system (automatic)
Abstract View of Software
1 A university employee can establish a new
course in a given faculty, if the employee is
the director of education of the faculty.
2 A university employee can change the
responsible teacher of a course, if the
employee is the director of education for the
faculty responsible for the course.
3 A university employee can change the
requirements for a B.Sc. degree granted by a
given faculty, if the employee is the director
of education of the faculty.
4 A student can be granted a B.Sc. degree, if
the student has passed all courses required
for the degree.
5 A student can register for a course, if the
student has the right to study at the
university, and the course is part of the
studies for a degree the student is studying
for.
6 A student can register for an exam, if the
student is registered for the course.
7 A university employee can record the exam
grade for a student, if the student was
registered for the exam, and the exam is for a
course for which the employee is the
responsible teacher.
8 A student is recorded as having passed a
course, if the student has passed an exam for
the course and fulfilled other requirements
(for example, done obligatory home
assignments and a course project.)
9 A university employee can mark a course as
passed for a student, if the employee is the
responsible teacher of the course, and the
student was enrolled on the course.
Rules of an Application
Each of the informal rules can formalized as three parts:
• Inputs
• What does the user supply when performing the action?
• Each input has a type (int, string, set, list, ...)
• Condition
• What condition has to hold for the action to be possible?
• Boolean combination of atomic conditions (and, or, not, ...)
• Also limits the possible inputs!
• Effect
• How does the action modify the data (in the DB)
• One or more pieces of “code”
Rules of an Application
Each of the informal rules can formalized as three parts:
• Inputs
• What does the user supply when performing the action?
• Each input has a type (int, string, set, list, ...)
• Condition
• What condition has to hold for the action to be possible?
• Boolean combination of atomic conditions (and, or, not, ...)
• Also limits the possible inputs!
• Effect
• How does the action modify the data (in the DB)
• One or more pieces of “code”
Rules of an Application
Each of the informal rules can formalized as three parts:
• Inputs
• What does the user supply when performing the action?
• Each input has a type (int, string, set, list, ...)
• Condition
• What condition has to hold for the action to be possible?
• Boolean combination of atomic conditions (and, or, not, ...)
• Also limits the possible inputs!
• Effect
• How does the action modify the data (in the DB)
• One or more pieces of “code”
Example
A Facebook-style social media application
Who can post on a wall?
• The owner of the wall
• Friends of the wall owner
Result: Post appears on the
wall and in all relevant feeds.
action post(p : feedData, wallOwner : user) {
wallOwner == currentuser
or currentuser in wallOwner.friends
==>
new ent : feedEntry [ t = now,
entry = p,
comments = [],
auth = currentuser.auth,
owner = currentuser ];
wallOwner.wall = concat(wallOwner.wall,[ent]);
currentuser.posts = concat(wallOwner.wall,[ent]);
forall (u in currentuser.friends)
u.feed = concat(u.feed,[ent]);
}
Example
Peer-reviewing for an academic journal
Some articles can be published
as a new volume if
• the current user is the editor
of the journal,
• the articles are unpublished
and belong to the journal,
• the set of articles is
non-empty.
action createNewVolume( p : article set,
j : journal ) {
currentuser == j.editor
and subseteq(p,j.unpublishedarticles)
and card(p) > 0
==>
j.lastvolumenumber = j.lastvolumenumber + 1;
j.unpublishedarticles = j.unpublishedarticles  p;
new v : volume [ volumenumber = j.lastvolumenumber,
publicationtime = now,
articles = p ];
j.publishedvolumes = j.publishedvolumes U { v };
forall (a in p) a.volume = v;
}
How Is A Rule Implemented?
1 Is current user able to take the action? (UI menus etc.)
• Can precondition be true, for some inputs?
• Conceptually, must go through all possible input values
2 What input options to offer user? (UI input forms)
• Which input combinations can make precondition true?
• Conceptually, must produce all input combinations
3 Execute the rule
• Is precondition (with inputs) true? (easy)
• Execute the “Effects” part (easy)
• Implemented as a DBMS transaction
First two are both NP-hard (or harder)!
How Is A Rule Implemented?
1 Is current user able to take the action? (UI menus etc.)
• Can precondition be true, for some inputs?
• Conceptually, must go through all possible input values
2 What input options to offer user? (UI input forms)
• Which input combinations can make precondition true?
• Conceptually, must produce all input combinations
3 Execute the rule
• Is precondition (with inputs) true? (easy)
• Execute the “Effects” part (easy)
• Implemented as a DBMS transaction
First two are both NP-hard (or harder)!
How Is A Rule Implemented?
1 Is current user able to take the action? (UI menus etc.)
• Can precondition be true, for some inputs?
• Conceptually, must go through all possible input values
2 What input options to offer user? (UI input forms)
• Which input combinations can make precondition true?
• Conceptually, must produce all input combinations
3 Execute the rule
• Is precondition (with inputs) true? (easy)
• Execute the “Effects” part (easy)
• Implemented as a DBMS transaction
First two are both NP-hard (or harder)!
EIAI / aitocode: What We Have Now
Project since 2016, with 2018 funding from Business Finland
• Core technology completed
• Prototype implementation works
• Demo applications running
• peer-reviewing and publication for academic journals (10 rules)
• university course management (5 rules)
• social media (“Facebook”) (7 rules)
• blogging website (3 rules)
• web chat (2 rules)
• Other applications under development
EIAI / aitocode: Next Steps
• IDE integration (Q3/2019)
• Alternative PL, OS, DBMS, UI (Q3/2019)
• Mobile apps (2020)
• Verification/validation (2020)
• correctness proofs (w.r.t. stated properties)
• spec anomalies: unreachable and redundant actions & data
• Intelligence (2021)
• optimal data input (w.r.t. evaluation of a condition)
• suggest actions to human users (w.r.t. users’ goals)
• take action sequences autonomously
• minimization of a cost measure, maximization of a reward measure
Interested?
We are looking for collaboration partners:
• Companies to participate in technology trials
• Software developers willing to try out
• Everything else to transfer the technology to real use
Conclusion
• Automation of software production
• data and knowledge-intensive information systems
• web applications
• et cetera
• Future:
• Increased intelligence (automated embedding of “AI” in SW)
• Highly automated analytics and validation
Code is not interesting, systems and their features are!
Jussi.Rintanen@aalto.fi (technology)
Mika.Parikka@aalto.fi (business)
aitocode.com

Model-based programming and AI-assisted software development

  • 1.
    Model-Based Methods and Automation ofSoftware Production Jussi Rintanen Department of Computer Science, Aalto University December 13, 2018
  • 2.
    The Problem • Massiveprogrammer shortage: • Finland: 7000+ • USA: 200000+ • Programmer productivity too low • Programming is a craft industry Completely new kind of solutions are needed!
  • 3.
    How do weprogram computers? mov ax,@data mov ds,ax mov bx,si_ze dec bx xx: mov cx,bx mov si,0 yy: mov al,a[si] inc si cmp al,a[si] jb zz xchg al,a[si] mov a[si-1],al zz: loop yy dec bx jnz xx
  • 4.
    How do weprogram computers? 40 N = N - 1 70 ISCAN = 1 IOK = 1 ISTOP = N IF(ISTART - ISTOP) 50, 110, 110 50 IF(NUMS(ISCAN) - NUMS(ISCAN+1)) 90,90,60 60 J = NUMS(ISCAN) NUMS(ISCAN) = NUMS(ISCAN+1) NUMS(ISCAN+1) = J IOK = 0 90 IF(ISCAN - (ISTOP - 1)) 80,100,100 80 ISCAN = ISCAN + 1 GOTO 50 100 IF(IOK) 105,105,110 105 ISTOP = ISTOP - 1 GOTO 70 110 DO 120 I=1, N 120 PRINT 130, NUMS(I) 130 FORMAT(I10) STOP END
  • 5.
    How do weprogram computers? for (c = 0; c < n; c++) scanf("%d", &array[c]); for (c = 0 ; c < n - 1; c++) { for (d = 0 ; d < n - c - 1; d++) { if (array[d] > array[d+1]) /* For decreasing order use < */ { swap = array[d]; array[d] = array[d+1]; array[d+1] = swap; } } }
  • 6.
    What are programsgood for? • Easy to compile to machine code • Easy to execute • Easy to understand what it really does, in terms of machine code
  • 7.
    What are programsnot so good for? • Difficult to prove correct • Difficult to analyze and reason about • Difficult to use for other purposes than execute (This is why testing beats correctness proofs) • Difficult to understand (by programmer, other people)
  • 8.
    Model-Based Approach toSoftware SW for managing electricity networks Model of a network: • power lines (topology) • switches • protection devices • transformers • customer connections Functionalities: • Monitoring and diagnosis • Control and reconfiguration • Management of maintenance crews • Medium and long-term planning of network maintenance, modifications, extensions
  • 9.
    Model-Based Approach toSoftware SW for data-intensive applications Model of an application: • Data model • Rules governing change of data • Permissions to access, modify (who? when?) Functionalities: • Analyze the model • Implement the model (code) • Automate tasks (A.I.)
  • 10.
    Our Goals • Make(some of) SW development engineering • Systematic process to develop SW specifications • “AI” to do (almost) all of the routine coding • Lift the abstraction level of code written by programmers • Shift focus from code to business/organizational processes • Result: • Decreased development effort • Easier testing and validation • More modifiable and extendible SW • Independence from execution environment (PL, OS, DBMS, UI)
  • 11.
    Our Goals: LongerTerm • Intelligent agents (A.I.) supporting (and replacing) humans in organizational roles • Networks of interacting and inter-operating SW systems • Fully automated companies, agencies, services, ... • Integration with physical assets and infrastructure • management of primary industries, energy, manufacturing, transportation and logistics, services, ...
  • 12.
    EIAI / aitocode:Software Production users HTML/HTTP mobile apps email/messaging SW DBMS cloud storage external SW
  • 13.
    How Is SoftwareProduced? 1 Precisely specify what the software is to do 2 Analyze software specification (automatic) 3 Choose: • Programming language • Database system(s) • Operating system / execution environment 4 Synthesize software system (automatic) 5 Deploy software system (automatic)
  • 14.
    Abstract View ofSoftware 1 A university employee can establish a new course in a given faculty, if the employee is the director of education of the faculty. 2 A university employee can change the responsible teacher of a course, if the employee is the director of education for the faculty responsible for the course. 3 A university employee can change the requirements for a B.Sc. degree granted by a given faculty, if the employee is the director of education of the faculty. 4 A student can be granted a B.Sc. degree, if the student has passed all courses required for the degree. 5 A student can register for a course, if the student has the right to study at the university, and the course is part of the studies for a degree the student is studying for. 6 A student can register for an exam, if the student is registered for the course. 7 A university employee can record the exam grade for a student, if the student was registered for the exam, and the exam is for a course for which the employee is the responsible teacher. 8 A student is recorded as having passed a course, if the student has passed an exam for the course and fulfilled other requirements (for example, done obligatory home assignments and a course project.) 9 A university employee can mark a course as passed for a student, if the employee is the responsible teacher of the course, and the student was enrolled on the course.
  • 15.
    Rules of anApplication Each of the informal rules can formalized as three parts: • Inputs • What does the user supply when performing the action? • Each input has a type (int, string, set, list, ...) • Condition • What condition has to hold for the action to be possible? • Boolean combination of atomic conditions (and, or, not, ...) • Also limits the possible inputs! • Effect • How does the action modify the data (in the DB) • One or more pieces of “code”
  • 16.
    Rules of anApplication Each of the informal rules can formalized as three parts: • Inputs • What does the user supply when performing the action? • Each input has a type (int, string, set, list, ...) • Condition • What condition has to hold for the action to be possible? • Boolean combination of atomic conditions (and, or, not, ...) • Also limits the possible inputs! • Effect • How does the action modify the data (in the DB) • One or more pieces of “code”
  • 17.
    Rules of anApplication Each of the informal rules can formalized as three parts: • Inputs • What does the user supply when performing the action? • Each input has a type (int, string, set, list, ...) • Condition • What condition has to hold for the action to be possible? • Boolean combination of atomic conditions (and, or, not, ...) • Also limits the possible inputs! • Effect • How does the action modify the data (in the DB) • One or more pieces of “code”
  • 18.
    Example A Facebook-style socialmedia application Who can post on a wall? • The owner of the wall • Friends of the wall owner Result: Post appears on the wall and in all relevant feeds. action post(p : feedData, wallOwner : user) { wallOwner == currentuser or currentuser in wallOwner.friends ==> new ent : feedEntry [ t = now, entry = p, comments = [], auth = currentuser.auth, owner = currentuser ]; wallOwner.wall = concat(wallOwner.wall,[ent]); currentuser.posts = concat(wallOwner.wall,[ent]); forall (u in currentuser.friends) u.feed = concat(u.feed,[ent]); }
  • 19.
    Example Peer-reviewing for anacademic journal Some articles can be published as a new volume if • the current user is the editor of the journal, • the articles are unpublished and belong to the journal, • the set of articles is non-empty. action createNewVolume( p : article set, j : journal ) { currentuser == j.editor and subseteq(p,j.unpublishedarticles) and card(p) > 0 ==> j.lastvolumenumber = j.lastvolumenumber + 1; j.unpublishedarticles = j.unpublishedarticles p; new v : volume [ volumenumber = j.lastvolumenumber, publicationtime = now, articles = p ]; j.publishedvolumes = j.publishedvolumes U { v }; forall (a in p) a.volume = v; }
  • 20.
    How Is ARule Implemented? 1 Is current user able to take the action? (UI menus etc.) • Can precondition be true, for some inputs? • Conceptually, must go through all possible input values 2 What input options to offer user? (UI input forms) • Which input combinations can make precondition true? • Conceptually, must produce all input combinations 3 Execute the rule • Is precondition (with inputs) true? (easy) • Execute the “Effects” part (easy) • Implemented as a DBMS transaction First two are both NP-hard (or harder)!
  • 21.
    How Is ARule Implemented? 1 Is current user able to take the action? (UI menus etc.) • Can precondition be true, for some inputs? • Conceptually, must go through all possible input values 2 What input options to offer user? (UI input forms) • Which input combinations can make precondition true? • Conceptually, must produce all input combinations 3 Execute the rule • Is precondition (with inputs) true? (easy) • Execute the “Effects” part (easy) • Implemented as a DBMS transaction First two are both NP-hard (or harder)!
  • 22.
    How Is ARule Implemented? 1 Is current user able to take the action? (UI menus etc.) • Can precondition be true, for some inputs? • Conceptually, must go through all possible input values 2 What input options to offer user? (UI input forms) • Which input combinations can make precondition true? • Conceptually, must produce all input combinations 3 Execute the rule • Is precondition (with inputs) true? (easy) • Execute the “Effects” part (easy) • Implemented as a DBMS transaction First two are both NP-hard (or harder)!
  • 23.
    EIAI / aitocode:What We Have Now Project since 2016, with 2018 funding from Business Finland • Core technology completed • Prototype implementation works • Demo applications running • peer-reviewing and publication for academic journals (10 rules) • university course management (5 rules) • social media (“Facebook”) (7 rules) • blogging website (3 rules) • web chat (2 rules) • Other applications under development
  • 24.
    EIAI / aitocode:Next Steps • IDE integration (Q3/2019) • Alternative PL, OS, DBMS, UI (Q3/2019) • Mobile apps (2020) • Verification/validation (2020) • correctness proofs (w.r.t. stated properties) • spec anomalies: unreachable and redundant actions & data • Intelligence (2021) • optimal data input (w.r.t. evaluation of a condition) • suggest actions to human users (w.r.t. users’ goals) • take action sequences autonomously • minimization of a cost measure, maximization of a reward measure
  • 25.
    Interested? We are lookingfor collaboration partners: • Companies to participate in technology trials • Software developers willing to try out • Everything else to transfer the technology to real use
  • 26.
    Conclusion • Automation ofsoftware production • data and knowledge-intensive information systems • web applications • et cetera • Future: • Increased intelligence (automated embedding of “AI” in SW) • Highly automated analytics and validation Code is not interesting, systems and their features are!
  • 27.