Chapter 1: Foundations: Sets, Logic, and Algorithms

Slides:



Advertisements
Similar presentations
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Advertisements

© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Sets DISCRETE STRUCTURE ABDUL BASIT TAHIR, KAMRAN ALI, FAIZAN ILLAHI, NOMAN AHMAD, ARSALAN MUBASHIR.
Discrete Mathematics CSE 2353 Fall 2007
Sets 1.
Sets 1.
Discrete Math 6A Max Welling. Recap 1. Proposition: statement that is true or false. 2. Logical operators: NOT, AND, OR, XOR, ,  3. Compound proposition:
Adapted from Discrete Math
Sets.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Systems of Linear Equation and Matrices
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
Chapter 3 – Set Theory  .
Homework Review notes Complete Worksheet #1. Homework Let A = {a,b,c,d}, B = {a,b,c,d,e}, C = {a,d}, D = {b, c} Describe any subset relationships. 1.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2011 Most slides modified from Discrete Mathematical Structures: Theory and Applications.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 7 Review Important Terms, Symbols, Concepts 7.1. Logic A proposition is a statement (not a question.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
DISCRETE COMPUTATIONAL STRUCTURES
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Sets and Sentences Open Sentences Foundations of Real Analysis.
CompSci 102 Discrete Math for Computer Science
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2005.
Copyright © Cengage Learning. All rights reserved.
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Mathematical Preliminaries
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Chapter 2 With Question/Answer Animations. Section 2.1.
Basic Structures: Sets, Functions, Sequences, and Sums.
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Fr: Discrete Mathematics by Washburn, Marlowe, and Ryan.
Discrete Mathematics CS 2610 August 31, Agenda Set Theory Set Builder Notation Universal Set Power Set and Cardinality Set Operations Set Identities.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
Discrete Mathematics IT223 Sem. 2, SY
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2011 Most slides modified from Discrete Mathematical Structures: Theory and Applications.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2010 Most slides modified from Discrete Mathematical Structures: Theory and Applications by D.S. Malik.
CPCS 222 Discrete Structures I
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Discrete Mathematics Margaret H. Dunham
Foundations: Sets, Logic, and Algorithms
Chapter 2 Sets and Functions.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Set Operations CS 202, Spring 2008 Epp, chapter 5.
CSNB 143 Discrete Mathematical Structures
Set, Combinatorics, Probability & Number Theory
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
Chapter 1 Logic and Proofs Homework 2 Given the statement “A valid password is necessary for you to log on to the campus server.” Express the statement.
DISCRETE COMPUTATIONAL STRUCTURES
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
DISCRETE COMPUTATIONAL STRUCTURES
CS100: Discrete structures
CHAPTER 1: LOGICS AND PROOF
2.1 Sets Dr. Halimah Alshehri.
Advanced Algorithms Analysis and Design
Discrete Mathematics CS 2610
The aim of education is to teach students how to think rather than what to think. Sets The set is the fundamental discrete structure on which all other.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Foundations of Discrete Mathematics
Presentation transcript:

Chapter 1: Foundations: Sets, Logic, and Algorithms Discrete Mathematical Structures: Theory and Applications

Sets Definition: Well-defined collection of distinct objects Members or Elements: part of the collection Roster Method: Description of a set by listing the elements, enclosed with braces Examples: Vowels = {a,e,i,o,u} Primary colors = {red, blue, yellow} Membership examples “a belongs to the set of Vowels” is written as: a  Vowels “j does not belong to the set of Vowels: j  Vowels Discrete Mathematical Structures: Theory and Applications

Sets Set-builder method A = { x | x  S, P(x) } or A = { x  S | P(x) } A is the set of all elements x of S, such that x satisfies the property P Example: If X = {2,4,6,8,10}, then in set-builder notation, X can be described as X = {n  Z | n is even and 2  n  10} Discrete Mathematical Structures: Theory and Applications

