Introduction to Sets and Logic

Slides:



Advertisements
Similar presentations
Introduction to Set Theory
Advertisements

Equivalence Relations
Chapter 2 Logic Circuits.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
Instructor: Hayk Melikya
(CSC 102) Discrete Structures Lecture 14.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
1 Section 1.7 Set Operations. 2 Union The union of 2 sets A and B is the set containing elements found either in A, or in B, or in both The denotation.
SET.   A set is a collection of elements.   Sets are usually denoted by capital letters A, B, Ω, etc.   Elements are usually denoted by lower case.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Sets 1.
Sets 1.
1 Set Theory. Notation S={a, b, c} refers to the set whose elements are a, b and c. a  S means “a is an element of set S”. d  S means “d is not an element.
1 CSE 20: Lecture 7 Boolean Algebra CK Cheng 4/21/2011.
Propositional Calculus Math Foundations of Computer Science.
1 Set Operations CS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield.
SETS A set B is a collection of objects such that for every object X in the universe the statement: “X is a member of B” Is a proposition.
Rosen 1.6. Approaches to Proofs Membership tables (similar to truth tables) Convert to a problem in propositional logic, prove, then convert back Use.
Intro to Set Theory. Sets and Their Elements A set A is a collection of elements. If x is an element of A, we write x  A; if not: x  A. Say: “x is a.
Logic Gates Circuits to manipulate 0’s and 1’s. 0’s and 1’s used for numbers Also to make decisions within the computer. In that context, 1 corresponds.
Boolean Algebra Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
1.1 Sets and Logic Set – a collection of objects. Set brackets {} are used to enclose the elements of a set. Example: {1, 2, 5, 9} Elements – objects inside.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Sets Defined A set is an object defined as a collection of other distinct objects, known as elements of the set The elements of a set can be anything:
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 7 Review Important Terms, Symbols, Concepts 7.1. Logic A proposition is a statement (not a question.
1 ENM 503 Block 1 Algebraic Systems Lesson 2 – The Algebra of Sets The Essence of Sets What are they?
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.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Language: Set of Strings
CS201: Data Structures and Discrete Mathematics I
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
1 Introduction to Abstract Mathematics Sets Section 2.1 Basic Notions of Sets Section 2.2 Operations with sets Section 2.3 Indexed Sets Instructor: Hayk.
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Mathematical Preliminaries
Sets Goal: Introduce the basic terminology of set theory.
2.1 Sets 2.2 Set Operations –Set Operations –Venn Diagrams –Set Identities –Union and Intersection of Indexed Collections 2.3 Functions 2.4 Sequences and.
Chapter 2 With Question/Answer Animations. Section 2.1.
Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
Discrete Mathematics CS 2610 January 27, part 2.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
Basic Definitions of Set Theory Lecture 23 Section 5.1 Mon, Feb 21, 2005.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Set Operations Section 2.2.
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Boolean Algebra. BOOLEAN ALGEBRA Formal logic: In formal logic, a statement (proposition) is a declarative sentence that is either true(1) or false (0).
Basic Probability. Introduction Our formal study of probability will base on Set theory Axiomatic approach (base for all our further studies of probability)
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.
Section 6.1 Set and Set Operations. Set: A set is a collection of objects/elements. Ex. A = {w, a, r, d} Sets are often named with capital letters. Order.
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.
The Relation Induced by a Partition
The Language of Sets If S is a set, then
Set Operations CS 202, Spring 2008 Epp, chapter 5.
Boolean Algebra.
Set, Combinatorics, Probability & Number Theory
RELATION KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS )
Ch. 3 stuff – Read entire Ch. 3 if you can’t remember
Basic Logic Gates 1.
Session – 2 SETS & Operations of SETS
Equivalence Relations
Equivalence Relations
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Presentation transcript:

Introduction to Sets and Logic Why do we need to know a bit of set theory? Set theory allows us to describe and classify entities So it allows us to describe and group the data that we may need to use for testing Set theory allows us to operate on groups of entities So it allows us to operate on groupings of test data Set theory allows us to extend the study to relations and functions So it allows us to relate test data or test scenarios and expected results Why do we need to know a bit about logic? Propositional logic allows us to manipulate statements and truth values of the statements; predicate logic allows us to introduce quantifiers such as “there exists” or “all” So it allows us to describe and combine test conditions and deduce validity of test coverage or validity of test results. Set theory and logic, while useful for all aspects of testing, it is most useful with functional testing (black box testing)

