Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.

Size: px
Start display at page:

Download "Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m."

Transcription

1 CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics. These both fall under the general style called structural operational semantics (SOS). We will also discuss why both the big-step and small-step approaches can be useful. 1 The IMP Language 1.1 Syntax of IMP There are three distinct types of expressions in IMP: arithmetic expressions AExp with elements denoted by a, a 0, a 1,... Boolean expressions BExp with elements denoted by b, b 0, b 1,... commands Com with elements denoted by c, c 0, c 1,... A program in the IMP language is a command in Com. Let n, n 0, n 1,... denote integers (elements of Z = {..., 2, 1, 0, 1, 2,...}). We will view n both as a number (a semantic object) and as a numeral (a syntactic object) representing the number n. This little bit of ambiguity should not cause any confusion; the numbers and the numerals are in one-to-one correspondence, so there is really no need to distinguish them. Similarly, there is no need to distinguish between the Boolean constants true and false (syntactic objects) and the Boolean values true, false 2 (semantic objects). Let Var be a countable set of variables ranging over Z. Elements of Var are denoted x, x 0, x The BNF grammar for IMP is AExp : a ::= n x a 0 + a 1 a 0 a 1 a 0 a 1 BExp : b ::= true false a 0 = a 1 a 0 a 1 b 0 b 1 b 0 b 1 b Com : c ::= skip x := a c 0 ; c 1 if b then c 1 else c 2 while b do c Note that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m. 1.2 Environments and Configurations An environment (also known as a valuation or a store) is a function σ : Var Z that assigns an integer to each variable. Environments are denoted σ, σ 1, τ,... and the set of all environments is denoted Env. In IMP semantics, environments are always total functions. A configuration is a pair c, σ, where c Com is a command and σ is an environment. Intuitively, the configuration c, σ represents an instantaneous snapshot of reality during a computation, in which σ represents the current values of the variables and c represents the next command to be executed. 1

