CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Similar documents
CMPSCI 250: Introduction to Computation. Lecture #30: Properties of the Regular Languages David Mix Barrington 7 April 2014

CMPSCI 250: Introduction to Computation. Lecture #30: Proving Properties of the Regular Languages David Mix Barrington 9 April 2012

CMPSCI 250: Introduction to Computation. Lecture #28: Regular Expressions and Languages David Mix Barrington 2 April 2014

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

Today s Topics. What is a set?

1.1 - Introduction to Sets

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

CSC Discrete Math I, Spring Sets

CMPSCI 187: Programming With Data Structures. Lecture #15: Thinking Recursively David Mix Barrington 10 October 2012

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

Material from Recitation 1

CmpSci 187: Programming with Data Structures Spring 2015

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

1 Elementary number theory

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

W13:Homework:H08. CS40 Foundations of Computer Science W13. From 40wiki

CMPSCI 250: Introduction to Computation. Lecture #22: Graphs, Paths, and Trees David Mix Barrington 12 March 2014

Lecture 6,

Hillel Academy. Grade 9 Mathematics End of Year Study Guide September June 2013

Lecture 6: Arithmetic and Threshold Circuits

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

Introduction to Sets and Logic (MATH 1190)

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

Chapter 6 Formal Relational Query Languages

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

Lecture 1. Course Overview Types & Expressions

MITOCW watch?v=kz7jjltq9r4

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Pre-Calc Unit 1 Lesson 1

The Size of the Cantor Set

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

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

2.1 Sets 2.2 Set Operations

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

Lecture 5: The Halting Problem. Michael Beeson

CMSC 330: Organization of Programming Languages. Operational Semantics

SET DEFINITION 1 elements members

Recursively Defined Functions

Subtraction Understand Subtraction on a Number Line Using a number line let s demonstrate the subtraction process using the problem 7 5.

Lecture 3: Recursion; Structural Induction

Math 2280: Introduction to Differential Equations- Syllabus

CMPSCI 250: Introduction to Computation. Lecture #24: General Search, DFS, and BFS David Mix Barrington 24 March 2014

Problem One: A Quick Algebra Review

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

CS103 Handout 42 Spring 2017 May 31, 2017 Practice Final Exam 1

Notes for Comp 454 Week 2

1. [5 points each] True or False. If the question is currently open, write O or Open.

Handout 9: Imperative Programs and State

CSE 20. Lecture 4: Number System and Boolean Function. CSE 20: Lecture2

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013

CMSC 330: Organization of Programming Languages. Lambda Calculus Encodings

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

Programming Lecture 3

Cardinality of Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Cardinality of Sets Fall / 15

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

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Midterm Practice Exam Sample Solutions

Examination Duration Date

Discrete Mathematics Lecture 4. Harper Langston New York University

Math Introduction to Advanced Mathematics

CSE 20 DISCRETE MATH. Fall

Introduction to Counting, Some Basic Principles

CSE 105 THEORY OF COMPUTATION

Unit: Rational Number Lesson 3.1: What is a Rational Number? Objectives: Students will compare and order rational numbers.

CS 101 Fall 2006 Midterm 1 Name: ID:

Chapter 1. Math review. 1.1 Some sets

Relations I. Margaret M. Fleck. 7 November 2008

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

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

Review of Operations on the Set of Real Numbers

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

T02 Tutorial Slides for Week 2

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

Mathematical Induction

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

Discrete Structures. Fall Homework3

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

CMPSCI 250: Introduction to Computation. Lecture #36: State Elimination David Mix Barrington 23 April 2014

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG

Computer-Aided Program Design

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Chapter 8 Algorithms 1

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

CMSC 330: Organization of Programming Languages

COT 3100 Spring 2010 Midterm 2

EEM 232 Digital System I

COMP-202: Foundations of Programming. Lecture 26: Review; Wrap-Up Jackie Cheung, Winter 2016

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

Lecture 1. 1 Notation

Introduction to Axiomatic Semantics

Math You ve Gotta Have This Book!

CS 275 Automata and Formal Language Theory. First Problem of URMs. (a) Definition of the Turing Machine. III.3 (a) Definition of the Turing Machine

Chapter 3 (part 3) Describing Syntax and Semantics

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

Full file at

Math 55 - Spring 04 - Lecture notes # 1 - Jan 20 (Tuesday)

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Fun facts about recursion

CMSC 330: Organization of Programming Languages

Transcription:

CMPSCI 250: Introduction to Computation Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Things, Sets, and Strings The Mathematical Method Administrative Stuff The Objects of Mathematics Pseudo-Java Set and String Definitions Languages and Decision Problems

The Mathematical Method The basic idea of mathematics is to take some aspect of the real world, create a mathematical system that shares some of its properties, and work with that mathematical system using logic and proof. Since computers follow logical rules, we can better understand what they do (and what we can do with them) by applying the mathematical method.

Overview of the Course We ll begin this course with the basic tools of logic -- propositions, predicates, and induction -- with number theory as our object of study. Later we ll use induction to reason about trees and search algorithms. Finally we ll study finite-state machines and have a very brief introduction to the theory of computability.

Administrative Stuff Most of you have taken CMPSCI 187 and MATH 132 -- there are a few exceptions. We will have two midterms (15% each), six homeworks (25% total), ten discussion assignments (10%), Moodle quizzes (5%), clicker questions (5%), and a final (25%). The final counts 50% if this helps you. The public course web site is http:// www.cs.umass.edu/~barring/cs250

