Discovering Counterexamples (and Proof Ingredients) for Knuth-like k-principles

Size: px
Start display at page:

Download "Discovering Counterexamples (and Proof Ingredients) for Knuth-like k-principles"

Transcription

1 Discovering Counterexamples (and Proof Ingredients) for Knuth-like k-principles Moritz Fürneisen and Janis Voigtländer University of Bonn October 9th, 2012

2 Knuth s 0-1-Principle [Knuth 1973] Informally: If a comparison-swap algorithm sorts Booleans correctly, it sorts integers correctly as well. Formally: Let (in Haskell, say): sort :: ((α, α) (α, α)) [α] [α] f :: (Int, Int) (Int, Int) f (x, y) = if x > y then (y, x) else (x, y) g :: (Bool, Bool) (Bool, Bool) g (x, y) = (x && y, x y) If for every xs :: [Bool], sort g xs gives the correct result, then for every xs :: [Int], sort f xs gives the correct result. 1

3 Parallel Prefix Computation Given: inputs x 1,..., x n and an associative operation Task: compute the values x 1, x 1 x 2,..., x 1 x 2 x n Solution: x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 2

4 Parallel Prefix Computation Alternative: x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 Or: x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 Or:... 3

5 Expressing Parallel Prefix Algorithms in Haskell Functions of type: scanl1 :: (α α α) [α] [α] For example, à la [Sklansky 1960]: sklansky :: (α α α) [α] [α] sklansky () [x] = [x] sklansky () xs = us ++ vs where t = ((length xs) + 1) div 2 (ys, zs) = splitat t xs us = sklansky () ys vs = [(last us) v v sklansky () zs] 4

6 Investigating Particular Instances Only Knuth s 0-1-Principle If a comparison-swap algorithm sorts correctly on the Booleans, it does so on arbitrary totally ordered value sets. A Knuth-like 0-1-Principle? If a parallel prefix algorithm is correct (for associative operations) on the Booleans, it is so on arbitrary value sets. Unfortunately not! 8

7 A Knuth-like Principle [V. 2008] Given: scanl1 :: (α α α) [α] [α] scanl1 () (x : xs) = go x xs where go x [ ] = [x] go x (y : ys) = x : (go (x y) ys) candidate :: (α α α) [α] [α] data Three = Zero One Two Theorem: If for every xs :: [Three] and associative () :: Three Three Three, candidate () xs = scanl1 () xs, then the same holds for every type τ, xs :: [τ], and associative () :: τ τ τ. 9

8 Why 0-1-2? And How? To get going, proof uses parametricity [Reynolds 1983], deriving a free theorem [Wadler 1989]. Proof crucially involves two specific associative functions: 1 Zero One Two Zero Zero One Two One One Two Two Two Two Two Two and 2 Zero One Two Zero Zero One Two One One One Two Two Two One Two and their behavior on lists [(Zero, ) One (, Zero) (, Two) ] and [(Zero, ) One, Two (, Zero) ], respectively. Formalisation available in Isabelle/HOL [Böhme 2007]. But: Does that really explain the why and how? What to do to get similar results for other algorithm classes? 10

9 Plan of the Talk Start telling the story of how 0-1-2, 1, 2,... were found (back in 2007, never recorded, but interesting I think). Challenge you to suggest other approaches to discover the required counterexamples and proof ingredients? Invite complaints about where the presented (deliberately naive, exploratory) approach is too ad-hoc, or unacceptably pulls a rabbit out of a hat. Provoke investigation/proposals of other algorithm classes on which one could try to play the same or similar trick(s)? 11

10 Investigating Particular Instances Only Knuth s 0-1-Principle If a comparison-swap algorithm sorts correctly on the Booleans, it does so on arbitrary totally ordered value sets. A Knuth-like 0-1-Principle? If a parallel prefix algorithm is correct (for associative operations) on the Booleans, it is so on arbitrary value sets. Unfortunately not! 12

11 Investigating Particular Instances Only Knuth s 0-1-Principle If a comparison-swap algorithm sorts correctly on the Booleans, it does so on arbitrary totally ordered value sets. A Knuth-like 0-1-Principle? If a parallel prefix algorithm is correct (for associative operations) on the Booleans, it is so on arbitrary value sets. Unfortunately not! Let s: try to find out why not, 12

12 Investigating Particular Instances Only Knuth s 0-1-Principle If a comparison-swap algorithm sorts correctly on the Booleans, it does so on arbitrary totally ordered value sets. A Knuth-like 0-1-Principle? If a parallel prefix algorithm is correct (for associative operations) on the Booleans, it is so on arbitrary value sets. Unfortunately not! Let s: try to find out why not, and why makes more sense to attempt proving, 12

13 Investigating Particular Instances Only Knuth s 0-1-Principle If a comparison-swap algorithm sorts correctly on the Booleans, it does so on arbitrary totally ordered value sets. A Knuth-like 0-1-Principle? If a parallel prefix algorithm is correct (for associative operations) on the Booleans, it is so on arbitrary value sets. Unfortunately not! Let s: try to find out why not, and why makes more sense to attempt proving, and let s try to do all that without pulling too many rabbits. 12

