Illinois Institute of Technology
Lecture 6
Hoare Triples
CS 536: Science of Programming
[9/16: p.5, Solved]
A. Why
To specify a programs correctness, we need to know its precondition and
postcondition (what should be true before and after executing it).
Illinois Institute of Technology
Homework 4
Basic Correctness Triples
CS 536: Science of Programming; Due Wed Sep 23
[9/20: p.1]
A. Why?
Correctness triples are how we write a program with its specication.
B. Outcomes
After this homework, you should be a
Illinois Institute of Technology
Lecture 1 Notes
Welcome; Propositional Logic
CS 536: Science of Programming
A. Why
Course guidelines are important.
Active learning is the style well be using in the class.
Understanding what Science of Programming i
CS536 Science of Programming Spring 2010
Due date Friday February 12 by midnight 1. Prove following a. cfw_ab = xy*z (y,z :=y-1,x*z) cfw_ ab = xy*z b. cfw_ab = xy*z ^even(y) ^y != 0 (x,y := x*x,y/2) cfw_ ab = xy*z
2.a
Assignment #3
(8 pts)
(8 pts) cfw
CS530-F09, Midterm Exam
Due: Tuesday 20th, 11.25 A.M.
1. Construct either DFA or NFA for the following language. L(w, x) = cfw_w1 x1 w2 x2 .wn xn : w = w1 w2 .wn L1 , x = x1 x2 .xn L2 , where L1 , L2 are regular. 2. Prove that the following language is no
Question -1 For non deterministic program S and post condition R there are two main concerns: Does S TERMINATE? (Possible cases: always, sometimes, never) Des it terminate 1n R? (Possible cases: always, sometimes, never) 1a. List the seven different chara
CS-536 spring 2010 Assignment #5
-Due date April 9th 2010 -Question 1. Prove total correctness using the lexicographic order for proving termination for the following GCD program cfw_a>0 ^ b>0 (x,y) : (a,b) LOOPSELECT x> y => x:=x-y or y>x => y:=y-x end L
CS-536 : Homework 1
1.[12=4*3points]Is
(a)pqrpq (pq)r)(p)q?FALSE
(b)(p (q) r (s p) p q r (s p)?FALSE
(c) x.py.qr (x.p)(y.q)r?FALSE
d x. y.p q (x.( y.(pq)?TRUE
Forquestions25,theminimalparenthesizationofapropositionorpredicateeliminatesall
redundantparenth
CS 536 SCIENCE OF PROGRAMMING, IIT, Spring 2010
SCIENCE OF PROGRAMMING
ASSIGNMENT # 5
47/50
Submitted by Abhay Kumar Singh CWID: A20242810 Spring - 2010
Question 1.
CS 536 SCIENCE OF PROGRAMMING, IIT, Spring 2010
Prove total correctness using the lexicogr
Pankaj Purandare
CWID : A20296536
Homework 3
CS-536 Homework 3 : wp Triples
1. Calculate w1 wp(L:=M,q) where q L < R and b[L] <= v < b[R]
Ans :
w1 wp(L:=M, q)
w1 M < R and b[M] <= v < b[R]
2. Calculate w2 wp(R:=M,q) where q L < R and b[L] <= v < b[R]
Ans
Pankaj Purandare
CWID : A20296536
Homework 4
1. [8 points] sp(x > y AND f(x,y) z, x := x+y; y := x+y).
Ans :
sp( x > y AND f(x,y) z, x := x+y; y := x+y )
sp( sp( x > y AND f(x,y) z, x := x+y ), y := x+y )
sp( x0 > y AND f(x0,y) z ANDx=x0+y, y := x+y )
Illinois Institute of Technology
1
Department of Computer Science
Homework 1
Spring 2015: CS 536 Science of Programming
Due on Jan 25, 2015 at 11:59pm
Name
Email ID
@iit.edu
Problem
1
2
3
4
5
6
7
8
9
Total
Points
5
4
6
10
10
15
15
15
20
100
Score
CS 536
H
Illinois Institute of Technology
2
Department of Computer Science
Exam 2
CS 536 Science of Programming
Spring 2014
Mar. 5, 2014 10:0011:15
This is a closed book and closed notes exam.
Do ALL problems in this booklet. Read each question very carefully.
You
Deterministic Program The While Program
Shangping Ren
Department of Computer Science
Illinois Institute of Technology
February 24, 2014
Shangping Ren
Deterministic Program The While Program
February 24, 2014
1 / 25
Outline
1
Verication
Total Correctness:
Illinois Institute of Technology
1
Department of Computer Science
Homework 1
CS 536 Science of Programming
Spring 2014
Jan 31, 2014 11:59pm
Name
Email ID
@iit.edu
Problem
1
2
3
4
5
6
Total
Points
15
10
20
10
15
30
100
Score
CS 536
Homework 1
Spring 2014
H
Illinois Institute of Technology
1
Department of Computer Science
Exam 1
CS 536 Science of Programming
Spring 2014
Feb. 10, 2014 10:0011:15
This is a closed book and closed notes exam.
Do ALL problems in this booklet. Read each question very carefully.
Yo
Illinois Institute of Technology
Quiz 2 (11/6/13) Solution
Quiz 2 Solution
CS 536: Science of Programming
1.
False. The sp isi[not i] >0i=i+1.
2.
False. The sp is 2*k>nk=k/2 [Note k>n is not 2*k>n (e.g., n=2,
k=3, k=1)
3.
False. The sp is x=x+1k=x [not x]
Illinois Institute of Technology
HW 3
Programs and Their Semantics
CS 536: Science of Programming Due Mon, Sep 22 Wed Sep 16
[9/15: Fixed due date to match calendar; 9/19: Solved]
A. Why?
Our simple programming language is a model for the kind of constru
Illinois Institute of Technology
HW 2
States, Values, and Predicates
CS 536: Science of Programming; Due Wed Sep 4
A. Why?
States describe memory; an expression has a value relative to a state.
A predicate is satisfied relative to a state; it is valid i
Illinois Institute of Technology
Homework 4
Basic Correctness Triples
CS 536: Science of Programming; Due Wed Sep 23
[9/20: p.1; 9/28: Solved]
A. Why?
Correctness triples are how we write a program with its specification.
B. Outcomes
After this homework,
Homework 1
CS 536: Science of Programming
Propositional and Predicate Logic
Problems [50 points total]
Q1. [8=4 * 2 points] Is
(a) p q r p q (p q) r) (p) q)?
Ans:
Taking the Left side of equality we get
p qrpq
= p qr(p)q
= (p q)r(p)q
= (p q)r)(p)q
= (p q)
Illinois Institute of Technology
HW 2
States, Values, and Predicates
CS 536: Science of Programming; Due Wed Sep 9
[9/13: p.3; Solved]
A. Why?
States describe memory; an expression has a value relative to a state.
A predicate is satisfied relative to a
Illinois Institute of Technology
Homework 8
Proof Rules and Proofs
CS 536: Science of Programming
Due Wed Oct 21
[10/20: p.3; 10/21: p.2; 10/28: Solved]
A. Why?
We cant generally prove that correctness triples are valid using truth tables.
A formal proo
Illinois Institute of Technology
Lecture 16
Finding Invariants
CS 536: Science of Programming
[10/28: pp.14; 11/1: pp.912; Solved]
A. Why
It is easier to write good programs and check them for defects than to write bad
programs and then debug them.
The
Name:
,l*
seq
f:
CS 536 Quiz 2 [30 min, 50 points]
Mon lfov 10, 2014
Instructions
This exam is closed book, one page of notes (8.5' x 11n or A4, both sides). No
sharing notes, no support equipment (calculators, phones, etc). The usual penalty
for copying
Illinois Institute of Technology
Lecture 5
Syntax and Semantics of Programs
CS 536: Science of Programming
[2/13: pp.7,8; 1/29: Solved]
A. Why
Our simple programming language is a model for the kind of constructs seen in
actual languages.
B. Outcomes
At
HW-01 NISHANT SHARMA, A20368125
Ques-1
a. p and q or r -> !p -> q = (p and q) or r) -> (!p) -> q)
b. (p or (!q) and r and (s -> p) = p or !q and r and (s -> p)
c. all x . p and all y . q -> r = (all x . p) and (all y . q) -> r
d. ! exist x . all y . p or
HW-03 NISHANT SHARMA A20368125
1. x:=1 ; j:=m while j>=1 do j:=j-1; x:=x*y[j]; od
2. j := m; x := 1;j:=j-1 while j>= 0 do x :=x * y[j] ; j:=j-1; od
3. x = 1; j = 0; while j<m do j=j+1; x= x*y[j] od; j=j+1
4. S t := x ; x := y; y := t
M(S, )=M(t := x ; x :
-)
CS 536 Final Exam, Fri Dec 9,2011.
Question sheets
Instructions
.This exam is closed book, one 8.5"x11" page of notes (both sides). No sharing notes and
no equipment (calculators, phones, music piavers, etc). The usual penalty for copying or
sharing an
Illinois Institute of Technology
HW 7
Proof Outlines; Runtime Errors;
Termination
CS 536: Science of Programming
Due Mon Oct 21
[10/21: Typos in #3 & #4]
A. Why?
Proof outlines are easier to use than proofs but give the same information.
Runtime errors
HW-02 NISHANT SHARMA A20368125
1.
a) Legal
b) Legal
c) Illegal
2.
a) There exists a variable with name b as well as an array
with name b. Hence does not show a proper memory
state.
b) As x does not return any value. Hence it does not show a
proper memory