Sets Standard Symbols which denote sets of numbers N : The set of all natural numbers (i.e.,all positive integers) Z : The set of all integers Z* : The set of all nonzero integers E : The set of all even integers Q : The set of all rational numbers Q* : The set of all nonzero rational numbers Q+ : The set of all positive rational numbers R : The set of all real numbers R* : The set of all nonzero real numbers R+ : The set of all positive real numbers C : The set of all complex numbers C* : The set of all nonzero complex numbers Discrete Mathematical Structures: Theory and Applications

Sets Subsets Superset “X is a subset of Y” is written as X  Y “X is not a subset of Y” is written as X Y Example: X = {a,e,i,o,u}, Y = {a, i, u} and z = {b,c,d,f,g} Y  X, since every element of Y is an element of X Y Z, since a  Y, but a  Z Superset X and Y are sets. If X  Y, then “X is contained in Y” or “Y contains X” or Y is a superset of X, written Y  X Discrete Mathematical Structures: Theory and Applications

Sets Set Equality Empty (Null) Set X and Y are sets. They are said to be equal if every element of X is an element of Y and every element of Y is an element of X, i.e. X  Y and Y  X Examples: {1,2,3} = {2,3,1} X = {red, blue, yellow} and Y = {c | c is a primary color} Therefore, X=Y Empty (Null) Set A Set is Empty (Null) if it contains no elements. The Empty Set is written as  The Empty Set is a subset of every set Discrete Mathematical Structures: Theory and Applications

Sets Finite and Infinite Sets X is a set. If there exists a nonnegative integer n such that X has n elements, then X is called a finite set with n elements. If a set is not finite, then it is an infinite set. Examples: Y = {1,2,3} is a finite set P = {red, blue, yellow} is a finite set E , the set of all even integers, is an infinite set  , the Empty Set, is a finite set with 0 elements Discrete Mathematical Structures: Theory and Applications

Sets Cardinality of Sets Let S be a finite set with n distinct elements, where n ≥ 0. Then |S| = n , where the cardinality (number of elements) of S is n Example: If P = {red, blue, yellow}, then |P| = 3 Singleton A set with only one element is a singleton H = { 4 }, |H| = 1, H is a singleton Discrete Mathematical Structures: Theory and Applications

Sets Power Set Universal Set For any set X ,the power set of X ,written P(X),is the set of all subsets of X Example: If X = {red, blue, yellow}, then P(X) = {  , {red}, {blue}, {yellow}, {red,blue}, {red, yellow}, {blue, yellow}, {red, blue, yellow} } Universal Set An arbitrarily (randomly) chosen, but fixed set Discrete Mathematical Structures: Theory and Applications

Sets Union of Sets Example: If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then X∪Y = {1,2,3,4,5,6,7,8,9} Discrete Mathematical Structures: Theory and Applications

Sets Intersection of Sets Example: If X = {1,2,3,4,5} and Y = {5,6,7,8,9}, then X ∩ Y = {5} Discrete Mathematical Structures: Theory and Applications

Sets Disjoint Sets Example: If X = {1,2,3,4,} and Y = {6,7,8,9}, then X ∩ Y =  Discrete Mathematical Structures: Theory and Applications

Sets Discrete Mathematical Structures: Theory and Applications

Sets Discrete Mathematical Structures: Theory and Applications

Sets Example: If A = {a,b,c}, B = {x, y, z} and C = {1,2,3} then A ∩ B =  and B ∩ C =  and A ∩ C = . Therefore, A,B,C are pairwise disjoint Discrete Mathematical Structures: Theory and Applications

Sets Difference Example: If X = {a,b,c,d} and Y = {c,d,e,f}, then X – Y = {a,b} and Y – X = {e,f} Discrete Mathematical Structures: Theory and Applications

Sets Complement Example: If U = {a,b,c,d,e,f} and X = {c,d,e,f}, then X’ = {a,b} Discrete Mathematical Structures: Theory and Applications

Sets Discrete Mathematical Structures: Theory and Applications

Sets Discrete Mathematical Structures: Theory and Applications

Sets Discrete Mathematical Structures: Theory and Applications

