Lecture 13 CS 1813 Discrete Mathematics. Induction Induction. CS 1813 Discrete Mathematics, Univ Oklahoma Copyright 2000 by Rex Page

Similar documents
CSE 20: Discrete Mathematics for Computer Science. Prof. Miles Jones. Today s Topics: 3-cent and 5-cent coins. 1. Mathematical Induction Proof

CS 202, section 2 Final Exam 13 December Pledge: Signature:

DVA325 Formal Languages, Automata and Models of Computation (FABER)

ON SPLITTING UP PILES OF STONES

The Cauchy Criterion

Monotone Sequences & Cauchy Sequences Philippe B. Laval

Theory of Probability - Brett Bernstein

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Tangent: Boromean Rings. The Beer Can Game. Plan. A Take-Away Game. Mathematical Games I. Introduction to Impartial Combinatorial Games

1. Functions and set sizes 2. Infinite set sizes. ! Let X,Y be finite sets, f:x!y a function. ! Theorem: If f is injective then X Y.

DISCRETE STRUCTURES COUNTING

Massachusetts Institute of Technology 6.042J/18.062J, Spring 04: Mathematics for Computer Science April 16 Prof. Albert R. Meyer and Dr.

Stanford University CS261: Optimization Handout 9 Luca Trevisan February 1, 2011

Arithmetic Sequences Read 8.2 Examples 1-4

Notes for Recitation 3

Greedy Flipping of Pancakes and Burnt Pancakes

Modal logic. Benzmüller/Rojas, 2014 Artificial Intelligence 2

October 16, proving lines parallel ink.notebook. page Prove Lines Parallel. page 113. Standards. page 115.

How to Become a Mathemagician: Mental Calculations and Math Magic

Dealing with some maths

Plan. Related courses. A Take-Away Game. Mathematical Games , (21-801) - Mathematical Games Look for it in Spring 11

ECS 20 (Spring 2013) Phillip Rogaway Lecture 1

Ramanujan-type Congruences for Overpartitions Modulo 5. Nankai University, Tianjin , P. R. China

With Question/Answer Animations. Chapter 6

Warm-Up Up Exercises. 1. Find the value of x. ANSWER 32

1.6 Congruence Modulo m

A Proof of the Invalidity of Proposition in Acemoglu(2009)

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Midterm 1. Exam location: 1 Pimentel, back half: SIDs ending in X or Y

Round and Round. - Circle Theorems 1: The Chord Theorem -

18 Completeness and Compactness of First-Order Tableaux

Reading 14 : Counting

ABSTRACT INTERPRETATION USING LAZINESS: PROVING CONWAY S LOST COSMOLOGICAL THEOREM

Pattern Avoidance in Unimodal and V-unimodal Permutations

Assignment 2. Due: Monday Oct. 15, :59pm

CS 3233 Discrete Mathematical Structure Midterm 2 Exam Solution Tuesday, April 17, :30 1:45 pm. Last Name: First Name: Student ID:

Chapter 6.2: Trig Proofs

Problem Set 8 Solutions R Y G R R G

1 Fisher Yates shuffle 2

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

CAP 5415 Computer Vision. Marshall Tappen Fall Lecture 1

Congruences Modulo Small Powers of 2 and 3 for Partitions into Odd Designated Summands

Counting. Chapter 6. With Question/Answer Animations

Counting constrained domino tilings of Aztec diamonds

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

arxiv: v1 [math.co] 24 Nov 2018

CDT314 FABER Formal Languages, Automata and Models of Computation MARK BURGIN INDUCTIVE TURING MACHINES

THE ASSOCIATION OF MATHEMATICS TEACHERS OF NEW JERSEY 2018 ANNUAL WINTER CONFERENCE FOSTERING GROWTH MINDSETS IN EVERY MATH CLASSROOM

8.2 Slippery Slopes. A Solidify Understanding Task

Lecture 18 - Counting

CSE 20 DISCRETE MATH. Fall

The Tilings of Deficient Squares by Ribbon L-Tetrominoes Are Diagonally Cracked

Evacuation and a Geometric Construction for Fibonacci Tableaux

Zhanjiang , People s Republic of China

Example Enemy agents are trying to invent a new type of cipher. They decide on the following encryption scheme: Plaintext converts to Ciphertext

Math 127: Equivalence Relations

Logical Agents (AIMA - Chapter 7)

11/18/2015. Outline. Logical Agents. The Wumpus World. 1. Automating Hunt the Wumpus : A different kind of problem

Game Theory and Algorithms Lecture 19: Nim & Impartial Combinatorial Games

Number Theory. Konkreetne Matemaatika

Shuffling with ordered cards

Introduction to Modular Arithmetic

arxiv: v1 [cs.cc] 21 Jun 2017

THE GAME CREATION OPERATOR

Carmen s Core Concepts (Math 135)

More Great Ideas in Theoretical Computer Science. Lecture 1: Sorting Pancakes

Primitive Roots. Chapter Orders and Primitive Roots

Ideas beyond Number. Teacher s guide to Activity worksheets

Counting Permutations by Putting Balls into Boxes

