1 / 31

IOA PRESENTATION

IOA PRESENTATION. May 01, 1999. IOA2JAVA Tool. Joe Balthazar. Jim Byrne. Christine Kenney. Ainsley Nathaniel. Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT 06269-3155. Input/Output Automata. P1. P2. init(v2).

istas
Download Presentation

IOA PRESENTATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IOAPRESENTATION May 01, 1999

  2. IOA2JAVA Tool Joe Balthazar Jim Byrne Christine Kenney Ainsley Nathaniel Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT 06269-3155

  3. Input/Output Automata P1 P2 init(v2) init(v1) decide(v2) Process decide(v1) send(m(1,2)) Channel C(1,2) receive(m(2,1)) receive(m(1,2)) C(2,1) send(m(2,1))

  4. Structure of an IOA • Main components of an I/O Automaton(A): • sig(A), a signature • states(A), a set of states • start states • trans(A), a state-transition relation that follows a precondition-effect style • input actions - no preconditions and hence, are permanently enabled • internal and output actions - have preconditions and effects • optional tasks

  5. Objectives • Create a tool to convert the general structure of an IOA to Java code • IOA can be used for algorithm correctness proofs • Recognize only a subset of the language • Automaton name, states and data types • Input, internal, and output actions • Preconditions and effects • Parses majority of language • Convert a single IOA to a single Java class • Produce necessary additional Java code to create a executable program with IOA functionality • Code will run on one machine

  6. Assumptions • Action names, parameters, and state variables are unique • Deal only basic data types • boolean • double • int • Preconditions and effects written as Java Code • May change state variables so long as same names are used • Code copied directly to Java class

  7. Assumptions • Internal and output actions have no parameters • Parameters values selected by IOA code in preconditions based on state • A large enough subset of IOA is not yet implemented to do this • Changes to IOA code in parser • All keywords have the first letter capitalized ie. Automaton, Transition, etc. • Some symbols were changed to accommodate the keyboard ie. E - There exist. • Java types were used instead of IOA types- this eliminated the need for a symbol table. • Type checking done by the Java Compiler.

  8. Java Compiler Compiler • Compiler Tool for Java Language. • The Java equivalent of Lex and Yacc • Parses grammar to produce Java code • JavaCC uses an input file written in a standard BNF grammar. • Example of simple BNF grammar • <exp> :: = <simp exp><rel op> <simp exp> • <rel op> :: = < | >= | <= | = | >

  9. Compiler Procedure • Get the tokens • The first part of the JCC specification defines the tokens for the language. • Parse the Language • The second part defines the transitions that make up the language. • Generate the code • The compiler output is generated by the insertion of Java code in the transitions.

  10. IOA Tokens • IOA Token definitions. • < AUTOMATON: “Automaton” > • < TRANSITION: “Transition” > • < INPUT: “Input” > • < OUTPUT: “Output” > • Resulting Java code is too complicated to put here, looks like assembly language.

  11. IOA grammar to JavaCC grammar • IOA grammar specification translates directly into JCC grammar because of similarity in structures. • states ::= ‘states’ state,+ (‘so’ ‘that’ predicate)? • void states() : • {} • { • <STATES> state()(“,” state())* • (<SO> <THAT> predicate())? • }

  12. Translation of Grammar Cont’d • JavaCC grammar with Java code inserted to create the IOA compiler. • states ::= ‘states’ state,+ (‘so’ ‘that’ predicate)? • void states() : • {} • { {String lTokStr;} • <STATES> lTokStr = state() • {pwOutput.println(lTokStr);} • ("," lTokStr = state() • {pwOutput.println(lTokStr);})* • ( <SO> <THAT> predicate())? • }

  13. Java file which implements the Parser • The IOA compiler takes an automaton definition as input and produces an equivalent automaton, written in Java, as output. • static final public void states() throws ParseException { • String lTokStr; • jj_consume_token(STATES); • lTokStr = state(); • System.out.println(lTokStr); • label_12: • while (true) { • if (jj_2_38(2)) { ;

  14. Differences in Grammars • JCC does not permit left recursion and hence two transitions have to be modified. • For example, A  C | AB is a transition with left-recursion. • The equivalent transition A  CB+ does not contain left recursion and can be used in a JavaCC grammar file. • subterm ::= subterm (opSym subterm)+ • | (quantifier | opSym)* opSym secondary • | (quantifier | opSym)* quantifier primary • | secondary opSym*

  15. Left Recursion Removed • String subterms() : • { } • { • subterm() (opSym() subterm())* • } • String subterm() : • { } • { • ( ((quantifier() | opSym())* secondary()) • | ((quantifier() | opSym())* quantifier() primary()) • | ( secondary() (opSym())*) • ) • }

  16. The FibonacciSkew IOA • What does it do? • Produces the Fibonacci sequence • The sequence can be skewed by a certain value from time to time • States • ready indicate state of sequence generation • skew value • printFlag indicates print state • first, second, current holding last three sequence values

  17. The FibonacciSkew IOA • Actions in the IOA • Input action to start or end the sequence • Input action to skew the sequence • Internal action that calculates the next value in the sequence • Output action that prints the next value

  18. The FibonacciSkew IOA setReady print FibonacciSkew skew Input Action Output Action calculate Internal Action

  19. IOA States to Private Data • IOA States automaton FibonacciSkew states ready: boolean := false; skew: int := 0; printFlag: boolean := false; first: int := 1; sec: int := 0; current: int := 0; • Private Data in Java Class class FibonacciSkew { // Private Data private boolean ready = false; private int skew = 0; private boolean printFlag = false; private int first = 1; private int sec = 0; private int current = 0; // Public Methods };

  20. Input Action to Public Method • IOA Input Action input setReady(flag: boolean) eff $ if (ready!=flag) { ready = flag; first = 1; sec = 0; current = 0; } $ • Public Method in Java Class public void setReady(boolean flag) { if (ready!=flag) { ready = flag; first = 1; sec = 0; current = 0; } }

  21. Input Action to Public Method • IOA Input Action input skew(k: int) eff $ if (ready==true) skew = k; else System.out.println(“Cannot skew: No sequence is being generated”); $ • Public Method in Java Class public void skew(int k) { if (ready==true) skew = k; else System.out.println(“Cannot skew: No sequence is being generated”); }

  22. Internal and Ouput Actions to Public Methods • IOA Internal Action internal calculate() pre $ return (ready); $ eff $ current = first + second + skew; skew = 0; first = sec; sec = current; printFlag = true; $ • Public Methods in Java Class public boolean Precalculate() { return (ready); } public void calculate() { current = first + second + skew; ... }

  23. Internal and Ouput Actions to Public Methods • IOA Output Action output print() pre $ return (printFlag); $ eff $ System.out.println(“The current value in sequence is “ + current); printFlag = false; $ • Public Methods in Java Class public boolean Preprint() { return (printFlag); } public void print() { System.out.println(“The current value in sequence is “ + current); printFlag = false; }

  24. IOA Input Parameters • paramFibonacciSkew.java • Created by Parameter.java • Simulates input parameter values for input actions coming in from environment • IOA Input Action parameter input setReady(flag: boolean) • Public Java method for each parameter public boolean returnflag() { input = getInput(“flag”); return retboolean(input); }

  25. Helper Methods • Methods for converting String to type value private boolean retboolean(String s) { return Boolean.valueOf(s).booleanValue(); } • Method to get any parameter value from user public String getInput(String message) { String response = “”; System.out.println(“Enter “ + message); try { BufferedReader brInp.readLine(); response = brInp.readLine(); } catch(Exception e){ e.printStackTrace(); } return response; }

  26. IOA Scheduler • FibonacciSkewScheduler.java • Created by Scheduler.java • Contains main program which calls a round robin scheduler to cycle through actions public static void RoundRobin() { boolean NotQuit; FibonacciSkew ioaFibonacciSkew = new FibonacciSkew(); paramFibonacciSkew inputFibonacciSkew = new paramFibonacciSkew(); while(NotQuit) { // Check each action NotQuit = askuser(“cycle again”); } }

  27. Round Robin Scheduler Internal Output Input while(NotQuit) { if(askuser(“setReady”)) { ioaFibonacciSkew.setReady( inputFibonacciSkew.Returnflag()); } if(askuser(“skew”)) { ioaFibonacciSkew.skew( inputFibonacciSkew.Returnk()); } if(ioaFibonacciSkew.PreCalculate()) { ioaFibonacciSkew.calculate(); } if(ioaFibonacciSkew.Preprint()) { ioaFibonacciSkew.print(); } NotQuit = askuser(“cycle again”); }

  28. Future Research • Solving Composition of Automata • Public Composed IOA Class Approach • All classes are in a package • Each independent IOA class is private • The composed IOA class is public • IOA Class Library Approach • All IOAs have their own class in a library • Create a new composed IOA importing 2 or more IOA classes from the library • Put back composed classes in library and reuse • Combination of Both • Package last composition of classes from library • Adapt parser to handle assumes clause

  29. Future Research • Generation of pre-conditions and effects in Java • Determining parameters for internal and output actions • Common mechanism for selecting values from state • Consider distributed systems modeled by IOA • Interaction in Java • Use of Java distributed technologies

  30. References • MIT-Theory of Distributed Systems Group • I/O Automata Model, Language and Tool Set. http://theory.lcs.mit.edu/tds/~vaziri/ioa.html • S. J. Garland, N. A. Lynch, and M.Vaziri, “IOA: A Language for Specifying, Programming, and Validating Distributed Systems Draft”, December 1997. • O. M. Cheiner and A. A. Shvartsman, “Implementing An Eventually-Serializable Data Service as a Distributed System Building Block”, July 1998. • Java Compiler Compiler - The Java Parser Generator - http://www.suntest.com/JavaCC/

  31. Flow ioaname.ioa IOA.java associated Java files IOA.jj grammar file *.class MethodInfo.java Scheduler.java Parameter.java Executable IOA ioaname.java ioanameScheduler.java paramioaname.java ioanameScheduler *.class javacc javac java java javac

More Related