14 What a Knuth-like 0-1-Principle Would Be Given: scanl1 :: (α α α) [α] [α] scanl1 () (x : xs) = go x xs where go x [ ] = [x] go x (y : ys) = x : (go (x y) ys) candidate :: (α α α) [α] [α] Theorem?: If for every associative () :: Bool Bool Bool and xs :: [Bool], candidate () xs = scanl1 () xs, then the same holds for every type τ, associative () :: τ τ τ, and xs :: [τ]. 13

15 What a Knuth-like 0-1-Principle Would Be Given: scanl1 :: (α α α) [α] [α] scanl1 () (x : xs) = go x xs where go x [ ] = [x] go x (y : ys) = x : (go (x y) ys) candidate :: (α α α) [α] [α] Theorem?: If for every associative () :: Bool Bool Bool and xs :: [Bool], candidate () xs = scanl1 () xs, then the same holds for every type τ, associative () :: τ τ τ, and xs :: [τ]. Let s try to find a counterexample by property-based testing. 13

16 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) 14

17 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) Hmm, this is problematic in so many ways! 14

18 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) Hmm, this is problematic in so many ways! generating (polymorphic) functions? 14

19 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) Hmm, this is problematic in so many ways! generating (polymorphic) functions? randomness vs. exhaustiveness? 14

20 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) Hmm, this is problematic in so many ways! generating (polymorphic) functions? randomness vs. exhaustiveness? a complex property as precondition of ==>? 14

21 Getting Started Somewhat naive expression of our intent: quickcheck $ λ(candidate :: (α α α) [α] [α]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool] candidate () xs == scanl1 () xs) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ] candidate () xs == scanl1 () xs) Hmm, this is problematic in so many ways! generating (polymorphic) functions? randomness vs. exhaustiveness? a complex property as precondition of ==>? generating/picking the type τ? 14

22 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. 15

23 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. A question: What can such a function do, given an operation and input list [x 0,..., x n 1 ]? 15

24 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. A question: What can such a function do, given an operation and input list [x 0,..., x n 1 ]? The answer: Create an output list consisting of expressions built from and x 0,..., x n 1. Independently of the α-type! 15

25 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. A question: What can such a function do, given an operation and input list [x 0,..., x n 1 ]? The answer: Create an output list consisting of expressions built from and x 0,..., x n 1. Independently of the α-type! But dependent on the input list length n! 15

26 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. A question: What can such a function do, given an operation and input list [x 0,..., x n 1 ]? The answer: Create an output list consisting of expressions built from and x 0,..., x n 1. Independently of the α-type! But dependent on the input list length n! So, to any candidate as above corresponds a function of type Nat [Expr], where data Expr = Var Nat Op Expr Expr 15

27 Transforming Polymorphism Away Let s try to get a grip on candidate :: (α α α) [α] [α]. A question: What can such a function do, given an operation and input list [x 0,..., x n 1 ]? The answer: Create an output list consisting of expressions built from and x 0,..., x n 1. Independently of the α-type! But dependent on the input list length n! So, to any candidate as above corresponds a function of type Nat [Expr], where data Expr = Var Nat Op Expr Expr We can prove this (almost) isomorphism using parametricity/ free theorems [Reynolds 1983, Wadler 1989], and can actually program appropriate conversions. 15

28 Where Are We Now? To test: quickcheck $ λ(representation :: Nat [Expr]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) 16

29 Where Are We Now? To test: quickcheck $ λ(representation :: Nat [Expr]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) The standard (QuickCheck) approach here, for dealing with Nat [Expr], would be: generate essentially partial functions 16

30 Where Are We Now? To test: quickcheck $ λ(representation :: Nat [Expr]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) The standard (QuickCheck) approach here, for dealing with Nat [Expr], would be: generate essentially partial functions, that take on a useful / used result only for finitely many inputs 16

31 Where Are We Now? To test: quickcheck $ λ(representation :: Nat [Expr]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) The standard (QuickCheck) approach here, for dealing with Nat [Expr], would be: generate essentially partial functions, that take on a useful / used result only for finitely many inputs, while choosing some default for all others. 16

32 Where Are We Now? To test: quickcheck $ λ(representation :: Nat [Expr]) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) The standard (QuickCheck) approach here, for dealing with Nat [Expr], would be: generate essentially partial functions, that take on a useful / used result only for finitely many inputs, while choosing some default for all others. That idea is basically fine here, but we actually need some more control because of our need to check the complex precondition. 16

33 Making Partiality Explicit (and Fixing the Default ) We go from Nat [Expr] to Nat Maybe [Expr], with the interpretation that representation n = Nothing means to take on the scanl1-behavior for lists of length n. 17