2 2 Small-Step Semantics Small-step semantics specifies the operation of a program one step at a time. There is a set of rules that we continue to apply to configurations until reaching a final configuration skip, σ (if ever). We write c, σ c, σ to indicate that the configuration c, σ reduces to c, σ in one step, and we write c, σ c, σ to indicate that c, σ reduces to c, σ in zero or more steps. Thus c, σ c, σ iff there exists k 0 and configurations c 0, σ 0,..., c k, σ k such that c, σ = c 0, σ 0, c, σ = c k, σ k, and c i, σ i c i+1, σ i+1 for 0 i k 1. To be completely proper, we will define auxiliary small-step operators a and b for arithmetic and Boolean expressions, respectively, as well as for commands. 1 These operators are partial functions: a : (AExp Env) AExp b : (BExp Env) BExp : (Com Env) (Com Env) Intuitively, a, σ a n if the expression a evaluates to the constant n in environment σ. We now present the small-step rules for evaluation in IMP. Just as with the λ-calculus, evaluation is defined by a set of inference rules that inductively define relations consisting of acceptable computation steps. 2.1 Arithmetic and Boolean Expressions Variables: Arithmetic: x, σ a σ(x) n 1 + n 2, σ a n 3 (where n 3 is the sum of n 1 and n 2 ) a 1, σ a a 1 a 1 + a 2, σ a a 1 + a 2 a 2, σ a a 2 n 1 + a 2, σ a n 1 + a 2 and similar rules for and. These rules say: If the reduction above the line can be performed, then the reduction below the line can be performed. The rules are thus inductive on the structure of the expression to be evaluated. Note that there is no rule that applies in the case n, σ. This configuration is irreducible. In all other cases, there is exactly one rule that applies. The rules for Booleans and comparison operators are similar. We leave them as exercises. 2.2 Commands Let us denote by σ[n/x] the environment that is identical to σ except possibly for the value of x, which is n. That is, { σ(y) if y x, σ[n/x](y) n if y = x. 1 Winskel [1] uses 1 instead of. 2

3 The construct [n/x] is called a rebinding operator. It is a meta-operator that is used to rebind a variable to a different value in the environment. Note that in the definition of σ[n/x], the condition y x does not mean that y and x are bound to different values, but that they are syntactically different variables. Assignment: x := n, σ skip, σ[n/x] a, σ a a x := a, σ x := a, σ Sequence: c 0, σ c 0, σ c 0 ; c 1, σ c 0 ; c 1, σ skip ; c 1, σ c 1, σ Conditional: b, σ b b if b then c 0 else c 1, σ if b then c 0 else c 1, σ While statement: if true then c 0 else c 1, σ c 0, σ if false then c 0 else c 1, σ c 1, σ while b do c, σ if b then (c ; while b do c) else skip, σ There is no rule for skip; the configuration skip, σ is irreducible. In all other cases, there is exactly one rule that applies. These rules tell us all we need to know to run IMP programs. 3 Big-Step Semantics As an alternative to small-step structural operational semantics, which specifies the operation of the program one step at a time, we now consider big-step operational semantics, in which we specify the entire transition from a configuration (an expression, environment pair) to a final value. This relation is denoted. For arithmetic expressions, the final value is an integer n Z; for Boolean expressions, it is a Boolean truth value true, false 2; and for commands, it is an environment σ : Var Z. Thus a : (AExp Env) Z b : (BExp Env) 2 : (Com Env) Env Here 2 represents the two-element Boolean algebra consisting of the two truth values {true, false} with the usual Boolean operations. Then c, σ σ says that σ is the environment of the final configuration, starting in configuration c, σ ; a, σ a n says that n Z is the integer value of arithmetic expression a evaluated in environment σ; and b, σ b t says that t 2 is the truth value of Boolean expression b evaluated in environment σ. 3

4 3.1 Arithmetic and Boolean Expressions The big-step rules for arithmetic and Boolean expressions are straightforward. The key when writing big-step rules is to think about how a recursive interpreter would evaluate the expression in question. The rules for arithmetic expressions are: Constants: Variables: Operations: and similarly for and. n, σ a n x, σ a σ(x) a 0, σ a n 0 a 1, σ a n 1 (where n2 is the sum of n 0 and n 1 ) a 0 + a 1, σ a n 2 The rules for evaluating Boolean expressions and comparison operators are similar. 3.2 Commands Skip: Assignments: Sequences: Conditionals: skip, σ σ a, σ a n x := a, σ σ[n/x] c 0, σ σ c 1, σ σ c 0 ; c 1, σ σ b, σ b true c 0, σ σ b, σ b false c 1, σ σ if b then c 0 else c 1, σ σ if b then c 0 else c 1, σ σ While statements: b, σ b false while b do c, σ σ b, σ b true c, σ σ while b do c, σ σ while b do c, σ σ 4 Big-Step vs. Small-Step SOS If the big-step and small-step semantics both describe the same language, we would expect them to agree. In particular, the relations and both capture the idea of a complete evaluation. We would expect that if c, σ is a configuration that evaluates in the small-step semantics to skip, σ, then σ should also be the result of the big-step evaluation, and vice-versa. Formally, Theorem 1. For all commands c Com and environments σ, τ Env, c, σ skip, τ c, σ τ. 4

5 One can prove this theorem by induction. Note that this statement about the agreement of big-step and small-step semantics has nothing to say about the agreement of nonterminating computations. This is because big-step semantics cannot talk directly about nontermination. If c, σ does not terminate, then there is no τ such that c, σ τ. Small-step semantics can model more complex features such as nonterminating programs and concurrency. However, in many cases it involves unnecessary extra work. If we do not care about modeling nonterminating computations, it is often easier to reason in terms of bigstep semantics. Moreover, big-step semantics more closely models an actual recursive interpreter. However, because evaluation skips over intermediate steps, all programs without final configurations are indistinguishable. References [1] Glynn Winskel. The Formal Semantics of Programming Languages. MIT Press,

axiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.

CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 1 Natural deduction is an instance of first-order logic; that is, it is the formal

3.7 Denotational Semantics

3.7 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each programming language construct a well-defined and rigorously understood mathematical object. These

Semantics. A. Demers Jan This material is primarily from Ch. 2 of the text. We present an imperative

CS411 Notes 1: IMP and Large Step Operational Semantics A. Demers 23-25 Jan 2001 This material is primarily from Ch. 2 of the text. We present an imperative language called IMP; wegive a formal definition

Induction and Semantics in Dafny

15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics

Brutus Is An Honorable Man HW2 will not be due today. Homework X+1 will never be due until after I have returned Homework X to you. Normally this is never an issue, but I was sick yesterday and was hosting

Application: Programming Language Semantics

Chapter 8 Application: Programming Language Semantics Prof. Dr. K. Madlener: Specification and Verification in Higher Order Logic 527 Introduction to Programming Language Semantics Programming Language

A CRASH COURSE IN SEMANTICS

LAST TIME Recdef More induction NICTA Advanced Course Well founded orders Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 Well founded recursion Calculations: also/finally {P}... {Q}

In Our Last Exciting Episode

In Our Last Exciting Episode #1 Lessons From Model Checking To find bugs, we need specifications What are some good specifications? To convert a program into a model, we need predicates/invariants and

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 19 Tuesday, April 3, 2018 1 Introduction to axiomatic semantics The idea in axiomatic semantics is to give specifications

1 Introduction. 3 Syntax

CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

CS422 - Programming Language Design

1 CS422 - Programming Language Design From SOS to Rewriting Logic Definitions Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign In this chapter we show how SOS language

Programming Languages Third Edition

Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

Introduction to Denotational Semantics Class Likes/Dislikes Survey would change [the bijection question] to be one that still tested students' recollection of set theory but that didn't take as much time

Contents. Chapter 1 SPECIFYING SYNTAX 1

Contents Chapter 1 SPECIFYING SYNTAX 1 1.1 GRAMMARS AND BNF 2 Context-Free Grammars 4 Context-Sensitive Grammars 8 Exercises 8 1.2 THE PROGRAMMING LANGUAGE WREN 10 Ambiguity 12 Context Constraints in Wren

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 21 Tuesday, April 15, 2014 1 Static program analyses For the last few weeks, we have been considering type systems.

2 Introduction to operational semantics

2 Introduction to operational semantics This chapter presents the syntax of a programming language, IMP, a small language of while programs. IMP is called an "imperative" language because program execution

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 1 Tuesday, January 29, 2013 1 Intro to semantics What is the meaning of a program? When we write a program, we use

CS422 - Programming Language Design

1 CS422 - Programming Language Design Denotational Semantics Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 Denotational semantics, alsoknownasfix-point semantics,

3.2 Big-Step Structural Operational Semantics (Big-Step SOS)

3.2 Big-Step Structural Operational Semantics (Big-Step SOS) Known also under the names natural semantics, relational semantics, and evaluation semantics, big-step structural operational semantics, or

CSC 7101: Programming Language Structures 1. Operational Semantics. Winskel, Ch. 2 Slonneger and Kurtz Ch 8.4, 8.5, 8.6. Operational vs.

Operational Semantics Winskel, Ch. 2 Slonneger and Kurtz Ch 8.4, 8.5, 8.6 1 Operational vs. Axiomatic Axiomatic semantics Describes properties of program state, using first-order logic Concerned with constructing

3.4 Denotational Semantics

3.4 Denotational Semantics Denotational semantics, also known as fixed-point semantics, associates to each syntactically welldefined fragment of program a well-defined, rigorous mathematical object. This

An Annotated Language

Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of

Denotational Semantics

Denotational Semantics 8 12 lectures for Part II CST 2010/11 Marcelo Fiore Course web page: http://www.cl.cam.ac.uk/teaching/1011/denotsem/ 1 Lecture 1 Introduction 2 What is this course about? General

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)