Practice Clicker Question #1 Final grades in this course are computed on a scale from 0.0 to 4.0 (or above). There will be 36 clicker scores, totalling to 5% of the course grade. What is the effect on the overall total of changing one clicker score from F to A? (a) increase by about 0.5 (b) decrease by about 0.05 (c) increase by about 0.05 (d) increase by about 0.005

Answer #1 Final grades in this course are computed on a scale from 0.0 to 4.0 (or above). There will be 36 clicker scores, totalling to 5% of the course grade. What is the effect on the overall total of changing one clicker score from F to A? (a) increase by about 0.5 (b) decrease by about 0.05 (c) increase by about 0.05 (d) increase by about 0.005 (4.0 * 5% * (1/36))

More Administration We are using Moodle, and quizzes and homeworks must be turned in through Moodle. You will be able to see your grades. Clicker questions will count starting a week from today (29 January). If you cheat on a test, I will fail you. You may work together on homework, but what you hand in must be yours in presentation. If it is identical to another s work, there s a problem.

The Textbook The text for the course is eight chapters of a book I am writing, called A Mathematical Foundation for Computer Science. It is sold at Collective Copies in downtown Amherst, in two volumes, for about $50. The texts for CMPSCI 250 the last four times I taught it (Fall 2010, Springs 2011 and 2012, and Fall 2013) are very similar and should be usable for this course if you check the errata pages for those offerings.

More on the Textbook Each chapter has eight ordinary sections and three excursion sections -- the latter will often be the basis of discussion exercises. My lectures will follow the book closely, but they will assume that you are also reading the book. Homework exercises will also be from the Problems in book. The Exercises in the book have answers in the back.

The Objects of Mathematics Each area of mathematics has its own set of objects. In calculus you used real numbers, and functions from reals to reals. In geometry you used points, lines, triangles, and so forth. In this course we will use natural numbers or naturals, which are the integers 0, 1, 2, 3,... going on forever. Less often we will use negative integers, and even less often rational numbers (fractions) or other real numbers.

More Objects We will use the boolean values true and false (sometimes written 1 and 0 ). Other objects come from data types. Any collection of objects can be a type, and we have a supertype thing that includes any object we might want to consider. The book uses the example type novelist, consisting of any person who has ever written a novel.

Pseudo-Java I will assume in this course that you are familiar with programming in Java. This is because we are learning about the mathematics of computation, and many abstract concepts will be clearer when you consider examples in Java. In our code examples, in the book and lecture, we will use a language called pseudo- Java rather than regular Java. The main difference is in the primitive types.

Types in Pseudo-Java In pseudo-java, the natural numbers are a type called natural, and rather than stopping at a maximum value like real Java ints or longs, they go on forever. Strings in pseudo-java come from a primitive type string rather than being objects. The letters used in strings will depend on context. Object-oriented concepts will be less important than in 187 (most of our methods will be static) but recursion will be used a lot.

Set Definitions A set is any collection of things, usually all of the same type. We will allow sets of sets only if they are from a common type (e.g., sets of sets of naturals). We can define the elements of a set by listing them all (e.g., {2, 3, 4, 7}) or by set builder notation (e.g, {n: n is an even number less than 24}). Two sets are equal if every element of one is an element of the other.

Practice Clicker Question #2 Which one of these statements is true? (a) {3, 7, 9} {9, 3, 7} (b) {0, 1} = {false, true} (c) {n: n is a natural and n < 4} = {1, 2, 3} (d) {Boston MLB team, 2013 World Series champions} = {Red Sox}

Answer #2 Which one of these statements is true? (a) {3, 7, 9} {9, 3, 7} (b) {0, 1} = {false, true} (c) {n: n is a natural and n < 4} = {1, 2, 3} (d) {Boston MLB team, 2013 World Series champions} = {Red Sox}

More Set Definitions A set A is a subset of a set B (A B) if every element of A is also in B. We have the rule that A = B means the same thing as A B and B A. A set is empty if it contains no elements. Any two empty sets are equal. The size of a set is the number of elements in it, if the set is finite. The set of a finite set is always a natural.

String Definitions A string is a sequence of elements from a finite set, called the alphabet. A binary string is a string where the alphabet is {0, 1}. The length of a string is the number of elements (letters) in it, and this must be a natural. Two strings are equal if they have the same length and each letter in one is equal to the corresponding letter in the other. In pseudo- Java, we use == for equality of strings.

More String Definitions The empty string λ is the string with no letters -- any two empty strings are equal. The symbol λ is not a letter, it denotes the string with no letters. (The empty string in real Java is denoted.) If Σ is an alphabet, the set of all strings over Σ is called Σ *. Every string in Σ * is finite, though Σ * itself is an infinite set. For Σ = {0, 1}, we can list Σ * as the set {λ, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, 100, 101, 110, 111,...}.

Practice Clicker Question #3 Which one of these languages is not equal to the other three? (a) {w: w contains no letters} (b) (c) {λ} (d) {w: w is a substring of every string in Σ * }

Answer #3 Which one of these languages is not equal to the other three? (a) {w: w contains no letters} (b) (c) {λ} (d) {w: w is a substring of every string in Σ * }

Formal Languages Any set of strings over Σ is called a language over Σ. We can define languages using any of our ways of defining sets. Let Σ = {0, 1}. Define the language X to be all strings that have a 1 at the beginning and the end, and 0 s in the middle. We can write X as {11, 101, 1001, 10001,...} or as {w: w starts and ends with 1 and has no other 1 s}. Later we ll call this language 10*1.

Decision Problems The decision problem for a language X is to input a string w (over Σ, the correct alphabet) and return a boolean that is true if w X and false if not. Given a language, how difficult is it for a computer to solve its decision problem? This is the central question of formal language theory. We ll touch on this at the end of the course.