Induction
Up to this point we have considered proofs of the following type:
Given a selected expression a Aexp and some state
compute the semantic value k,
(a, ) k .
Or we have considered equivalence proofs of the form,
Given two selected programs c , c
Program Evaluation
Compute the semantic value of the program x := 2; y := 3.
Assume the initial state 0 . We want to compute the value
where
(x := 2; y := 3, 0 )
From our evaluation rules we have,
(2, 0 ) 2
(3, 0 [2/x ]) 3
(x := 2, 0 ) 0 [2/x ]
(y := 3,
CSC 501 - Assignment #1
version 3.1
Due Tuesday 9/27/11 in Class
Problems
Given the grammar G = (, R, ):
= T N where
T = cfw_0, . . . , 9, a, . . . , z, true, false, skip, if, then, else, while, do, end+, , , =, , !, &, |, :=, ; , (, )
and
N = cfw_A, B,
Natural Semantics
Goals:
Dene the syntax of a simple imperative language
Dene 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
Grammars
Observations:
We have seen in the case of the palindrome generator that SRSs are
well suited for generating strings with structure.
By modifying the standard SRS just slightly we obtain a convenient
framework for generating strings with desirable
CSC 501 - Assignment #2
version 8.0
Due Tuesday 10/4/11 in Class
Problems
1. Given the production
C := skip | V := A | C ; C | if B then C else C end | while B do C end
give an inductive denition of set Com, the set of all well formed commands. You can
as
String Rewriting Systems
The rst step in exploring the formal aspects of programming languages
is the denition of their structure or syntax.
In order to accomplish this we will use a formal system known as String
Rewriting System (SRS).
We begin with the
Arithmetic Expression Summary
(n, ) eval (n)
(x , ) (x )
(a0 , ) k0
for n I
for x Loc
(a1 , ) k1
(a0 + a1 , ) k
(a0 , ) k0
(a1 , ) k1
(a0 a1 , ) k
(a0 , ) k0
(a1 , ) k1
(a0 a1 , ) k
where k = k0 + k1
where k = k0 k1
where k = k0 k1
(a, ) k
(a), ) k
with k