Fundamental Concepts. Chapter 1

Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There

3.3 Small-Step Structural Operational Semantics (Small-Step SOS)

3.3 Small-Step Structural Operational Semantics (Small-Step SOS) Known also under the names transition semantics, reduction semantics, one-step operational semantics, and computational semantics, small-step

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014 1 Introduction to Abstract Interpretation At this point in the course, we have looked at several aspects of programming languages: operational

Static Program Analysis

Static Program Analysis Lecture 1: Introduction to Program Analysis Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ws-1415/spa/

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Design

CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS422 Programming Language Design Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and tools,

Programming Languages

CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

Static Program Analysis

Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-18/spa/ Preliminaries Outline of Lecture 1 Preliminaries Introduction

PROGRAM ANALYSIS & SYNTHESIS

Lecture 02 Structural Operational Semantics (SOS) PROGRAM ANALYSIS & SYNTHESIS EranYahav 1 Previously static analysis over-approximation of program behavior abstract interpretation abstraction, transformers,

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Semantics

CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS422 Programming Language Semantics Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS522 Programming Language Semantics

CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS522 Programming Language Semantics Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and

CSc 520 Principles of Programming Languages

CSc 520 Principles of Programming Languages 50: Semantics Introduction Christian Collberg collberg@cs.arizona.edu Department of Computer Science University of Arizona Copyright c 2005 Christian Collberg

