1 / 26

Optimal Divide & Query

Exploring strategies of declarative debugging and the limitations of divide & query approach in software debugging.

Download Presentation

Optimal Divide & Query

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Optimal Divide & Query David Insa Cabrera

  2. Contents Introduction DeclarativeDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  3. DeclarativeDebugging • DeclarativeDebugging[Shapiro 82]Logicparadigm • TWO PHASES: • Generatetheexecutiontree • Traversetheexecutiontreeaskingquestionsuntilitfindsthe bug If a symptom of an error isdetected thenthe AD willfindthe bug main = 4 WhatisanExecutionTree? listSum [1,2] = 4 Example: main = listSum [1,2] listSum [] = 1 listSum (x:xs) = x + (listSumxs) 1+3 = 4 listSum [2] = 3 2+1 = 3 listSum [] = 1

  4. DeclarativeDebugging • Traversingtheexecutiontree • GOLD RULE:When a wrongnode has notanywrongchildrenthen • thisnodeis a buggynode. main = 4 listSum [1,2] = 4 Example: main = listSum [1,2] listSum [] = 1 listSum (x:xs) = x + (listSumxs) 1+3 = 4 listSum [2] = 3 2+1 = 3 listSum [] = 1

  5. DeclarativeDebugging • Traversingtheexecutiontree • GOLD RULE:When a wrongnode has notanywrongchildrenthen • thisnodeis a buggynode. main = 5 listSum [1,2] = 5 Example: main = listSum [1,2] listSum [] = 0 listSum (x:xs) = x + (listSumxs) + 1 1+3+1 = 5 listSum [2] = 3 2+0+1 = 3 listSum [] = 0

  6. DeclarativeDebugging • do • node = selectNode(T) • answer = askNode(node) • if (answer = NO) • then M(node) = Wrong • buggyNode = node • N = {n ∈ N | (node n) ∈ E*} • elseN = N \ {n ∈N | (noden) ∈E*} • while (∃n ∈N, M(n) = Undefined) • returnbuggyNode

  7. Contents Introduction DeclarativeDebugging • Strategies of AD Divide & Query • Debuggingsession Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  8. Strategies of DeclarativeDebugging Strategies Single Stepping Single Stepping Divide & Query Top Down Top Down - Left to Right Top Down - Heaviest First Top Down - More Rules First Divide & Query (by Shapiro) Divide & Query (by Hirunkitti) Divide by Rules & Query Hat Delta Hat Delta - More Wrongs Hat Delta - Less Rights Hat Delta - Best Division

  9. Debuggingsession Debuggingsession main = sqrTest[1,2] sqrTestx = test (squares (listSumx)) test (x,y,z) = (x==y) && (y==z) listSum[] = 0 listSum(x:xs) = x + (listSumxs) squares x = ((square1 x),(square2 x),(square3 x)) square1 x = square x square x = x*x square2 x = listSum(list x x) list x y | y==0 = [] | otherwise = x:list x (y-1) square3 x = listSum(partialSumsx) partialSumsx = [(sum1 x),(sum2 x)] sum1 x = div (x * (incr x)) 2 sum2 x = div (x + (decr x)) 2 incr x = x + 1 decr x = x - 1

  10. Debuggingsession DebuggingsessionusingDivide & Query(byHirunkitti). main = False Startingthedebuggingsession… square2 3 = 9? YES square3 3 = 8? NO partialSums 3 = [6,2]? NO sum1 3 = 6? YES sum2 3 = 2? NO decr 3 = 2? YES Bug found in rule: sum2 x = div (x + (decr x)) 2 sqrTest [1,2] = False test (9,9,8) = False squares 3 = (9,9,8) listSum [1,2] = 3 listSum [2] = 2 squares1 3 = 9 squares2 3 = 9 squares3 3 = 8 listSum [] = 0 square 3 = 9 listSum [3,3,3] = 9 list 3 3 = [3,3,3] partialSums 3 = [6,2] listSum [6,2] = 8 listSum [3,3] = 6 list 3 2 = [3,3] listSum [2] = 2 sum1 3 = 6 sum2 3 = 2 decr 3 = 2 listSum [3] = 3 list 3 1 = [3] listSum [] = 0 incr 3 = 4 listSum [] = 0 list 3 0 = []

  11. Contents Introduction DeclarativeDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  12. Counterexample 1 3 2 8 1 3 3 3 3 3 2 5 1 1 1 1 1 2 2 2 2 2 2 4 1 1 1 1 1 1 2 1 1 1 1 1 1 9 8

  13. Counterexample 2 3 2 5 5 3 2 4 4 3 3 2 1 2 1 2 3 3 3 1 1 2 3 16 16

  14. Limitations 6 6,5 6 6,5 3 2 3,5 2 3 2 3,5 2 1 1 1 1 2 2,5 2 2,5 1 1 1 1

  15. Contents Introduction DeclarativeDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  16. Up and Down Up(n’) = Down(n’) |un’ – dn’| < |un’’- dn’’| 8 6 2 x/2 * x/2 4 1 1 0 * x d u 0 x x/2 2 1 1 Equation 1: wn = Up(n’) + Down(n’) + win’ Equation 2: wn’ = Down(n’) + win’

  17. Equation

  18. Equation 8 6 2 4 1 1 2 1 1

  19. Path 7 7 7 7 5 2 5 2 5 2 5 2 1 1 1 1 4 4 4 4 3 3 3 3 1 1 1 1 1 1 1 1 Case 2 Case 4 Case 1 Case 3

  20. Algorithm Candidate = root do Best = Candidate Children = {m | (Best→m) ∈E} if (Children =∅) thenreturn Best Candidate = n‘ | ∀n’’ with n’, n’’ ∈ Children, wn’ ≥ wn’’ while (wCandidate > wroot/2) if (M(Best) = Wrong) thenreturnCandidate if(wroot ≥ wBest + wCandidate – wiroot) thenreturnBest elsereturnCandidate

  21. Algorithm Candidate = root do Best = Candidate Children = {m | (Best→m) ∈E} if (Children =∅) thenreturn Best Candidate = n‘ | ∀n’’ with n’, n’’ ∈ Children, wn’ ≥ wn’’ while (wCandidate > wroot/2) if (M(Best) = Wrong) thenreturnCandidate if(wroot ≥ wBest + wCandidate – wiroot) thenreturnBest elsereturnCandidate 20 8 5 2 12 1 3 11 12 8 3 4 1 1 5 7 2 5 1 1 2 1 1 1 4 1 1 1

  22. General Algorithm Candidate = root do Best = Candidate Children = {m | (Best→m) ∈E} if (Children =∅) thenreturn Best Candidate = n′ |∀n′′ withn′ , n′′ ∈Children, wn’ ≥ wn′′ while (wCandidate− wiCandidate/2 > wroot/2) Candidate = n‘ ∈ Children | ∀n’’ ∈ Children, wn′ − win′/2 ≥ wn′′ − win′′/2 if (M(Best) = Wrong) thenreturnCandidate if (wroot ≥ wBest + wCandidate – wiBest/2 – wiCandidate/2) thenreturnBest elsereturnCandidate

  23. Contents Introduction DeclarativeDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  24. Contents Introduction DeclarativeDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  25. Conclusions WehaveadaptedDivide & Querytothree new situations Rootmarked as Undefined Variable individual weights 6 6,5 6 6,5 Analgorithmforeachkind of tree Completeness 3 2 3,5 2 3 2 3,5 2 1 1 1 1 2 2,5 2 2,5 1 1 1 1

  26. Conclusions

More Related