1 / 43

Is there a search plan for the highest safe rung, with q tests in the worst case?

2. HSR(n, k, q). Is there a search plan for the highest safe rung, with q tests in the worst case?. 1. 2. k. n. 2. 1. 0 (safe). Search Plan. A search plan is a tree made up of two kinds of nods. x?. yes. no. x. Test node; do jars break when thrown from rung x?.

donnan
Download Presentation

Is there a search plan for the highest safe rung, with q tests in the worst case?

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. 2 HSR(n, k, q) Is there a search plan for the highest safe rung, with q tests in the worst case? 1 2 ... k n ... 2 1 0 (safe)

  2. Search Plan A search plan is a tree made up of two kinds of nods x? yes no x Test node; do jars break when thrown from rung x? Conclusion; x is the highest safe rung

  3. 2 minHSR(n, k, q) Is q the worst case minimum number of tests to be performed by a search plan for the highest safe rung? 1 2 ... k n ... 2 1 0 (safe)

  4. 2 minHSR(n, 1, n) n rungs 1,3,..., n must be sequentially (a.k.a. linearly) tested. ... 2 1 0 (safe)

  5. Linear Search Plan3 rungs, 3 jars 1? no yes 2? 3? q = 3 2 3 0 1

  6. 2 minHSR(n, ⌈lg n⌉, lg n) n binary search is feasible. ... 2 1 0 (safe)

  7. Binary Search Plan7 rungs, ⌈lg 7⌉ = 3 jars 4? yes no q = 3 6? 2? 7? 5? 3? 1? 6 7 4 5 2 3 0 1

  8. 2 minHSR(n, k, q) 1 2 ... k n If 1<k<lg n,what is the search plan with the minimum number of tests? ... 2 1 0 (safe)

  9. 2 1 2 ... K N What is the highest rung a jar can be safely thrown from? ... 2 1 (safe)

  10. 2 N If K=1,rungs 2,3,..., N must be sequentially tested. ... 2 1 (safe)

  11. 2 N If K>lg N,binary search is feasible. ... 2 1 (safe)

  12. 2 N If1<K<lg N,what is the search plan with the minimum number of tests? ... 2 1 (safe)

  13. Search Plan (a.k.a. Decision Tree) A search plan is a tree made up of two kinds of nods x? yes no x Test node; do jars break when thrown from rung x? Conclusion; x is the highest safe rung

  14. Binary Search Plan8 rungs, lg 8 = 3 jars 5? Jar1 breaks Depth = 3 tests 7? 3? Jar 2 breaks 8? 6? 4? 2? Jar 3 breaks 7 8 5 6 3 4 1 2

  15. 2 HSR(n, k, q) HSR(n, k, q) = ∃ p ∈ SearchPlans: correct(p, n, k, q). 1 2 ... k n ... 2 1 (safe)

  16. What is the Formal Science Wikipedia (FSW) and How to Use it and Contribute to it?

  17. Introduction to the Formal Science Wikipedia (FSW)

  18. Agenda • What is FSW? • How to use FSW? • How to contribute to FSW?

  19. What is FSW?

  20. FSW vs. Wikipedia Lab (parameterized logical statement) Page(informal text) Develop an Avatar Edit Pages Code the lab Create a page

  21. How to use FSW?

  22. Investigation Cycle

  23. How to contribute to FSW?(as a user)

  24. 3 Toy Labs AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]: EyIneq(c, x) Given c ∈ [0,2], does every x ∈ [0,1] make EyIneq(c, x) hold? EyIneq(c ∈ [0,2], x ∈ [0,1]) := ∃y ∈ [0,1]: Ineq(c, x, y) Given c ∈ [0,2] and x ∈ [0,1], is there y ∈ [0,1] that makes Ineq(c, x, y) hold? Ineq(c ∈ [0,2], x ∈ [0,1], y ∈ [0,1]) := x + y > c Given c ∈ [0,2], x ∈ [0,1] and y ∈ [0,1], does the inequality x+y > c hold?

  25. 3 Toy LabsCompact Notation AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]:EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c Given c ∈ [0,2], does every x ∈ [0,1] has a y ∈ [0,1] such that x+y>c .

  26. Developing Avatars Implement an interface derived from the logical statement.

  27. An Avatar for the “Toy” Lab interface AxEyIneqAvatar { /** Given c ∈ [0,2] and x ∈ [0,1], which y ∈ [0,1] makes Ineq(c, x, y) hold? */ double move (EyIneq dummy, double c, double x); /** Given c ∈ [0,2], which x ∈ [0,1] makes EyIneq(c, x) NOT hold? */ double move (AxEyIneq dummy, double c); /** Given c ∈ [0,2], do all x ∈ [0,1] make EyIneq(c, x) hold? */ Position position (AxEyIneq dummy, double c); }

  28. An Avatar for the “Toy” Lab AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]:EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c /** Given c ∈ [0,2] and x ∈ [0,1], which y ∈ [0,1] makes Ineq(c, x, y) hold? */ double move (EyIneq dummy, double c, double x){ return 1; } Best strategy: y as big as possible

  29. An Avatar for the “Toy” Lab AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]:EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c ∀x ∈ [0,1]:EyIneq /** Given c ∈ [0,2], which x ∈ [0,1] makes EyIneq(c, x) NOT hold? */ double move (AxEyIneq dummy, double c){ return 0; } Best strategy: x as small as possible

  30. An Avatar for the “Toy” Lab AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]:EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c ∀x ∈ [0,1]:EyIneq /** Given c ∈ [0,2], do all x ∈ [0,1] make EyIneq(c, x) hold? */ Position position (AxEyIneq dummy, double c){ return c<1?Position.VERIFIER:Position.FALSIFIER; } AxEyIneq(c) is true for c ∈ [0,1) and false for c ∈ [1,2]

  31. How Are Avatars Used?

  32. How to contribute to FSW?(as a user)

  33. Coding Labs Develop a set of nested Java classes

  34. Coding the “Toy” Lab AxEyIneq(c) := publicclass AxEyIneq { @Paramdoublec; }

  35. Coding the “Toy” Lab AxEyIneq(c) := ∀x publicclass AxEyIneq implements IForall{ @Paramdoublec; doublex; }

  36. Coding the “Toy” Lab AxEyIneq(c) := ∀x :EyIneq: ∃y publicclass AxEyIneq implements IForall{ @Paramdoublec; doublex; publicclass EyIneq implements IExists{ doubley; } }

  37. Coding the “Toy” Lab AxEyIneq(c) := ∀x :EyIneq: ∃y : Ineq: x + y > c publicclass AxEyIneq implements IForall{ @Paramdoublec; doublex; publicclass EyIneq implements IExists{ doubley; publicclass Ineq implements IPred{ publicboolean execute() { returnx+y>c; } } } }

  38. Coding the “Toy” Lab AxEyIneq(c) := ∀x ∈ [0,1]:EyIneq: ∃y : Ineq: x + y > c ∈ [0,1] publicclass AxEyIneq implements IForall{ @Paramdoublec; doublex; publicboolean checkecProvidedValue() { return 0<=x && x<=1; } publicclass EyIneq implements IExists{ doubley; publicclass Ineq implements IPred{ publicboolean execute() { returnx+y>c; } } } }

  39. Coding the “Toy” Lab AxEyIneq(c ∈ [0,2]) := ∀x ∈ [0,1]:EyIneq: ∃y ∈ [0,1]:Ineq: x + y > c ∈ [0,2] publicclass AxEyIneq implements IForall{ @Paramdoublec; doublex; publicclass EyIneq implements IExists{ doubley; publicclass Ineq implements IPred{ publicboolean execute() { returnx+y>c; } } publicboolean checkecProvidedValue() { return 0<=y && y<=1; } } publicboolean checkecProvidedValue() { return 0<=x && x<=1; } public AxEyIneq(double c) { if( c<0 || c>3 ){ thrownew RuntimeException(); } this.c = c; } }

More Related