LECTURE 8: SETS. Software Engineering Mike Wooldridge

Similar documents
CSC Discrete Math I, Spring Sets

Review of Sets. Review. Philippe B. Laval. Current Semester. Kennesaw State University. Philippe B. Laval (KSU) Sets Current Semester 1 / 16

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

Chapter 3. Set Theory. 3.1 What is a Set?

2.1 Sets 2.2 Set Operations

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

SET DEFINITION 1 elements members

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T

1.1 - Introduction to Sets

Sets. Sets. Subset, universe. Specifying sets, membership. Examples: Specifying a set using a predicate. Examples

Today s Topics. What is a set?

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Set and Set Operations

Introduction II. Sets. Terminology III. Definition. Definition. Definition. Example

2 Review of Set Theory

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

A set with only one member is called a SINGLETON. A set with no members is called the EMPTY SET or 2 N

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

SOFTWARE ENGINEERING DESIGN I

Some basic set theory (and how it relates to Haskell)

CSC 501 Semantics of Programming Languages

Relational Database: The Relational Data Model; Operations on Database Relations

Sets. Margaret M. Fleck. 15 September 2010

CS100: DISCRETE STRUCTURES

Slides for Faculty Oxford University Press All rights reserved.

Johns Hopkins Math Tournament Proof Round: Point Set Topology

Lecture 1. 1 Notation

CS 512, Spring 2017: Take-Home End-of-Term Examination

COMP1730/COMP6730 Programming for Scientists. Dictionaries and sets


Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

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

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

1 Introduction CHAPTER ONE: SETS

Material from Recitation 1

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Arithmetic expressions can be typed into Maple using the regular operators:

Mathematically Rigorous Software Design Review of mathematical prerequisites

Sets and set operations

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

9.5 Equivalence Relations

Discrete Mathematics Lecture 4. Harper Langston New York University

Sets. {1, 2, 3, Calvin}.

Discrete Mathematics

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

MITOCW watch?v=kz7jjltq9r4

Relational terminology. Databases - Sets & Relations. Sets. Membership

2 Sets. 2.1 Notation. last edited January 26, 2016

Topology notes. Basic Definitions and Properties.

This Lecture. We will first introduce some basic set theory before we do counting. Basic Definitions. Operations on Sets.

Information Systems. Relational Databases. Nikolaj Popov

Lecture : Topological Space

Lecture 15: The subspace topology, Closed sets

Informatics 1: Data & Analysis

Lecture - 8A: Subbasis of Topology

CS103 Spring 2018 Mathematical Vocabulary

Algebra of Sets. Aditya Ghosh. April 6, 2018 It is recommended that while reading it, sit with a pen and a paper.

Propositional Logic. Part I

What is an algebra? A formal system of manipulation of symbols to deal with general statements of relations.

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

Solution: It may be helpful to list out exactly what is in each of these events:

Cantor s Diagonal Argument for Different Levels of Infinity

What is a Set? Set Theory. Set Notation. Standard Sets. Standard Sets. Part 1.1. Organizing Information

SETS. Sets are of two sorts: finite infinite A system of sets is a set, whose elements are again sets.

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

CMPSCI 250: Introduction to Computation. Lecture #7: Quantifiers and Languages 6 February 2012

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 4

Comparing sizes of sets

SWEN-220 Mathematical Models of Software

Problem One: A Quick Algebra Review

SQL Data Querying and Views

Modern Programming Languages. Lecture LISP Programming Language An Introduction

Domination, Independence and Other Numbers Associated With the Intersection Graph of a Set of Half-planes

What is Set? Set Theory. Notation. Venn Diagram

4 Mathematical Data Types

6.001 Notes: Section 8.1

The Language of Sets and Functions

Lists. Michael P. Fourman. February 2, 2010

Computer Science and Mathematics. Part I: Fundamental Mathematical Concepts Winfried Kurth

FMA901F: Machine Learning Lecture 6: Graphical Models. Cristian Sminchisescu

Programming Languages Third Edition