34 Making Partiality Explicit (and Fixing the Default ) We go from Nat [Expr] to Nat Maybe [Expr], with the interpretation that representation n = Nothing means to take on the scanl1-behavior for lists of length n. For example, representation :: Nat Maybe [Expr] representation n n == 1 = Just [Op (Var 0) (Var 0)] n == 3 = Just [Var 0, Op (Var 1) (Var 2)] otherwise = Nothing corresponds to candidate :: (α α α) [α] [α] candidate () [x ] = [x x ] candidate () [x, y, z ] = [x, y z ] candidate () xs = scanl1 () xs 17

35 Another Problem Even representation :: Nat Maybe [Expr] is not very testable for our purposes, since we can only find out which outputs are Nothing by actually applying the function. 18

36 Another Problem Even representation :: Nat Maybe [Expr] is not very testable for our purposes, since we can only find out which outputs are Nothing by actually applying the function. What we need to shortcut the complex precondition check is explicit access to the definedness domain. 18

37 Another Problem Even representation :: Nat Maybe [Expr] is not very testable for our purposes, since we can only find out which outputs are Nothing by actually applying the function. What we need to shortcut the complex precondition check is explicit access to the definedness domain. So, we store only the non-nothing positions, as key-value-pairs: type Sparse = [(Nat, [Expr])] 18

38 Another Problem Even representation :: Nat Maybe [Expr] is not very testable for our purposes, since we can only find out which outputs are Nothing by actually applying the function. What we need to shortcut the complex precondition check is explicit access to the definedness domain. So, we store only the non-nothing positions, as key-value-pairs: type Sparse = [(Nat, [Expr])] Previous example then corresponds to (among others): sparse :: Sparse sparse = [(1, [Op (Var 0) (Var 0)]), (3, [Var 0, Op (Var 1) (Var 2)])] 18

39 Another Problem Even representation :: Nat Maybe [Expr] is not very testable for our purposes, since we can only find out which outputs are Nothing by actually applying the function. What we need to shortcut the complex precondition check is explicit access to the definedness domain. So, we store only the non-nothing positions, as key-value-pairs: type Sparse = [(Nat, [Expr])] Previous example then corresponds to (among others): sparse :: Sparse sparse = [(1, [Op (Var 0) (Var 0)]), (3, [Var 0, Op (Var 1) (Var 2)])] Actually a technical challenge now: programmatic conversion between [(Nat, [Expr])] and Nat Maybe [Expr]? 18

40 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. 19

41 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. For example, sparsify (const Nothing) would simply give :: Sparse, from which we could not learn anything. 19

42 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. For example, sparsify (const Nothing) would simply give :: Sparse, from which we could not learn anything. Solution: work with lazy natural numbers: data Nat = Z S Nat 19

43 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. For example, sparsify (const Nothing) would simply give :: Sparse, from which we could not learn anything. Solution: work with lazy natural numbers: data Nat = Z S Nat use an appropriately lazy function for lookup in [(Nat, [Expr])] 19

44 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. For example, sparsify (const Nothing) would simply give :: Sparse, from which we could not learn anything. Solution: work with lazy natural numbers: data Nat = Z S Nat use an appropriately lazy function for lookup in [(Nat, [Expr])] convert with care 19

45 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Problem: A naive sparsification, iterating through all natural numbers and keeping those for which the result is non-nothing, does not work well. For example, sparsify (const Nothing) would simply give :: Sparse, from which we could not learn anything. Solution: work with lazy natural numbers: data Nat = Z S Nat use an appropriately lazy function for lookup in [(Nat, [Expr])] convert with care (for convenience, actually store only the gap lengths ) 19

46 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Solution: work with lazy natural numbers: data Nat = Z S Nat use an appropriately lazy function for lookup in [(Nat, [Expr])] convert with care (for convenience, actually store only the gap lengths ) Example: representation :: Nat Maybe [Expr] representation n n == 1 = Just [Op (Var 0) (Var 0)] n == 3 = Just [Var 0,...] otherwise = Nothing 19

47 Excurse: from Nat Maybe [Expr] to [(Nat, [Expr])] Solution: work with lazy natural numbers: data Nat = Z S Nat use an appropriately lazy function for lookup in [(Nat, [Expr])] convert with care (for convenience, actually store only the gap lengths ) Example: representation :: Nat Maybe [Expr] representation n n == 1 = Just [Op (Var 0) (Var 0)] n == 3 = Just [Var 0,...] otherwise = Nothing now turns into: sparse :: Sparse sparse = [(S Z, [Op (Var 0) (Var 0)]), (S Z, [Var 0,...]), (S (S (S... )), )] + 19

48 Wrapping up the Transformation We now have: quickcheck $ λ(sparse :: Sparse) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) 20

49 Wrapping up the Transformation We now have: quickcheck $ λ(sparse :: Sparse) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) Now we can: implement the complex precondition check (by handcoding or using SmallCheck machinery) 20