CS2104 Prog. Lang. Concepts

CS2104 Prog. Lang. Concepts Operational Semantics Abhik Roychoudhury Department of Computer Science National University of Singapore Organization An imperative language IMP Formalizing the syntax of IMP

Semantics and Concurrence Module on Semantic of Programming Languages

Semantics and Concurrence Module on Semantic of Programming Languages Pietro Di Gianantonio Università di Udine Presentation Module of 6 credits (48 hours), Semantics of programming languages Describe

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

Syntax vs. semantics. Detour: Natural deduction. Syntax vs. semantics (cont d) Syntax = grammatical structure Semantics = underlying meaning

Syntax vs. semantics CMSC 631 Program nalysis and Understanding Spring 2013 Operational Semantics Syntax = grammatical structure Semantics = underlying meaning Sentences in a language can be syntactically

Program Syntax; Operational Semantics

9/5 Solved Program Syntax; Operational Semantics CS 536: Science of Programming, Fall 2018 A. Why Our simple programming language is a model for the kind of constructs seen in actual languages. Step-by-step

Semantics and Concurrence Module on Semantic of Programming Languages

Semantics and Concurrence Module on Semantic of Programming Languages Pietro Di Gianantonio Università di Udine Presentation Module of 6 credits (48 hours), Semantics of programming languages Describe

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front

Chapter 3. Describing Syntax and Semantics

Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

Chapter 3. The While programming language

Chapter 3 The While programming language 1 Contents 3 The While programming language 1 3.1 Big-step semantics........................... 2 3.2 Small-step semantics.......................... 9 3.3 Properties................................

CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011

CS 6110 S11 Lecture 12 Naming and Scope 21 February 2011 In this lecture we introduce the topic of scope in the context of the λ-calculus and define translations from λ-cbv to FL for the two most common

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

The Formal Semantics of Programming Languages An Introduction Glynn Winskel The MIT Press Cambridge, Massachusetts London, England Series foreword Preface xiii xv 1 Basic set theory 1 1.1 Logical notation

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Propositional Logic Formal Syntax and Semantics Computability and Logic Syntax and Semantics Syntax: The study of how expressions are structured (think: grammar) Semantics: The study of the relationship

Semantics with Applications 3. More on Operational Semantics

Semantics with Applications 3. More on Operational Semantics Hanne Riis Nielson, Flemming Nielson (thanks to Henrik Pilegaard) [SwA] Hanne Riis Nielson, Flemming Nielson Semantics with Applications: An

Formal Systems and their Applications

Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

The Substitution Model

The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on

Lecture 9: Typed Lambda Calculus

Advanced Topics in Programming Languages Spring Semester, 2012 Lecture 9: Typed Lambda Calculus May 8, 2012 Lecturer: Mooly Sagiv Scribe: Guy Golan Gueta and Shachar Itzhaky 1 Defining a Type System for

