Dr. Muhammed Al-Mulhem 1ICS535-101 ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Operational Semantics ICS.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
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.
Hoare’s Correctness Triplets Dijkstra’s Predicate Transformers
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
David Evans CS655: Programming Languages University of Virginia Computer Science Lecture 19: Minding Ps & Qs: Axiomatic.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Copyright © 2006 Addison-Wesley. All rights reserved. 3.5 Dynamic Semantics Meanings of expressions, statements, and program units Static semantics – type.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
CS 355 – Programming Languages
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Lecture 02 – Structural Operational Semantics (SOS) Eran Yahav 1.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Axiomatic Semantics Dr. M Al-Mulhem ICS
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Computability (Chapter 2) ICS 535 Design and Implementation.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Operational Semantics.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Kernel language semantics Carlos Varela RPI Adapted with permission.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 OpenMP -Example ICS 535 Design and Implementation.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 18 Program Correctness To treat programming.
MinML: an idealized programming language CS 510 David Walker.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Axiomatic Semantics ICS 535.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Describing Syntax and Semantics
Programming Languages Third Edition Chapter 12 Formal Semantics.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Denotational Semantics ICS.
Imperative Programming
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 2: Operational Semantics I Roman Manevich Ben-Gurion University.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
Sequence – a function whose domain is positive integers. Section 9.1 – Sequences.
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.
Dr. Muhammed Al-MulhemICS (Denotational Semantics)
Semantics (1).
CS412/413 Introduction to Compilers Radu Rugina Lecture 13 : Static Semantics 18 Feb 02.
1 Overview of Programming Principles of Computers.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Denotational Semantics.
CMSC 330: Organization of Programming Languages Operational Semantics.
Sum of Arithmetic Sequences. Definitions Sequence Series.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Formal Semantics of Programming Languages 虞慧群 Topic 2: Operational Semantics.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
March 1, 2009 Dr. Muhammed Al-Mulhem 1 ICS 482 Natural Language Processing SLR Parsing Muhammed Al-Mulhem March 1, 2009.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Dr. M. Al-Mulhem Denotational Semantics 1 Chapter 4 Fundamentals (Denotational Semantics)
Semantics(1). 2 Symantec(1)  To provide an authoritative definition of the meaning of all language constructs for: 1.Programmers 2.Compiler writers 3.Standards.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 8 Semantic Interpretation To understand a.
EQUATION IN TWO VARIABLES:
Spring 2017 Program Analysis and Verification Operational Semantics
Programming Misconceptions
FACTORIALS Dr. Shildneck.
Computer Science 210 Computer Organization
Programming Languages 2nd edition Tucker and Noonan
Chapter (3) - Looping Questions.
The Metacircular Evaluator
Flow of Control.
Spring 2016 Program Analysis and Verification Operational Semantics
Programming Languages
Programming Languages 2nd edition Tucker and Noonan
Presentation transcript:

Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Operational Semantics ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Operational Semantics

Dr. Muhammed Al-Mulhem 2ICS Semantic Domains and State Transformation Semantic domain Semantic domain A semantic domain is any set whose properties and operations are independently well-understood and upon which the functions that define the semantics of a language are ultimately based, Examples: natural numbers, integers, booleans Examples: natural numbers, integers, booleans Useful semantic domains for programming languages are Useful semantic domains for programming languages are 1. Environment 2. Memory 3. Locations

Dr. Muhammed Al-Mulhem 3ICS Semantic Domains and State Transformation Suppose we have variables i and j with values 13 and -1 at memory locations 154 and 155. Suppose we have variables i and j with values 13 and -1 at memory locations 154 and 155. Environment Environment A set of pairs that unite specific variables with memory locations  = {, } Memory [static and dynamic] Memory [static and dynamic] A set of pairs that unite specific locations with values  = {, ….,, …} Locations Locations Locations are the natural numbers.

Dr. Muhammed Al-Mulhem 4ICS Semantic Domains and State Transformation State State The state of a program is the product of its environment and its memory Simplified form The state  of a program is a set of pairs that represents all the active variables and their currently assigned values at some stage during the execution of the program.  = {,, … }  = {,, … } NOTE: Value of each variable is undefined before the program begins execution.