50 Wrapping up the Transformation We now have: quickcheck $ λ(sparse :: Sparse) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) Now we can: implement the complex precondition check (by handcoding or using SmallCheck machinery) generalize to other finite types 20

51 Wrapping up the Transformation We now have: quickcheck $ λ(sparse :: Sparse) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) Now we can: implement the complex precondition check (by handcoding or using SmallCheck machinery) generalize to other finite types experiment with different choices for τ 20

52 Wrapping up the Transformation We now have: quickcheck $ λ(sparse :: Sparse) (forall associative $ λ(() :: Bool Bool Bool) λxs :: [Bool]... ) ==> τ. (forall associative $ λ(() :: τ τ τ) λxs :: [τ ]... ) Now we can: implement the complex precondition check (by handcoding or using SmallCheck machinery) generalize to other finite types experiment with different choices for τ experiment with different generators for Sparse-candidates experiment with QuickCheck vs. SmallCheck 20

53 Some Counterexamples Thus Found candidate :: (α α α) [α] [α] candidate () [x 0 ] = [x 0 ] candidate () [x 0, x 1 ] = [x 0, (((x 0 x 1 ) x 0 ) x 0 ) (x 1 x 1 )] candidate () xs = scanl1 () xs 21

54 Some Counterexamples Thus Found candidate :: (α α α) [α] [α] candidate () [x 0 ] = [x 0 ] candidate () [x 0, x 1 ] = [x 0, (((x 0 x 1 ) x 0 ) x 0 ) (x 1 x 1 )] candidate () xs = scanl1 () xs candidate :: (α α α) [α] [α] candidate () [x 0 ] = [x 0 ] candidate () [x 0, x 1 ] = [x 0, ((x 0 x 0 ) x 0 ) x 1 ] candidate () xs = scanl1 () xs 21

55 Some Counterexamples Thus Found candidate :: (α α α) [α] [α] candidate () [x 0 ] = [x 0 ] candidate () [x 0, x 1 ] = [x 0, (((x 0 x 1 ) x 0 ) x 0 ) (x 1 x 1 )] candidate () xs = scanl1 () xs candidate :: (α α α) [α] [α] candidate () [x 0 ] = [x 0 ] candidate () [x 0, x 1 ] = [x 0, ((x 0 x 0 ) x 0 ) x 1 ] candidate () xs = scanl1 () xs candidate :: (α α α) [α] [α] candidate () [x 0, x 1, x 2 ] = [x 0, (x 0 x 0 ) (x 0 x 1 ), x 0 (x 1 x 2 )] candidate () xs = scanl1 () xs 21

56 Recall: Plan of the Talk Start telling the story of how 0-1-2, 1, 2,... were found (back in 2007, never recorded, but interesting I think). Challenge you to suggest other approaches to discover the required counterexamples and proof ingredients? Invite complaints about where the presented (deliberately naive, exploratory) approach is too ad-hoc, or unacceptably pulls a rabbit out of a hat. Provoke investigation/proposals of other algorithm classes on which one could try to play the same or similar trick(s)? 23

57 References I G.E. Blelloch. Prefix sums and their applications. In J.H. Reif, editor, Synthesis of Parallel Algorithms, pages Morgan Kaufmann, S. Böhme. Much Ado about Two. Formal proof development. In The Archive of Formal Proofs N.A. Day, J. Launchbury, and J.R. Lewis. Logical abstractions in Haskell. In Haskell Workshop, Proceedings,

58 References II D.E. Knuth. The Art of Computer Programming, volume 3: Sorting and Searching. Addison-Wesley, J.C. Reynolds. Types, abstraction and parametric polymorphism. In Information Processing, Proceedings, pages Elsevier Science Publishers B.V., M. Sheeran. Searching for prefix networks to fit in a context using a lazy functional programming language. Hardware Design and Functional Languages,

59 References III J. Sklansky. Conditional-sum addition logic. IRE Transactions on Electronic Computers, EC-9(6): , J. Voigtländer. Much ado about two: A pearl on parallel prefix computation. In Principles of Programming Languages, Proceedings, pages ACM Press, P. Wadler. Theorems for free! In Functional Programming Languages and Computer Architecture, Proceedings, pages ACM Press,

The countdown problem

The countdown problem JFP 12 (6): 609 616, November 2002. c 2002 Cambridge University Press DOI: 10.1017/S0956796801004300 Printed in the United Kingdom 609 F U N C T I O N A L P E A R L The countdown problem GRAHAM HUTTON

More information

Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011. Lecture 1 Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

More information

(Refer Slide Time: 2:03)

(Refer Slide Time: 2:03) Control Engineering Prof. Madan Gopal Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 11 Models of Industrial Control Devices and Systems (Contd.) Last time we were

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.080/6.089 GITCS Feb 12, 2008. Lecture 3 6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

More information

Base Conversion written by Cathy Saxton

Base Conversion written by Cathy Saxton Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,

More information

NP-Completeness and Cook s Theorem

