0% found this document useful (0 votes)
4 views33 pages

1 Prelim

The document outlines the first lecture of COMPSCI 250, focusing on foundational concepts in computation, including mathematical methods, set and string definitions, and decision problems. It also covers course logistics, including prerequisites, grading structure, and academic integrity policies. The lecture introduces the use of pseudo-Java for programming examples and emphasizes the importance of understanding formal languages in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views33 pages

1 Prelim

The document outlines the first lecture of COMPSCI 250, focusing on foundational concepts in computation, including mathematical methods, set and string definitions, and decision problems. It also covers course logistics, including prerequisites, grading structure, and academic integrity policies. The lecture introduces the use of pseudo-Java for programming examples and emphasizes the importance of understanding formal languages in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

COMPSCI 250: Introduction to

Computation
Lecture #1: Things, Sets and Strings
David Mix Barrington and Mordecai Golin
4 September, 2024

1
Things, Sets, and Strings

• The Mathematical Method


• Administrative Stuff
• The Objects of Mathematics
• Pseudo-Java
• Set and String Definitions
• Languages and Decision Problems

2
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.
3
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.

• After that, we’ll use induction to reason


about trees and search algorithms.

• We’ll conclude by studying finite-state


machines and providing a very brief
introduction to the theory of computability.
4
Administrative Stuff
• All of you should have taken CICS 160 and MATH
132, or equivalents.
• We will have two midterms (15% each),
six homeworks (20% total),
ten discussion assignments (6%),
weekly textbook quizzes (6%),
clicker attendance (3%),
and a final (35%).
• The public course web site is
http://www.cs.umass.edu/~barring/cs250
• There is also a Piazza site. 5
Practice Clicker Question #1
Suppose you get a score of
280 (B-) on exams (65%),
340 (B+) on homework (20%), and
400 (A) on the other parts (15%).
Which of these will be the weighted average for your
course grade?

• (a) (280+340+400)/3 = 340 (B+)


• (b) (280*0.65+340*0.20+400*0.15) = 310 (B)
• (c) (280/65+340/20+400/15) = 47.97
• (d) this first has to be changed to a 0-100 scale
6
Not the Answer

7
Practice Clicker Answer #1
Suppose you get a score of
280 (B-) on exams (65%),
340 (B+) on homework (20%), and
400 (A) on the other parts (15%).
Which of these will be the weighted average for your
course grade?

• (a) (280+340+400)/3 = 340 (B+)


• (b) (280*0.65+340*0.20+400*0.15) = 310 (B)
• (c) (280/65+340/20+400/15) = 47.97
• (d) this first has to be changed to a 0-100 scale 8
More Administration
• We are using Canvas, on which you will later be able to see
your grades.
• You’ll turn in homework on Gradescope and
turn in quizzes using the textbook.
• “Clicker” questions (using ClassQuestion) will count starting
one week from today (11 September). You get full credit for
attendance if you answer about 75% or more of the in-class
questions.
• First quiz is due Tuesday 17 September, 8:00 p.m.
• “Homework 0” student survey is due 10 September.
It is exceptionally being hosted on Canvas
(Go to Quizzes and look at Surveys)
• Homework 1 will be due on 20 September.
9
There is Still COVID
• This is an in-person course, unless the
authorities tell us otherwise.
• But we don’t want you to come to class if it’s
not safe for you or for others.
• So if you think it’s not safe, skip the lecture or
discussion and apply for an excused absence
using the survey form on Canvas.
• We need the form even if we’ve talked to
you or emailed about it personally.

10
Academic Honesty

• If you cheat on a test, we will fail you for the course.


• 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.
• Also, you must always acknowledge your sources,
whether they are people you worked with or web pages
you consulted.
• In one recent term, 13 people had their CS 250 grades
lowered for academic honesty violations.
• Writing your answers using an AI tool is not allowed!
11
The Textbook

• The text for the course is eight chapters of a book


Dave is writing, called A Mathematical
Foundation for Computer Science, an e-book
available from Kendall Hunt Publishing for
somewhat more than $60.
• The course is similar to recent versions of CS 250,
but you will need a new version of the book in
order to get the quiz questions. You’ll also get
practice quizzes that you can use to study.
12
A Co-Taught Course!

• This term CS 250 is being jointly taught by Dave


(who taught it a lot here) and Mordecai (who
taught it last spring and has also taught similar
things a lot in Hong Kong)
• The lectures happen on the same day at different
times, and will be similar. “Clickers” done at either
section will count.
• Exams, homeworks, and discussions are the same
for the two sections, both in design and in grading.

13
More on the Textbook
• Each chapter has eight ordinary sections and
three “excursion” sections –
the latter will often be the basis of discussion
exercises.
• The lectures will follow the book closely, but
they will assume that you are also reading the
book.

Homework exercises will also primarily be from


the “Problems” in book.

The “Exercises” in the book have answers in the


back. 14
More on the Textbook

• The quizzes are to be taken using the


