SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Similar documents
SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Recursively Defined Functions

SC/MATH Boolean Formulae. Ref: G. Tourlakis, Mathematical Logic, John Wiley & Sons, York University

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Lamé s Theorem. Strings. Recursively Defined Sets and Structures. Recursively Defined Sets and Structures

Backtracking. The Eight Queens Problem. The Eight Queens Problem. The Eight Queens Problem. The Eight Queens Problem. Chapter 5

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Announcements. CS243: Discrete Structures. Strong Induction and Recursively Defined Structures. Review. Example (review) Example (review), cont.

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Basic Counting Principles: The Product Rule

Computer Science 236 Fall Nov. 11, 2010

Backtracking. Module 6. The Eight Queens Problem. CS 147 Sam Houston State University Dr. McGuire. Backtracking. Recursion Revisited

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Propositional Logic. Andreas Klappenecker

Lecture Chapter 6 Recursion as a Problem Solving Technique

Recursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences

Chapter 2 & 3: Representations & Reasoning Systems (2.2)

What if current foundations of mathematics are inconsistent? Vladimir Voevodsky September 25, 2010

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

Warmup Problem. Translate the following sentence from English into Propositional Logic. I want to eat ice cream even though I am on a diet.

Math 3336 Section 6.1 The Basics of Counting The Product Rule The Sum Rule The Subtraction Rule The Division Rule

Recursive Definitions Structural Induction Recursive Algorithms

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

Recursion and Structural Induction

Programming Languages Third Edition

Chapter 3: Propositional Languages

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

This book is licensed under a Creative Commons Attribution 3.0 License

COMP 330 Autumn 2018 McGill University

Quiz 1: Solutions J/18.400J: Automata, Computability and Complexity. Nati Srebro, Susan Hohenberger

Chapter Summary. Recursively defined Functions. Recursively defined sets and Structures Structural Induction

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

Recursive definition of sets and structural induction

Inference rule for Induction

CS 220: Discrete Structures and their Applications. Recursive objects and structural induction in zybooks

To illustrate what is intended the following are three write ups by students. Diagonalization

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Recursion as a Problem-Solving Technique. Chapter 5

Virtual World Development

Discrete Structures. Fall Homework3

CIT3130: Theory of Computation. Regular languages

Consider a description of arithmetic. It includes two equations that define the structural types of digit and operator:

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Math 485, Graph Theory: Homework #3

Handout 9: Imperative Programs and State

Chapter 1: Number and Operations

Introduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms

Mathematical Induction

Counting Product Rule

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

Boolean Algebra. P1. The OR operation is closed for all x, y B x + y B

Context-Free Languages & Grammars (CFLs & CFGs) Reading: Chapter 5

CS173 Longest Increasing Substrings. Tandy Warnow

Limits and Their Properties. Copyright Cengage Learning. All rights reserved.

Standard Boolean Forms

Ma/CS 6b Class 5: Graph Connectivity

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

LECTURE 2 An Introduction to Boolean Algebra

Formal Semantics of Programming Languages

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

ECS 120 Lesson 7 Regular Expressions, Pt. 1

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Chapter 3. Describing Syntax and Semantics

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

Solution Set 8 Date: 1 December, 1992

Formal Semantics of Programming Languages

1.1 - Introduction to Sets

Operators. Java operators are classified into three categories:

CS402 - Theory of Automata Glossary By

Alphabets, strings and formal. An introduction to information representation

SECTION 5.1. Sequences

Boolean Algebra & Digital Logic

11.2 Eulerian Trails

Action graphs and Catalan numbers

Binary Search to find item in sorted array

Slides for Faculty Oxford University Press All rights reserved.

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms

Recursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Lecture 5: Formation Tree and Parsing Algorithm

Glynda, the good witch of the North

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

Limits and an Introduction to Calculus. Copyright Cengage Learning. All rights reserved.

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

MATH20902: Discrete Maths, Solutions to Problem Set 1. These solutions, as well as the corresponding problems, are available at

Lecture 2 Finite Automata

What does this print?

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

CS4215 Programming Language Implementation. Martin Henz

Compiler Construction

6 NFA and Regular Expressions

