Discrete Math: CS101/IIT103

Robert Batzinger
12 Jan 18

Unit 0 - Course Introduction

Assignment 1: Index

Unit 0
Course Introduction

Course Outline

  • Unit 0. Introduction and Preliminaries
  • Unit 1: Sets: Definitions, Functions, Counting
  • Unit 2: Combinations, Permutations and Sequences
  • Unit 3: Predicate Logic
  • Unit 4: Trees
  • Unit 5: Graphs Theory
  • Unit 6: Presentations and Review

Course Mechanics

  • Chapter Readings
  • Instruction with end of session review
  • Exercises/Assignments
  • Experiments conducted with software written in Ruby
  • Reporting using LaTeX
  • Sample questions
  • Unit Test

classroom

Course Goals

  • Master discrete mathematics and understand its applications
  • Use Ruby to implement principles covered and conduct experiments
  • Use LaTeX to develop report documents in the style of ACM
  • Deliver a 5 min Ignite presentation to describe the work

logo

Course Resources

Course Resources Online

textbook

Strategy of this course

Workflow

Software systems used in this course

Development systems Documentation systems
GIT: source code development, versioning, distribution and submission LaTeX: documentation platform to produce PDF files
RUBY: an object-oriented programming language used for experimentation yEd: Diagram editor for illustrating concepts, relationships and networks

Reference to Software used

Download, Install and Use Git

  • Sign up for an account with https://gitLab.com
  • Download and install Git on your computer
  • Do the Git tutorial at Online tutorial
  • Create the web interfaces to GitLab to create a test project
  • Follow the instructions provided by GitLab to clone the project and configure Git on your computer.

My example: mytest

git config --global user.name "Ajarn Bob"
git config --global user.email "robert_b@payap.ac.th"
git clone git@gitlab.com:rbatzing/mytest.git
cd mytest
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Verify that Git is working

  • Use A text editor to add content to README.md on your computer
  • Add the file to your git system using git add -A
  • Commit the changes using git commit -am "ReadMe file"
  • Push the changes to your GitLab account using git push origin master
  • Use the web interface to GitLab to verify the updates

Set up the Course Project

  • Create a project on GitLab called DiscreteMath
  • Clone this project to your computer and configure your Git settings.
  • Add rbatzing as a member of your class project
  • Pull the course Git files from https://gitlab.com/rbatzing/DiscreteMathClass into your course directory on your computer.
  • Commit the files and push to your GITLAB account.
  • Verify the update with the web interface to your GitLab account

Download, Install and Use Ruby

  1. Install Ruby on your computer
  2. Do the online tutorial at Online tutorial
  3. Run the Ruby program SERVEY.RB in Unit 0 subdirectory and answer the questions.
  4. Edit your responses as neccessary
  5. Upload the file SURVEY1.YAML to the Google Classroom
StuID: '209154'
FullName: Dr. R Batz...
NickName: Ajarn Bob
Email: robert_b@payap...
GitLab: rbatzing
Reason: Make this...
Goal: Use Ruby to...
Math: Enjoy the insights
Gitexp: 'yes'
Rubyexp: 'yes'
LabPartner: Ajarn Geng
Computer: i5 230GHz 8GB RAM 

Why Ruby?

  • Interpreted scripting language:

    • can call operating system directly
    • powerful string operations and regular expressions
    • immediate feedback during development
  • Quick and easy:

    • no variable declarations, typing
    • syntax is simple and consistent
    • automatic memory management

Language Features of Ruby

  • Object oriented programming:

    • everything is an object
    • classes, methods, inheritance, iterators and closures
    • singleton methods, “mixin” functionality
  • Advanced features:

    • multiple precision integers
    • convenient exception processing
    • dynamic loading
    • symbol processing
    • threading support

Ex. 1: Review of SURVEY.RB

When you finish the tutorial, answer the following questions:

  • What is the class defined in this program?

  • What is the meaning of the attributes of this class?

  • What do the various methods do?

  • Which lines invoke and use an object of this class?

  • How were the global data for the survey stored?

  • How were the results stored? And in what format?

\[ \]

What is Discrete Mathematics?

Definition

  • Discrete mathematics is the branch of mathematics dealing with objects that can assume only distinct, separated values.
  • Discrete mathematics contrasts with continuous mathematics which uses real values to produce smooth variations
  • Computer science is built almost entirely on discrete math especially combinatorics and graph theory.
  • Discrete mathematics is a required skill for pursuing a successful career in IT.