NP-Completeness and Cook s Theorem NP-Completeness and Cook s Theorem Lecture notes for COM3412 Logic and Computation 15th January 2002 1 NP decision problems The decision problem D L for a formal language L Σ is the computational task:

More information

Deterministic Discrete Modeling

Deterministic Discrete Modeling Deterministic Discrete Modeling Formal Semantics of Firewalls in Isabelle/HOL Cornelius Diekmann, M.Sc. Dr. Heiko Niedermayer Prof. Dr.-Ing. Georg Carle Lehrstuhl für Netzarchitekturen und Netzdienste

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

Testing and Tracing Lazy Functional Programs using QuickCheck and Hat

Testing and Tracing Lazy Functional Programs using QuickCheck and Hat Testing and Tracing Lazy Functional Programs using QuickCheck and Hat Koen Claessen 1, Colin Runciman 2, Olaf Chitil 2, John Hughes 1, and Malcolm Wallace 2 1 Chalmers University of Technology, Sweden

More information

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014!

Programming Language Rankings. Lecture 15: Type Inference, polymorphism & Type Classes. Top Combined. Tiobe Index. CSC 131! Fall, 2014! Programming Language Rankings Lecture 15: Type Inference, polymorphism & Type Classes CSC 131 Fall, 2014 Kim Bruce Top Combined Tiobe Index 1. JavaScript (+1) 2. Java (-1) 3. PHP 4. C# (+2) 5. Python (-1)

More information

25 Integers: Addition and Subtraction

25 Integers: Addition and Subtraction 25 Integers: Addition and Subtraction Whole numbers and their operations were developed as a direct result of people s need to count. But nowadays many quantitative needs aside from counting require numbers

More information

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix:

NUMBER SYSTEMS APPENDIX D. You will learn about the following in this appendix: APPENDIX D NUMBER SYSTEMS You will learn about the following in this appendix: The four important number systems in computing binary, octal, decimal, and hexadecimal. A number system converter program

More information

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful

POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful POLYTYPIC PROGRAMMING OR: Programming Language Theory is Helpful RALF HINZE Institute of Information and Computing Sciences Utrecht University Email: ralf@cs.uu.nl Homepage: http://www.cs.uu.nl/~ralf/

More information

if and if-else: Part 1

if and if-else: Part 1 if and if-else: Part 1 Objectives Write if statements (including blocks) Write if-else statements (including blocks) Write nested if-else statements We will now talk about writing statements that make

More information

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

More information

The Euclidean Algorithm

The Euclidean Algorithm The Euclidean Algorithm A METHOD FOR FINDING THE GREATEST COMMON DIVISOR FOR TWO LARGE NUMBERS To be successful using this method you have got to know how to divide. If this is something that you have

More information

Formal Methods for Software Development

Formal Methods for Software Development Formal Methods for Software Development Till Mossakowski, Lutz Schröder 03./08.11.2004 2 Monadic QuickCheck extension of QuickCheck for monadic (= imperative) programs specifications are equations between

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

Factoring & Primality

Factoring & Primality Factoring & Primality Lecturer: Dimitris Papadopoulos In this lecture we will discuss the problem of integer factorization and primality testing, two problems that have been the focus of a great amount

More information

Polynomial Invariants

