Presentation is loading. Please wait.

Presentation is loading. Please wait.

12K... 2 1 (safe) N 2... What is the search plan, with the minimum number of tests in the worst case, for the highest safe rung?

Similar presentations


Presentation on theme: "12K... 2 1 (safe) N 2... What is the search plan, with the minimum number of tests in the worst case, for the highest safe rung?"— Presentation transcript:

1 12K... 2 1 (safe) N 2... What is the search plan, with the minimum number of tests in the worst case, for the highest safe rung?

2 12k... 2 1 n 2 Is there a search plan for the highest safe rung, with q tests in the worst case? HSR(n, k, q) 0 (safe)

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

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

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

6 Linear Search Plan 3 rungs, 3 jars 1? 23 2? 3? 01 yes no q = 3

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

8 Binary Search Plan 7 rungs, ⌈ lg 7 ⌉ = 3 jars 4? 67 6? 7? 45 5? 23 2? 3? 01 1? q = 3 yesno

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

10

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

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

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

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

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

16 Binary Search Plan 8 rungs, lg 8 = 3 jars 5? 78 7? 8? 56 6? 34 3? 4? 12 2? Jar1 break s Jar 2 breaks Jar 3 break s Depth = 3 tests

17

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

19

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

21 Introduction to the Formal Science Wikipedia (FSW)

22 Agenda What is FSW? How to use FSW? How to contribute to FSW?

23 What is FSW?

24 FSWWikipedia Lab (parameterized logical statement) Page (informal text) Develop an AvatarEdit Pages vs. Code the labCreate a page

25 How to use FSW?

26 Investigation Cycle

27 How to contribute to FSW? (as a user)

28 A Toy FSW Lab AxEyIneq(c ∈ [0,2]) : = ∀ x ∈ [0,1]: EyIneq(c, x) EyIneq(c ∈ [0,2], x ∈ [0,1]) : = ∃ y ∈ [0,1]: Ineq(c, x, y) Ineq(c ∈ [0,2], x ∈ [0,1], y ∈ [0,1]) : = x + y > c Given c ∈ [0,2], does every x ∈ [0,1] make EyIneq(c, x) hold? Given c ∈ [0,2] and x ∈ [0,1], is there y ∈ [0,1] that makes Ineq(c, x,y) hold? Given c ∈ [0,2], x ∈ [0,1] and y ∈ [0,1], does x+y > c hold?

29 3 Toy Labs 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? 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?

30 3 Toy Labs Compact 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.

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

32 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); }

33 33 An Avatar for the “Toy” Lab AxEyIneq(c ∈ [0,2]) : = ∀ x ∈ [0,1]: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; } EyIneq: ∃ y ∈ [0,1]:Ineq: x + y > c Best strategy: y as big as possible

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

35 35 An Avatar for the “Toy” Lab /** 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] AxEyIneq(c ∈ [0,2]) : = ∀ x ∈ [0,1]:EyIneq: ∃ y ∈ [0,1]:Ineq: x + y > c ∀ x ∈ [0,1]:EyIneq

36 How Are Avatars Used?

37 37

38 How to contribute to FSW? (as a user)

39 Coding Labs Develop a set of nested Java classes

40 Coding the “Toy” Lab AxEyIneq(c) : = public class AxEyIneq { @Param double c; }

41 Coding the “Toy” Lab AxEyIneq(c) : = ∀ x public class AxEyIneq implements IForall{ @Param double c; double x; }

42 Coding the “Toy” Lab AxEyIneq(c) : = ∀ x :EyIneq: ∃ y public class AxEyIneq implements IForall{ @Param double c; double x; public class EyIneq implements IExists{ double y; }

43 Coding the “Toy” Lab AxEyIneq(c) : = ∀ x :EyIneq: ∃ y : Ineq: x + y > c public class AxEyIneq implements IForall{ @Param double c; double x; public class EyIneq implements IExists{ double y; public class Ineq implements IPred{ public boolean execute() { return x+y>c; }

44 Coding the “Toy” Lab AxEyIneq(c) : = ∀ x ∈ [0,1]:EyIneq: ∃ y : Ineq: x + y > c public class AxEyIneq implements IForall{ @Param double c; double x; public boolean checkecProvidedValue() { return 0<=x && x<=1; } public class EyIneq implements IExists{ double y; public class Ineq implements IPred{ public boolean execute() { return x+y>c; } ∈ [0,1]

45 Coding the “Toy” Lab AxEyIneq(c ∈ [0,2]) : = ∀ x ∈ [0,1]:EyIneq: ∃ y ∈ [0,1]:Ineq: x + y > c public class AxEyIneq implements IForall{ @Param double c; double x; public class EyIneq implements IExists{ double y; public class Ineq implements IPred{ public boolean execute() { return x+y>c; } public boolean checkecProvidedValue() { return 0<=y && y<=1; } public boolean checkecProvidedValue() { return 0<=x && x<=1; } public AxEyIneq(double c) { if( c 3 ){ throw new RuntimeException(); } this.c = c; } ∈ [0,2]


Download ppt "12K... 2 1 (safe) N 2... What is the search plan, with the minimum number of tests in the worst case, for the highest safe rung?"

Similar presentations


Ads by Google