Types, Expressions, and States

8/27: solved Types, Expressions, and States CS 536: Science of Programming, Fall 2018 A. Why? Expressions represent values in programming languages, relative to a state. Types describe common properties

Handout 9: Imperative Programs and State

06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 9: Imperative Programs and State Imperative

Exercises on Semantics of Programming Languages

Technische Universität Wien SS 2014 Fakultät für Informatik Repetition sheet Assist. Prof. Florian Zuleger Tuesday, 8 April 2014 Assist. Prof. Georg Weissenbacher Univ. Prof. Agata Ciabattoni Moritz Sinn,

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters. Corky Cartwright January 26, 2018

Comp 411 Principles of Programming Languages Lecture 7 Meta-interpreters Corky Cartwright January 26, 2018 Denotational Semantics The primary alternative to syntactic semantics is denotational semantics.

Formal Semantics. Prof. Clarkson Fall Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack

Formal Semantics Prof. Clarkson Fall 2015 Today s music: Down to Earth by Peter Gabriel from the WALL-E soundtrack Review Previously in 3110: simple interpreter for expression language: abstract syntax

Operational Semantics 1 / 13

Operational Semantics 1 / 13 Outline What is semantics? Operational Semantics What is semantics? 2 / 13 What is the meaning of a program? Recall: aspects of a language syntax: the structure of its programs

CSE505, Fall 2012, Midterm Examination October 30, 2012

CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart

Chapter 3. Describing Syntax and Semantics ISBN

Chapter 3 Describing Syntax and Semantics ISBN 0-321-49362-1 Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the

Chapter 3. Describing Syntax and Semantics

Chapter 3 Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings of Programs:

Lectures 20, 21: Axiomatic Semantics

Lectures 20, 21: Axiomatic Semantics Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Based on slides by George Necula Pratikakis (CSD) Axiomatic Semantics

Semantics of programming languages

Semantics of programming languages Informatics 2A: Lecture 28 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 21 November 2018 1 / 18 Two parallel pipelines A large proportion

Introduction to Denotational Semantics (1/2)

Introduction to Denotational Semantics (1/2) Gone in Sixty Seconds Denotation semantics is a formal way of assigning meanings to programs. In it, the meaning of a program is a mathematical object. Denotation

Lecture 3: Recursion; Structural Induction

15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion

Programming Languages Fall 2013

