Set A formal collection of objects, which can be anything May be finite or infinite Can be defined by: – Listing the elements – Drawing a picture – Writing.

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Number Theory and Cryptography
Denoting the beginning
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 3 Dr. Shi Dept. of Electrical and Computer Engineering.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Sets 1.
Sets 1.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Entry Task 10/03/ ) 6.) 7.). Algebra 1 Section 2.1 Objective: Graph and compare real numbers using a number line.
Algebraic Properties: The Rules of Algebra Be Cool - Follow The Rules!
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.
Binary Numbers.
Number Systems Lecture 02.
Basic Concepts of Algebra
Sullivan Algebra and Trigonometry: Section R.1 Real Numbers Objectives of this Section Classify Numbers Evaluate Numerical Expressions Work with Properties.
Copyright © 2011 Pearson Education, Inc. Real Numbers and Their Properties Section P.1 Prerequisites.
CENG 311 Machine Representation/Numbers
Taks Objective 2 Properties and attributes of function.
Numbering systems.
Chapter 6: The Real Numbers and Their Representations
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
CSC312 Automata Theory Lecture # 2 Languages.
Data Structures and Algorithms Discrete Math Review.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
Copyright © Curt Hill BitWise Operators Packing Logicals with Other Bases as a Bonus.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
P.1 Real Numbers. 2 What You Should Learn Represent and classify real numbers. Order real numbers and use inequalities. Find the absolute values of real.
Properties of Real Numbers. Sets In mathematics, a set is a collection of things Sets can be studies as a topic all on its own (known as set theory),
Logic (continuation) Boolean Logic and Bit Operations.
Thinking Mathematically Number Theory and the Real Number System 5.5 Real Numbers and Their Properties.
Discrete Mathematics R. Johnsonbaugh
The Irrational Numbers and the Real Number System
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
Properties and Scientific Notation
Mathematical Preliminaries
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Chapter P Prerequisites: Fundamental Concepts of Algebra 1 Copyright © 2014, 2010, 2007 Pearson Education, Inc. 1 P.1 Algebraic Expressions, Mathematical.
Section 3.4 Boolean Algebra. A link between:  Section 1.3: Logic Systems  Section 3.3: Set Systems Application:  Section 3.5: Logic Circuits in Computer.
Chapter 8 Integers.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
Number Systems and Computer Arithmetic Winter 2014 COMP 1380 Discrete Structures I Computing Science Thompson Rivers University.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
Chapter 1 Review. Examples: Write the numeric expression 1.) Eight more than a number n 2.) The difference of six and a number 3.) The product of three.
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)
5.2 Multiplication, Division, and Other Properties of Integers Remember to silence your cell phone and put it in your bag!
Appendix A Basic Algebra Review
Chapter 6: The Real Numbers and Their Representations
Basic Rules Of ALGEBRA.
Fundamentals & Ethics of Information Systems IS 201
Specification of tokens using regular expressions
Properties of Real Numbers
1.1 Apply Properties of Real Numbers
Section 10.1 Groups.
Integers & Absolute Value
CSC312 Automata Theory Lecture # 2 Languages.
Presentation transcript:

Set A formal collection of objects, which can be anything May be finite or infinite Can be defined by: – Listing the elements – Drawing a picture – Writing a rule defining what is inside Operations –    ’ –  = – Cartesian Product: A  B = { (x, y) | x  A and y  B } Think of picking food from a menu: how many possible meals? The empty set is a subset of every set. It’s unique.

Sets of strings Begin with an alphabet Σ Σ n = all words with n “letters” Σ * = all words of any length, including length 0 * in general means “0 or more instances of” – 0* means all words containing any number of 0’s only – (0 + 11)* means any concatentations of “0” and “11” “language” = any set of words from Σ * Example: Let’s say Σ = { a, b }. – L = { ε, a, b, aa, ab, ba, bb } is a language with 7 words. This language happens to be Σ 0  Σ 1  Σ 2. Example: set of legal identifiers

Working with sets Boolean algebras Characteristic value of a set Bit vectors – Representation – Operations – Use in programming language Example: Vacation program – Bit masks

Properties Set theory and propositional logic are both boolean algebras. – What do we mean by “an algebra” ? Definition of a boolean algebra: a mathematical system with values 0 and 1 and operators + and * having these properties: – Closure, Commutativity, Distributivity, identity element, inverse Logic and set theory are “subclasses” of boolean algebra. They inherit these properties.

Properties (2) What is the practical consequence? Expressions involving set operations are analogous to boolean expressions. So, to verify that A  (B  C)  (A  B)  (A  C), we can do so by converting it to the corresponding propositional formula, and seeing if it’s a tautology. a  (b  c)  (a  b)  (a  c) In general, another way to show X  Y is to pick an arbitrary x  X and show why it must be in Y. – To show X = Y is done in two parts: X  Y and Y  X.

Characteristic value Often, a set consists of just whole numbers. – E.g. { 1, 4, 6 } In this case, it’s convenient to refer to the set by a single numerical value: the set’s characteristic value. The value is the sum of all 2 i where i is a number in the set. – E.g. { 1, 4, 6 }  The binary representation of this number shows the set! This is called a bit vector

Logic operations Examples AND AND Try the same examples with “OR” and “XOR” Observations: – What happens when you AND with a 1? With a 0? – What about OR’ing with a 1 versus a 0? – What about XOR? How would we … – Make the rightmost three bits all 1’s? All 0’s?

Operations Inside the computer, set operations on bit vectors are very fast. Notation in C, C++ and Java: | & ^ ~ Let’s look at x = { 1, 4, 6 } and y = { 3, 4, 5 }. How would you handle subset? what31… x111 y111 x | y11111 x & y1 x ^ y1111 ~x Blank cells are zero.

Binary number Value is based on powers of two: This number equals = 173 Interesting relationship between unary ~ and – ~n = – (n + 1) …

Shorthand Occasionally we need to write a large number in binary. Better to do so as “hexadecimal” – a shorthand that compresses 4 bits in one symbol. Notation: begin with “0x” followed by, usually, 8 digits. Each digit is: 0-9, a-f a = ten = “1010”d = thirteen = “1101” b = eleven = “1011”e = fourteen = “1110” c = twelve = “1100”f = fifteen = “1111” Example: What does 0x7ffc0 look like in binary?

Shift operations Two directions – Shift left (<<) basically means to multiply by a power of 2. – Shift right (>>) essentially divides by a power of 2 and eliminates the remainder. For example 1 << 4 = 2 4 = 16 5 << 3 = 5 * 2 3 = >> 1 = 13 / 2 1 = 6

Practical use Let’s suppose we want to use an integer to hold 31 boolean values, representing the days of a month. We’ll use bit positions 1-31 only. Start with sept = 0, clearing all bits. To turn on a certain bit, we need to “or with 1” sept = sept | (1 << 29) To turn off a bit, we need to “and with 0” sept = sept & ~(1 << 29) How would we determine value of just 29 th bit? Multiple bits? …

Mask Often we want to inspect/modify more than 1 bit, so we need to create an operand that looks like: – Ones in middle: – Zeros in middle: How? Two ways – Can subtract powers of 2 – Use only bitwise operations

Examples ~0 … ~0 << 5 … ~(~0 << 5)… ~(~0 << 5) << 4… And you can invert one more time if needed. How could we write this as a difference of powers of 2 ?

Bit field Store more than one value in a variable, to save space. Example: date as month-day-year – How many bits do we need for each? date = 0 date |= month << 16 date |= day << 11 date |= year MonthDayYear 4511