Sets Ordered Pair Cartesian Product X and Y are sets. If x  X and y  Y, then an ordered pair is written (x,y) Order of elements is important. (x,y) is not necessarily equal to (y,x) Cartesian Product The Cartesian product of two sets X and Y ,written X × Y ,is the set X × Y ={(x,y)|x ∈ X , y ∈ Y} For any set X, X ×  =  =  × X Example: X = {a,b}, Y = {c,d} X × Y = {(a,c), (a,d), (b,c), (b,d)} Y × X = {(c,a), (d,a), (c,b), (d,b)} Discrete Mathematical Structures: Theory and Applications

Sets Diagonal of a Set δx = {(x,x) | x ∈ X} For a set X ,the set δx , is the diagonal of X, defined by δx = {(x,x) | x ∈ X} Example: X = {a,b,c}, δx = {(a,a), (b,b), (c,c)} Discrete Mathematical Structures: Theory and Applications

Sets Computer Representation of Sets A Set may be stored in a computer in an array as an unordered list Problem: Difficult to perform operations on the set. Solution: use Bit Strings A Bit String is a sequence of 0s and 1s Length of a Bit String is the number of digits in the string Elements appear in order in the bit string A 0 indicates an element is absent, a 1 indicates that the element is present Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Definition: Methods of reasoning, provides rules and techniques to determine whether an argument is valid Theorem: a statement that can be shown to be true (under certain conditions) Example: If x is an even integer, then x + 1 is an odd integer This statement is true under the condition that x is an integer is true Discrete Mathematical Structures: Theory and Applications

Mathematical Logic A statement, or a proposition, is a declarative sentence that is either true or false, but not both Lowercase letters denote propositions Examples: p: 2 is an even number (true) q: 3 is an odd number (true) r: A is a consonant (false) The following are not propositions: p: My cat is beautiful q: Are you in charge? Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Truth value Negation One of the values “truth” or “falsity” assigned to a statement True is abbreviated to T or 1 False is abbreviated to F or 0 Negation The negation of p, written ∼p, is the statement obtained by negating statement p Truth values of p and ∼p are opposite Symbol ~ is called “not” ~p is read as as “not p” Example: p: A is a consonant ~p: it is the case that A is not a consonant q: Are you in charge? Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Truth Table Conjunction Let p and q be statements.The conjunction of p and q, written p ^ q , is the statement formed by joining statements p and q using the word “and” The statement p∧q is true if both p and q are true; otherwise p∧q is false Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Conjunction Truth Table for Conjunction: Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Disjunction Let p and q be statements. The disjunction of p and q, written p ∨ q , is the statement formed by joining statements p and q using the word “or” The statement p∨q is true if at least one of the statements p and q is true; otherwise p∨q is false The symbol ∨ is read “or” Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Disjunction Truth Table for Disjunction: Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Implication Let p and q be statements. The statement “if p then q” is called an implication or condition. The implication “if p then q” is written p  q p  q is read: “If p, then q” “p is sufficient for q” q if p q whenever p Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Implication Truth Table for Implication: p is called the hypothesis, q is called the conclusion Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Implication Let p: Today is Sunday and q: I will wash the car. The conjunction p  q is the statement: p  q : If today is Sunday, then I will wash the car The converse of this implication is written q  p If I wash the car, then today is Sunday The inverse of this implication is ~p  ~q If today is not Sunday, then I will not wash the car The contrapositive of this implication is ~q  ~p If I do not wash the car, then today is not Sunday Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Biimplication Let p and q be statements. The statement “p if and only if q” is called the biimplication or biconditional of p and q The biconditional “p if and only if q” is written p  q p  q is read: “p if and only if q” “p is necessary and sufficient for q” “q if and only if p” “q when and only when p” Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Biconditional Truth Table for the Biconditional: Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Statement Formulas Definitions Symbols p ,q ,r ,...,called statement variables Symbols ~, ∧, ∨, →,and ↔ are called logical connectives A statement variable is a statement formula If A and B are statement formulas, then the expressions (~A ), (A ∧ B) , (A ∨ B ), (A → B ) and (A ↔ B ) are statement formulas Expressions are statement formulas that are constructed only by using 1) and 2) above Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Precedence of logical connectives is: ~ highest ∧ second highest ∨ third highest → fourth highest ↔ fifth highest Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Example: Let A be the statement formula (~(p ∨q )) → (q ∧p ) Truth Table for A is: Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Tautology Contradiction A statement formula A is said to be a tautology if the truth value of A is T for any assignment of the truth values T and F to the statement variables occurring in A Contradiction A statement formula A is said to be a contradiction if the truth value of A is F for any assignment of the truth values T and F to the statement variables occurring in A Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Logically Implies Logically Equivalent A statement formula A is said to logically imply a statement formula B if the statement formula A → B is a tautology. If A logically implies B, then symbolically we write A → B Logically Equivalent A statement formula A is said to be logically equivalent to a statement formula B if the statement formula A ↔ B is a tautology. If A is logically equivalent to B , then symbolically we write A ≡ B (or A ⇔ B) Discrete Mathematical Structures: Theory and Applications