Discrete Mathematics 1

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Reverse Polish notation in constructing the algorithm for polygon triangulation

Today. Types of graphs. Complete Graphs. Trees. Hypercubes.

Transcription:

CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/

SECTION 5.9 General Recursive Definitions and Structural Induction Copyright Cengage Learning. All rights reserved.

Recursively Defined Sets 3

Recursively Defined Sets To define a set of objects recursively, you identify a few core objects as belonging to the set and give rules showing how to build new set elements from old. A recursive definition for a set consists of the following: I. BASE: A statement that certain objects belong to the set. II. RECURSION: A collection of rules indicating how to form new objects from those already known to be in the set. III. RESTRICTION: A statement that no objects belong to the set other than those defined in I and II. 4

Example 1 Recursive Definition of Boolean Expressions An expression composed of boolean variables, as letters from the alphabet L = {a, b, c,..., x, y, z}, and the connectives,, and ~ is called a boolean expression and are defined recursively. I. BASE: Each symbol of the alphabet L is a Boolean expression. II. RECURSION: If P and Q are Boolean expressions, then so are (a) (P Q) and (b) (P Q) and (c) ~P. III. RESTRICTION: There are no Boolean expressions over the alphabet L other than those obtained from I and II. 5

Example 1 Recursive Definition of Boolean Expressions cont d Derive the fact that the following is a Boolean expression over the English alphabet {a, b, c,..., x, y, z}: (~(p q) (~r p)). (1) By I, p, q, and r are Boolean expressions. (2) By (1) and II(a) and (c), (p q) and ~ r are Boolean expressions. (3) By (2) and II(c) and (a), ~(p q) and (~ r p) are Boolean expressions. (4) By (3) and II(b), (~ (p q) (~ r p)) is a Boolean expression. 6

Example 4 Parenthesis Structures Certain configurations of parentheses in algebraic expressions are legal [such as(())() and()()()], whereas others are not [such as)())) and()))((( ]. Here is a recursive definition to generate the set P of legal configurations of parentheses. I. BASE: () is in P. II. RECURSION: a. If E is in P, so is (E). b. If E and F are in P, so is EF. 7

Example 4 Parenthesis Structures cont d III. RESTRICTION: No configurations of parentheses are in P other than those derived from I and II above. Derive the fact that (())() is in P. Solution: (1) By I, () is in P. (2) By (1) and II(a), (()) is in P. (3) By (2), (1), and II(b), (())() is in P. 8

Proving Properties about Recursively Defined Sets 9

Proving Properties about Recursively Defined Sets When a set has been defined recursively, a version of mathematical induction, called structural induction, can be used to prove that every object in the set satisfies a given property. 10

Proving Properties about Recursively Defined Sets 11

Example 5 A Property of the Set of Parenthesis Structures Consider the set P of all grammatical configurations of parentheses defined in Example 4. Prove that every configuration in P contains an equal number of left and right parentheses. Solution: Proof (by structural induction): Given any parenthesis configuration, let the property be the claim that it has an equal number of left and right parentheses. Show that each object in the BASE for P satisfies the property: The only object in the base for P is (), which has one left parenthesis and one right parenthesis, so it has an equal number of left and right parentheses. 12

Example 5 Solution cont d Show that for each rule in the RECURSION for P, if the rule is applied to an object in P that satisfies the property, then the object defined by the rule also satisfies the property: The recursion for P consists of two rules denoted II(a) and II(b). Suppose E is a parenthesis configuration that has an equal number of left and right parentheses. When rule II(a) is applied to E, the result is (E), so both the number of left parentheses and the number of right parentheses are increased by one. Since these numbers were equal to start with, they remain equal when each is increased by one. 13

Example 5 Solution cont d Suppose E and F are parenthesis configurations with equal numbers of left and right parentheses. Say E has m left and right parentheses, and F has n left and right parentheses. When rule II(b) is applied, the result is EF, which has an equal number, namely m + n, of left and right parentheses. Thus when each rule in the RECURSION is applied to a configuration of parentheses in P with an equal number of left and right parentheses, the result is a configuration with an equal number of left and right parentheses. Therefore, every structure in P has an equal number of left and right parentheses. 14