Chapter 3. Semantics. Topics. Introduction. Introduction. Introduction. Introduction

CSE20: Discrete Mathematics

Formally-Proven Kosaraju s algorithm

Logic as a framework for NL semantics. Outline. Syntax of FOL [1] Semantic Theory Type Theory

Notes for Recitation 8

Figure 1.1: This is an illustration of a generic set and its elements.

THREE LECTURES ON BASIC TOPOLOGY. 1. Basic notions.

Reasoning About Set Comprehensions

Lofting 3D Shapes. Abstract

Virtual World Development

From: FM 2006 Alloy Intro and Logic. Greg Dennis and Rob Seater Software Design Group, MIT

Lecture 5: Duality Theory

Software Engineering: A Practitioner s s Approach, 6/e Roger Pressman. Chapter 28 Formal Methods

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.

Relational Data Model

Transcription:

LECTURE 8: SETS Mike Wooldridge

1 What is a Set? The concept of a set is used throughout mathematics; its formal definition matches closely our intuitive understanding of the word. Definition: A set is an unordered collection of distinct objects. We can build sets containing any objects that we like, but usually we consider sets whose elements have some property in common. The objects comprising a set are called its elements or members. Note that: sets do not contain duplicates; the order of elements in a set is not significant. Mike Wooldridge 1

2 Defining Sets Enumeration By convention, a set can be defined by enumerating its components in curly brackets. EXAMPLE. Vowels == {a, e, i, o, u} EXAMPLE. Weekend == {Sat, Sun} The double-equals symbol (==) is read is defined to be ; it gives us a method for naming sets, so that we can subsequently use them. (We can t use sets unless they have been previously defined in some way.) Mike Wooldridge 2

In Z, another equivalent method for defining sets is allowed... EXAMPLE. Vowels := a e i o u Another standard convention is to allow number ranges... EXAMPLE. Days == 1.. 365 Mike Wooldridge 3

Some sets occur so often that they have been pre-defined and given standard names. IN the natural numbers: IN = {0, 1, 2, 3,...} IN 1 the natural numbers greater than 0: IN 1 = {1, 2, 3,...} Z the integers: Z = {..., 2, 1, 0, 1, 2,...} IB the truth values: IB = {true, false} Mike Wooldridge 4

3 Relational Operators for Sets The set theory in Z provides us with a variety of relational operators for expressing the properties of sets. 3.1 Set Membership To express the fact that an object x is a member of set S, we write x S Note that an expression with this form is either true or false; the thing is either a member or not. EXAMPLES. a {a, e, i, o, u} 1 IN 23 Days Mike Wooldridge 5

Note that the r.h.s. of the expression x S must be an expression which returns a set of values of the same type as the expression on the l.h.s returns. EXAMPLE. This isn t allowed: {1, 2, 3} {4, 5, 6} But this is: {1, 2, 3} {{6, 7, 8}, {1, 2, 3}} and so is this: {1, 2, 3} {{6, 2, 1}} The first legal expression above evaluates to true; the second evaluates to false. Note that Z differs in this respect from what might be called naive set theory: Z is said to be a typed set theory, (because we must check the types on the l.h.s and r.h.s. of our expressions.) Mike Wooldridge 6

3.2 Set Equality Definition: Let S and T be arbitrary sets of the same type. Then S = T is true iff S and T contain precisely the same members. Note that the order in which values occur in the set is not significant. EXAMPLES. The following is a true expression: {1, 2, 3} = {2, 3, 1} as is this Days = 1.. 365 however, the following is not: Days = IN. Mike Wooldridge 7

3.3 Subsets Definition: Let S and T be arbitrary sets of the same type. Then S T is true iff every member of S is also a member of y. EXAMPLES. The following are true expressions: {1, 2, 3} IN; {true} IB; IN Z; IN 1 IN; {1, 2, 3} {1, 2, 3}. whereas the following are not: {1, 2, 3, 4} {1, 2, 3}; Z IN. Note that equal sets are subsets of each other; we can express this fact in the following theorem about sets: (S = T) (S T) Mike Wooldridge 8