SUDOKU Colorings of the Hexagonal Bipyramid Fractal

Enumeration of Two Particular Sets of Minimal Permutations

CLASS NOTES. A mathematical proof is an argument which convinces other people that something is true.

Edge-disjoint tree representation of three tree degree sequences

Topics to be covered

Combinatorial Proofs

Week 3-4: Permutations and Combinations

Playing with Permutations: Examining Mathematics in Children s Toys

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Formidable Fourteen Puzzle = 6. Boxing Match Example. Part II - Sums of Games. Sums of Games. Example Contd. Mathematical Games II Sums of Games

Honors Precalculus Chapter 9 Summary Basic Combinatorics

Algorithms and Data Structures: Network Flows. 24th & 28th Oct, 2014

6-3 Conditions for Parallelograms

Grades 7 & 8, Math Circles 27/28 February, 1 March, Mathematical Magic

arxiv: v1 [math.gm] 29 Mar 2015

First Cycle Games. Benjamin Aminof (IST Austria) and Sasha Rubin (TU Wien) Strategic Reasoning /20

Countability. Jason Filippou UMCP. Jason Filippou UMCP) Countability / 12

REU 2006 Discrete Math Lecture 3

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

NIM Games: Handout 1

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

A Study of Relationship Among Goldbach Conjecture, Twin prime and Fibonacci number

Algorithmic Number Theory and Cryptography (CS 303)

NOT QUITE NUMBER THEORY

On uniquely k-determined permutations

132-avoiding Two-stack Sortable Permutations, Fibonacci Numbers, and Pell Numbers

Eric Duchêne (Univ. Claude Bernard Lyon 1) Michel Rigo (University of Liège)

NUMBER THEORY AMIN WITNO

To Your Hearts Content

Instructor Notes for Chapter 4

QUOTIENT AND PSEUDO-OPEN IMAGES OF SEPARABLE METRIC SPACES

THE NUMBER OF PERMUTATIONS WHICH FORM ARITHMETIC PROGRESSIONS MODULO m

Transcription:

Lecture 13 CS 1813 Discrete Mathematics Induction Induction Induction 1

Concatenating Sequences (++) :: [a] -> [a] -> [a] (x: xs) ++ ys = x: (xs ++ ys) (++).: [ ] ++ ys = ys (++).[] Proposition P(n) (universe of discourse: n N ) length xs = n length(xs ++ ys) = length xs + length ys P(0): length xs = 0 length(xs++ys) = length xs + length ys length(xs ++ ys) = length([ ] ++ ys) len 0 [ ] = length ys (++).[] = 0 + length ys 2 nd -grade arithmetic = length xs + length ys hypothesis of implication Next, prove P(n) P(n+1) next slide 2

Concatenating Sequences the inductive case P(n+1): length xs = n+1 length(xs++ys) = (length xs) + (length ys) length(xs++ys) = length((z:zs) ++ ys) xs = (z: zs) {see note} = length(z: (zs ++ ys)) (++).: = 1 + length(zs ++ ys) (length).: = 1 + length zs + length ys P(n), since length zs = n = 1 + n + length ys (length zs) = n {see note} = n + 1 + length ys +comm = length xs + length ys hypothesis in P(n+1) Note: z. zs. (xs = (z: zs)) ((length zs) = n) (:len) corollary 3

Proved: P(0) Concatenating Sequences applying the principle of induction Proved: P(n) P(n+1) Conclude n N. P(n) by the principle of induction P(n): length xs = n length(xs ++ ys) = length xs + length ys qed 4

Concatenating a List of Sequences the big ++ concat :: [[a]] -> [a] concat(xs: xss) = xs ++ concat xss concat[ ] = [ ] (concat).: (concat).[] Theorem: n N. P(n) where P(n) is defined as follows: P(n) ( k {1, 2, n}. length(xs k ) N ) length(concat [xs 1, xs 2, xs n ]) = sum[length xs 1, length xs 2, length xs n ] List Comprehension like set comprehension, but for sequences [sequence-element generator, optional-constraint] [x - 2 x <- [12, 9, 27, 19, 13]] = [10, 7, 25, 17, 11] [x x <- [12, 9, 27, 19, 13], x < 15] = [12, 9, 13] [x + 3 x <- [12, 9, 27, 19, 13], x < 15] = [15, 12, 16] Proof Induction on n All this stuff is starting to look alike, isn t it? 5

shuffle shuffle :: [a] -> [a] -> [a] Examples shuffle [1, 2, 3, 4, 5] [6, 7, 8, 9, 10] = [1, 6, 2, 7, 3, 8, 4, 9, 5, 10] shuffle [1, 2, 3, 4, 5] [6, 7, 8] = [1, 6, 2, 7, 3, 8, 4, 5] shuffle [1, 2, 3, 4] [6, 7, 8, 9, 10] = [1, 6, 2, 7, 3, 8, 4, 9, 10] Pattern of computation shuffle [x 1, x 2, x n ] [y 1, y 2, y n ] = [x 1, y 1, x 2, y 2, x n, y n ] Note: extra elements in either sequence appended to the end Definition shuffle (x: xs) (y: ys) = [x, y] ++ shuffle xs ys shuffle [ ] ys = shuffle xs [ ] = ys xs 6