Skills related to Discrete Mathematics

  • Mathematics Reasoning: ability to apply mathematical logic, proofs, and induction to read, comprehend and construct mathematical arguments.
  • Combinatorial Analysis: ability to count or enumerate objects and combinations.
  • Discrete Structures: Use of discrete structures to represent objects and relationships between them. Includes sets, permutations, relations, graphs, trees, and finite-state machines.
  • Algorithmic Thinking: Ability to specify an algorithm, verify correctness and analysis time and resources.
  • Applications and Modeling: Ability to apply principles to solve problems

A riddle: Only one sign is true

chest

If this chest is empty,
then the other chest's
message is true.

chest

This chest is filled
with treasure or the
other chest contains
deadly scorpions

Mini Soduku Problem

Rules

  • Every cell contains: \( E \epsilon\ 1,2,3,4 \)
  • No duplicate values:
    • within rows
    • within columns
    • within \( 2 \times 2 \) clusters

Example

1 2 3 4
3 4 2 1
4 3 1 2
2 1 4 3

Sample Problem

3 1
 
4
1 3

List all Possibilities

(2,4) 3 (2,4) 1
(2,4) (1) (2,4) (3)
(3) 4 (1) (2)
1 (2) 3 (4)

Anchor Determined Values

(2,4) 3 (2,4) 1
(2,4) 1 (2,4) 3
3 4 1 2
1 2 3 4

2 Solutions

\[ \begin{array}{|c|c|c|c|} \hline 2 & \bf 3& 4 & \bf 1 \\ \hline 4 & 1 & 2 & 3 \\ \hline 3 & \bf 4 & 1 & 2 \\ \hline \bf 1 & 2 & \bf 3 & 4 \\ \hline \end{array}\qquad\begin{array}{|c|c|c|c|} \hline 4 & \bf 3 & 2 & \bf 1 \\ \hline 2 & 1 & 4 & 3 \\ \hline 3 & \bf 4 & 1 & 2 \\ \hline \bf 1 & 2 & \bf 3 & 4 \\ \hline \end{array} \]

Running new roads

villages

How would you connect the villages with these constraints?

Too many students were having serious accidents at intersections. So five small towns decided they wanted to build roads directly connecting each pair of towns without any intersection. While the towns had plenty of money to build roads as long and as winding as they wished, but there is no money for tunnels or bridges.

Photograph Restrictions

people

How many combinations will be permitted for this set of 5 friends?

Eddy E never allows a photographer to take a picture with any woman on his left.

Other problems solved using Discrete Math

  • How many license plates can be made using 3 Thai letters and 3 digits?
  • What is the shortest path between Payap University and the airport?
  • What is the fastest way to sort a list with limited memory?
  • What is the best way to randomize a list?
  • What is the best way to color a map with the fewest colors?

\[ \]

Mathematical Statements

any declarative sentence which is either TRUE or FALSE.

Ex 2: What is the difference?

Statements

  • Thai zipcodes have 5 digits.
  • The moon is made of cheese.
  • 42 is a perfect square.
  • Every odd number expressed as the sum of two odd numbers.
  • \( 3 + 7 = 12 \)

Non-Statements

  • Would you like some cake?
  • The sum of two squares.
  • \( 1 + 3 + 5 + 7 + \dots + (2n + 1) \)
  • Go to your room!
  • \( 3 + x = 12 \)

Atomic vs Molecular Statements

Atomic

cannot be divided into smaller statements

Molecular

can be divided into smaller statements

Implication or conditional

  • a molecular statement of the form \( P \rightarrow Q \)
  • P is the hypothesis (or antecedent statement).
  • Q is the conclusion (or consequent statement).
  • The only way for \( P \rightarrow Q \) to be false is for \( P=T \) and \( Q = F \)
  • To prove an implication \( P \rightarrow Q \) :

It is enough to assume P, and from it, deduce Q

Connectives

  • Conjunction: means (P AND Q), written as \( P \cap Q \) or \( P \land Q \)
  • Disjunction: means (P OR Q), written as \( P \cup Q \) or \( P \lor Q \)
  • Implication or conditional: means (IF P THEN Q), written as \( P \rightarrow Q \)
  • Biconditional: means (P IF AND ONLY IF Q), written as \( P \leftrightarrow Q \)
  • Negation: means (NOT P), written as \( \neg P \) or \( !P \)

