Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

27
Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili

Transcript of Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Page 1: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair

Nafi DialloComputer Science

NJITAdvisor: Dr. Ali Mili

Page 2: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 2

Outline

1. Introduction

2. Progress

3. Prospects

4. Conclusion

• Introduction• Research Progress• Proposed work• Conclusion

Page 3: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 3

Loop Analysis and Repair

• Loop Analysis – Convergence• Termination + Absence of Abort

– Correctness/Incorrectness

• Loop Repair– Diagnose/Remove Faults– Verification

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 4: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 4

Definition

• We consider a while loop w of the form :

• denotes the state space of and • represent the function of the loop:

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 5: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 5

Definition

• T is the relational vector defined by:

• The loop semantics is defined by means of the reflexive transitive closure of ∩ :𝑇 𝐵

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 6: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 6

Invariant Relation

Interpretation:– pairs of states (s,s') that are separated by an arbitrary

number of iterations

• Example:𝐰𝐡𝐢𝐥𝐞( ! = ){ = + ; = ;}𝐤 𝐧 𝐤 𝐤 𝟏 𝐟 𝐟∗ 𝐤

• An invariant relation is :

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 7: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 7

Invariant Relations and Invariant Assertions

• All invariant assertions stem from invariant relations

• Only a subset of invariant relations can be derived from invariant assertions

Invariant Relation

Invariant Assertion

Inductive Invariant Relation

Invariant Assertion

1. Introduction

2. Progress

3. Prospects

4. Conclusion• R is an invariant relation• is a vectorν• A is an invariant assertion

Page 8: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 8

Convergence: Integrating Abort freedom with Termination

• A general framework for Convergence

Theorem 1We consider a while loop w of the form on space S, and we let R be an invariant relation for w. Then:

• Capturing aspects of abort freedom

Theorem 2 We consider a while loop w of the form w: while (t) {b} on space , and we let B′ be a superset of If B′ satisfies the following conditions:

– – The following relation is transitive, for an arbitrary vector V . – ( condition of concordance)

then is an invariant relation for w.

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 9: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 9

Abort-Freedom Invariant Relations

• Logical form of Theorem 2

Applications:• Array out of bounds• Illegal arithmetic operations• Arithmetic overflow• Illegal Pointer reference

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 10: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 10

Termination: Example

• Abort condition: Illegal arithmetic operation

• Termination condition

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 11: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 11

Termination: Example

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 12: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 12

Correctness/Incorrectness

• A necessary condition of correctnessProposition: Let w be a while loop of the form that terminates for all states in S. Let R be an invariant relation for w, and let V be a specification on S. If w is correct with respect to V then .

– Interpretation: Incorrect if the invariant relation is incompatible with the specification

• A sufficient condition of correctnessProposition: Given a while loop w of the form that terminates for all states in its space , and given a specification on , if an invariant relation R of w satisfies the condition then w is correct with respect to U.

– Interpretation: Correct only if the invariant relation subsumes the specification.

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 13: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 13

Algorithm for Verifying Loop Correctness

13

S = S and Termination(w) [CumR = L]

More-inv-relation(w)?

yes

R=get-inv-relation(w)

Loop w, Space S, Specification spec

Necessary(R,spec) ?

Correct OR Incorrect OR Undecided

INPUT

OUTPUT

No

No

yes

[CumR=CumR∩R]sufficient(CumR,spec) ?

yes

No

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 14: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 14

Relative Correctness

Definition 1Given • a specification R and • a program Pdefines the competence domain of P and denotes the set of states on which obeys .𝑷 𝑹

Definition 2Given • a specification R and • two programs P and P’, deterministic

’ 𝑷 more-correct than with respect to :𝑷 𝑹• ’ 𝑷 has a larger competence domain than .𝑷

Denoted:

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 15: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 15

Relative Correctness

𝒅𝒐𝒎 (𝑹∩𝑷 )= {1,2,3,4 }× 𝐿

𝒅𝒐𝒎 (𝑹∩𝑷 ′ )={1,2,3,4,5 }× 𝐿Therefore

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 16: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 16

Impact of Relative Correctness on Testing

• Impact on Test Data Generation:• vs.

• Impact on Oracle Design:– • : oracle for absolute correctness.• : oracle for relative correctness.

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 17: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 17

Absolute Correctness and Relative Correctness

(Absolute) Correctness

Relative Correctness

Culminates

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 18: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 18

A Formal Definition of fault

Definition 1A feature in a program P is a statement, condition, formula, or combination thereof

Definition 2Given • Specification , Program , feature in :

– A feature is said to be a fault in if and only if there exists a substitute of that would make more-correct.

– A pair of features is said to be a (monotonic) fault removal of if and only if program obtained from by substituting for is more-correct than .

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 19: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 19

Loop Repair

• Mutation Testing consists of :– Generating Mutants– Testing Mutants against some sample test data

• Selecting mutants that pass• Rejecting mutants that fail

– We argue• Selecting mutants that pass is wrong: a mutant may pass the test but

still not be more-correct.• Rejecting mutants that fail is also wrong: a mutant may fail and still be

more-correct.

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 20: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 20

Proving Relative Correctness

• Traditionally: – static verification techniques applicable only to

correct programs;– dynamic testing techniques used to expose/ diagnose

faults in incorrect programs.

• Using relative correctness: – We remove a fault from a program, check a set of

conditions statically and locally, and conclude that the new program is more-correct than the old, all• Without testing (and its attending uncertainties),• Without remorse (final determination: no going back to

question wisdom of fault removal).

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 21: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 21

A Framework for Monotonic Fault Removal

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 22: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 22

Proving Relative Correctness

1. Introduction

2. Progress

3. Prospects

4. Conclusion

TheoremLet R be a specification on space and let be a while loop of the form which terminates for all . Let be an invariant relation of that is incompatible with and let be the largest invariant relation of such that Let be the while loop that has as an invariant relation , terminates for all and admits an invariant relation that is compatible with And satisfies the condition Then is strictly more correct that

Page 23: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 23

Illustration

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Specification

Invariant Relations

Page 24: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 24

Illustration

1. Introduction

2. Progress

3. Prospects

4. Conclusion

• Compute constraints

• Pick , thus consider to be involved in fault

• Working by elimination, we choose mutant 2. • Testing for absolute correctness fails but testing for relative

correctness succeeds

• We repeat the process and end up with one incompatible invariant relation

• Compute constraints and remove 2nd fault

Page 25: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 25

Deployment

• FxLoop Analyzer (C++ based)

• Client-server application• Thin client• Server(HTTP) has 2 components

– CCA compiler– Invariant relation generator using semantic matching

• Databases of recognizers based on application domain

• Computing termination condition– Traditional sense– In combination with Abort-freedom

• Correctness verification

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 26: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 26

Analytical Research

• To further explore the implications and applications of relative correctness,

• To derive techniques for proving relative correctness by static analysis of the source code.

1. Introduction

2. Progress

3. Prospects

4. Conclusion

Page 27: Loop Analysis and Repair Nafi Diallo Computer Science NJIT Advisor: Dr. Ali Mili.

Loop Analysis and Repair- RAMICS 2015 27

Thank you!