Polynomial Invariants Polynomial Invariants Dylan Wilson October 9, 2014 (1) Today we will be interested in the following Question 1.1. What are all the possible polynomials in two variables f(x, y) such that f(x, y) = f(y,

More information

Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

More information

Primes in Sequences. Lee 1. By: Jae Young Lee. Project for MA 341 (Number Theory) Boston University Summer Term I 2009 Instructor: Kalin Kostadinov

Primes in Sequences. Lee 1. By: Jae Young Lee. Project for MA 341 (Number Theory) Boston University Summer Term I 2009 Instructor: Kalin Kostadinov Lee 1 Primes in Sequences By: Jae Young Lee Project for MA 341 (Number Theory) Boston University Summer Term I 2009 Instructor: Kalin Kostadinov Lee 2 Jae Young Lee MA341 Number Theory PRIMES IN SEQUENCES

More information

Understanding Logic Design

Understanding Logic Design Understanding Logic Design ppendix of your Textbook does not have the needed background information. This document supplements it. When you write add DD R0, R1, R2, you imagine something like this: R1

More information

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

More information

Activity 1: Using base ten blocks to model operations on decimals

Activity 1: Using base ten blocks to model operations on decimals Rational Numbers 9: Decimal Form of Rational Numbers Objectives To use base ten blocks to model operations on decimal numbers To review the algorithms for addition, subtraction, multiplication and division

More information

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification: Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

More information

[Refer Slide Time: 05:10]

[Refer Slide Time: 05:10] Principles of Programming Languages Prof: S. Arun Kumar Department of Computer Science and Engineering Indian Institute of Technology Delhi Lecture no 7 Lecture Title: Syntactic Classes Welcome to lecture

More information

Math 319 Problem Set #3 Solution 21 February 2002

Math 319 Problem Set #3 Solution 21 February 2002 Math 319 Problem Set #3 Solution 21 February 2002 1. ( 2.1, problem 15) Find integers a 1, a 2, a 3, a 4, a 5 such that every integer x satisfies at least one of the congruences x a 1 (mod 2), x a 2 (mod

More information

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions

More information

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

More information

Today s Topics. Primes & Greatest Common Divisors

Today s Topics. Primes & Greatest Common Divisors Today s Topics Primes & Greatest Common Divisors Prime representations Important theorems about primality Greatest Common Divisors Least Common Multiples Euclid s algorithm Once and for all, what are prime

More information

CMPSCI611: Approximating MAX-CUT Lecture 20

CMPSCI611: Approximating MAX-CUT Lecture 20 CMPSCI611: Approximating MAX-CUT Lecture 20 For the next two lectures we ll be seeing examples of approximation algorithms for interesting NP-hard problems. Today we consider MAX-CUT, which we proved to

More information

Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

More information

A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation PLDI 03 A Static Analyzer for Large Safety-Critical Software B. Blanchet, P. Cousot, R. Cousot, J. Feret L. Mauborgne, A. Miné, D. Monniaux,. Rival CNRS École normale supérieure École polytechnique Paris

More information

15-150 Lecture 11: Tail Recursion; Continuations

15-150 Lecture 11: Tail Recursion; Continuations 15-150 Lecture 11: Tail Recursion; Continuations Lecture by Dan Licata February 21, 2011 In this lecture we will discuss space usage: analyzing the memory it takes your program to run tail calls and tail

More information

Lecture Notes on Linear Search

Lecture Notes on Linear Search Lecture Notes on Linear Search 15-122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is

More information

Lecture 9 - Message Authentication Codes

Lecture 9 - Message Authentication Codes Lecture 9 - Message Authentication Codes Boaz Barak March 1, 2010 Reading: Boneh-Shoup chapter 6, Sections 9.1 9.3. Data integrity Until now we ve only been interested in protecting secrecy of data. However,

More information

Binary Adders: Half Adders and Full Adders

Binary Adders: Half Adders and Full Adders Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order

More information

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012 Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

More information

So let us begin our quest to find the holy grail of real analysis.

So let us begin our quest to find the holy grail of real analysis. 1 Section 5.2 The Complete Ordered Field: Purpose of Section We present an axiomatic description of the real numbers as a complete ordered field. The axioms which describe the arithmetic of the real numbers

More information

Algorithms are the threads that tie together most of the subfields of computer science.

Algorithms are the threads that tie together most of the subfields of computer science. Algorithms Algorithms 1 Algorithms are the threads that tie together most of the subfields of computer science. Something magically beautiful happens when a sequence of commands and decisions is able to

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

Boolean Algebra Part 1

Boolean Algebra Part 1 Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems

More information

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing

More information

Grade 6 Math Circles. Binary and Beyond

Grade 6 Math Circles. Binary and Beyond Faculty of Mathematics Waterloo, Ontario N2L 3G1 The Decimal System Grade 6 Math Circles October 15/16, 2013 Binary and Beyond The cool reality is that we learn to count in only one of many possible number

More information

Maar hoe moet het dan?

Maar hoe moet het dan? Maar hoe moet het dan? Onderzoek naar feedback in interactieve leeromgevingen bij de Faculteit Informatica Johan Jeuring Met bijdragen van Alex Gerdes, Bastiaan Heeren, Josje Lodder, Harrie Passier, Sylvia

More information

Growing testing skills using the Agile Testing Ecosystem. Dr Lee Hawkins Principal Test Architect Dell Software, Melbourne

Growing testing skills using the Agile Testing Ecosystem. Dr Lee Hawkins Principal Test Architect Dell Software, Melbourne Growing testing skills using the Agile Testing Ecosystem Dr Lee Hawkins Principal Test Architect Dell Software, Melbourne Who am I? 16 years at Quest Software / Dell Software in Melbourne, Australia. Really

More information

Introduction to Programming (in C++) Sorting. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Sorting. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Introduction to Programming (in C++) Sorting Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Sorting Let elem be a type with a operation, which is a total order A vector

More information

QA or the Highway 2016 Presentation Notes

QA or the Highway 2016 Presentation Notes QA or the Highway 2016 Presentation Notes Making QA Strategic Let s Get Real (Panel Discussion) Does testing belong at the strategic table? What is that strategic value that testing provides? Conquering

More information

Solutions to Math 51 First Exam January 29, 2015

Solutions to Math 51 First Exam January 29, 2015 Solutions to Math 5 First Exam January 29, 25. ( points) (a) Complete the following sentence: A set of vectors {v,..., v k } is defined to be linearly dependent if (2 points) there exist c,... c k R, not

More information

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

Kapitel 1 Multiplication of Long Integers (Faster than Long Multiplication)

Kapitel 1 Multiplication of Long Integers (Faster than Long Multiplication) Kapitel 1 Multiplication of Long Integers (Faster than Long Multiplication) Arno Eigenwillig und Kurt Mehlhorn An algorithm for multiplication of integers is taught already in primary school: To multiply

More information

Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative

More information

RSA Encryption. Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles October 10, 2003

RSA Encryption. Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles October 10, 2003 RSA Encryption Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles October 10, 2003 1 Public Key Cryptography One of the biggest problems in cryptography is the distribution of keys.

More information

Type Classes with Functional Dependencies

Type Classes with Functional Dependencies Appears in Proceedings of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, March 2000, Springer-Verlag LNCS 1782. Type Classes with Functional Dependencies Mark P. Jones Department

More information

CONTENTS 1. Peter Kahn. Spring 2007

CONTENTS 1. Peter Kahn. Spring 2007 CONTENTS 1 MATH 304: CONSTRUCTING THE REAL NUMBERS Peter Kahn Spring 2007 Contents 2 The Integers 1 2.1 The basic construction.......................... 1 2.2 Adding integers..............................

More information

Automata and Formal Languages

Automata and Formal Languages Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

More information

3.1. RATIONAL EXPRESSIONS

3.1. RATIONAL EXPRESSIONS 3.1. RATIONAL EXPRESSIONS RATIONAL NUMBERS In previous courses you have learned how to operate (do addition, subtraction, multiplication, and division) on rational numbers (fractions). Rational numbers

More information

DERIVATIVES AS MATRICES; CHAIN RULE

DERIVATIVES AS MATRICES; CHAIN RULE DERIVATIVES AS MATRICES; CHAIN RULE 1. Derivatives of Real-valued Functions Let s first consider functions f : R 2 R. Recall that if the partial derivatives of f exist at the point (x 0, y 0 ), then we

More information

Writing learning objectives

Writing learning objectives Writing learning objectives This material was excerpted and adapted from the following web site: http://www.utexas.edu/academic/diia/assessment/iar/students/plan/objectives/ What is a learning objective?

More information

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value CMSC 33: Organization of Programming Languages Programming Language Features (cont.) Names & binding Namespaces Static (lexical) scopes Dynamic scopes Polymorphism Parametric Subtype Ad-hoc Parameter Passing

More information

Introduction to Fractions, Equivalent and Simplifying (1-2 days)

Introduction to Fractions, Equivalent and Simplifying (1-2 days) Introduction to Fractions, Equivalent and Simplifying (1-2 days) 1. Fraction 2. Numerator 3. Denominator 4. Equivalent 5. Simplest form Real World Examples: 1. Fractions in general, why and where we use

More information

Lab 11. Simulations. The Concept

Lab 11. Simulations. The Concept Lab 11 Simulations In this lab you ll learn how to create simulations to provide approximate answers to probability questions. We ll make use of a particular kind of structure, called a box model, that

More information

Properties of Real Numbers

Properties of Real Numbers 16 Chapter P Prerequisites P.2 Properties of Real Numbers What you should learn: Identify and use the basic properties of real numbers Develop and use additional properties of real numbers Why you should

More information

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10 Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

More information

THE DIMENSION OF A VECTOR SPACE

THE DIMENSION OF A VECTOR SPACE THE DIMENSION OF A VECTOR SPACE KEITH CONRAD This handout is a supplementary discussion leading up to the definition of dimension and some of its basic properties. Let V be a vector space over a field

More information

The Halting Problem is Undecidable

The Halting Problem is Undecidable 185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

More information

Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

More information

Haskell Programming With Tests, and Some Alloy

Haskell Programming With Tests, and Some Alloy Haskell Programming With Tests, and Some Alloy Jan van Eijck jve@cwi.nl Master SE, 2010 Abstract How to write a program in Haskell, and how to use the Haskell testing tools... QuickCheck is a tool written

More information

Math 4310 Handout - Quotient Vector Spaces

Math 4310 Handout - Quotient Vector Spaces Math 4310 Handout - Quotient Vector Spaces Dan Collins The textbook defines a subspace of a vector space in Chapter 4, but it avoids ever discussing the notion of a quotient space. This is understandable

More information

CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

More information

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce

More information

Vieta s Formulas and the Identity Theorem

Vieta s Formulas and the Identity Theorem Vieta s Formulas and the Identity Theorem This worksheet will work through the material from our class on 3/21/2013 with some examples that should help you with the homework The topic of our discussion

More information

There is a simple equation for calculating dilutions. It is also easy to present the logic of the equation.

There is a simple equation for calculating dilutions. It is also easy to present the logic of the equation. Solutions: Dilutions. A. Dilutions: Introduction... 1 B. The dilution equation... 2 C. The logic of the dilution equation... 3 D. Should you memorize the dilution equation? -- Attention X11 students...

More information

KS3 Computing Group 1 Programme of Study 2015 2016 2 hours per week

KS3 Computing Group 1 Programme of Study 2015 2016 2 hours per week 1 07/09/15 2 14/09/15 3 21/09/15 4 28/09/15 Communication and Networks esafety Obtains content from the World Wide Web using a web browser. Understands the importance of communicating safely and respectfully

More information

Conditions & Boolean Expressions

Conditions & Boolean Expressions Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In

More information

def: An axiom is a statement that is assumed to be true, or in the case of a mathematical system, is used to specify the system.

def: An axiom is a statement that is assumed to be true, or in the case of a mathematical system, is used to specify the system. Section 1.5 Methods of Proof 1.5.1 1.5 METHODS OF PROOF Some forms of argument ( valid ) never lead from correct statements to an incorrect. Some other forms of argument ( fallacies ) can lead from true

More information

Solving Equations. How do you know that x = 3 in the equation, 2x - 1 = 5?

Solving Equations. How do you know that x = 3 in the equation, 2x - 1 = 5? Question: Solving Equations How do you know that x = 3 in the equation, 2x - 1 = 5? Possible answers to the question are: 1. If you use guess and check, the only number that works for x is 3. 2. Why should

More information

Coverability for Parallel Programs

Coverability for Parallel Programs 2015 http://excel.fit.vutbr.cz Coverability for Parallel Programs Lenka Turoňová* Abstract We improve existing method for the automatic verification of systems with parallel running processes. The technique

More information

1 Solving LPs: The Simplex Algorithm of George Dantzig

1 Solving LPs: The Simplex Algorithm of George Dantzig Solving LPs: The Simplex Algorithm of George Dantzig. Simplex Pivoting: Dictionary Format We illustrate a general solution procedure, called the simplex algorithm, by implementing it on a very simple example.

More information

5544 = 2 2772 = 2 2 1386 = 2 2 2 693. Now we have to find a divisor of 693. We can try 3, and 693 = 3 231,and we keep dividing by 3 to get: 1

5544 = 2 2772 = 2 2 1386 = 2 2 2 693. Now we have to find a divisor of 693. We can try 3, and 693 = 3 231,and we keep dividing by 3 to get: 1 MATH 13150: Freshman Seminar Unit 8 1. Prime numbers 1.1. Primes. A number bigger than 1 is called prime if its only divisors are 1 and itself. For example, 3 is prime because the only numbers dividing

More information

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

WRITING PROOFS. Christopher Heil Georgia Institute of Technology WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this

More information

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic: Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents

More information

2.4 Real Zeros of Polynomial Functions

2.4 Real Zeros of Polynomial Functions SECTION 2.4 Real Zeros of Polynomial Functions 197 What you ll learn about Long Division and the Division Algorithm Remainder and Factor Theorems Synthetic Division Rational Zeros Theorem Upper and Lower

More information

Chapter 15 Functional Programming Languages

Chapter 15 Functional Programming Languages Chapter 15 Functional Programming Languages Introduction - The design of the imperative languages is based directly on the von Neumann architecture Efficiency (at least at first) is the primary concern,

More information

7 Gaussian Elimination and LU Factorization

7 Gaussian Elimination and LU Factorization 7 Gaussian Elimination and LU Factorization In this final section on matrix factorization methods for solving Ax = b we want to take a closer look at Gaussian elimination (probably the best known method

More information

Numerical Matrix Analysis

Numerical Matrix Analysis Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

More information

Ummmm! Definitely interested. She took the pen and pad out of my hand and constructed a third one for herself:

Ummmm! Definitely interested. She took the pen and pad out of my hand and constructed a third one for herself: Sum of Cubes Jo was supposed to be studying for her grade 12 physics test, but her soul was wandering. Show me something fun, she said. Well I wasn t sure just what she had in mind, but it happened that

More information

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution 16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

More information

HiDb: A Haskell In-Memory Relational Database

HiDb: A Haskell In-Memory Relational Database HiDb: A Haskell In-Memory Relational Database Rohan Puttagunta Arun Debray Susan Tu CS240H rohanp adebray sctu @stanford.edu June 11, 2014 Abstract We describe our experience implementing an in-memory

More information

Using Use Cases for requirements capture. Pete McBreen. 1998 McBreen.Consulting

Using Use Cases for requirements capture. Pete McBreen. 1998 McBreen.Consulting Using Use Cases for requirements capture Pete McBreen 1998 McBreen.Consulting petemcbreen@acm.org All rights reserved. You have permission to copy and distribute the document as long as you make no changes

More information

Interface Definition Language

Interface Definition Language Interface Definition Language by David G. Messerschmitt Supplementary section for Understanding Networked Applications: A First Course, Morgan Kaufmann, 1999. Copyright notice: Permission is granted to

More information

Efficient representation of integer sets

Efficient representation of integer sets Efficient representation of integer sets Marco Almeida Rogério Reis Technical Report Series: DCC-2006-06 Version 1.0 Departamento de Ciência de Computadores & Laboratório de Inteligência Artificial e Ciência

More information