“assessment package” of the textbook, which
you register for at Kendall Hunt, the publisher.
• The true/false questions (20 per quiz) each come
from a section of the textbook.
• Each of you gets a different random selection of
the questions.
• There is no time limit, except the deadline at the
end.
15
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, etc.

• In this course we will use natural numbers or naturals,


sometimes written as ℕ (or N) which are the integers
0, 1, 2, 3, … going on “forever”.

Less often we will use negative integers, and even more


rarely, rational numbers (fractions) or other real numbers.

Tip: Remember that “𝟎” is the first natural


number. That will come up often 16
More Objects
• We will also 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.

17
Pseudo-Java

• We 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.
18
Types in Pseudo-Java
• In pseudo-Java, the natural numbers are a type
called natural, and rather than being bounded by
some maximum value like real Java ints or longs,
they are unbounded.

• Object-oriented concepts will be less important


than in 160 (most of our methods will be static)
but recursion will be used a lot.

19
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., {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24},
or by set builder notation e.g,
{𝑛 ∶ 𝑛 is an even natural less than or equal to 24}
or, equivalently,
𝑛 ∈ ℕ ∶ 𝑛 is even and 𝑛 ≤ 24 .

• Two sets are equal if every element of one is an element


of the other, e.g. 1, 3, 4 = {4, 1, 3, 3}.
20
More Set Definitions
• A set A is a subset of a set B (𝐴 ⊆ 𝐵)
if every element of A is also in B.
We have the rule that “𝐴 = 𝐵” means the same
thing as “𝐴 ⊆ 𝐵 and 𝐵 ⊆ 𝐴”.

• A set is empty if it contains no elements.


We sometimes write X = {}.
Any two empty sets are equal.

• The size of a set is the number of elements it


contains, if the set is finite.
The size of a finite set is always a natural.
21
Practice Clicker Question #2
Let X = {Blaze, Rhonda},
Y = {Clover, Rhonda}, and
Z = {Rhonda, Blaze} be three sets of dogs. Which
statement is false?

(a) “X ⊆ Y” and “Y ⊆ X” are both false


(b) “X = Z” is true
(c) {Rhonda, Clover, Rhonda} = Y
(d) “X ⊆ Z” and “Z ⊆ X” are both false
22
Not the Answer

23
Practice Clicker Answer #2
Let X = {Blaze, Rhonda},
Y = {Clover, Rhonda}, and
Z = {Rhonda, Blaze} be three sets of dogs. Which
statement is false?

(a) “X ⊆ Y” and “Y ⊆ X” are both false


(b) “X = Z” is true
(c) {Rhonda, Clover, Rhonda} = Y
d) “X ⊆ Z” and “Z ⊆ X” are both false
(both are true)
24
String Definitions
• A string is a sequence of elements from a finite set,
called the alphabet.
A binary string is a string from alphabet 0,1 .
The length of a string is the number of elements
(letters) it contains. This is always 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 == to denote
equality of strings.
25
More String Definitions
• The empty string λ is the string with no letters --
any two empty strings are equal. The symbol “λ”
is not a letter, but 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,...}.
26
Practice Clicker Question #3

Suppose Σ is any non-empty alphabet, and let u and v


be any two strings over the alphabet Σ. Which of these
statements is not necessarily true?

(a) if u and v have the same length, then 𝑢 = 𝑣.


(b) if 𝑢 = 𝑣, then u and v have the same length
(c) if u and v are both empty, then 𝑢 = 𝑣.
(d) if 𝑢 = 𝑣, then every letter of u occurs in v, and
every letter of v occurs in u
27
Not the Answer

28
Practice Clicker Question #3

Suppose Σ is any non-empty alphabet, and let u and v


be any two strings over the alphabet Σ. Which of these
statements is not necessarily true?

(a) if u and v have the same length, then 𝑢 = 𝑣.


(b) if 𝑢 = 𝑣, then u and v have the same length
(c) if u and v are both empty, then 𝑢 = 𝑣.
(d) if 𝑢 = 𝑣, then every letter of u occurs in v, and
every letter of v occurs in u
29
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,
a different 1 at the end, and 0’s in the middle.

• We can write X as {11, 101, 1001, 10001,...} or as


′ ′
{𝑤: 𝑤 starts and ends with distinct 1 s and contains no other 1 s}
Later we’ll call this language “10*1”. 30
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.
31
Side Comment
Let Σ = {0, 1}. Define the language X to be
all strings that have between 1 and 7 0’s between every two
consecutive “1”s
For example:
0100010010, and 01000100001 are in X, but 01100010
and 010001000000001 are not in X
X is known as the R(1,7) language and is one of the two
languages used (the other is R(2,7)) describing how data
is coded in high density drives.
Point is: Formal Languages might seem abstract and
formal, but they pop up in a surprising number of places
in CS.
32
Reminders

• “HW#0” questionnaire —
due by Tuesday 10 September,
on Canvas. (This is a survey under Quizzes on Canvas)
• Quiz #1 —
due by 8:00 p.m, Tuesday 17 September,
using the textbook.
• HW#1 —
due on Friday 20 September,
to be posted on Canvas soon,
to be handed in using Gradescope.

33

You might also like