Just Enough Type Theory or, Featherweight Java A Simple Formal Model of Objects Jonathan Aldrich 15-819.

Slides:



Advertisements
Similar presentations
Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Advertisements

Types and Programming Languages Lecture 4 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Semantics Static semantics Dynamic semantics attribute grammars
Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal.
- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
CS7100 (Prasad)L16-7AG1 Attribute Grammars Attribute Grammar is a Framework for specifying semantics and enables Modular specification.
ISBN Chapter 3 Describing Syntax and Semantics.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 355 – Programming Languages
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
7. Fixed Points. © O. Nierstrasz PS — Fixed Points 7.2 Roadmap  Representing Numbers  Recursion and the Fixed-Point Combinator  The typed lambda calculus.
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Syntax With Binders COS 441 Princeton University Fall 2004.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
MinML: an idealized programming language CS 510 David Walker.
7. Fixed Points. © O. Nierstrasz PS — Fixed Points 7.2 Roadmap  Representing Numbers  Recursion and the Fixed-Point Combinator  The typed lambda calculus.
Feather-Weight Java COS 441 Princeton University Fall 2004.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Describing Syntax and Semantics
1 Type-Directed Concurrency Deepak Garg, Frank Pfenning {dg+, Carnegie Mellon University.
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
Foundations of Programming Languages – Course Overview Xinyu Feng Acknowledgments: some slides taken or adapted from lecture notes of Stanford CS242
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
Hoare logic for higher order store using simple semantics Billiejoe (Nathaniel) Charlton University of Sussex WoLLIC 2011.
1 Static Type Analysis of Path Expressions in XQuery Using Rho-Calculus Wang Zhen (Selina) Oct 26, 2006.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Self Type Constructors Atsushi Igarashi Kyoto University Joint work with Chieri Saito 1.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
CS 363 Comparative Programming Languages Semantics.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Semantics In Text: Chapter 3.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Featherweight Generic Ownership Alex Potanin, James Noble Victoria University of Wellington Dave Clarke CWI, Netherlands Robert Biddle Carlton University.
From Hoare Logic to Matching Logic Reachability Grigore Rosu and Andrei Stefanescu University of Illinois, USA.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
Soundness of Types Ensuring that a type system is not broken.
CMSC 330: Organization of Programming Languages Operational Semantics.
Type soundness In a more formal way. Proving Soundness of Type Systems Goal of a sound type system: –if the program type checks, then it never “crashes”
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
Lecture 16b Turing Machines Topics: Closure Properties of Context Free Languages Cocke-Younger-Kasimi Parsing Algorithm June 23, 2015 CSCE 355 Foundations.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
CS5205Semantics1 CS5205: Foundation in Programming Languages Semantics Static Semantics Dynamic Semantics Operational Semantics Big-step Small-Step Denotational.
Towards a Semantic Model for Java Wildcards Sophia Drossopoulou Mariangiola Dezani-Ciancaglini Imperial College London Università di Torino Italy Nicholas.
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Model Checking Early Requirements Specifications in Tropos Presented by Chin-Yi Tsai.
A Simple Syntax-Directed Translator
CS 326 Programming Languages, Concepts and Implementation
Formal Language & Automata Theory
Syntax Analysis Chapter 4.
Syntax Questions 6. Define a left recursive grammar rule.
Formal Models for Programming Languages
Towards a Unified Theory of Operational and Axiomatic Semantics
Presentation transcript:

Just Enough Type Theory or, Featherweight Java A Simple Formal Model of Objects Jonathan Aldrich

Why Formal Models? Make precise what a language means –What can you say in the language? –How does a program execute? Allow us to prove formal properties –Typically, lack of certain run-time errors This course –Type theory not required for much of the reading –However, some papers use formal notation A brief introduction will help us get more out of it

Example: Featherweight Java A minimal core calculus for Java –Classes, methods, fields, inheritance –Any FJ program is a Java program Purpose of a core language –Leaves out unnecessary details –Focuses attention on issues of interest –Makes proving formal properties easier Citation –Atsushi Igarashi, Benjamin Pierce, and Philip Wadler. Featherweight Java: A Minimal Core Calculus for Java and GJ. OOPSLA ’99.

FJ Syntax Standard BNF definition Overbar represents a sequence

Subtyping Judgments If we know this Then we can conclude this Base case: each class subtypes itself Transitivity rule Both exprs on top must hold

Dynamic Semantics Computation expressed as rewriting rules [d/x] e – substitute d for x in e

Evaluation Examples

Type System Conceptually: –Annotates an object or expression –Describes operations that are applicable Prevents run-time errors from undefined operations –X = “hello” – 2 –snail.fly() Type soundness –A well-typed program will not halt with an undefined operation error Java’s type system does a dynamic check at casts, and so programs can halt with a cast error. FJ’s type system, however prevents all other run time errors. –Real languages have additional error cases; however, the type soundness guarantee is still useful

FJ Types  maps var -> class Read  ├ e  C as, “in the context of type environment , expression e has type C

Class/Method Typing

Other definitions

Type Soundness A well-typed program remains well-typed after a reduction step A well-typed program can take a step Well-typed FJ programs eventually reduce to either a value or an expression with an embedded cast error Proofs are by induction, beyond the scope of this course