This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction A Simple Imperative Language The following is the grammar G for our simple imperative language with T , N as the obvious sets and C the start symbol, A ::= D  V  A + A  A − A  A ∗ A  (A) B ::= true  false  A = A  A ≤ A  !B  B&&B  B  B  (B) C ∗ ::= skip  V := A  C ; C  if B then C else C end  while B do C end D ::= L  − L L ::= L  . . .  9 L   . . .  9 V ::= a V  . . .  z V  a  . . . z Semantics Our goal is to define a semantics for each component of our language so that composing the semantics of each component will then give us a semantics of programs written in that language. Furthermore, we want to construct our models or semantics using relations and functions, that means we need to describe our syntax using sets . 1 We need a more mathematical view of syntax – abstract syntax ignore pragmatics like operator precedence and actual parsing introduce syntactic sets sometimes also called syntactic domains (not to be confused with semantic domains!) 1 Read Sections 1.1 and 2.1 and 2.2 in the book by David Schmidt. IMP  A Simple Imperative Language Syntactic Sets (syntax only!!! not to be confused with the mathematical notions of integers, booleans, or variables, etc. ): 2 I This set consists of all positive and negative integer digits including zero T Truth constants true and false . Loc Locations (variable names as strings). Aexp Arithmetic expressions Bexp Boolean expressions Com Commands NOTE: I 6 = I , where I is the set of all integer values . 2 This material is based on the book by Glynn Winskel, “The Formal Semantics of Programming Languages.” Formation Rules for Syntactic Sets The syntax set for boolean constants is straight forward: T = { true , false } All other syntax sets are infinite and have structured terms as elements. Consider the syntax set Loc of all variable names: Loc = { x, y, xname, price, studentname , . . . } This set consists of an infinite number of possible strings and we know exactly what these strings look like from the grammar rule,...
View
Full
Document
This note was uploaded on 10/03/2011 for the course CSC 501 taught by Professor Staff during the Spring '09 term at Rhode Island.
 Spring '09
 Staff

Click to edit the document details