CoCoViLa @ devclub.eu

  • 1,143 views
Uploaded on

CoCoViLa homepage: http://www.cs.ioc.ee/cocovila …

CoCoViLa homepage: http://www.cs.ioc.ee/cocovila
Video (in russian): http://vimeo.com/41040729

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,143
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. CoCoViLaVisual DSLs and Automatic Synthesis of Programs Pavel Grigorenko DevClub 25.04.2012
  • 2. About(me);http://cs.ioc.ee/~pavelg
  • 3. • Founded in 1960 (Estonian Academy of Sciences)• Since 1997 - R&D @ TUT• Research staff: ~70 people• Fields: mechanics, control systems, applied mathematics, computer science, systems biology, human language technology, ...
  • 4. CoCoViLa• Declarative model-based software development• Domain-specific languages• Visual specification• Program synthesis• Java + OSS + GPL• Portable and extensible
  • 5. Visual DSLs In CoCoViLa• Automatic Editor generation from language definition• Well-defined abstract syntax• No need to implement custom parsers and code generators• Precise semantics: • Shallow semantics textual representation • Deep semantics executable code
  • 6. (Pre)History Programmeerimiskeelte tasemed:• Research in Artificialülesannete kirjeldamise keeled (6) Intelligence Visuaalkeeled:• Structural Synthesis of Programs (E. Tyugu 1979; G. Mints, E. Tyugu 1982)• 1980s - PRIZ/UTOPIST• 1990s - NUT• >= 2003 - CoCoViLa (A. Saabas, A. Aasmaa, P. Grigorenko)
  • 7. Structural Synthesis Of Programs• Structural properties of computations• Based on implicational fragment of intuitionistic propositional logic (uses Curry-Howard correspondence)• Deductive method: (specification existence theorem proof code)• Complexity: Polynomial-space complete (Statman ’78)
  • 8. Computational Problems In SSP Knowing M, compute y1,...,yn from x1,...,xm Example: (Triangle; a,b,c S)Triangle var: ⊢a, b, c p {sp}; a, b, c ⊢ a, b, c ( -) a, b, c, p, S; ⊢a, b, c, p S {h}; a, b, c ⊢a, b, c, p ( -) rel: a, b, c ⊢ S (h(a,b,c,sp(a,b,c))) ( +) a, b, c p {sp}; ⊢a, b, c S (λabc.h(a,b,c,sp(a,b,c))) a, b, c, p S {h};
  • 9. CreateVisual Language Lifecycle Use Execute
  • 10. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 11. Metaclasspublic class AndGate { /*@ specification AndGate { int in1, in2, out; in1, in2 -> out {calc}; } @*/ public int calc( int x, int y ) { return Math.min(x, y); }}
  • 12. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 13. Visual Class• Metaclass• Image/Graphics• Ports• Fields• Toolbar icon
  • 14. CoCoViLa Class Editor
  • 15. Package<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE package SYSTEM "package2.dtd"><package> <name>Logic</name> <description>Logical circuits builder</description> <class type="class"> <name>And</name> <description>And</description> <icon>images/and.png</icon> <graphics> <bounds height="83" width="202" x="0" y="0"/> <image fixed="false" height="100" path="/images/200px-AND_ANSI.png" width="200" x="3" y="-11"/> </graphics> <ports> <port name="in1" portConnection="" strict="false" type="int" x="13" y="19"/> <port name="in2" portConnection="" strict="false" type="int" x="13" y="59"/> <port name="out" portConnection="" strict="false" type="int" x="190" y="39"/> </ports> <fields> <field name="in1" type="int">
  • 16. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 17. CoCoViLa Scheme Editor• Instantiate objects• Connect ports• Assign values• Assign a superclass
  • 18. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 19. Scheme To Metaclass
  • 20. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 21. Metaclasses To Code
  • 22. Domain Programming Java classes ConceptsDesigner Add spec Visual Draw Metaclasses classes ComposeUser Scheme Translate Execute Bytecode (w/ feedback) MetaclassAutomatic Compile Transform Planning and Computational Java classes code generation model
  • 23. Compilation• Storing generated Java files: in memory or file system• Eclipse JDT Core compiler• Compiling Classloader (CCL) RunnerClassLoaderURLClassLoader CCL PackageClassLoader
  • 24. Execution
  • 25. Specification Language• Variables double a, b; AndGate and;• Constants const double PI = Math.PI;• Bindings (equality) a = b;• Value assignments a = 3; and.in1 = 1;
  • 26. Simple Functional Dependenciesin1, in2 -> out {calc};Realization in Java:public int calc( int x, int y ) { return Math.min(x, y); }
  • 27. Higher-order F. D-s (w/ Subtasks)[arg -> val], from, to, step -> done {loop};Realization in Java:public void loop(Subtask s, int st, int fn, int inc){ for(int i = st; i <= fn; i+=inc){ s.run(new Object[]{ i }); }}public interface Subtask { public Object[] run(Object[] args);}
  • 28. Higher-order Dataflowfrom, to, step done loop arg val
  • 29. Specification Language• Equations (built-in solver) specification AndGate { double in1, in2, out; in1*in2 = out; } specification Complex { double re, im, arg, mod; mod^2 = re^2 + im^2; mod * sin(arg) = im; }
  • 30. Specification Language• Tuples • Wildcards alias x = (a, b); alias ts = (*.t); alias y = (c, d); x.*.1 = y.*.z; x = y; • Inheritance x.0 = y.1; • Goals x.length -> x {init}; • Polymorphic types • Control variables • ...
  • 31. Tuplesalias axial = (n, T);alias tang = (v, m, F);
  • 32. Tuplesalias axial = (n, T); W0.axial = W1.axial;alias tang = (v, m, F); W1.tang = W2.tang;
  • 33. Tuples alias axial = (n, T); W0.axial = W1.axial; alias tang = (v, m, F); W0.n = W1.n; W0.T = W1.T;W1.v = W2.v;W1.m = W2.m;W1.F = W2.F; W1.tang = W2.tang;
  • 34. Inheritancepublic class Dif { public class Dif extends Process { /*@ specification Dif { /*@ specification Dif super Process { Process Process_0; Clock Clock_0; Clock Clock_0; Integrator Integrator_0; Integrator Integrator_0; Integrator Integrator_1; Integrator Integrator_1; } @*/ } @*/ }}
  • 35. Wildcards (example)scheme’s superclass
  • 36. Wildcards (example) state stat double state, nextstate; double state, nextstatescheme’s superclass
  • 37. Wildcards (example) state stat double state, nextstate; double state, nextstate alias st = (*.state); alias nst = (*.nextstate); st -> nst {calculate};scheme’s superclass
  • 38. Wildcards (example) state stat double state, nextstate; double state, nextstate alias st = (*.state); alias nst = (*.nextstate);st = (Clock_0.state, st -> nst {calculate};Integrator_0.state,Integrator_1.state);scheme’s superclass
  • 39. Applications• Hydraulic systems • Logic Circuits• GrADAR model • Electric Circuits• Security Costs Optimization • Gearbox kinematics• Web-service composition • Neural networks• Functional Constraint Networks • Petri nets• Differential Equations • Attack Trees• Discrete Event Simulation • UML diagrams• Hybrid Network Simulation • ∞
  • 40. Hands-on Demo
  • 41. Starting CoCoViLa• Requires Java 1.6• How to run: • Java Web Start (http://cs.ioc.ee/cocovila -> Web Start) • Download zipped version and execute .jar • git clone git://cocovila.git.sourceforge.net/ gitroot/cocovila/cocovila -> ant run-se
  • 42. Predator-Prey Model (Lotka-Volterra)• Prey (rabbits) dR = kR − aRW dt dR = kR − aRW Predators + bRW•dW dt = −rW (wolfs) dt dW = −rW + bRW dtParameters: k = .08, a = .001, r=.02, b=.00002, R=1000, W=30
  • 43. Modeling And Simulation Of An Electro-hydraulic Servo-valve *;34/!&/!A&?+!^+! ! ! !-%)!LS!H%3**!*)75&3/!30!/3RR()=0($22)%!5.2)!*)%#3#$(#)!4&5;! A&?-%)!"S!A-/75&3/$(!*7;)6)!30!$/!)()75%3=;.1%$-(&7!*)%#3#$(#) Servo-valve Mechanical Functional scheme with mechanical parts feedback
  • 44. Modeling And Simulation Of An Electro-hydraulic Servo-valve *;34/!&/!A&?+!^+! ! ! !-%)!LS!H%3**!*)75&3/!30!/3RR()=0($22)%!5.2)!*)%#3#$(#)!4&5;! A&?-%)!"S!A-/75&3/$(!*7;)6)!30!$/!)()75%3=;.1%$-(&7!*)%#3#$(#) Servo-valve Mechanical Functional scheme with mechanical parts feedback
  • 45. Modeling And Simulation Of An Electro-hydraulic Servo-valve *;34/!&/!A&?+!^+! ! ! !-%)!LS!H%3**!*)75&3/!30!/3RR()=0($22)%!5.2)!*)%#3#$(#)!4&5;! A&?-%)!"S!A-/75&3/$(!*7;)6)!30!$/!)()75%3=;.1%$-(&7!*)%#3#$(#) Servo-valve Mechanical Functional scheme with mechanical parts feedback
  • 46. Composition Of X-Road Services
  • 47. Graded IT Security Cost Optimization
  • 48. Modeling and Simulation Group @ IoC http://www.cs.ioc.ee/msg/
  • 49. Thank You!