Loop Invariants-Methods of Software Engineering-Lecture Slides, Slides of Software Engineering

This course includes software-- development process, process models, project planning, quality assurance, configuration management, process and project metrics, change, re-engineering, risk analysis and management and project management. This lecture includes: Loop, Invariants, Elements, Incremented, Weakest, Precondition, Condition, Termination, True

Typology: Slides

2011/2012

Uploaded on 08/06/2012

angarika
angarika 🇮🇳

4.4

(56)

90 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Loop Invariants
s = 0;
for i := 1 to n do
s = s + a[i];
What is the ‘loop invariant’?
s is the sum of elements from a[1] to a[i]
immediately before i is incremented!
docsity.com
pf3
pf4

Partial preview of the text

Download Loop Invariants-Methods of Software Engineering-Lecture Slides and more Slides Software Engineering in PDF only on Docsity!

Loop Invariants^ s = 0;for i := 1 to n do

s = s + a[i];

What is the ‘loop invariant’?

s is the sum of elements from a[1] to a[i] immediately before i is incremented!

Weakest Precondition for While

Statement

{P} while B do S {Q}

-^ Let W be while B do S -^ condition for termination of the loopP

 0 (not B) P^1

^ B and wp(S,P

)^0

^ wp(S, not B)

Pk

^ B and wp(S, P

)k-

  • wp(W, true)

wp(W, not B)

(k: k

^

0: P

)k docsity.com

a = 0;i = 0;while (i < N)

a = a + i++; Loop Invariant: a =

^1 N ^0 i

i