1 / 14

A Rewriting Logic Approach To Operational Semantics

A Rewriting Logic Approach To Operational Semantics. By Grigore Ro şu , Jos é Meseguer, Traian Florin Şerbănuţă. Motivation. B ecause we like rewriting  All operational semantics rules have a “rewriting flavor” … yet, they are completely distinct logics

traugott
Download Presentation

A Rewriting Logic Approach To Operational Semantics

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. A Rewriting Logic Approach To Operational Semantics By Grigore Roşu,José Meseguer, Traian Florin Şerbănuţă

  2. Motivation • Because we like rewriting • All operational semantics rules have a “rewriting flavor” • … yet, they are completely distinct logics • An executable unified logical framework can help in either teaching or research

  3. Previous work • [Meseguer, 1990]: embedding Cham • [Marti-Oliet, Meseguer,1993]: representing Natural semantics and SOS • [Meseguer, Braga, 2004]: MSOS –> modular rewriting semantics • Our paper synthesizes these results

  4. New contributions • Relation with reduction semantics • Faithful representation • Correspondence between transition systems • Representing Abstract Machines • First-order, continuations-like definitions • Here presented as a faithful encoding of Reduction Semantics, but can go beyond that

  5. Rewriting Logic • Extends Equational Logic with transitions • Models: transitions systems between equivalence classes of states • Equations used to canonicalize state • Rules are used for computational steps C C R R’

  6. C C’ R R’ Reduction Semantics

  7. Reduction semantic in Rewriting Logic • Context syntax rules -> a “parser” function • Split a term in a context-redex pair C[R] • Reduction rules stay unchanged • Apply on C[R] a Context Reduction rule • Put redex back in the context • Using a morphism-like function

  8. Continuation based semantics • Transform the program into a list of tasks • Flattening the program to post-order representation • Advantages: • No need to search for the redex • Disadvantages: • More syntax is needed for flattening

  9. Our approach • First-order representation of continuations • Equations flatten the program • If B then E1else E2 = Bif(E1,E2) • Rules specify execution steps • true if(K1,K2)  K1 • Provides a way to compactly specify and execute abstract machines for any PL

  10. Implementing RLS specifications • They are executable rewrite theories in Maude (for testing and analysis purposes) • The associated rewrite system is executable in any generic rewrite system • Mechanically generate interpreters for PL with limited support for matching: • Haskell, Ocaml, Prolog

  11. Experiments • Defined Imp, a simple imperative language • Mechanically derived interpreters in Haskell and Ocaml • Compared with existing interpreters defined in Scheme: EOPL (bigstep&continuations) and PLT Redex (Red Semantics) Running time for verifying Collatz’ conjecture up to 300 (times are in seconds) • Ocaml interpreter is comparable in speed to Linux BC (13.8 sec)

  12. Teaching experience • Used in teaching programming languages design and verification at UIUC for 3 years • Students like executable formal definitions • Continuation-based is easy to understand, modular, flexible and fun to teach  • Students are able to (partially) define Scheme or Prolog as a class project

  13. Future Work • Make the interpreter generation automatic • Build end-to-end framework for continuation-based definitions • Research other definitional styles in their relation to RLS • Any suggestions?

  14. Thank you!

More Related