Discrete Mathematics - Odt
Discrete Mathematics - Odt
Special sets:
N - set of natural numbers = {1,2,3,4, ...}
Z - set of integers = {..., -3,-2,-1,0,1,2,3, ...}
Q - set of rational numbers (of form a/b where a and b are elements of Z and b≠0)
R - set of real numbers
Set representation:
- listing methos (ex.{1,2,3,4,5,6,7,8,9})
- set builder notation (rules of inclusion) (ex. Q={n/m | n,m ∈ Z and m≠0}
Powerset of a set is the set containing all the subsets of the set (ex. the powerset of set S = P(S)).
S = {1,2,3}; P(S) = {∅,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}.
Attention!
P(∅) = ?
∅⊄∅
P(∅) = {∅}
∅ ⊄ P(∅)
{∅} ⊄ P(∅)
P(P(∅) = {∅, {∅}}
Cardinality of a powerset
Given a set S, then |P(S)| = 2|S| (ex. S={1,2,3}. |S| = 3. |P(S)| = 8 = 23 = 2|S|.
Given a set A, then |P(P(P(A)))| = 2|P(P(A))| = 2 to the power of 2 to the power of 2 to the power of n where n is the cardinality of A.
Set operations
∪ (union) - given two sets A and B, the union of A and B, A∪B, contains all the elements in EITHER A or B (A∪B={x | x ∈ A or x
∈ B}).
∩ (intersection) - given two sets A and B, the intersection of A and B, A∩B, contains all the elements IN BOTH A and B (A∩B={x | x
∈ A and x ∈ B}).
- (difference) - given two sets A and B, the set difference, A-B, contains the elements that are in A BUT NOT IN B (A-B={x | x ∈ A
and x ∉ B}).
∆ or ⊕ (symmetric difference) - gitven two sets A and B, the symmetric difference, A∆B, contains the elements that are in A OR IN B
BUT NOT IN both (A∆B={x | (x ∈ A or x ∈ B) and x ∉ A∩B)}).
Example:
A={1,2,3} and B={3,4,5}
A∪B={1,2,3,4,5 }
A∩B={3}
A-B={1,2}
A∆B={1,2,4,5}
1.2 Sets. Set representation and manipulation
U
A⊆U
A
Complement of a set. The complement of a set A, denoted A' or , contains all the elements in the universal set U but not in A
(A'=U-A; U=A'∪A=U).
De Morgan's laws
Describe how mathematical statements and concepts are related through their opposites. In set theory, De Morgan's laws relate to the
intersection and union of sets through their complements.
=A'∩B'
=A'∪B'
Inclusion-exclusion principle
|A∪B| = |A| + |B| - |A∩B|
|A∪B∪C| = |A| + |B| + |C| - |A∩B| - |A∩C| - |B∩C| + |A∩B∩C|
Laws of sets
commutativity is an operation in which the order of elements does not affect the result:
- set union (A∪B=B∪A)
- set intersection (A∩B=B∩A)
- symmetric difference (A⊕B=B⊕A)
associativity concerns the grouping of elements in an operation:
- set union ( (A∪B)∪C=A∪(B∪C) )
- set intersection ( (A∩B)∩C=A∩(B∩C) )
- symmetric difference( (A⊕B)⊕C=A⊕(B⊕C) )
distributivity is an operation in which the multiplying a sum by a number gives the same result as multiplying each number and them
adding the products together ( 3*(2+5)=3*2 + 3*5=21 ):
- set union is distributive over the set intersection ( A∪(B∩C)=(A∪B)∩(A∪C) )
- set intersection is distributive over the set union ( A∩(B∪C)=(A∩B)∪(A∩C) )
Partition is a subdivision of the object into parts, so that these parts are completely sepatated from each other, yet together they form
the whole object.
dis-joint sets when A∩B=∅
A partition of A is a set of subsets Ai of A such that all the subsets Ai are dis-joints. The union of all subsets Ai is equal to A. Example,
{A1,A2,A3,A4,A5} is a partition on A.
2.1 Functions. Introduction to functions
Function is a rule that relates to how one quantity depends on other quantities. It is a relation between a set of inputs and a set of
outputs in which each input maps to exactly one output.
Given a function f: A → B
x ∈ A → f(x) = y ∈ B
Linear function
f(x)=ax+b where a ∈ R and b ∈ R.
- straight line function
- passes through the point (0,b)
- a is the gradient
if a>0 then the function is increasing (x1 ≤ x2 then f(x1) ≤ f(x2))
Exponential function
f(x)=bx where b>0 and b≠1.
base of the function is the value of b.
Types:
- exponential growth
- exponential decay
Function properties:
Injective (one-to-one) functions. The function is injective (one-to-one) if and only if
- for all a,b ∈ A, if a≠b then f(a)≠f(b)
- for all a,b ∈ A, if f(a)=f(b) then a=b
Surjective (onto) functions. The function is surjective (onto) if and only if every element of the co-domain of f (co-Df), B, has at least
one pre-image in the domain of f (Df).
- for all y ∈ B there exists x ∈ A such that y=f(x) ≡ co-Df=Rf
Bijective functions (invertible; one-to-one correspondence) are both injective (one-to-one) and surjective (onto).
Suppose that f: A → B
To show that f is injective Show that if f(x)=f(y) for arbitrary x,y ∈ A, then x=y
To show that f is not injective Find particular elements x,y ∈ A such that x≠y and f(x)=f(y)
To show that f is surjective Consider an arbitrary element y ∈ B and find an element x ∈ A such that f(x)=y
To show that f is not surjective Find a particular y ∈ B such that f(x)≠y for all x ∈ A
2.2 Functions. More about functions
Function composition
(f o g)(x) = f(g(x)) - given two functions f and g.
Df o g = Dg, Rg ⊆ Df
(f -1 o f)(a) = f -1(f(a)) = f -1(b) = a - identity function
(f o f -1)(b) = f(f -1(b)) = f(a) = b - identity function
Function operations
(f1 + f2)(x) = f1(x) + f2(x)
(f1f2)(x) = f1(x)f2(x)
Graph
The graph of the function f is the set of ordered pairs {(a,b) | a ∈ A and f(a)=b}. The graph of a function f from A to B is the subset of
AxB containing the ordered pairs with the second entry equal to the element of B assigned by f to the first entry.
Logarithmic functions
The logarithmic function with base b where b > 0 and b ≠ 1 is defined as follows:
logb x = y if and only if x = by
logb x is the inverse function of the exponential function bx.
Laws of logarithms:
logb m*n = logb m + logb n
logb m/n = logb m - logb n
logb mn = n logb m
logb 1 = 0
logb b = 1
Natural logarithm: ln x
ln x = loge x where e = 2.71828
Floor functions
The function R → Z. It takes a real number x as an input and returns the largest integer that is less than or equal to x, denoted as
floor(x) = ⌊ x ⌋
Ceiling function
The function R → Z. It takes a real number x as an input and returns the smallest integer that is greater than or equal to x, denoted as
ceiling(x) = ⌈ x ⌉.
Properties of ceiling and floor functions:
1. ⌊ x ⌋ = n if and only if n ≤ x < n+1
2. ⌈ x ⌉ = n if and only if n-1 < x ≤ n
3. ⌊ x ⌋ = n if and only if n-1 < n ≤ x
4. ⌈ x ⌉ = n if and only if x ≤ n < x+1
5. x-1 < ⌊ x ⌋ ≤ x ≤ ⌈ x ⌉ < x+1
6. ⌊ -x ⌋ = - ⌊ x ⌋
7. ⌈ -x ⌉ = - ⌈ x ⌉
8. ⌈ x+n ⌉ = ⌈ x ⌉ + n
9. ⌊ x+n ⌋ = ⌊ x ⌋ + n
Proposition is a declarative sentence that is either true or false, but not both (most basic element of logic).
Example of propositions:
London is the capital of the United Kingdom - true proposition
1 + 1 = 2 - true proposition
Madrid is the capital of France - false proposition
3 < 2 - false proposition
Example that are not propositions:
x + 1 = 2 - not proposition, because we do not know x
x + y = z - not proposition, because we do not know x, y, z
this coffee is strong - not proposition, because have relative meaning of strong
Truth table is a tabular representation of all the possible combinations of its constituent variables.
Example:
Here are two propositional variables p and q:
p q
FALSE FALSE
TRUE FALSE
FALSE TRUE
TRUE TRUE
Truth set of p is the set of elements of S for which p is true (let p be a proposition on a set S).
A capital letter a proposition is used to refer to a truth set of the proposition, i.e. the truth set of a proposition p is noted as P.
Example:
S = {1,2,3,4,5,6,7,8,9,10}
p and q - two propositions concerning an integer n in S, defined as follows:
p: n is even
q: n is odd
P = {2,4,6,8,10} - the truth set of p written as P
Q = {1,3,5,7,9} - the truth set of q written as Q
Compound statements
Compound propositions are statements built by combining multiple propositions using certain rules.
Logic operators:
• negation (¬)
Let p be a proposition. The negation of p, denoted by ¬p, and read "not p", is the statements "It is not the case that p.".
• conjunction (Λ)
Let p and q be propositions. The conjunction of p and q, denoted by pΛq, is the proposition "p and q". The conjunction pΛq is
only true when both p and q are true, and is false if this isn't the case.
p q pΛq
F F F
T F F
F T F
T T T
• disjunction (ν)
Let p and q be propositions. The disjunction of p and q, denoted by pνq, is the proposition "p or q". The disjunction pνq is
only false when both p and q are false, and is otherwise true.
p q pνq
F F F
T F T
F T T
T T T
• exclusive-or (⊕)
Let p and q be propositions. The exclusive-or of p and q, denoted by p⊕q, is the proposition "p or q (but not both)". The
exclusive-or p⊕q is true when p is true and q is false and when p is false and q is true.
p q p⊕q
F F F
T F T
F T T
T T F
p q p→q
F F T
T F F
F T T
T T T
Different expressions of p → q:
• if p then q
• if p,q
• p implies q
• p only if q
• q follows from p
• p is sufficient for q
• q unless ¬p
• q is necessary for p
p q p→q q→p (p → q) Λ (q → p)
F F T T T
T F F T F
F T T F F
T T T T T
3.2 Propositional logic. Applications
Tautology - a compound proposition that is always true, no matter what the truth values of the propositional variables that occur in it.
Contradiction - a compound proposition that is always false.
Contingency - a compound proposition that is neither a tautology nor a contradiction.
Equivalent propositions
p and q are logically equivalent if they always have the same truth value. p ≡ q is not a compound proposition but, rather, is the
statement that p ↔ q is always true - tautology.
operator precedence
¬ 1
Λ 2
ν 3
→ 4
↔ 5
De Morgan's Laws
¬ (p Λ q) ≡ ¬p ν ¬q
¬ (p ν q) ≡ ¬p Λ ¬q
Predicates are a more general form of proposition. They behave as functions whose values are T or F. Predicates become
propositions when their variables are given actual values.
P(x) - propositional function - where P is the predicate "x2=4" and x is the variable. Once a value is assigned to the variable x, the
statement P(x) becomes a proposition and has a truth value.
Quantification expresses the extent to which a predicate is true over a range of elements. They expresses the meaning of the words all
and some.
Types of quantifiers:
• universal - "P(x) is true for all values of x in the universe of discourse" (Ɐx P(x) - "for all x"); if finite {n1, n2 ..., nk},
ⱯxP(x)↔P(n1)^P(n2) ^ ... ^ P(nk)
Ɐx <0(x2 >0) ↔ Ɐx(x<0 → x2>0)
*if the domain is empty, then ⱯxP(x) is true for any propositional function P(x), because there are no elemtns x in the domain
for which P(x) is false
• existential - "There exists a value x in the universe of discourse such that P(x) is true" (ⱻx P(x) - "there exists x"); if finite
{n1,n2 ..., nk}, ⱻxP(x)↔P (n1) v P(n2) v ... v P(nk)
ⱻz>0(z2=2) ↔ ⱻz(z>0^z2=2)
*if the domain is empty, then ⱻxQ(x) is false whenever Q(x) is a propositional function, because when the domain is empty,
there can be no element x in the domain for which Q(x) is true
• uniqueness (special case of existential) - "There exists a unique value x in the universe of discourse such that P(x) is true"
( ⱻ!xP(x) - "there exists a unique x")
Order of operators
- same type = order does not matter (ⱯxⱯy P(x,y) ≡ ⱯyⱯx P(x,y)
- different type = order does matter (Ɐxⱻy P(x,y) is different from ⱻyⱯx P(x,y)
Precedence of quantifiers
The quantifiers Ɐ and ⱻ have a higher precedence priority than all logical operators.
De Morgan's Laws
¬ⱯP(x) ≡ ⱻx¬P(x)
¬ⱻxP(x) ≡ Ɐx¬P(x)
in the case of nested quantifiers, we apply De Morgan's laws successively from left to right:
¬ⱯxⱻyⱯzP(x,y,z) ≡ ⱻx¬ⱻyⱯzP(x,y,z) ≡ ⱻxⱯy¬ⱯzP(x,y,z) ≡ ⱻxⱯyⱻz¬P(x,y,z)
4.2 Predicate logic. Rules of inference
Rules of inference can be seen as building blocks in constructing incrementally complex valid arguments.
Rules of inference:
• Modus ponens
• Modus tollens
• Conjunction
• Simplification
• Addition
• Hypothetical syllogism
• Disjunctive syllogism
• Resolution
Boolean algebra is a set B with two binary operations ν and Λ, elements 0 and 1, and a unary operation --- (') such that these
properties hold for all x, y, and z in B:
Fundamental operations:
- and (.) (logical product, intersection, conjunction)
- or (+) (sum, union, disjunction)
- not(') (logical complement of negation)
Precedence:
1) not
2) and
3) or
Boolean Function
Let B = {0, 1}, then Bn = {(x1,x2, ..., xn)} | xi ∈ B for 1 ≤ i ≤ n - is the set of all possible n-tuples of 0s and 1s.
Boolean variable is variable x, if it assumes values only from B, that is, if its only possible values are 0 and 1.
Boolean function is a function which defines a mapping from one or multiple Boolean input values to a Boolean output value.
Boolean function of degree n is a function from Bn to B.
Boolean Identities
Basic theorems
• idempotent laws
x + x = x, x . x = x
• tautology and contradiction
x + 1 = 1, x . 0 = 0
• involution
(x')' = x
• associative laws
(x + y) + z = x + (y + z), (x . y) . z = x . (y . z)
• absorption laws
x + (x . y) = x, x . (x + y) = x
• uniqueness of complement
if y + x = 1 and y . x = 0, then x = y'
• inversion law
0' = 1, 1' = 0
Duality (Fd)
we can build another equivalent Boolean relation by:
- chaning each + to . and each . to +
- changing each 0 to 1 and each 1 to 0
Example:
e1: (a . 1) . (0 + a') = 0 - dual for e1: (a + 0) + (1 . a') = 1
e2: a + a' . b = a + b - dual for e2: a . (a' + b) = a . b
Forms of function:
• in algebraic form, a function can be expressed in a variety of ways.
Example:
f(x) = x + x' . y and
f(x) = x + y
are both algebraic represenctions of the same truth Table.
• standardised forms
- sum of products ( f(x,y,z) = xy + xz + yz )
to build it, focus on:
- values that make the function 1
- if an input = 1, it appears uncomplemented
- if an input = 0, it appears complemented
- the function f is then expressed as the sum of products of all the terms for with f = 1
- product of sums ( f(x,y,z) = (x + y)(x + z)(y + z) )
Useful funcitons:
- 'exlusive-or' function ( x ⊕ y = x'y + xy' )
- 'implies' function ( x → y = x' + y )
5.2 Boolean argebra. Applications
A logic gate is defined as the basic element of circuits implementing a Boolean operation.
Additional gates
• XOR gate (true only when the values of the inputs differ)
• NAND gate (not and) commutative, but not associative
• NOR gate (not or) commutative and associative
• XNOR gate (not XOR)
Combinational circuits (logical networks) are a combination of logic gates designed to model Boolean functions.
The logic values assigned to the output signals is a Boolean function of the current configuration of input signals.
Simplifications
• algebraic simplification is based on the use of Boolean algebra theorems to represent and simplify the behaviour of Boolean
functions.
• karnaugh maps (or K-Map) is a graphical representation of Boolean functions and is different from a truth table. It can be
used for expressions with 2, 3, 4 or 5 variables. It is shown in a array of cells.
Number of cells in a KMap is the total number of possible input variable combinations = 2 k.