towards a module system for k
play

Towards a Module System for K Mark Hills and Grigore Ro su { - PowerPoint PPT Presentation

Outline Motivation K Context Transformers Variable Patterns and Sort Inference The K Module System Related and Future Work Towards a Module System for K Mark Hills and Grigore Ro su { mhills, grosu } @cs.uiuc.edu Department of Computer


  1. Outline Motivation K Context Transformers Variable Patterns and Sort Inference The K Module System Related and Future Work Towards a Module System for K Mark Hills and Grigore Ro¸ su { mhills, grosu } @cs.uiuc.edu Department of Computer Science University of Illinois at Urbana-Champaign WADT’08, 14 June 2008 Hills and Ro¸ su WADT’08: Towards a Module System for K 1 / 29

  2. Outline Motivation K Context Transformers Variable Patterns and Sort Inference The K Module System Related and Future Work Motivation 1 K 2 Context Transformers 3 Variable Patterns and Sort Inference 4 The K Module System 5 Related and Future Work 6 Hills and Ro¸ su WADT’08: Towards a Module System for K 2 / 29

  3. Outline Motivation K Context Transformers Variable Patterns and Sort Inference The K Module System Related and Future Work Motivation Formal semantics of programming languages not used widely outside of research community We strongly believe that one important way to increase use of formal semantics is to make semantic definitions more broadly usable and useful This work focuses on two aspects of this goal: Enable improved reuse of definitions through definitional modularity Provide tool support for working with language definitions Hills and Ro¸ su WADT’08: Towards a Module System for K 3 / 29

  4. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work K: High Level View K provides a rewrite-based method to formally define computation Focus here: formal definitions of programming languages Definitions should be flexible and modular: use, and reuse, for language documentation, program execution, analysis, proof Hills and Ro¸ su WADT’08: Towards a Module System for K 4 / 29

  5. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work K Basics: Computations K based around concepts from Rewriting Logic Semantics, with some intuitions from Chemical Abstract Machines and Reduction Semantics Abstract computational structures contain context needed to produce a future computation (like continuations) Context can consist of lists or multisets, generally representing sequential or concurrent computation potential Context includes special component, k , made up of list of computational tasks separated by � , like t 1 � t 2 � ... � t n From here on, computational structures called computations Hills and Ro¸ su WADT’08: Towards a Module System for K 5 / 29

  6. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work K Basics: Computations, Continued Intuition from CHAMs: language constructs can heat (break apart into pieces for evaluation) and cool (form back together) Represented using ⇋ , like a 1 + a 2 ⇋ a 1 � � + a 2 Operators containing � called freezer s Heating/cooling pair can be seen as an equation Intuition from RS: � can be seen as similar to evaluation contexts, marking the location where evaluation can occur Hills and Ro¸ su WADT’08: Towards a Module System for K 6 / 29

  7. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work K Basics: Cells Computations take place in context of a configuration Configurations hierarchical (like in RLS), made up of K cells Each cell holds specific piece of information: computation, environment, store, etc Two regularly used cells: ⊤ ( top ), representing entire configuration k , representing current computation Cells can be repeated (e.g., multiple computations in a concurrent language) Hills and Ro¸ su WADT’08: Towards a Module System for K 7 / 29

  8. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work Example: K Configuration Hills and Ro¸ su WADT’08: Towards a Module System for K 8 / 29

  9. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work K Basics: Equations and Rules Computations defined used equations and rules Heating/Cooling Rules (Structural Equations): manipulate term structure, non-computational, reversible, can think of as just equations Rules: computational, not reversible, may be concurrent Hills and Ro¸ su WADT’08: Towards a Module System for K 9 / 29

  10. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work Example: Equations a 1 + a 2 ⇋ a 1 � � + a 2 a 1 + a 2 ⇋ a 2 � a 1 + � if b then s 1 else s 2 = b � if � then s 1 else s 2 Reminder: � is not an evaluation context, but a freezer. Also, operations with freezers are boring to write, so we can mark operations strict(natlist) , with a freezer generated for each position in the list. To do so for all operands, just use strict . _+_ : AExp AExp -> AExp [strict] Hills and Ro¸ su WADT’08: Towards a Module System for K 10 / 29

  11. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work Example: Rules i 1 + i 2 → i , where i is the sum of i 1 and i 2 if true then s 1 else s 2 → s 1 if false then s 1 else s 2 → s 2 � x := v | � k � | ( x , l ) | � env � | ( l , | � store · v Hills and Ro¸ su WADT’08: Towards a Module System for K 11 / 29

  12. Outline Motivation K K Overview Context Transformers Language Semantics in K Variable Patterns and Sort Inference For More Information The K Module System Related and Future Work For More Information For more information on K: “A Rewriting Logic Approach to Type Inference” (earlier talk) K website: http://fsl.cs.uiuc.edu/k Includes tech reports and other papers related to K Hills and Ro¸ su WADT’08: Towards a Module System for K 12 / 29

  13. Outline Motivation K Overview Context Transformers Example Problem Variable Patterns and Sort Inference Context Transformers The K Module System Related and Future Work The Need for Context Transformers Rewriting logic semantics equations/rules (just rules from here, unless distinction matters) match across configuration items Configuration items provide context to where rule can apply Hills and Ro¸ su WADT’08: Towards a Module System for K 13 / 29

  14. Outline Motivation K Overview Context Transformers Example Problem Variable Patterns and Sort Inference Context Transformers The K Module System Related and Future Work The Need for Context Transformers Rewriting logic semantics equations/rules (just rules from here, unless distinction matters) match across configuration items Configuration items provide context to where rule can apply Problem: change in configuration structure can change context, break existing rules Hills and Ro¸ su WADT’08: Towards a Module System for K 13 / 29

  15. Outline Motivation K Overview Context Transformers Example Problem Variable Patterns and Sort Inference Context Transformers The K Module System Related and Future Work Example � x := v | � k � | ( x , l ) | � env � | ( l , | � store · v Hills and Ro¸ su WADT’08: Towards a Module System for K 14 / 29

  16. Outline Motivation K Overview Context Transformers Example Problem Variable Patterns and Sort Inference Context Transformers The K Module System Related and Future Work Example, After Configuration Change �� x := v | � k � | ( x , l ) | � env � t � | ( l , | � store · v Hills and Ro¸ su WADT’08: Towards a Module System for K 15 / 29

  17. Outline Motivation K Overview Context Transformers Example Problem Variable Patterns and Sort Inference Context Transformers The K Module System Related and Future Work Context Transformers Context transformers solve problem by transforming context of rule to match configuration Handles almost all common cases using simple restrictions Top level configuration items should have distinct names Matching items are those closest together in graph Ambiguous matches will be flagged by tool User can explicitly specify context to handle unusual cases Hills and Ro¸ su WADT’08: Towards a Module System for K 16 / 29

  18. Outline Motivation K Variable Patterns Context Transformers Sort Inference Variable Patterns and Sort Inference The K Module System Related and Future Work Variable Patterns Provide way to define sorts of variables based on regular expressions for variable names Similar concepts found in other formalisms (e.g., ASF+SDF) Patterns visible throughout specification, not just in declaration module Example: var Var[0-9] for variables Var0, Var1, ..., Var9 Hills and Ro¸ su WADT’08: Towards a Module System for K 17 / 29

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend