CSSE 490 Model-Based Software Engineering: Transformational Programming

Similar documents
CSSE 490 Model-Based Software Engineering: Transformation Systems

Model-Driven Architecture/ Development

CSSE 490 Model-Based Software Engineering: Domain Specific Language Introduction

CSSE 490 Model-Based Software Engineering: Software Factories

CSSE 490 Model-Based Software Engineering: Domain Engineering

CSSE 490 Model-Based Software Engineering: More MBSD. Shawn Bohner Office: Moench Room F212 Phone: (812)

A Survey of Rewriting Strategies in Program Transformation Systems

A Survey of Rewriting Strategies in Program Transformation Systems

ISR 2014 Strategies. Hélène KIRCHNER Inria. August Topics, Objectives, Contents. Hélène KIRCHNER Inria ISR 2014 Strategies 1 / 48

CSSE 490 Model-Based Software Engineering: Cougaar Model-Driven Architecture Example

CSSE 490 Model-Based Software Engineering: Introduction to Domain Engineering

CSSE 374: UML Activity Diagrams. Shawn Bohner Office: Moench Room F212 Phone: (812)

CSSE 490 Model-Based Software Engineering: MDSD and Case Study

CS 242. Fundamentals. Reading: See last slide

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

CSSE 374: Even More Object Design with Gang of Four Design Patterns

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

CSSE 374: Logical Architecture. Shawn Bohner Office: Moench Room F212 Phone: (812)

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Principles of Programming Languages

SIR C R REDDY COLLEGE OF ENGINEERING

Functions & First Class Function Values

CSSE 374: GRASP ing at the First Five Patterns Principles. Shawn Bohner Office: Moench Room F212 Phone: (812)

Program generation for schema-based, typed data access

CSSE 490 Model-Based Software Engineering: Architecture Description Languages (ADL)

CSSE 490 Model-Based Software Engineering: Introduction to MetaModels

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Model driven Engineering & Model driven Architecture

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

Lecture 15 CIS 341: COMPILERS

Introduction to Lexical Analysis

Programming Languages Assignment #7

Assistant for Language Theory. SASyLF: An Educational Proof. Corporation. Microsoft. Key Shin. Workshop on Mechanizing Metatheory

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

We are at System Operation Contracts

An experiment with variable binding, denotational semantics, and logical relations in Coq. Adam Chlipala University of California, Berkeley

LOGIC AND DISCRETE MATHEMATICS

Decision, Computation and Language

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

CSE 504: Compiler Design. Instruction Selection

CSSE 374: More Object Design with Gang of Four Design Patterns

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Computer-Aided Program Design

CS153: Compilers Lecture 15: Local Optimization

LOGIC SYNTHESIS AND VERIFICATION ALGORITHMS. Gary D. Hachtel University of Colorado. Fabio Somenzi University of Colorado.

Static program checking and verification

ELAN. A rule-based programming language. Hélène Kirchner and Pierre-Etienne Moreau LORIA CNRS INRIA Nancy, France

1. Abstract syntax: deep structure and binding. 2. Static semantics: typing rules. 3. Dynamic semantics: execution rules.

Query Evaluation and Optimization

Lecture #14 Optimizer Implementation (Part I)

Compiler Code Generation COMP360

Crafting a Compiler with C (II) Compiler V. S. Interpreter

EXTENSIONS OF FIRST ORDER LOGIC

Contents. Chapter 1 SPECIFYING SYNTAX 1

Principles of Programming Languages

CMPT 379 Compilers. Anoop Sarkar.

Clock-directed Modular Code-generation for Synchronous Data-flow Languages

U4L4B Box Problem - TI Nspire CAS Teacher Notes

Implementation of Lexical Analysis. Lecture 4

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

Type Systems COMP 311 Rice University Houston, Texas

On Meaning Preservation of a Calculus of Records

Programming Assignment IV

Logik für Informatiker Logic for computer scientists

CS 6110 S14 Lecture 1 Introduction 24 January 2014

Computing Fundamentals 2 Introduction to CafeOBJ

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

2 Introduction to operational semantics

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6

CS2383 Programming Assignment 3

ADVANCED DATABASE SYSTEMS. Lecture #15. Optimizer Implementation (Part // // Spring 2018

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

Bindings & Substitution

Introduction to Dependable Systems: Meta-modeling and modeldriven

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

Compiler Design. Fall Control-Flow Analysis. Prof. Pedro C. Diniz

Operational Semantics. One-Slide Summary. Lecture Outline

Language Techniques for Provably Safe Mobile Code

PRESENTATION SLIDES FOR PUN-LOSP William Bricken July Interface as Overview

1.1: Basic Functions and Translations

The RASTA Framework. Joel Becker October 3, 2001

Lexical Analysis. Finite Automata

Lexical Analysis. Lecture 2-4

Outlook on Composite Type Labels in User-Defined Type Systems

Introduction to MDE and Model Transformation

The Relational Model

Cover Page. The handle holds various files of this Leiden University dissertation

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

Lexical Analysis. Chapter 2

Oklahoma City Community College

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation

A New Model Checking Tool

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Introduction to Axiomatic Semantics

Transcription:

CSSE 490 Model-Based Software Engineering: Transformational Programming Shawn Bohner Office: Moench Room F212 Phone: (812) 877-8685 Email: bohner@rose-hulman.edu