Mathematical Logic Discrete Mathematical Structures: Theory and Applications

Algorithms Definition: step-by-step problem-solving process in which a solution is arrived at in a finite amount of time All algorithms have the following properties: Input : For example, a set of numbers to find the sum of the numbers Output : For example, the sum of the numbers Precision : Each step of the algorithm is precisely defined Uniqueness : Results of each step are unique and depend on the input and results of previous step Finiteness : Algorithm must terminate after executing a finite number of steps Generality : Algorithm is general in that it applies to a set of inputs Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions The symbol := is called the assignment operator Example: The statement x := a is read as “assign the value a to x” or “x gets the value a” or “copy the value of a into x” x := a is also known as an assignment statement Control Structures One way-selection if booleanExpression then statement If booleanExpression evaluates to true, statement is evaluated Two way-selection if booleanExpression then statement1 else statement2 If booleanExpression evaluates to true , statement1 executes, otherwise statement2 executes Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Control Structures The while loop takes the form: while booleanExpression do loopBody The booleanExpression is evaluated. If it evaluates to true, loopBody executes. Thereafter loopBody continues to execute as long as booleanExpression is true The for loop takes the form: for var := start to limit do loopBody var is an integer variable. The variable var is set to the value specified by start. If var limit, loopBody executes. After executing the loopBody , var is incremented by 1. The statement continues to execute until var > limit Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Control Structures The do/while loop takes the form: do loopBody while booleanExpression The loopBody is executed first and then the booleanExpression is evaluated. The loopBody continues to execute as long as the booleanExpression is true Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Block of Statement To consider a set of statements a single statement, the statements are written between the words begin and end begin statement1 statement2 ... statementn; end Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Return Statement The return statement is used to return the value computed by the algorithm and it takes the following form: return expression; The value specified by expression is returned. In an algorithm, the execution of a return statement also terminates the algorithm Read and Print Statements read x; Read the next value and store it in the variable x print x; Output the value of x Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Arrays (List) A list is a set of elements of the same type The length of the list is the number of elements in the list L[1...n ]. L is an array of n components, indexed 1 to n . L[i ] denotes the ith element of L For data in tabular form, a two-dimensional array is used: M[1...m,1...n ] M is a two-dimensional array of m rows and n columns The rows are indexed 1 to m and the columns are indexed 1 to n M[i,j] denotes the (i,j)th element of M, that is, the element at the ith row and jth column position Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Subprograms (Procedures) In a programming language,an algorithm is implemented in the form of a subprogram, a.k.a. a subroutine or a module Two types of subprograms Functions Returns a unique value Procedure Other types of subprograms body of the function or procedure is enclosed between the words begin and end the execution of a return statement in a function terminates the function Discrete Mathematical Structures: Theory and Applications

Algorithms Pseudocode Conventions Comments In describing the steps of an algorithm, comments are included wherever necessary to clarify the steps Two types of comments: single-line and multi-line Single-line comments start anywhere in the line with the pair of symbols // Multi-line comments are enclosed between the pair of symbols /* and */ Specifies what the algorithm does, as well as the input and output Discrete Mathematical Structures: Theory and Applications