1 / 30

Optimal Divide & Query

Optimal Divide & Query. Josep Silva. ( Joint work with David Insa). Universidad Politécnica de Valencia. Contents. Introduction. Algorithmic Debugging. Divide & Query. Limitations of Divide & Query. Optimal Divide & Query. Demonstration. DDJ. Conclusions. Contents.

cianna
Télécharger la présentation

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 Josep Silva (Jointworkwith David Insa) Universidad Politécnica de Valencia

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

  3. Contents Introduction AlgorithmicDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  4. AlgorithmicDebugging • TWO PHASES: • Generatetheexecutiontree • Traversetheexecutiontreeaskingquestionsuntilthe bug isfound 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

  5. AlgorithmicDebugging • Traversingtheexecutiontree • GOLDEN 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

  6. AlgorithmicDebugging • Traversingtheexecutiontree • GOLDEN 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

  7. AlgorithmicDebugging • 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

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

  9. Strategies of AlgorithmicDebugging 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 Corrects Hat Delta - Best Division

  10. Strategies of AlgorithmicDebugging

  11. Debuggingsession main = False 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 = []

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

  13. 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 = []

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

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

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

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

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

  19. Contents Introduction AlgorithmicDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

  20. 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’

  21. Equation

  22. Equation 8 6 2 4 1 1 2 1 1

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

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

  25. 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 5 2 12 8 3 4 1 2 5 1 1 2 1 1 1 4 1 1 1

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

  27. Contents Introduction AlgorithmicDebugging Divide & Query Limitations of Divide & Query Optimal Divide & Query Demonstration DDJ Conclusions

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

  29. Conclusions

  30. Optimal Divide & Query Josep Silva TheDeclarativeDebuggerfor Java (DDJ) http://www.dsic.upv.es/~jsilva/DDJ

More Related