Learning Outcomes: Transformations Define transformation rules for abstraction and refinement. Outline transformation systems Introduce transformational programming Discuss paper (if time) Q3

For all the SQL calls in a 2M line program done in MySQL, how would you rewrite them in Oracle SQL? (not the details, just the strategy) Think for a minute Turn to a neighbor and discuss it for a minute Q2

Rules need verifiers

Transformational System Applications General support for program modification Program synthesis from a formal specification Automatic program generation Adaptation to different environments Verification of program correctness

Transformation Systems Correct programs can be built if the task is split into sufficiently small and formally justified steps Many of those steps are automatable If the automatable steps are performed by a machine, the programmer is free to focus on creative aspects of the job Q1

Transformation System Issues Specification vs. programming languages Level of automation full, semi, user-driven Transformation mechanism approaches Catalog approach: Production rules, knowledge-based systems Generative set approach: Elementary transformations used in constructing new rules Q2

Types of Transformational Systems Restructuring/Optimization Same input and output language Conversion/Synthesis Different input and output language Q3,4

Transformational Programming Programming by successive application of transformation rules Transformation a relation between two programs Transformation rule mapping from one program to another that constitutes a correct transformation (e.g., equivalency) Guarantees that the final version of the program satisfies the initial formal specification Q5

Specifying Basic Transformation Steps Rewrite rules Substitution Pattern Matching Rule application Examples Propositional formulae Lambda calculus

Rewrite Rules Rule: L : l à r Label/name L Left-hand side pattern l Right-hand side pattern r Pattern: term with variables t := x C(t1,, tn) C int string Examples A : Plus(Zero, x) à x Like engineering you must first write before you rewrite

Substitution A substitution is a mapping from variables to terms Notation: [t1/x1,, tn/xn] is a finite substitution mapping xi to ti and all other variables to themselves Application of a substitution s to a pattern subst(s, x) = s(x) subst(s, str) = str subst(s, num) = num There is no substitute for a good substitution subst(s, C(t1,, tn)) = C(subst(s,t1),, subst(s,tn)) Q6

Term Pattern Matching A term t matches with a pattern p if there is a substitution s such that subst(s,p) = t There is no match for a term without a pattern

Application of Rule Rule L : l à r Term t Application of L to t = subst(s, r), if subst(s, l) = t = fail, otherwise If you are a rule, then applying yourself should work t1 Là t2 : L t1 rewrites to t2 under rule L t1 à t2 : t1 rewrites to t2 under some rule

Prop: Algebraic Simplification Module prop-laws imports prop Rules // Associativity relation AA : And(And(x, y), z) And(x, And(y, z)) AO : Or(Or(x, y), z) Or(x, Or(y, z)) AI : Imp(Imp(x, y), z) Imp(x, Imp(y, z)) AE : Eq(Eq(x, y), z) Eq(x, Eq(y, z)) // Commutative relation CA : And(x, y) And(y, x) CO : Or(x, y) Or(y, x) CE : Eq(x, y) Eq(y, x) Q7

Program Transformation Paradigms Interactive Program Transformation Syntactic Abstractions in Intentional Programming Simple Tree Parsing Tree Parsing with Dynamic Programming Term Rewriting Term Rewriting with Strategy Annotations Functional Rewriting Rewriting with Traversal Functions Controlling Rewriting by Reflection Sequences of Canonical Forms Non-deterministic Sequential Strategies Generic Traversal Strategies

Simple Transformational System

Example Rewrite Rules InlineF : [ let f(xs) = e in e'[f(es)] ] -> [ let f(xs) = e in e'[e[es/xs]] ] InlineV : [ let x = e in e'[x] ] -> [ let x = e in e'[e] ] Dead : [ let x = e in e' ] -> [ e' ] where <not(in)> (x,e') Extract(f,xs) : [ e ] -> [ let f(xs) = e in f(xs) ] Hoist : [ let x = e1 in let f(xs) = e2 in e3 ] -> [ let f(xs) = e2 in let x = e1 in e3 ] where <not(in)> (x, <free-vars> e2)

Applications of Software Transformation 1/2 Compilers Translation (e.g. Java into C#) Desugaring (e.g. Java's foreach into for) Instruction selection Maximal munch vs BURG-style dynamic programming Optimization Data-flow optimization, Vectorization, GHC-style simplification, Deforestation, Domain-specific optimization, Partial evaluation Type checking Specialization of dynamic typing Q8

Applications of Software Transformation 2/2 Program generators Pretty-printer and signature generation from syntax definitions Application generation (e.g. data format checkers from specifications) Program migration Platform conversion (e.g. MacOS to Linux) Program understanding Documentation generation (e.g. JavaDoc) Document generation/transformation Web/XML programming (server-side scripts)

So, What does this have to do with MBE? Reduces requirements errors as it forces rigor in the requirements analysis Incompleteness and inconsistencies can be discovered and resolved Correctness by construction - preserving and guaranteeing essential properties Both specification and transformation rely on the rigors of Formal Specification and Transformation

Paper Discussion: Feature-Based Transformation Approach Paper Feature-based survey of model transformation approaches What are the main thrusts of the paper? What are the controversial points and your positions? What did you get out of reading about feature-based transformation approaches?

Homework and Milestone Reminders Continue to familiarize yourself with material on Eclipse Modeling Project http://www.eclipse.org/modeling/