What is a set ? A set is a collection or a group of something. For example : a set of items in a classroom may be represented as follows. Classrooom_items = { chair1, chair2, desk1, student 1, student2, desk2, desk3, chair3, instructor, whiteboard, computer} Student_ages = {18, 17, 23, 19} A word of caution: a set can not have repetition. If you had two students of the same age, then you may be tempted to say: Student_ages = { 17, 18, 18, 23} but in set theory you can only say: Student_ages = {17, 18, 23} incorrect correct

Different Ways to Represent a Set A) Listing the elements that belong to the set, just as shown earlier: my_lucky_ numbers = {3, 106, 7689, -4} B) Providing a decision rule that defines the set possible_male_ages = { age | 0 < age ≤ 200 } C) Combinations of or redefinition of sets students_in_class = boy_students U girl_students There is a special set called the empty set which contains no element. It is represented with the symbol, Ø. For example the set, possible_male_age = { age| age ≤ -3}, is an empty set. So this set is Ø.

Common Set Operations Union : union of set A and set B is the combination of sets A and B, represented as A U B. If A= {apple, orange, grapes} and B = {shoe, tie, shirt}, then AUB = {apple, orange, grapes, shoe, tie, shirt} Intersection: intersection of set A and B is the set whose elements are composed of only the common elements from set A and set B, represented as A ∩ B. If A and B are as defined above, then A∩B = Ø If A = { apple, grape, orange} and B = { tomato, grape, lettuce}, then A∩B = {grape} Complement: complement of a set A is the set that has all the elements that are not in A, represented as A’ or ¬A If A = { numbers | numbers > 0 }, then ¬A = {numbers| numbers ≤ 0 }

Some more Set Operations Minus: set A minus set B is the set which contains all elements in A that is not in B, represented as (A – B). this set is sometimes known as “relative complement” of B with respect to A. If A = {2, 34, 67, 98, -3, -54, -300} and B = { integers | integers ≤ 0}, then (A – B) = {2,34,67,98} Symmetric Difference: the symmetric difference of sets A and B, represented as A B, is a set that is defined as the result of operations, {A U B} – { A ∩ B} If A = { apple, orange, grape} and B = { pear, grape, orange}, then A B = {apple, pear} + +

Specification vs Implementation vs Test Cases Actual Expected 2 3 1 5 4 6 7 Look at this earlier Venn Diagram Tested The area represented by “number 2” may be represented as [{Expected} ∩{Actual} ] – {Tested} Test Cases

A few More Definitions Set A is a subset of set B, written A B, if every element in A is also an element in B. Set A is a proper subset of set B, written A B, if it is a subset of B and there exists at least one element in B that is not in A (or B – A ≠ Ø). Set A and set B are equal, written A = B, if every element in A is in B and vise versa.

Set Partition A partitioning of a set is a division of a set into groups. This is a useful concept for many areas where we want to take samples from groups formed based on some criteria. Example: performing an opinion survey of teenagers on clothes. We may partition the survey by: Age groups - {13 to 15} , {16 to 17}, {18 to 19} Gender - { male} , {female} Types of schools - {Catholic}, {Jewish}, {Baptist}, {non-religious public} This concept is important when we have to design test cases based on picking the input data. Formally, a dividing of a set X into subset x1, x2, - - - xn is called a partitioning of X if the following is true: a) x1 U x2 U - - - U xn = X b) for any xi and xk , where i ≠ k , xi ∩ xk = Ø For later: Discuss - partitioning the outputs of the “triangle” problem for testing

Some “Rules” about sets A U Ø = A A ∩ Ø = Ø (A’)’ = A Commutative rules: A U B = B U A; A ∩ B = B ∩ A Associative rules: A U (B U C) = (A U B) U C A ∩ (B ∩ C) = (A ∩ B) ∩ C Distributive rules : A ∩ (B U C) = (A ∩ B) U (A ∩ C) A U (B ∩ C) = (A U B) ∩ (A U C) DeMorgan’s rules: ¬(A U B) = ¬A ∩ ¬B ¬(A ∩ B) = ¬A U ¬B

Informally - Relation A Relation is, as the English word says, a “connection” between two sets. Given a set A = {Tom, Sam, Sally, Jane} and a set B = (Joe, Mary, Abe}, then a “relation” such as “ parent of” may be defined between these set B and A. If Joe is the father of Sam and Mary is the mother of Tom, then the relation, B “parent of” A, is true with some of the elements. For the above sets of A and B, there may or may not be any “meaningful” relation.

