Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.

Slides:



Advertisements
Similar presentations
Semantics Static semantics Dynamic semantics attribute grammars
Advertisements

Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
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.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Propositional Logic Reading: C , C Logic: Outline Propositional Logic Inference in Propositional Logic First-order logic.
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
ISBN Chapter 3 Describing Syntax and Semantics.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
CS 330 Programming Languages 09 / 19 / 2006 Instructor: Michael Eckmann.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 LECTURE: ABSTRACT SYNTAX SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics Fall 2005.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Overview of Programming Paradigms
CS 330 Programming Languages 09 / 18 / 2007 Instructor: Michael Eckmann.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
C SC 520 Principles of Programming Languages 1 C SC 520: Principles of Programming Languages Peter J. Downey Department of Computer Science Spring 2006.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
Describing Syntax and Semantics
Programming Languages Third Edition Chapter 12 Formal Semantics.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – 23/09/20151.
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
Programming Languages –14 David Watt (Glasgow) Steven Wong (Singapore) Moodle : Computing Science → Level 3 → Programming Languages 3 © 2012 David.
Overview of Formal Methods. Topics Introduction and terminology FM and Software Engineering Applications of FM Propositional and Predicate Logic Program.
Chapter 25 Formal Methods Formal methods Specify program using math Develop program using math Prove program matches specification using.
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
Discrete Structures for Computing
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
Muhammad Idrees Lecturer University of Lahore 1. Outline Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax Attribute.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
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.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
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,
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Languages and Compilers
Logical and Functional Programming
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
Programming Language Descriptions. What drives PL Development? Computers are “in charge” of extremely important issues Execute a program literally. Exercise.
1-1 1 Introduction  Programming linguistics: concepts and paradigms syntax, semantics, and pragmatics language processors.  Historical development of.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
NATURAL LANGUAGE PROCESSING
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
Describing Syntax and Semantics
Discrete Mathematics and Its Applications
CSCE 330 Programming Language Structures Ch.2: Syntax and Semantics
Motivation for Language Specification
Chapter 10: Compilers and Language Translation
OBJ first-order functional language based on equational logic
Motivation for Language Specification
Programming Languages and Compilers (CS 421)
Presentation transcript:

Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical Sciences Web Site:

Aims To give you a DEEP understanding of the meaning and structure of (programming) languages.. So that in the future when you encounter a new one you can analyse and classify it - and hence easily pick it up

Content This Module will concentrate on PROGRAM LANGUAGE SEMANTICS - specifically DENOTATIONAL SEMANTICS.

Last Term’s Work: - Functional PL: Haskell/Gofer - Lambda Calculus - Reductions, Normal forms, Fixed Points, Church - Rosser Theorem.. - Functional PL + Lambda Calculus relationship - Operational Semantics of Functional PL, type checking + type inference - Implementation of FPL’s

This Term’s Work: -- Denotational Semantics of basic Imperative PL Control Structures (using Lambda Calculus) -- Prototyping the Denotational Semantics using Haskell -- Algebraic Semantics of Data Types (Objects)

Kinds of (Programming) Languages GENERAL PLs e.g. C,Java,Haskell, Pascal, Ada, Prolog.. fall into 3 groups depending on their underlying model of computation: Procedural (state change) Functional (function evaluation) Logic (logical inference) SPECIALIST PLs e.g. Maths, Web, Multimedia, Database, Op Sys

SYNTAX..is all about the set of symbols allowed in a language and the order in which they may be written. This is usually specified in a structured, compositional manner, e.g.: sentence := noun verb noun “.” loop := “WHILE” exp “DO” stm This can be very subtle e.g. what is the role of a ‘;’ in Java vs. the role of ‘;’ in Pascal?

SEMANTICS..is all about the relationship between the symbols in a language and their meaning. The meaning of a language is often defined by ascribing meaning to the grammatical components of the language. E.g. semantics(“REPEAT” stm “UNTIL” exp) = execute stm, then check if exp is true; if it is then halt else execute REPEAT again

SEMANTICS- EXAMPLE WHAT CAN YOU SAY ABOUT THE FOLLOWING COMMANDS? X := X+1 (Pascal) X = X+1 ( C ) X++ ( C )

PRAGMATICS..is all about the use or utility of the components of a language. To write complex programs we use decomposition: procedures/methods solve sub-problems of the main problem abstraction: objects encapsulate the representation of a data type, procedures/methods encapsulate the particular algorithm used to solve the sub-problem. Reasoning: documentation, invariants, long variable names all help us to reason about the workings of a program None of these add to the computational power of a PL!

RELATED CONCEPTS Semiotics – the science of SIGNS and SYMBOLS – esp. their form and meaning Linguistics – as semiotics but specific to the SYMBOLS contained in a language Syntax can be broken up into: Morphology – make-up of words Grammar – legal orderings of words, the structure of the phrases and sentences language

SEMANTICS.. WHY?..There are many uses for semantic definitions: compiler specification documentation analysis / classification of a language checking properties of a language standardisation deriving proofs of correctness of programs

Semantics: Different Definitions Natural Language Semantics Axiomatic Semantics Operational Semantics Denotational Semantics

Natural Language Semantics Giving the meaning of (components of) a language in pure natural language form. The meaning may well suffer from ambiguities and inconsistencies typical in such definitions. It has been said that there have been no correct definitions of usable languages completed in natural language

Axiomatic Semantics Commands change states: each command in the language is given a meaning in terms of axioms / inference rules which defines how the command changes a program “state” Commands are defined in terms of pre- and post- conditions on states AS are good for proving the (partial) correctness of programs.

Operational Semantics Language components are defined in terms of a simple, well-defined abstract “machine”. Operational Semantics are good for proving the implementation of a PL correct.

Denotational Semantics Syntax Classes are mapped via “meaning functions” to a mathematical language - typically lambda calculus A denotational definition usually consists of - the (abstract) syntax of the language a set of meaning functions for each of the syntax classes

Denotational Semantics: Revision You will need to revise: sets and functions Functional Programming Syntax Definitions (BNF)

Exercises Look up the definition of some of the key concepts in this lecture on the internet eg Semiotics, linguistics, semantics, meaning, denotation, syntax, grammar, pragmatics, morphology, phrase structure Try to relate the concepts using a diagram. Write down a “one line” definition of each concept.