# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

10 Pages

### program-development

Course: UI 181, Fall 2009
School: Iowa State
Rating:

Word Count: 1818

#### Document Preview

Specifications I. (Cohen's chapter 4) A. what is programming? (omit) ----------------------- EQUATION WITH UNKNOWN SPECIFIED consider x*x + b*x + c == 0 could solve for x, b, or c! x: x*x + b*x + c == 0 means solve for x in... ----------------------- ----------------------- WHAT IS PROGRAMMING? Programming is solving the equation: S: {Q} S {R} ----------------------- B. writing specifications 1....

Register Now

#### Unformatted Document Excerpt

Coursehero >> Iowa >> Iowa State >> UI 181

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Specifications I. (Cohen's chapter 4) A. what is programming? (omit) ----------------------- EQUATION WITH UNKNOWN SPECIFIED consider x*x + b*x + c == 0 could solve for x, b, or c! x: x*x + b*x + c == 0 means solve for x in... ----------------------- ----------------------- WHAT IS PROGRAMMING? Programming is solving the equation: S: {Q} S {R} ----------------------- B. writing specifications 1. notation ----------------------- TOTAL CORRECTNESS HOARE TRIPLE {Q} S {R} =def= Q ==> wp.S.R ----------------------- C. form of specification ------------------- FORM OF SPECIFICATION example: var a,b,z: int {a >= 0 /\ b >= 0} ; z: z == a*b ------------------- ---------------------- SYNTAX OF SPECIFICATIONS <spec> ::= <decl> [ ; <decl> ] ... ; <ident-list> : <cond> <decl> ::= var <ident-list> : <type> [ <cond> ] <ident-list> ::= <ident> [ , <ident> ] ... <cond> ::= <boolean-expression> | <label> : <boolean-expression> ---------------------- 1. examples ---------------- EXAMPLE SPECS set z to absolute value of x var x,z : int ; z : z == |x| set z to its own absolute value var z : int {z == Z} ; z: z == |Z| ---------------- ------------------ swap the values of x and y var x,y: bool {x == X /\ y == Y} ; x,y : x == Y /\ y == X ------------------ can you specify setting z to the max of integers x and y? can you specify setting x to the max of integers x and y? ------------------- set q and r to the quotient of x by y: var x,y,q,r: int {x>=0 /\ y>0} ; q,r : q*y + r == x /\ 0<=r /\ r<y set x to integer square root of N: var N: int {N >= 0} var x:int ; x : x <= sqrt(N) /\ sqrt(N) < x+1 ------------ Can you specify a program that sets x to the integer log base 2 on N? D. arrays (4.4) ------------------- ARRAYS var f(i : x <= i < y) : bool provided x <= y x is lower bound, y is upper bound i is dummy index f.k is an element of f =def= x <= k < y length: #f =def= y - x v occurs in f =def= (\exists i : x <= i < y : f.i == v) def: bag.f is the multiset of elements of f f(k:i<=k<j) is an array section =def= x <= i <= j <= y var f(0..N-1): T =def= var f(i: 0 <= i < N): T var f: array of int =def= var f(i:0 <= i < #f): int {#f >= 0} -------------------- can you specify setting x to the max value occuring in an integer array g? E. monotonicity defs. ---------------- DEFINITIONS RELATED TO SORTING AND MONOTONICITY f is increasing =def= (\forall i,j:: i<j <==> f.i < f.j) f is nondecreasing (or ascending) =def= (\forall i,j:: i<j <== f.i < f.j) f is decreasing =def= (\forall i,j:: i<j <==> f.i > f.j) f is nonincreasing (or decending) =def= (\forall i,j:: i<j <== f.i > f.j) ---------------- F. more examples of specs (4.7) G. other notations (4.8) -------------------------- OTHER NOTATIONS FOR SPECIFICATIONS Cohen's var x,y: int {x>y} ; x : x == y Gries's: Given fixed integer y such that x>y, establish x == y Dijkstra and Feijen's: |[ var y: int |[ var x: int {x>y} ;S {x == y} ]| ]| Hesselink's: ext y, x!: int; pre x>y, post x==y Refinement Calculus (of C. Morgan) x: [x > y, x == y] Refinement Calculus (of Morris, Butler, Back) {x > y} x := x' | x' == y JML assuming int x,y is in the context. /*@ behavior @ requires x > y; @ assignable x; @ ensures x == y; @*/ -------------------------- II. The guarded command language (Cohen's chapter 5) A. shapes, or grammar, of programs (5.1) -------------------------- ABSTRACT SYNTAX OF PROGRAMS S ::= skip | abort | S1 ; S2 | x := E | if G* fi | do G* od G* ::= | G | G1 [] G2 G ::= B -> S where x is a list of variables, E is a list of expressions B is a boolean expression (guard) -------------------------- B. semantics (5.2 - 5.4) -------------------- WEAKEST PRECONDITION SEMANTICS (POSTULATES ABOUT wp) Excluded miracle: wp.S.false <==> false Conjunctivity (wp is conjunctive): wp.S.(X /\ Y) <==> wp.S.X /\ wp.S.Y -------------------- can you prove this? --------------------- wp of skip: wp.skip.R <==> R --------------------- --------------------- wp of abort: wp.abort.R <==> false --------------------- What's this in terms of total correctness Hoare triples? --------------------- wp of composition: wp.(S1;S2).R <==> wp.S1.(wp.S2.R) --------------------- can you prove this? 1. assignment (5.4.2) ------------------- wp of assignment: wp.(x := E).R <==> def.E /\ R(x := E) Thm: if E is always defined, then wp.(x := E).R <==> R(x := E) -------------------- -------------------- TEXTUAL SUBSTITUTION EXAMPLES Let R be i <= j. R(i := i+1) == i+1 <= j R(i,j := i+1,i+j) == i+1 <= i+j R(x := 3) == i <= j Let Q be x < y /\ (\forall j :: f.j < y). Q(y := y+1) == x < (y+1) /\ (\forall j :: f.j < y+1) Q(y := y+j) == x < y+j /\ (\forall k :: f.k < y+j) ------------------- what is wp.(x,y := x+1,x+y).(x == y)? what is wp.(x := 6*x + 15).(x == 57)? 2. alternation or if (5.4.3) ----------------------- wp of if: wp(if B.0 -> S.0 [] B.1 -> S.1 ... [] B.(n-1) -> S.(n-1) fi, R) <==> (\exists i : 0<=i<n : B.i) /\ (\forall i : 0<=i<n : B.i ==> wp.(S.i).R) abbreviations: IF =def= if B.0 -> S.0 [] B.1 -> S.1 ... [] B.(n-1) -> S.(n-1) fi BB =def= (\exists i : 0<=i<n : B.i) Thus (wp of if): wp(IF,R) <==> BB /\ (\forall i : 0<=i<n : B.i ==> wp.(S.i).R) ----------------------- 3. repetition or loop or do (5.4.4) ---------------------- Invariance Thm: {P} do B -> S od {P /\ !B} <== {P /\ B} S {P} (Invariance) /\ {P /\ B /\ t==T} S {t<T} (Progress) /\ P /\ t<=0 ==> !B (Boundedness) ---------------------- a. theorems III. not excluding miracles A. excluded miracle and excluded middle B. predicate transformation semantics (Hesselink's 0.2) 1. axioms -------------- AXIOMS FOR PREDICATE TRANSFORMERS {wp.S.p is stronger}: [wp.S.P ==> is wlp.S.P] {wp.S monotone}: [P ==> Q] ==> [wp.S.P ==> wp.S.Q] {wlp.S is monotone}: [P ==> Q] ==> [wlp.S.P ==> wlp.S.Q] --------------- 2. semantic equality ----------------- SEMANTIC EQUALITY def: commands S and T are *semantically equal*, written S == T, iff (wp.S = wp.T) /\ (wlp.S = wlp.T) ------------------ C. guards, assertions, termination, and totality (1.3) 1. guards ---------------- GUARDS form: assume B examples: assume (x < 3), assume (x == 3) axioms: wp.(assume B).P = (B ==> P) wlp.(assume B).P = (B ==> P) ----------------- 2. assertions --------------- ASSERTIONS form: assert B examples: assert (x < 3), assert (x = 3) axioms: wp.(assert B).P = (B /\ P) wlp.(assert B).P = (B ==> P) --------------- 3. special cases do our wp laws for skip and abort hold? what is wlp.skip.P? wlp.abort.P? wp.miracle.P? wlp.miracle.P? how is miracle miraculous? 4. termination is skip necessarily terminating? abort? miracle? assignment? 5. totality can you prove that ((assume B) is total) <==> (B == true)? 6. summary ------------------------------------------ assert false = abort (abort [] miracle) ! ^ ! ! ! less termin. ! assert odd(i) ! ! ! assume odd(i) miracle assert true !__________________________ = = skip = assume true assume false less defined (less total) -> ------------------------------------------ D. composition and nondeterministic choice (Hesselink's 1.4) 1. sequential composition --------------- SEQUENTIAL COMPOSITION form: c;d example: x:=1; y:= 2 axioms: wp.(S;T).P = wp.S.(wp.T.P) wlp.(S;T).P = wlp.S.(wlp.T.P) i.e., wp.(S;T) = wp.S o wp.T wlp.(S;T) = wlp.S o wlp.T --------------- can you verify the laws of wp and wlp for these? 2. nondeterminate choice ---------------------- NONDETERMINATE CHOICE form: S [] T example: x:=1 [] x:=2 axioms: wp.(S [] T).P = wp.S.P /\ wp.T.P wlp.(S [] T).P = wlp.S.P /\ wlp.T.P ---------------------- why these axioms? can you develop the semantic of angelic and demonic choice? as a relation on states, what is demonic(S,T).x? What are the wlps? 3. semantics is compositional E. conditionals (Hesselink's 1.5) can you continue the proof from here? IV. intermezzo on calculations (Cohen's chapter 6) A. what a calculation means -------------------- WHAT A CALCULATION MEANS P op <H0> X op <H1> Q means (H0 ==> P op X) /\ (H1 ==> X op Q) --------------------- B. proving implications ---------------------- SHAPES OF CALCULATIONS TO PROVE Q <== P Q <== <hint why Q <== P> P Q <==> <assuming P> true ---------------------- why is this last valid? ------------------------ TO PROVE P0 /\ P1 ==> Q P1 ==><assuming P0> Q P1 <==><assuming P0> Q ------------------------ ------------------------ Q <==> <assuming P0> X <==> <assuming P1> true ------------------------ C. substitution with an implication ---------------------- USING ==> IN A LARGER CONTEXT The following are valid X /\ Y ==> < hint why Y ==> Z > X /\ Z X /\ Z <== < hint why Z <== Y > X /\ Y ---------------------- why is it? can you prove it for disjunction, assuming Y ==> Z? consider a step of the following form: (\forall y \in X :: (\forall x \in X :: p.x) \/ q.y) ==>{instantiation, that is (\forall x \in X :: p.x) ==> p.y} (\forall y \in X :: p.y \/ q.y) Can you state the justification for this and prove it's valid? D. ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Iowa State - UI - 181
I. developing loops, an introduction (Cohen's chapter 8) A. before and after 1. other forms of postconditions 2. establishing the invariant B. steps- INVARIANCE THEOREM FOR LOOPS cfw_P do B -&gt; S od cfw_P /\ !B &lt;= cfw_P /\ B S cfw_P (Invariance)
Iowa State - UI - 181
From leavens@cs.uiowa.edu Mon Feb 12 16:03:54 2001MIME-Version: 1.0Date: Mon, 12 Feb 2001 16:04:24 -0600From: &quot;Gary T. Leavens&quot; &lt;leavens@cs.uiowa.edu&gt;Reply-To: leavens@cs.uiowa.eduX-Accept-Language: en,de,frTo: Kevin Lillis &lt;klillis@saunix.sau.edu&gt;
CSU Fullerton - C - 340
10 flagrant grammar mistakes that make you look stupidVersion 1.0 May 23, 2006By Jody Gilbert These days, we tend to communicate via the keyboard as much as we do verbally. Often, we're in a hurry, quickly dashing off e-mails with typos, grammatical sho
Iowa State - COP - 4020
I. Relational Programming (Ch 9) A. Motivation- MOTIVATIONS FOR RELATIONAL PROGRAMMING - 1. programming is difficult, expensive Why is programming so hard? What approaches might solve this problem? What are the steps in building a computer system
Western Washington - BIOL - 345
Bacteria Are Beautifulby Dianne K. NewmanAbove: The widespread use of antibacterial chemicals in common household products could be doing more harm than good (Annals of Internal Medi-cine, 2004, 140, 321329).Below: In contrast to the bacteriophobia of
Iowa State - COP - 4020
COP 4020 Lecture -*- Outline -*-* Relational Programming (Ch 9) Based on Peter van Roy and Seif Haridi's book, &quot;Concepts, Techniques, and Models of Computer Programming&quot; (MIT Press, 2004), where all references that are not otherwise attributed are fo
Iowa State - COP - 4020
COP 4020 Lecture -*- Outline -*-* Message-Passing Concurrency (Ch 5) Based on Peter van Roy and Seif Haridi's book, &quot;Concepts, Techniques, and Models of Computer Programming&quot; (MIT Press, 2004), where all references that are not otherwise attributed a
Iowa State - COP - 4020
COP 4020 Lecture -*- Outline -*-* Declarative Computation Model (Ch 2) Based on Peter van Roy and Seif Haridi's book, &quot;Concepts, Techniques, and Models of Computer Programming&quot; (MIT Press, 2004), where all references that are not otherwise attributed
Iowa State - COP - 4020
COP 4020 Lecture -*- Outline -*-* The Data-Driven Concurrent Model (Ch 4) Based on Peter van Roy and Seif Haridi's book, &quot;Concepts, Techniques, and Models of Computer Programming&quot; (MIT Press, 2004), where all references that are not otherwise attribu
Iowa State - COP - 4020
COP 4020 Lecture -*- Outline -*-* Introduction to Programming Concepts (Chapter 1) Based on Peter van Roy and Seif Haridi's book, &quot;Concepts, Techniques, and Models of Computer Programming&quot; (MIT Press, 2004), where all references that are not otherwis
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 9.4Section 9.4 Connectivity We extent the notion of a path to undirected graphs. An informal definition (see the text for a formal definition): There is a path v0, v1, v
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 9.3Section 9.3 Representing Graphs and Graph Isomorphism We wish to be able to determine when two graphs are identical except perhaps for the labeling of the vertices. W
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 9.2Section 9.2 Graph Terminology and Special Types of Graphs Undirected Graphs Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 7.4Section 7.4 Generating Functions Generating functions are useful for manipulating sequences and therefore for solving counting problems. _ Definition: Let S = cfw_a0,
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 9.1Section 9.1 Graphs and Graph Models Undirected Graphs A simple graph (V,E) consists of vertices, V, and edges, E, connecting distinct elements of V. - no arrows - no
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 7.3Section 7.3 Divide-and-Conquer Algorithms and Recurrence Relations The form: The sequence: cfw_am ,am ,am ,., am ,.0 1 2 kan = an/ m + f (n)_ n = mk for some k. -
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 7.2Section 7.2 Solving Linear Recurrence Relations If ag(n) = f (ag(0) ,ag(1) ,., ag(n1) ) find a closed form or an expression for ag(n). Recall: nth degree polynomials
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSection 7.1Section 7.1 Recurrence Relations Definition: Given a sequence cfw_ag(0) ,ag(1) ,ag(2) ,., a recurrence relation (sometimes called a difference equation) is an equatio
Iowa State - CPRE - 310
Transparencies to accompany Rosen, Discrete Mathematics and Its ApplicationsSections 4.1 &amp; 4.2Section 4.1 - Mathematical Induction and Section 4.2 - Strong Induction and Well-Ordering A very special rule of inference! Definition: A set S is well ordered
Iowa State - CPRE - 588
SpecC Modeling GuidelinesAndreas GerstlauerTechnical Report CECS-02-16 (revision of ICS-TR-00-48) April 12, 2002 Center for Embedded Computer Systems University of California, Irvine Irvine, CA 92697-3425, USA (949) 824-8919 gerstl@cecs.uci.edu http:/ww
Dallas - DXA - 081000
Linux Kernel Internals The File Subsystem- Gerlof Langeveld gerlof@ATComputing.nlNijmegen, The NetherlandsVersion: april 20032Linux Kernel Internals - The File SubsystemPrefaceThis document describes how the Linux-kernel keeps track of the administ
Iowa State - CPRE - 588
k &amp; u twsxpv(h pyVhb&quot;rx mpv1hphwehut)dqseqVVr%purh )th sqrvVi s thhq VDVhrequtpxi @h)v x vx)ssqhsx 1fi x&amp; s x y q s i q rQwsvVhVrhrpfphs pVhb pppr ehieqbhVDv bdvxk)ssqhs1fq utx(ybm1hwut Vh%p 1h)1xVgwvs u 1fx Vxrxx iVhkrq equsi tpxx b Vx1if vVus VruvGVsx
Caltech - CH - 111
Supplemental Material can be found at: http:/www.jbc.org/cgi/content/full/M806668200/DC1 THE JOURNAL OF BIOLOGICAL CHEMISTRY VOL. 283, NO. 49, pp. 34129 34140, December 5, 2008 Printed in the U.S.A.Flexibility of Eukaryotic Okazaki Fragment Maturation th
Stanford - ILPUBS - 621
Adaptive Ordering of Pipelined Stream FiltersShivnath Babu Stanford University Rajeev Motwani Stanford University Kamesh Munagala Stanford UniversityItaru Nishizawa Jennifer Widom Hitachi, Ltd. Stanford University cfw_shivnath,rajeev,kamesh,widom@cs.sta
Lewis-Clark - HW - 106
Homework Assignment 3Perform the following conversions (HINT: use the iside cover of the back of your textbook for the relationships . . .): a.) 45.0 kcal to kJ b.) 1.00 g/cm3 to kg/dm3 c.) 9.81 m/s2 to miles/hr2 d.) 2.9979 x 108 m/s to miles/hr e.) 179
Cornell - WEB - 191
Math 191FINAL EXAMFall 2000SHOW ALL WORK. CIRCLE YOUR ANSWERS. CLOSED BOOK. NO CALCULATORS. 1. (25 pts) Let f (x) = xx = ex ln x , x &gt; 0 (a) Compute lim f (x) if it exists. +x0(b) Locate and identify the critical points of f (x) in x &gt; 0. (c) Find th
Cornell - WEB - 191
Math 191FINAL EXAM SOLUTIONSFall 20001. (a) Using l'Hopital's rule, the limit is 1. (b) The only critical point is x = e-1 . (f (x) = (1 + ln x)ex ln x ) (c) The absolute minimum occurs when x = e-1 where the value is e-1/e . There is no absolute maxim
Purdue - LISTS - 20030304
A10K 1 KFITC10K 1KB10K 1KPE10K 1KPE100A-633100PE100A-6331001 01010101 1 1011 1 10 1001 1 10FITC1001K10K10K10KPE1K10KFITC1001K10K11 010K10KPE1001K10K1 K1K1K1KA-633100A-680100A-633100A-6801001 01010
Oakland University - ME - 463
Table Top
Oakland University - ME - 463
Table Middle Level
Oakland University - ME - 463
Table (Bottom Level)
Oakland University - ME - 463
Table Top Legs
Oakland University - ME - 463
Steel Plate
Oakland University - ME - 463
Spring Cover
Oakland University - ME - 463
Spring Top Washer
Oakland University - ME - 463
Split Lock Washer
Oakland University - ME - 463
Pipe Clamp
Oakland University - ME - 463
Bike Pedal Surface
Oakland University - ME - 463
Bike Pedal Crank
Oakland University - ME - 463
Oakland University - ME - 463
Hex Nut
Oakland University - ME - 463
Hex Lock Nut
Oakland University - ME - 463
- 20 x 2 Hex Cap Screw
Oakland University - ME - 463
- 20 x 1 Hex Cap Screw
Oakland University - ME - 463
- 20 x 1 Hex Cap Screw
Oakland University - ME - 463
- 20 x 3/4 Hex Cap Screw
Oakland University - ME - 463
- 20 x Hex Cap Screw
Oakland University - ME - 463
Glass Clamp
Oakland University - ME - 463
Glass Clamp Rod
Oakland University - ME - 463
Floor Mount
Oakland University - ME - 463
Flat Washer
Oakland University - ME - 463
Fender Washer
Oakland University - ME - 463
Condensing Coil
Oakland University - ME - 463