Relationship between Two Sets SWE_students Good_Programs written by The arrows represent the relationship, “written by.” Then one can see that 3 of the Good_Programs are written by 2 of the SWE students.

Relation (more formally) Given two sets A and B, the cross-product of A x B is the set composed of paired items, where first element of the pair is from A and the second element of the pair is from B. Example : A = {3. 4, 8} and B = {mod_x, mod_y} then cross-product of A x B = { (3, mod_x), (4, mod_x), (8,mod_x), (3, mod_y), (4, mod_y) , (8, mod_y) } Given a set A and a set B, a relation, R, is a subset of cross-product of A and B. So R A x B . Example : A = { tom, mary} and B = {abu, kathy}, A x B = { (tom, abu), (tom, kathy), (mary, abu), (mary, kathy) }. If kathy is the sister of tom, then a relation, R, called “brother of” is a subset of A x B where “brother of” = { (tom, kathy) }

Some Properties of Relation A relation, R1, defined over a set A, is said to be reflexive if for every a in set A, (a,a) is in R1. Example: If A is set of positive integers and R1 is the “=“ relation, then R1 is reflexive because every positive integer = itself. But if R1 were defined as >, then R1 is not reflexive. A relation, R2, is said to be symmetric if for every (a,b) in R2, (b,a) is also inR2. Example: if for (a,b) in R2 means a is b’s classmate, then b is also a’s classmate. Thus (b,a) is also in R2. But if R2 is defined as (a,b) mean a is b’s father, the R2 is not symmetric. A relation, R3, is said to be transitive if for every (a.b) and (b,c) in R3 implies that (a,c) is in R3. Example: If R3 is defined as “>”, then (7,4) and (4,2) in R3 implies that (7,2) is also in R3 because 7 > 2. Example: R3 defined as “mother of” relation is not transitive There is a relation called equivalence relation which is reflexive, symmetric, and transitive. We will use the partitioning of test data into subsets that are each considered to be an equivalence class and pick a test case from each class.

Function is a special type of relation. A relation, RF, is a function if for every (x,y) in RF and (x,z) in RF implies that y= z. RF is a function RF is a non-function Is the inverse, RF-1, a function? Is the inverse, RF-1, a function?

Simple Logic: Propositional Calculus A proposition is a statement. A proposition, just like a statement, carries the value of True or False, but not both. Example: Let X be the proposition, “Howard is a student in SWE 3643.” Then X is either True or False. Example: Let Y be the proposition, “It will rain tomorrow.” Is Y True or False ? Note that “it will rain tomorrow” is not a proposition that can be handled by propositional calculus because its truth vale can not determined until tomorrow.

Basic Operators of Propositional Calculus Let P and Q be propositions, then the truth values of 5 logical operators (NOT,AND, OR, Exclusive OR, Implies) is shown in the following truth table. p q ¬q P Λ q P v q P q + P → q T T F T T F T T F T F T T F F T F F T T T F F T F F F T Legend: ¬ is NOT ; Λ is logical AND; v is logical OR ; is logical Exclusive OR ; → is logical Implies. +

Logical Implies All the truth operations are quite intuitive, except for “implies,” also known as “if ---then” P implies Q intuitively says that when P is true then Q must be true It is also intuitive that when P is true then Q can not be false. What happens when P is NOT True? Propositional Calculus defines this situation as True regardless of the truth value of Q. Sometimes “P implies Q,” P →Q, is stated as { (P AND Q ) OR (NOT P) }. Look at the previous truth table for (PΛ Q) OR ( ¬P)

Some Logical Expression Rules Simple ones: P Λ True = P P v False = P P v True = True P Λ False = False ¬ (¬ P) = P P Λ Q = Q Λ P P v Q = Q v P Associative : (P v Q) v R = P v (Q v R) ; ( P Λ Q) Λ R = P Λ (Q Λ R) Distributive: P Λ (Q v R) = (P Λ Q) v (P Λ R) ; P v (Q Λ R) = (P v Q) Λ (P v R) Demorgan’s Law : ¬ (P Λ Q) = ¬P v ¬Q ¬ (P v Q) = ¬P Λ ¬Q Use the truth table to prove to yourself one of the DeMorgan’s Law