# 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.

3 Pages

### loops

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

Word Count: 638

#### Document Preview

developing I. 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 {P} do B -&gt; S od {P /\ !B} &lt;== {P /\ B} S {P} (Invariance) /\ {P /\ B /\ t==T} S {t&lt;T} (Progress) /\ P /\ t&lt;=0 ==&gt; !B (Boundedness)...

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.
developing I. 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 {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) ---------------------- 1. invariant choice and initialization --------------------------------------------------------- STEPS IN DEVELOPMENT OF LOOP 0. choose invariant P and guard B so that P /\ !B ==> R 1. Develop S0 to establish P, i.e. find S0 so that {Q} S0 {P} --------------------------- C. the loop body what would you choose for t if P is 0 <= i and B is i > 1? -------------------- FINISHING STEPS 2. choose bound function, t, such that P /\ (t <= 0) ==> !B 3. develop loop body S to satisfy a. invariance {P /\ B} S {P} b. progress {P /\ B /\ t == T} S {t < T} -------------------- 1. summary ----------------- ANNOTATED FORM OF TYPICAL LOOP {PROOF} {Q} S0 {invariant P, bound t} ; do B -> {P /\ B /\ t = T} S {P /\ t < T} od {P /\ t <= 0, hence P /\ !B, hence R} --------------------------------------------------------- D. remarks II. developing loops (Cohen's chapters 9-10) A. heuristic 1: deleting a conjunct (chapter 9) ------------- HEURISTIC 1 FOR CHOOSING INVARIANT (deleting a conjunct): if postcondition R is a conjunction, then delete the most difficult to truthify. (what's most difficult?): conjunct that gives enough info for solution (i.e, part of answer) -------------- 1. integer division example (9.1) ---------------- EXAMPLE (INTEGER DIVISION) var x,y: int {Q: 0<=x /\ 0<y} ; var q,r:int ; q,r: (R:0<=r /\ r<y /\ q*y+r == x) ----------------- a. choose invariant ----------------- 0. choose invariant and guard invariant, P: 0<=r /\ q*y+r == x guard: r>=y, ------------------ b. establish invariant ---------------- 1. establish invariant {Q: 0<=x /\ 0<y} q,r := 0,x {P} ----------------- check that wp.(q,r := 0,x).P <== Q? c. choose bound function ------------------ 2. choose bound function let bound function be r ------------------ d. develop loop body --------------- 3. develop loop body solve for K>0 and E in {P /\ (r>=y)} := r,q r-K,E {P} --------------- why does boundness hold? 2. linear search example (9.2) ---------------- EXAMPLE (LINEAR SEARCH) var x: int {0 <= X /\ f.X} ; x: (R: 0 <= x /\ f.x /\ (\forall i : 0 <= i /\ i < x : !f.x)) ----------------- can you develop this? What are the steps? 3. avoid avoidable case analysis (9.3) (omit) 4. postpone design decisions (9.4) (omit) B. replacing constants by fresh variables (chapter 10) ------------------- HEURISTIC 2 FOR CHOOSING INVARIANT (replace constants by fresh variables): If the postcondition has the form x == f.N, then rewrite it as x == f.n /\ n == N and choose invariant: x == f.n guard: !(n == N) (constrain fresh vars to ensure defined): If f is partial, and defined on (i:0<=i<M) then choose invariant: x == f.n /\ (0<=n<M) guard: !(n == N) ---------------------- --------------------------------------------------------- EXAMPLE (10.2) THE MINIMUM VALUE var b: array of int {#b > 0} ; var x: int ; x : (R: x == (\min i : 0 <= i /\ i < #b : b.i)) where \min is not allowed in the program. --------------------------------------------------------- what constant can you eliminate? What constraints are needed? 1. accumulators (10.2, 10.4, 10.5) --------------------------------------------------------- ACCUMULATORS Assume P0: x == (\min i : 0 <= i /\ i < n : b.i), ...

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
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
Hex Washer Head Screw
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
Oakland University - ME - 463