Unary Connective True Table

Negation:

\[ \begin{array}{r|c|} \neg P& Outcome\\ \hline P=T & F \\ P=F & T \\ \hline \end{array} \]

Binary Connective True Tables

Conjunction:

\[ \begin{array}{r|c|c} P\land Q& Q=T & Q = F \\ \hline P=T & T & F \\ P=F & F & F \\ \hline \end{array} \]

Disjunction:

\[ \begin{array}{r|c|c} P\lor Q& Q=T & Q = F \\ \hline P=T & T & T \\ P=F & T & F \\ \hline \end{array} \]

Implication or Conditional:

\[ \begin{array}{r|c|c} P\rightarrow Q& Q=T & Q = F \\ \hline P=T & T & F \\ P=F & T & T \\ \hline \end{array} \]

Biconditional:

\[ \begin{array}{r|c|c} P\leftrightarrow Q& Q=T & Q = F \\ \hline P=T & T & F \\ P=F & F & T \\ \hline \end{array} \]

Converse of an Implication

Given the implication \( P \rightarrow Q \) :

\( Q \rightarrow P \) (can be false)

For \( numbers > 2 \) :
\( Prime \rightarrow Odd\ number \) (True)
\( Odd\ number \rightarrow Prime\ \) (Often False)

Contrapositive of an Implication

Given the implication \( P\rightarrow Q \) :

\( \neg Q \rightarrow \neg P \) (always True)

For \( numbers > 2 \) :
\( Prime \rightarrow Odd\ number \) (True)
\( \neg Odd\ number \rightarrow \neg Prime\ \) (True)

Neccessary and Sufficient

  • P is necessary for Q means \( Q \rightarrow P \)
  • P is sufficient for Q means \( P\rightarrow Q \)
  • P is necessary and sufficient for Q means \( P\leftrightarrow Q \)

Ex 3: Which statements are equivalent?

  • You can fool some people all of the time.
  • You can fool everyone some of the time.
  • You can always fool some people.
  • Sometimes you can fool everyone.

Quantifiers

Existential quantifier means “there exists” or “there is.”

\[ \exists x (x < 0) \]

There exists at least one number < 0

Universal quantifier means “for all” or “every.”“

\[ \forall x (x > 0) \]

Asserts that every number > 0

Ex 4: What do these statements mean?

\[ \forall x \exists y ( y < x) \]

\[ \exists x \forall y (y < x) \]

Quantifiers and Negation

Assuming \( P(x) \) means x is a prime number

\[ \neg \forall x P(x) \equiv \exists x \neg P(x) \]

\[ \neg\exists x P(x) \equiv \forall x \neg P(x) \]

Ex 5: Translate the statements

Given:

  • P: Jack passed math
  • Q: Jill passed math
  • \( P\rightarrow Q \)
  • \( \neg(P \cap Q) \rightarrow Q \)
  • \( P\cup Q \)
  • \( \neg P \cup \neg Q \)
  • \( P\leftrightarrow Q \)
  • \( P\cup \neg P \)
  • \( P\cap \neg P \)

Ex 6: Convert these to math statements

  • Either you win the lottery or else you are not rich.
  • Either you don’t win the lottery or else you are rich.
  • You will win the lottery and be rich.
  • You will be rich if you win the lottery.
  • You will win the lottery if you are rich.
  • It is necessary for you to win the lottery to be rich.
  • It is sufficient to win the lottery to be rich.
  • You will be rich only if you win the lottery.
  • Unless you win the lottery, you won’t be rich.
  • If you are rich, you must have won the lottery.
  • If you are not rich, then you did not win the lottery.
  • You will win the lottery if and only if you are rich

Ex 7: Reviewing terms:

What is the meaning of these terms?

  • Conjunction
  • Disjunction
  • Implication
  • Biconditional
  • Negation
  • Atomic Statement
  • Molecular Statement
  • Existential quantifier
  • Universal quantifier
  • Neccessary
  • Sufficient

Assignment 1

  • Do each and every activity and exercise in this Unit.
  • Record and label your results in a text file.
  • Submission due in Google Classroom before class on 12 Jun

Assignment 1: Index