Sunteți pe pagina 1din 6

Discrete Mathematics for CS

Purpose of the course


In BITI #### is a course designed for computer science students. Here we will focus on several topics
that will be motivated by computational tasks. Our aims of this course is to make it more relevant to the
computer science students and helps them to instill deeper and longer-lasting understanding of the
underlying mathematics.
What we what to discuss in this course are:
Precise, Reliable, Powerful thinking
Ability to state and prove nontrivial facts
- Will help students to write correct programs, which provide a solid fundamental for more
complex systems.
Mathematical foundations and ideas
- This course will provide familiarity with logic, inductively defined structures, integer and
polynomial arithmetic, and probabilities.
- All concepts that we learn in this course will underlie all of the more advanced courses in
Computer Science.
Course outline

Topic 1: Logic, Sets and Function

Logic is essential in any formal discipline and consists of rule for drawing inference
Topic 2: Algorithms and Integers
Topics 3: Mathematical Reasoning
Topics 4: Counting
Topics 5: Relations
Topics 6: Graph
Topics 7: Trees and Boolean Algebra
Topic 1: Logic, Sets and Function

1. LOGIC AND PROPOSITIONS
Logic is the discipline that deals with the methods of reasoning. Logical reasoning is used in
mathematics to prove theorems, in computer science to verify the correctness of programs and to prove
theorems.
The building block for logic is the proposition. A proposition is a declarative sentence that is either true
or false, but not both. Examples: the earth is round, 2+3=5. Propositional variables (statements) can
be combined together by logical connectives to obtain compound propositions (compound statements).
For example, if we have two propositions, e.g. (1) the sun is shining, (2) it is cold, we can combine
them together by the connective and to form the compound statement the sun is shining and it is
cold. The truth value of an entire compound proposition depends only on the truth values of the
statements being combined and on the types of connectives being used. These connectives in logic are
called logical operators. Logical operations are operations that can be carried out on logical variables
(means on propositions).
Example 1
Let P be the proposition logic is fun and Q be the proposition today is Friday. Express each of the
following compound propositions in symbolic form:
(a) Logic is not fun and today is Friday
(b) Today is not Friday, nor is logic fun
(c) Either logic is fun or it is Friday
SOLUTION
(a) (not P) and Q
(b) (not Q) and (not P)
(c) P or Q
There are a number of logic operators in use. The most frequently used amongst these include:

Figure 1
To determine the truth value of compound proposition we need to know the effect of logical operators.
These can be summarized using a truth table. Here is a set of examples of truth tables prepared for all
main logical operators listed in Figure 1:
Table 1: Truth Table -NOT /NEGATION ()
A truth table that expresses a relationship a propositional variable (p) and a negation of that variable
(p):
(p) (p)
T F
F T

Table 2: Truth Table for AND/CONJUCTION (), OR/DISJUNCTION (V), EXCLUSIVE OR (V), IMPLICATION
(), and EQUIVALENCE ()

(p) (q) (p q) (p V q) (p V q) (p q) (p q)
T T T T F T T
T F F T T F F
F T F T T T F
F F F F F T T

In implication/ conditional propositions (p q), the preposition p is sometimes called the antecedent
(hypothesis) and q is called the consequent (conclusion).
Two compound propositions are logically equivalent () if they have the same truth value for every
possible set of truth values of the constituent propositions.
and (in programming language denoted by the
symbol &&)
V or (logical or also known as inclusive or in
programming language denoted by
the symbol ||)
! or (exclusive or rarely used),
not (negation in programming language denoted
by the symbol ~),
Implication/ Conditional Propositions (if
then )
Equivalence/ Biconditional Propositions (a
proposition is logically equivalent to a proposition
Example 2
Show that the proposition (not (P and (not Q))) is logically equivalent to the proposition ((not P) or Q)
SOLUTION
We construct a combined truth table (Table 3) for the compound propositions R= (not (P and (not Q)))
and S= ((not P) or Q). Intermediary columns are used as required to build up each of the expressions
from P and Q.
P Q not P not Q P and (not Q) R S
T T F F F T T
T F F T T F F
F T T F F T T
F F T T F T T

Since the last two columns are identical, R is logically equivalent to S (RS).
1.1 More about conditionals
Given the conditional proposition (p q), we define the following:
(a) The converse of p q : q p
(b) The inverse of p q :
(c) The contrapositive of p q :
Table 3: Truth Table for Converse, Inverse, and Contrapositive
(p) (q) (p q) (q p) ( ) ( )
T T T T T T
T F F T T F
F T T F F T
F F T T T T

1.2 Tautology, Contradiction and Contingency
Tautology: A compound proposition that is always true, no matter what the truth values of proposition
that occur
Contradiction: A compound proposition that is always false, no matter what the truth values of
proposition that occur
Contingency: A compound proposition that is neither a tautology nor contradictory.
Example 3
Show that V is a tautology
SOLUTION
Constructing the truth table for V , we have :
(p) ( ) ( V )
T F T
F T T

Note that V is always true (no matter what proposition is substituted for p) and is therefore a
tautology.
2. PREDICATES AND QUANTIFIES
A predicates describes a property of one or several objects or individuals that we called variables which
is either true or false depending on the values assigned to the variables.
Example 4
x is an integer satisfying x=x
2

is a predicate since it is true for x=0 or 1
and false for all other values.
Logical operations can now be applied to predicates. In general, the truth of a compound predicate
ultimately depends on the values assigned to the variables involved. However, there are further logical
operators, known as quantifiers, which when applied to a predicate produce either a true proposition.
The following are the two predicate quantifiers,
(a) Universal quantifier: The symbol is
x is read as for all x or for every x

(b) Existential quantifier: The symbol is
x is read as there exist at least one x or for some x
Example 5
Which of the following statements are true, and which are false?
1) All triangles have the sum of their angles equal to 180.
2) All cats have tails.
3) There is an integer x satisfying x
2
= 2.
4) There is a prime number which is not odd
5) There is a prime number which is not odd.
SOLUTION
1) True
2) False. Many cats have no tails
3) False
4) True. The number 2 is both a prime number and it is even.
Example 6
Let P(x) be the predicate x is an integer and x
2
= 9. Express the proposition (()) in words and
determine its truth value.
SOLUTION
The proposition (()) states that there is an integer x satisfying the equation x
2
= 9. This
proposition is true since, for example x
2
= 9 holds for x=3 and x=-3.
Example 7
Let P(x) be the predicate x is a real number and x
2
+1= 0. Express the proposition (()) in words
and determine its truth value.
SOLUTION
The proposition (()) states that there is a real number x satisfying the equation x
2
+1 1.
Therefore, the proposition (()) is false.
3. METHODS OF PROOF
Logical arguments are used to give us proofs of theorems. In computing such proofs are essential in the
design and verification of algorithms. The commonest types of proofs are ones where we wish to
establish the truth of a proposition of the form (P Q). There are several standards methods of proof,
including the following.
3.1 Direct Argument
Assume P is true and show that Q is truss. This rules out the situation where P is true and Q is false
which is the only case where (P Q) is false.
3.2 Contrapositive Argument
Assume Q is false and show that P is false. This demonstrates that ((Q)(P)) is true which by Example
# is the same as showing that (P Q) is true.

S-ar putea să vă placă și