Dr. Muhammed Al-Mulhem 5ICS Semantic Domains and State Transformation Example of a state Example of a state  = {,, }  = {,, } Value retrieval function  (var) Value retrieval function  (var)  (y) gives the value 12  (y) gives the value 12 State transformations represent the changes in state of a program due to the execution of program statements. State transformations represent the changes in state of a program due to the execution of program statements. State transformation can be represented mathematically by a special function called Overriding Union ( Ū ). State transformation can be represented mathematically by a special function called Overriding Union ( Ū ).

Dr. Muhammed Al-Mulhem 6ICS Semantic Domains and State Transformation Overriding union Ū between two sets of pairs Overriding union Ū between two sets of pairs X Ū Y = replace in X all pairs whose first member matches a pair from Y by and then add to X any remaining pairs in Y Ū is a formal and generalized model of assignment statement Example Example  1 = {,, } y = 2*w + 3; z = 14;  2 = {, }  =  1 Ū  2 = {,,, }

Dr. Muhammed Al-Mulhem 7ICS Operational Semantics Operational semantics of a program provides a definition of program meaning by simulating the program’s behavior on a machine model Operational semantics of a program provides a definition of program meaning by simulating the program’s behavior on a machine model Structured operational semantics model use Structured operational semantics model use Rule-based approach Rule-based approach We developed this kind of operational semantics for Jay language. We developed this kind of operational semantics for Jay language.

Dr. Muhammed Al-Mulhem 8ICS Operational Semantics Operational semantics model uses the following notations: Operational semantics model uses the following notations: 1. Expression computation  (e)  v The computation of a value v from the expression e in state  2. Execution rule: It has the form If the premise is true then the conclusion is true. premise Conclusion

Dr. Muhammed Al-Mulhem 9ICS Operational Semantics Execution rule for addition Execution rule for addition  (e 1 )  v 1  (e 2 )  v 2 :  (e 1 + e 2 )  v 1 + v 2 Execution rule for an assignment statement Execution rule for an assignment statement s.target = s.source  (s.source)  v :  (s.target = s.source;)   Ū { } Execution rule for statement sequences s 1, s 2 Execution rule for statement sequences s 1, s 2  (s 1 )   1  1 (s 2 )   2 :  (s 1, s 2 )   2

Dr. Muhammed Al-Mulhem 10ICS Operational Semantics Execution rule for conditional statement Execution rule for conditional statement s = if (s.test) s.thenpart else s.elsepart  (s.test)  true  (s.thenpart)   1 :  (if(s.test) s.thenpart else s.elsepart)   1  (s.test)  false  (s.elsepart)   1 :  (if(s.test) s.thenpart else s.elsepart)   1

Dr. Muhammed Al-Mulhem 11ICS Operational Semantics Execution rule for loops Execution rule for loops s = while (s.test) s.body;  (s.test)  true  (s.body)   1  (while(s.test) s.body)   2 :  (while(s.test) s.body)   2  (s.test)  false :  (while(s.test) s.body)  

Dr. Muhammed Al-Mulhem 12ICS Examples - addition Suppose we have x = x + 1; and a current state in which the value of x is 5. That is Suppose we have x = x + 1; and a current state in which the value of x is 5. That is  = { …,, …}  = { …,, …} The operational semantics computes a new state as follows: The operational semantics computes a new state as follows:  (x)  5  (1)  1  (x + 1)  6  (x = x + 1;)  { …,, …} Ū {…, …}  This transformed the state to  = { …,, …}

Dr. Muhammed Al-Mulhem 13ICS Example - conditional If we have the state  = { …,, …} If we have the state  = { …,, …} And the following Jay statement And the following Jay statement If ( x<0 ) x = x -1; else x = x + 1; We apply the false rule We apply the false rule The rule concludes that the result of executing the conditional is the same as the result of executing x = x + 1; in state  = { …,, …} leaving as final result the state  1 = { …,, …} The rule concludes that the result of executing the conditional is the same as the result of executing x = x + 1; in state  = { …,, …} leaving as final result the state  1 = { …,, …}