1 / 27

K Framework

K Framework. k-framework.org. Joint project between the FSL group at UIUC (USA) and the FMSE group at UAIC (Romania). K Team. UAIC, Iasi, Romania Dorel Lucanu Traian Serbanuta Andrei Arusoae Denis Bogdanas Stefan Ciobaca Gheorghe Grigoras Radu Mereuta

lilith
Download Presentation

K Framework

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. K Framework k-framework.org Joint project between the FSL group at UIUC (USA) and the FMSE group at UAIC (Romania)

  2. K Team • UAIC, Iasi, Romania • Dorel Lucanu • TraianSerbanuta • Andrei Arusoae • Denis Bogdanas • Stefan Ciobaca • Gheorghe Grigoras • RaduMereuta • RalucaNecula • EmilianNecula Former Members • Irina Asavoae • MihaiAsavoae • UIUC, USA • GrigoreRosu (started K in 2003) • CansuErdogan • Dwight Guth • David Lazar • Patrick Meredith • Andrei Stefanescu Former members • Kyle Blocher • Peter Dinges • Chucky Ellison • Mike Ilseman • TraianSerbanuta

  3. Current State-of-the-Art in PL Design, Implementation and Analysis Consider some programming language, L • Formal semantics of L? • Typically skipped: considered expensive and useless • Implementations for L • Based on some adhocunderstanding of what L is • Model checkers for L • Based on some adhoc encodings/models of L • Program verifiers for L • Based on some other adhoc encodings/models of L • …

  4. Example of C Program • What should the following program evaluate to? • According to the C “standard”, it is undefined • GCC4, MSVC: it returns 4GCC3, ICC, Clang: it returns 3By April 2011, both Frama-C (with its Jessie verification plugin) and Havoc "prove" it returns 4 int main(void) {int x = 0; return (x = 1) + (x = 2);}

  5. A Formal Semantics Manifesto • Programming languages must have formal semantics!(period) • And analysis/verification tools should build on them • Otherwise they are adhoc and likely wrong • Informal manuals are not sufficient • Manuals typically have a formal syntax of the language (in an appendix) • Why not a formal semantics appendix as well?

  6. Motivation and Goal We want a semantic framework which makes it easy and fun to define programming languages, no matter how complex or large they are!

  7. The K Frameworkk-framework.org A tool-supported rewrite-based framework for defining programming language design and semantics.

  8. Complete K Definition of KernelC

  9. Complete K Definition of KernelC Syntax declared using annotated BNF …

  10. Complete K Definition of KernelC Configuration given as a nested cell structure. Leaves can be sets, multisets, lists, maps, or syntax

  11. Complete K Definition of KernelC Semantic rules given contextually <k> X = V => V …</k> <env>… X |-> (_ => V) …</env>

  12. What does the K Tool Offer? … … cfg[pgm] … Efficient and interactive execution (interpreters) State-space exploration (search and model-checking) Deductive program verification (in progress)

  13. K Scales Besides smaller and paradigmatic teaching languages, several larger languages were defined • Java 1.4 : by Chen [CAV’06] • Verilog : by Meredith&Katelman[MEMOCODE’10] • C : by Chucky Ellison [POPL’12] etc.

  14. The K Configuration of C Heap 75 Cells!

  15. Statistics for the C definition • Total number of rules:   ~1200 • Tested on thousands of C programs (several benchmarks, including the gcc torture test, code from the obfuscated C competition, etc.) • Passed 99.2% so far! • GCC 4.1.2 passes 99%, ICC 99.4%, Clang 98.3% (no opt.) • The most complete formal C semantics

  16. Next Steps for Learning • Watch the five-minute video demo • Download the K tool • Do the K Tutorial • Define your own language! • Watch the interview on rewrite-based semantics if you’d like to better understand our viewpoint • Read select publications for a deeper understanding of K’s foundations

  17. Part 2 • History • Technicalities (parsers) • Basic parsing • Concrete parsing • Disambiguation

  18. History • K2 • Maude, Perl, Haskell, Java • K3 • SDF for parsing • Java for tools • Maude for execution

  19. Technicalities • Parsers • Basic parser • Modules • Syntax • Sentences with concrete syntax (rules, configurations) • Concrete parser (finish the above)* • Parser for programs* *generated during compilation

  20. Basic parsing module EXAMPLE syntax Exp ::= Exp “*” Exp [left, strict] > Exp “+” Exp [left, strict] configuration <T> <k> 1 + 2 * 3 </k> </T> rule E1:Int + E2:Int => E1 +Int E2 …. endmodule

  21. Basic parsing module EXAMPLE syntax Exp ::= Exp “*” Exp [left, strict] > Exp “+” Exp [left, strict] configuration<T><k>1+2*3</k></T> ruleE1:Int+E2:Int=>E1+IntE2 …. endmodule

  22. Concrete parser • K syntax • K “=>” K -> K • <cell> Content </cell> • Language syntax • Exp “+” Exp -> Exp … • Connections • Exp -> K > K -> Exp and K -> Exp > Exp -> K • Typed variables

  23. Disambiguation • Cell disambiguation • Variable type inference • Second type checker • Report the rest of ambiguities

  24. Rest of the compilation • Syntax flattening • Context transformation • …

  25. Krun (runtime) PGM <T> <k> $PGM </k> <env> a |-> 1 </env> </T>

  26. Future work • Right now • Bug hunting • Performance improvements • Long term • Finish the java version of the compilation • IDE • Specialized rewrite system

  27. Next Steps • Watch the five-minute video demo • Download the K tool • Do the K Tutorial • Define your own language! • Watch the interview on rewrite-based semantics if you’d like to better understand our viewpoint • Read select publications for a deeper understanding of K’s foundations

More Related