3.4 Proper Subsets As we just saw, if two sets are equal, then they are subsets of each other. This may seem strange! We introduce another relational operator that more accurately captures our intuitive understanding of what subset means. Definition: Let S and T be arbitrary sets of the same type. Then: S T is true iff both S T and S T. If S T then then S is said to be a proper subset of T. Note that we can formally define the relation using concepts introduced earlier: S T (S T) (S T) Note the use of to introduce definitions. Mike Wooldridge 9

4 The Empty Set There is a special set that has the property of having no members; this set is called the empty set, and is denoted either {} or (more usually) Note that if x is any value, then the expression x must be false. (Nothing is a member of the empty set.) Similarly, if S is an arbitrary set, then S must be true; this includes of course (The emptyset is a subset of every set.) But note that this is not a theorem: Why? S Mike Wooldridge 10

5 The Powerset Operator Definition: Let S be an arbitrary set. Then the set of all subsets of S is given by IP S. EXAMPLES. If S = {1} then IP S = {, {1}} If S = {1, 2} then IP S = {, {1}, {2}, {1, 2}} If S = {a, b, c} then IP S =? Mike Wooldridge 11

We can again use to introduce IP as a derived operator: T IP S (T S) Note that if S has n members, then IP S has 2 n members. For this reason, the powerset of a set S is sometimes denoted by 2 S. (But not by us.) Mike Wooldridge 12

6 Manipulating Sets 6.1 Set Union The union of two sets is a third set that contains the members of both. The symbol for union is. Definition: Let S and T be arbitrary sets. Then x (S T) is true iff either x S or x T. Note that we can introduce this as a derived operator: x S T x S x T. EXAMPLES. {a, e, i} {o, u} = {a, e, i, o, u}; {a, e} {e, i} = {a, e, i}; {a, e} = {a, e}. Mike Wooldridge 13

6.2 Set Intersection The intersection of two sets is a third set that contains only elements common to both. Definition: Let S and T be arbitrary sets. Then x (S T) iff both x S and x T. As a derived operator: x (S T) (x S) (x T). EXAMPLES. {a, e, i} {o, u} = ; a {a, e, i} {e, i}; IN = IN Z. Mike Wooldridge 14

6.3 Set Difference The notation S \ T denotes the set obtained from S by removing from it all the elements of T tha occur in it; in other words, you take T away from S. Definition: Let S and T be arbitrary sets. Then x (S \ T) is true iff x S and x T. As a derived operator:... EXAMPLES. {a, e, i, o, u} \ {o} = {a, e, i, u} \ {1, 2, 3} =. Mike Wooldridge 15

6.4 Theorems about Sets Let S, T, and U be arbitrary sets of the same type. Then: S S = S S S = S (S T) U = S (T U) (S T) U = S (T U) S T = T S S T = T S S (T U) = (S T) (S U) S (T U) = (S T) (S U) S = S S = Mike Wooldridge 16

6.5 Cardinality The cardinality of a set is the number of elements in it. Definition: If S is an arbitrary set, then the cardinality of S is denoted #S. Note that for an arbitrary set S: #S IN. EXAMPLES. #{1, 2, 3} = 3; # = 0; #({1, 2, 3} {2}) = 1. Mike Wooldridge 17

7 Defining Sets: Comprehension We have seen how sets may be defined by numeration listing their contents. This technique is impractical for large sets! Comprehension is a way of defining sets: in terms of their properties; in terms of other sets. Comprehension is best explained via examples: {n : IN (n 0) (n 3)} = {0, 1, 2, 3} {n : Z (n > 1) (n < 1)} = {n : IN (n 0) (n 3) n + 1} = {1, 2, 3, 4} Mike Wooldridge 18

In general, a set comprehension expression will have three parts: a signature specifies the base sets from which values are extracted; a predicate the defining property of the set; a term specifies how the actual values in the set are computed. Generally, we omit the term part we just have a signature and a predicate, as in examples (1) and (2), above. Mike Wooldridge 19