Programming Languages Fall 2013 Lecture 3: Induction Prof. Liang Huang huang@qc.cs.cuny.edu Recursive Data Types (trees) data Ast = ANum Integer APlus Ast Ast ATimes Ast Ast eval (ANum x) = x eval (ATimes

4.5 Pure Linear Functional Programming

4.5 Pure Linear Functional Programming 99 4.5 Pure Linear Functional Programming The linear λ-calculus developed in the preceding sections can serve as the basis for a programming language. The step from

Last class. CS Principles of Programming Languages. Introduction. Outline

Last class CS6848 - Principles of Programming Languages Principles of Programming Languages V. Krishna Nandivada IIT Madras Interpreters A Environment B Cells C Closures D Recursive environments E Interpreting

Program Analysis: Lecture 02 Page 1 of 32

Program Analysis: Lecture 02 Page 1 of 32 Program Analysis/ Mooly Sagiv Lecture 1, 31/10/2012 Operational Semantics Notes by: Kalev Alpernas As background to the subject of Program Analysis, we will first

Abstract Interpretation

Abstract Interpretation Ranjit Jhala, UC San Diego April 22, 2013 Fundamental Challenge of Program Analysis How to infer (loop) invariants? Fundamental Challenge of Program Analysis Key issue for any analysis

3.1 IMP: A Simple Imperative Language

Int = the domain of (unbounded) integer numbers, with usual operations on them Bool = the domain of Booleans Id = standard identifiers AExp = Int Id AExp +AExp AExp /AExp BExp = Bool AExp

Introduction to Denotational Semantics

Introduction to Denotational Semantics Overview:! Syntax and Semantics! Approaches to Specifying Semantics! Sets, Semantic Domains, Domain Algebra, and Valuation Functions! Semantics of Expressions! Semantics

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

Shared Variables and Interference

Solved Shared Variables and Interference CS 536: Science of Programming, Fall 2018 A. Why Parallel programs can coordinate their work using shared variables, but it s important for threads to not interfere

Semantics of programming languages

Semantics of programming languages Informatics 2A: Lecture 27 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 18 November, 2014 1 / 18 Two parallel pipelines A large proportion

Chapter 3 (part 3) Describing Syntax and Semantics

Chapter 3 (part 3) Describing Syntax and Semantics Chapter 3 Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute Grammars Describing the Meanings

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

Topics Chapter 3 Semantics Introduction Static Semantics Attribute Grammars Dynamic Semantics Operational Semantics Axiomatic Semantics Denotational Semantics 2 Introduction Introduction Language implementors

CSE 505: Concepts of Programming Languages

CSE 505: Concepts of Programming Languages Dan Grossman Fall 2009 Lecture 4 Proofs about Operational Semantics; Pseudo-Denotational Semantics Dan Grossman CSE505 Fall 2009, Lecture 4 1 This lecture Continue

Defining syntax using CFGs

Defining syntax using CFGs Roadmap Last time Defined context-free grammar This time CFGs for specifying a language s syntax Language membership List grammars Resolving ambiguity CFG Review G = (N,Σ,P,S)

Denotational Semantics

Denotational Semantics 10 lectures for Part II CST 2011/12 Andrew Pitts Course web page: http://www.cl.cam.ac.uk/teaching/1112/denotsem/ 1 Styles of formal semantics Operational. Meanings for program phrases

Operational Semantics. One-Slide Summary. Lecture Outline

Operational Semantics #1 One-Slide Summary Operational semantics are a precise way of specifying how to evaluate a program. A formal semantics tells you what each expression means. Meaning depends on context:

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language

Type Systems. Today. 1. Organizational Matters. 1. Organizational Matters. Lecture 1 Oct. 20th, 2004 Sebastian Maneth. 1. Organizational Matters

Today Type Systems 1. Organizational Matters 2. What is this course about? 3. Where do types come from? 4. Def. of the small language Expr. Its syntax and semantics. Lecture 1 Oct. 20th, 2004 Sebastian

A Rewriting Logic Approach to Operational Semantics

A Rewriting Logic Approach to Operational Semantics Traian Florin Şerbănuţă, Grigore Roşu and José Meseguer Department of Computer Science, University of Illinois at Urbana-Champaign. {tserban2,grosu,meseguer}@cs.uiuc.edu

CS 242. Fundamentals. Reading: See last slide

CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

CMSC 330: Organization of Programming Languages. Operational Semantics

CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged

COSC252: Programming Languages: Semantic Specification. Jeremy Bolton, PhD Adjunct Professor

COSC252: Programming Languages: Semantic Specification Jeremy Bolton, PhD Adjunct Professor Outline I. What happens after syntactic analysis (parsing)? II. Attribute Grammars: bridging the gap III. Semantic

CS 6110 S14 Lecture 1 Introduction 24 January 2014

CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions

02157 Functional Programming Interpreters for two simple languages including exercises

Interpreters for two simple languages including exercises nsen 1 DTU Informatics, Technical University of Denmark Purpose To show the power of a functional programming language, we present a prototype

Lecture 5: Predicate Calculus. ffl Predicate Logic ffl The Language ffl Semantics: Structures

Lecture 5: Predicate Calculus ffl Predicate Logic ffl The Language ffl Semantics: Structures 1 Why Predicate Logic? Propositional logic is not powerful enough to express statements such as ffl For every

Compilers and computer architecture From strings to ASTs (2): context free grammars

1 / 1 Compilers and computer architecture From strings to ASTs (2): context free grammars Martin Berger October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall we are discussing parsing Source

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

CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e