We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byJalynn Groft
Modified about 1 year ago
© 2003, Yishai Feldman Proving Sufficient Completeness Example: Set ADT
© 2003, Yishai Feldman The Set ADT: Types and Functions TYPES SET[G] FUNCTIONS u emptyset : SET[G] u has : SET[G] G BOOLEAN u count : SET[G] INTEGER u empty : SET[G] BOOLEAN u extend : SET[G] G SET[G] u prune : SET[G] G SET[G] u intersect : SET[G] SET[G] SET[G] u merge : SET[G] SET[G] SET[G]
© 2003, Yishai Feldman The Set ADT: Axioms, Part 1 AXIOMS A1 empty (s) count (s) = 0 A2 count (emptyset) = 0 A3 not has (emptyset, x) A4 has (s, x) extend (s, x) = s A5 not has (s, x) count (extend (s, x)) = count (s) + 1 A6 has (extend (s, x), y) has (s, y) or x = y A7 not has (s, x) prune (s, x) = s A8 has (s, x) count (prune (s, x)) = count (s) – 1 A9 has (prune (s, x), y) has (s, y) and x y A10 has (merge(s, t), x) has (s, x) or has (t, x) A11 has (intersect (s, t), x) has (s, x) and has (t, x)
© 2003, Yishai Feldman Proof Summary emptysetextendpruneintersectmerge hasA3A6A9A10A11 countA2A4, A5A7, A8—— emptyA1
© 2003, Yishai Feldman Sufficient Completeness Part I: Correctness Since there are no preconditions, every well- formed expression is correct.
© 2003, Yishai Feldman Sufficient Completeness Part II: Compute Values The axioms in Part 1 are sufficiently complete for for has queries with all set expressions, and for empty and count queries with set expressions that do not contain intersect and merge. Any query expression must have the form q(e), where q is one of the query functions, and e is a set- valued expression. We will treat each query function separately, and will prove the claim by induction on the structure of the set-expression e. The induction measure is the size of the expression, that is, the number of function symbols in it.
© 2003, Yishai Feldman Induction Scheme The base case is e = emptyset. In the inductive case, e can be one of the following expressions: u extend (s, x), u prune (s, x), u merge (s, t), or u intersect (s, t). Because of the restrictions in the claim of sufficient completeness, we can ignore the last two cases except when q = has.
© 2003, Yishai Feldman Case 1: q = has(e, y) e = emptyset. In this case, the expression is has (emptyset, y). By A3 we know that not has (emptyset, y) is true, so that has (emptyset, y) is false. e = extend (s, x). By A6 we can reduce the expression has (e, y) to has (s, y) or x = y, which is computable by induction since s is a smaller expression than e. e = prune (s, x). This is similar to the previous case, using A9. e = merge (s, t). Use A10 to reduce the given expression to has (s, y) or has (t, y). Both s and t are smaller than e, and therefore both queries are computable by induction. e = intersect (s, t). This is similar to the previous case, using A11.
© 2003, Yishai Feldman Case 2: q = count(e) e = emptyset. By A2 we know that count (emptyset) = 0. e = extend (s, x). By the previous case, we can compute the value of has (s, x). If it is true, we can use A4 to show that e = extend (s, x) = s, and therefore the expression count (e) reduces to count (s), which is computable by induction. If has (s, x) is false, we can use A5 to reduce the expression count (e) to count (s) + 1, which is again computable by induction. e = prune (s, x). Again, we know the value of has (s, x). If it is true, we can use A8 to reduce the expression count (e) to count (s) – 1, which is computable by induction. If it is false, we can use A7 to show that e = prune (s, x) = s, and therefore the expression count (e) reduces to count (s), which is again computable by induction.
© 2003, Yishai Feldman Case 3: q = empty(e) By the previous case, we can always compute the value of count (e). We can then use A1 to compute the value of empty (e).
© 2003, Yishai Feldman The Set ADT: Axioms, Part 2 A12 merge (extend (s, x), t) = extend (merge (s, t), x) A13 has (t, x) merge (prune (s, x), t) = merge (s, t) A14 not has (t, x) merge (prune (s, x), t) = prune (merge (s, t), x) A15 not has (t, x) intersect (extend (s, x), t) = intersect (s, t) A16 has (t, x) intersect (extend (s, x), t) = extend (intersect (s, t), x) A17 intersect (prune (s, x), t) = prune (intersect (s, t), x) A18 merge (emptyset, s) = s A19 intersect (emptyset, s) = emptyset
© 2003, Yishai Feldman Sufficient Completeness, Part 2 We can now complete the proof of sufficient completeness for the remaining cases: count and empty queries for set-expressions containing merge and intersect. The proof will show that it is possible to reduce any set expression containing merge and intersect to one that does not contain them, using Part 2 of the axioms. Intuitive idea: axioms A12-A17 “push down” occurrences of merge and intersect into their first arguments to the innermost parts of the expression, where axioms A18-A19 eliminate them.
© 2003, Yishai Feldman Induction Scheme The induction measure m(e) is defined for a set- expression e as follows: u The weight of a function call in e is: 0, if the function is extend, prune, or emptyset; size (s), if the function is merge (s, t) or intersect (s, t); u m(e) is the sum of the weights of all function calls in e. It is easy to see that m(e) 0.
© 2003, Yishai Feldman Base Case If m(e) = 0, the expression e does not contain merge or intersect, and the claim is trivially true.
© 2003, Yishai Feldman Inductive Case (1) Suppose m(e) > 0. Let f (s, t) be the innermost occurrence of merge or intersect in e. If s = emptyset, use axiom A18 or A19 to reduce this expression to t or emptyset. All non-zero weights of function calls in e necessarily decrease, and one has been completely eliminated. Therefore the expression e is equal to another expression of smaller weight, and the claim is true by the induction hypothesis.
© 2003, Yishai Feldman Inductive Case (2) If s is not emptyset, it can only be a call to extend or prune. One of the axioms A12-A17 can be used to reduce e to an equal expression of smaller weight. (By the previous part of the proof we can compute the values of all has expressions.) The claim now follows from the induction hypothesis.
With examples from Number Theory (Rosen 1.5, 3.1, sections on methods of proving theorems and fallacies)
Mathematical Induction Rosen 3.3. Basics The Well-Ordering Property - Every nonempty set of nonnegative integers has a least element. Many theorems state.
Solving Quadratic Equations Using the Zero Product Property.
Mathematical Induction. Mathematical Induction is a technique for proving theorems Theorems are typically of the form P(n) is true for all positive integers.
Of. and a to the in is you that it at be.
5.3 Inverse Function. After this lesson, you should be able to: Verify that one function is the inverse function of another function. Determine whether.
Types and Programming Languages Lecture 4 Simon Gay Department of Computing Science University of Glasgow 2006/07.
CHAPTER 7 Functions Functions Reading: Epp Chp 7.1, 7.2, 7.4.
Page 20 Why [0/0] and [ – ] Are Indeterminate Forms Whereas k/0 Isnt? [0/0] is an indeterminate form because a limit of this form is unpredictable. If.
The. of and a to in is you that it he was.
Analysis of Algorithms II The Recursive Case Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
The. of and a to in is you that it he for.
High Frequency Words List A Group 1. the of and.
2.3 Continuity When you plot function values generated in a laboratory or collected in a field, you can connect the plotted points with an unbroken curve.
Roots & Zeros of Polynomials How the roots, solutions, zeros, x-intercepts and factors of a polynomial function are related. 2.5 Zeros of Polynomial Functions.
Using First Derivatives to Find Maximum and Minimum Values and Sketch Graphs OBJECTIVES Find relative extrema of a continuous function using the First-Derivative.
1 Register Allocation Consists of two parts: register allocation What will be stored in registers Only unambiguous values register assignment Which register.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
The Rational Zero Theorem. The Rational Zero Theorem gives a list of possible rational zeros of a polynomial function. Equivalently, the theorem gives.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
CS 336 March 19, 2012 Tandy Warnow. Basic Graph Terminology Nodes, vertices, edges, degrees, paths, cycles, connected components, adjacency, isolated.
Set and Set Operations Section 2.1. Introduction A set is a collection of objects. The objects in a set are called elements of the set. A well – defined.
Ch 3.2: Solutions of Linear Homogeneous Equations; Wronskian Let p, q be continuous functions on an interval I = ( , ), which could be infinite. For.
1.4 Inverses; Rules of Matrix Arithmetic. Properties of Matrix Operations For real numbers a and b,we always have ab=ba, which is called the commutative.
Lecture 1Discrete Structures 1 1 u Introduction to sets and set notation (5.1, 5.3) u Visualizing sets: Venn diagrams (5.1) u Axiom of extension (5.1)
Introduction to Proofs A proof is a valid argument that establishes the truth of a statement. Previous section discussed formal proofs Informal proofs.
110/6/2014CSE Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and Analysis of Algorithms.
Warm Up Complete the conjecture by looking for a pattern in the diagram below. The number of sides of a polygon that has n vertices is________________.
Divide-and-Conquer CIS 606 Spring Analyzing Divide-and-Conquer Algorithms Use a recurrence to characterize the running time of a divide-and-conquer.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 17 part 1 By Herbert I. Gross and Richard A. Medeiros next.
© 2016 SlidePlayer.com Inc. All rights reserved.