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 over 2 years 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.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Specifying an ADT Give function specification. Identify partial functions A function which cannot be applied on all of its possible parameters Categorize.
Reading and Writing Mathematical Proofs
1 Intro to Induction Supplementary Notes Prepared by Raymond Wong Presented by Raymond Wong.
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
Mathematical Induction I Lecture 4: Sep 16. This Lecture Last time we have discussed different proof techniques. This time we will focus on probably the.
Review for CS1050. Review Questions Without using truth tables, prove that (p q) q is a tautology. Prove that the sum of an even integer and an.
Mathematical induction Isaac Fung. Announcement ► Homework 1 released ► Due on 6 Oct 2008 (in class)
Mathematical Induction II Lecture 21 Section 4.3 Mon, Feb 27, 2006.
Mathematical Induction I Lecture 19 Section 4.2 Mon, Feb 14, 2005.
Section 3.3 Proving set properties. Element-wise set proofs Claim. For all sets A and B, (A B) A. Proof. Let sets A and B be given. Since every element.
Section 2.3 Mathematical Induction. First Example Investigate the sum of the first n positive odd integers. 1= ____ 1 + 3= ____ = ____
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Mathematical Induction I Lecture 5: Sep 20 (chapter of the textbook and chapter of the course notes)
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
PROOF BY CONTRADICTION
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
March 3, 2015Applied Discrete Mathematics Week 5: Mathematical Reasoning 1Arguments Just like a rule of inference, an argument consists of one or more.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
(CSC 102) Discrete Structures Lecture 14.
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
Possible World Semantics for Modal Logic
Basic properties of the integers
5-5 Indirect Proof. Indirect Reasoning: all possibilities are considered and then all but one are proved false. The remaining possibility must be true.
CS104:Discrete Structures Chapter 2: Proof Techniques.
So far we have learned about:
(CSC 102) Lecture 23 Discrete Structures. Previous Lecture Summery Sequences Alternating Sequence Summation Notation Product Notation Properties.
© M. Winter COSC 4P41 – Functional Programming Testing vs Proving Testing –uses a set of “typical” examples, –symbolic testing, –may find errors,
Proving the Correctness of Algorithms Algorithm Design and Analysis Week 2
Copyright © Curt Hill Quantifiers. Copyright © Curt Hill Introduction What we have seen is called propositional logic It includes.
Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach a particular.
Methods of Proof Lecture 3: Sep 9. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical.
1 Conjunctions of Queries. 2 Conjunctive Queries A conjunctive query is a single Datalog rule with only non-negated atoms in the body. (Note: No negated.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 3 The Foundations: Logic and Proof,
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
Word : Let F be a field then the expression of the form a 1, a 2, …, a n where a i F i is called a word of length n over the field F. We denote the.
Copyright © 2007 Pearson Education, Inc. Slide 8-1.
Making an Argument The goal of communication is to achieve the desired affect on the target audience. Often we want to convince the audience of something.
Defining Liveness by Bowen Alpern and Fred B. Schneider Presented by Joe Melnyk.
CSI 3125, Axiomatic Semantics, page 1 Axiomatic semantics The assignment statement Statement composition The "if-then-else" statement The "while" statement.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Program Proving Notes Ellen L. Walker.
Extensible Networking Platform CSE 240 – Logic and Discrete Mathematics Review: Mathematical Induction Use induction to prove that the sum of the.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Predicate Logic One step stronger than propositional logic Copyright © Curt Hill.
Can a and b both be whole numbers? similar triangles so.
Discrete Mathematics Chapter 1 Logic and proofs. Logic Logic = the study of correct reasoning Use of logic In mathematics: to prove theorems In.
© 2017 SlidePlayer.com Inc. All rights reserved.