shuffle :: [a] -> [a] -> [a] shuffle Works shuffle (x: xs) (y: ys) = [x, y] ++ shuffle xs ys shuffle [ ] ys = ys (shf).[] L shuffle xs [ ] = xs (shf).[] R Theorem (shuffle works) n N.P(n) where P(n) shuffle [x 1, x 2, x n ] [y 1, y 2, y n ] = [x 1, y 1, x 2, y 2, x n,y n ] P(0) = shuffle [ ] [ ] = [ ] Why? Because (shf).[] L That s why! P(n+1) shuffle [x 1, x 2, x n+1 ] [y 1, y 2, y n+1 ]=[x 1, y 1, x 2, y 2, x n+1, y n+1 ] Proof of P(n+1) shuffle [x 1, x 2, x n+1 ] [y 1, y 2, y n+1 ] = shuffle (x 1 : [x 2, x 3, x n+1 ] ) (y 1 : [y 2, y 3, y n+1 ] ) (: ) (twice) = [x 1, y 1 ] ++ shuffle [x 2, x 3, x n+1 ] [y 2, y 3, y n+1 ] (shf).: = [x 1, y 1 ] ++ [x 2, y 2, x 3, y 3, x n+1, y n+1 ] P(n) = x 1 : (y 1 : [x 2, y 2, x 3, y 3, x n+1,y n+1 ] ) (++).: (twice) = [x 1, y 1, x 2, y 2, x n+1,y n+1 ] (: ) (twice) (shf).: 7

Indexing (!!) (!!):: [a] -> Int -> a (x: xs)!! 0 = x (!!).0 (x: xs)!! (n+1) = xs!! n (!!).n+1 Note: n N N = {0, 1, 2, } Pattern of computation [x 0, x 1, x 2, ]!! k = x k What do the (!!)-equations say about the following formula? [ ]!! 0 How about this formula? [ ]!! k How about these? (x: xs)!! (-1) xs!! (-1) 8

shuffle Works more formally shuffle (x: xs) (y: ys) = [x, y] ++ shuffle xs ys (shf).: Theorem (shuffle works) n N.P(n) where P(n) ( ((length xs) > n) ((length ys) > n) ) ( k, 0 k n. (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) P(0) ( ((length xs) > 0) ((length ys) > 0) ) ( k, 0 k 0. (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) = ( ((length xs) > 0) ((length ys) > 0) ) ( (((shuffle xs ys)!! 0) = (xs!! 0)) (((shuffle xs ys)!! 1) = (ys!! 0)) ) {finite -universe} = ( ( x. ws. xs = (x: ws)) ( y. zs. ys = (y: zs)) ) ( (((shuffle (x: ws) (y: zs))!! 0) = ((x: ws)!! 0)) (((shuffle (x: ws) (y: zs))!! 1) = ((y: zs)!! 0)) ) {(:), len 0 [ ], arith} = ( ( x. ws. xs = (x: ws)) ( y. zs. ys = (y: zs)) ) ( ((([x, y] ++ shuffle ws zs)!! 0) = ((x: ws)!! 0)) ((([x, y] ++ shuffle ws zs)!! 1) = ((y: zs)!! 0)) ) {(shf).:} = ( ( x. ws. xs = (x: ws)) ( y. zs. ys = (y: zs)) ) ( (x = x ) (y = y) ) { (++).:,, (!!).n+1, (!!).0} = True {= reflexive, id, Thm: (a True) = True } end of base case 9

shuffle Works more formally inductive case P(n+1) ( ((length xs) > n+1) ((length ys) > n+1) ) ( k, 0 k n+1. (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) = ( ( x. ws.xs=(x:ws) ((length ws) > n) ) ( y. zs.ys=(y:zs) ((length zs) > n)) ) ( k, 0 k n+1. (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) {len 0 [ ], } = ( ( x. ws.xs=(x:ws) ((length ws) > n) ) ( y. zs.ys=(y:zs) ((length zs) > n)) ) (( k, 0 k n.( (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) (((shuffle (x:ws) (y:zs))!!(2*(n+1))) = ((x:ws)!!(n+1))) (((shuffle (x:ws) (y:zs))!!(2*(n+1)+1)) = ((y:zs)!!(n+1))) ) {subst, finite -univ} = ( ( x. ws.xs=(x: ws) ((length ws) > n)) ( y. zs.ys=(y: zs) ((length zs) > n))) ( k, 0 k n.( (((shuffle xs ys)!! (2*k)) = (xs!! k)) (((shuffle xs ys)!! (2*k + 1)) = (ys!! k)) ) (((shuffle ws zs)!!(2*n)) = (ws!!n)) (((shuffle ws zs)!!(2*n+1)) = (zs!!n)) ) {(shf).:, (++).:,, (!!).n+1} = ( ( x. ws.xs=(x: ws) ((length ws) > n)) ( y. zs.ys=(y: zs) ((length zs) > n))) (True True True) {P(n)} = True { id, Thm: (a True) = True} qed 10

End of Lecture 11