TOC Chapter-1-for reference

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 70

THEORY OF

COMPUTATION
Subject Code: 3160704

Nidhi S. Periwal
CKPCET, Surat
Chapter-1
Review of Mathematical Theory:

● Sets, Functions, Logical statements,


● Proofs, Relations, Languages,
● Principle of Mathematical Induction, Strong Principle, Recursive Definitions,
Structural Induction.
GTU Asked Questions of Previous Year
1. Define: Set, Subset, Complement
2. Write and explain the principle of mathematical induction using example.
3. Define one-to-one, onto and bijection function
4. The given relation R on set A= {1,2,3} determine whether the Relation is
reflexive, symmetric or transitive, give reason. R ={(1,1), (1,2), (1, 3),(2,1), (2,
2), (3, 1),(3,3)}
5. Write Principle of Mathematical Induction. Prove that for every n ≥ 1, 1 + 3 + 5
+ … + (2n - 1) = n^2
6. Define the following functions: one-one, on-to, and inverse.
7. Prove “There must be a prime number between n and n!”
SETS
● SETS
○ A set is a group of objects represented as a unit.
○ Sets may contain any type of object, including numbers, symbols, and even other sets.
○ The objects in a set are called its elements or members.
○ S = {7, 21, 57}
○ The symbols ∈ and denote set membership and nonmembership.
○ 7 ∈ {7, 21, 57} and 8 {7, 21, 57}.
SETS
● The order of describing a set doesn’t matter, nor does repetition of its members.
● We get the same set S by writing {57, 7, 7, 7, 21}.
● If we do want to take the number of occurrences of members into account, we call the group a
multiset instead of a set.
● Thus {7} and {7, 7} are different as multisets but identical as sets.
● An infinite set contains infinitely many elements.
● The set of natural numbers N as {1, 2, 3, . . . }.
● The set with zero members is called the empty set and is written ∅.
● A set with one member is sometimes called a singleton set, and a set with two members is called an
unordered pair.
● For sets, we use a type of picture called a Venn diagram. It represents sets as regions enclosed by
circular lines
● If we have two sets A and B, the union of A and B, written A∪B, is the set we get by combining all the
elements in A and B into a single set.
● The intersection of A and B, written A ∩ B, is the set of elements that are in both A and B.
● The complement of A, written , is the set of all elements under consideration that are not in A.
SETS
SETS
● To represent both sets in the same Venn diagram, we must draw them so that
they overlap, indicating that they share some elements, as shown in the
following figure.
● For example, the word topaz is in both sets. The figure also contains a circle
for the set START -j. It doesn’t overlap the circle for START -t because no
word lies in both sets.
SETS
SETS
SEQUENCES AND TUPLES
● A sequence of objects is a list of these objects in some order. We usually
designate a sequence by writing the list within parentheses. For example, the
sequence 7, 21, 57 would be written (7, 21, 57).
● The order doesn’t matter in a set, but in a sequence it does. Hence (7, 21, 57)
is not the same as (57, 7, 21).
● (7, 7, 21, 57) is different from both of the other sequences,
● The set {7, 21, 57} is identical to the set {7, 7, 21, 57}.
● As with sets, sequences may be finite or infinite.
● Finite sequences often are called tuples.
● A sequence with k elements is a k-tuple.
● Thus (7, 21, 57) is a 3-tuple.
● A 2-tuple is also called an ordered pair.
SEQUENCES AND TUPLES
● Sets and sequences may appear as elements of other sets and sequences.
For example, the power set of A is the set of all subsets of A.
● If A is the set {0, 1}, the power set of A is the set { ∅, {0}, {1}, {0, 1} }.
● The set of all ordered pairs whose elements are 0s and 1s is { (0, 0), (0, 1),
(1, 0), (1, 1) }.
● If A and B are two sets, the Cartesian product or cross product of A and B,
written A × B, is the set of all ordered pairs wherein the first element is a
member of A and the second element is a member of B.
SEQUENCES AND TUPLES
SEQUENCES AND TUPLES
Set operations
Set operations
Set operations
Set operations
Set operations
FUNCTIONS AND RELATIONS
● Functions are central to mathematics.
● A function is an object that sets up an input–output relationship.
● A function takes an input and produces an output. In every function, the same input always
produces the same output. If f is a function whose output value is b when the input value is
a, we write f (a) = b.
● A function also is called a mapping, and, if f (a) = b, we say that f maps a to b.
● For example, the absolute value function abs takes a number x as input and returns x if x is
positive and −x if x is negative. Thus abs(2) = abs(−2) = 2.
● Addition is another example of a function, written add .
● The input to the addition function is an ordered pair of numbers, and the output is the sum
of those numbers.
● The set of possible inputs to the function is called its domain.
● The outputs of a function come from a set called its range.
FUNCTIONS AND RELATIONS
FUNCTIONS AND RELATIONS
FUNCTIONS AND RELATIONS

● A function f : A → B is one-to-one if f never assigns the same value to two


different elements of its domain.
FUNCTIONS AND RELATIONS
FUNCTIONS AND RELATIONS

● Inverse Functions
○ An inverse function or an anti function is defined as a function, which can reverse
into another function. In simple words, if any function “f” takes x to y then, the
inverse of “f” will take y to x. If the function is denoted by ‘f’ or ‘F’, then the inverse
function is denoted by f-1 or F-1.
○ If f and g are inverse functions, then f(x) = y if and only if g(y) = x
○ In trigonometry, the inverse sine function is used to find the measure of angle for
which sine function generated the value. For example, sin-1(1) = sin-1(sin 90) = 90
degrees. Hence, sin 90 degrees is equal to 1.
FUNCTIONS AND RELATIONS-summary
● A function f : A → B is one-to-one if f never assigns the same value to two different elements
of its domain.
● It is onto if its range is the entire set B.
● A function from A to B that is both one-to-one and onto is called a bijection from A to B.
● If f and g are inverse functions, then f(x) = y if and only if g(y) = x
Relation
● A predicate or property is a function whose range is {TRUE , FALSE }.
● For example,
○ Let Even be a property that is TRUE if its input is an even number and FALSE if its input is an
odd number.
○ Thus even(4) = TRUE and even(5) = FALSE .
● A property whose domain is a set of k-tuples A × · · · × A is called a relation, a
k-ary relation, or a k-ary relation on A.
● A common case is a 2-ary relation called a binary relation.
● A special type of binary relation, called an equivalence relation, captures the
notion of two objects being equal in some feature.
LOGIC
● Logic involves propositions, which have truth values, either the value true or
the value false.
● The propositions “0 = 1” and “peanut butter is a source of protein” have truth
values false and true, respectively.
● When a simple proposition, which has no variables and is not constructed
from other simpler propositions, is used in a logical argument, its truth
value is the only information that is relevant.
● A proposition involving a variable may be true or false, depending on
the value of the variable. If the domain, or set of possible values, is
taken to be N , the set of nonnegative integers, the proposition “x − 1 is
prime” is true for the value x = 8 and false when x = 10.
● Implication : p -> q , p implies q
LOGIC
LOGIC

● Truth table
LOGIC
● A tautology is a compound proposition that is true for every possible
combination of truth values of its constituent propositions—in other words,
true in every case.
● A contradiction is the opposite, a proposition that is false in every case.
● The proposition p ∨ ¬p is a tautology, and p ∧ ¬p is a contradiction.
● p ↔ q is true precisely when p and q have the same truth values
● P ⇔ Q to mean that the compound propositions P and Q are logically
equivalent. A related idea is logical implication.
● We write P ⇒ Q to mean that in every case where P is true, Q is also true,
and we describe this situation by saying that P logically implies Q.
Proof
● A proof is a convincing logical argument that a statement is true.
● A theorem is a mathematical statement proved true.
● We prove statements that are interesting only because they assist in the proof
of another, more significant statement. Such statements are called lemmas.
● Lemmas: Generally minor, proven proposition which is used as a stepping
stone to a larger result.
● A typical step in a proof is to derive a statement from initial assumptions and
hypotheses, or from statements that have been derived previously, or from
other generally accepted facts, using principles of logical reasoning.
Proof
● proof by Example
● proof by contrapositive
● proof by contradiction.
Proof
If statement p implies q, then its contrapositive is ∼q implies ∼p, and its converse is q implies p.
Proof by Contradiction
Mathematical Induction
● Mathematical Induction is a technique of proving a statement, theorem or
formula which is thought to be true, for each and every natural number n.
● It is a concept in mathematics that is used to prove various mathematical
statements and theorems.
● The principle of mathematical induction is sometimes referred to as PMI.
● It is a technique that is used to prove the basic theorems in mathematics which
involve the solution up to n finite natural terms.
● The technique involves two steps to prove a statement, as stated below −
○ Step 1(Base step) − It proves that a statement is true for the initial value.
○ Step 2(Inductive step) − It proves that if the statement is true for the nth iteration (or number n), then it
is also true for (n+1)th iteration ( or number n+1).
○ Step 1 − Consider an initial value for which the statement is true. It is to be shown that the statement is true for n = initial value.
○ Step 2 − Assume the statement is true for any value of n = k. Then prove the statement is true for n = k+1. We actually break n =
k+1 into two parts, one part is n = k (which is already proved) and try to prove the other part.
Mathematical Induction
Let P(n): n3 + 2n is divisible by 3 be the given statement.

Step 1: Basic Step

Firstly we prove that P(1) is true. Let n = 1 in n3 + 2n


= 13 + 2(1)
=3

As 3 is divisible by 3. Hence, P(1) is true.

Step 2: Assumption Step

Let us assume that P(k) is true

Then, k3 + 2k is divisible by 3

Thus, we can write it as k3 + 2k = 3n, (where n is any positive integer)….(i)


Step 3: Induction Steps

Now we have to prove that algebraic expression (k + 1)3 + 2(k + 1) is divisible by 3

= (k + 1)3 + 2(k + 1)

= k3 + 3k2 + 5k + 3

= (k3 + 2 k) + (3k2 + 3k + 3)

from eq(i)

= 3n + 3(k2 + k + 1)

= 3(n + k2 + k + 1)

As it is a multiple of 3 we can say that it is divisible by 3.

Thus, P(k+1) is true i.e. (k + 1)3 + 2(k + 1) is be divisible by 3. Now by the Principle of Mathematical
Induction, we can say that, P(n): n3 + 2n is divisible by 3 is true.
● Strong induction is a variant of induction, in which we assume that the
statement holds for all values preceding k. This provides us with more
information to use when trying to prove the statement.
LANGUAGES
● A language to be any set of strings over an alphabet of symbols.
● Many of the languages we study initially will be much simpler. They might
involve alphabets with just one or two symbols, and perhaps just one or two
basic patterns to which all the strings must conform.
LANGUAGES
Operations
● The basic operation on strings is concatenation. If x and y are two strings
over an alphabet, the concatenation of x and y is written xy and consists of
the symbols of x followed by those of y. If x = ab and y = bab, for example,
then xy = abbab and yx = babab.
● When we concatenate the null string with another string, the result is
just the other string.
● (for every string x, xΛ = Λx = x);
● In general, for two strings x and y, |xy| = |x| + |y|.
● Concatenation is an associative operation; that is, (xy)z = x(yz), for all
possible strings x, y, and z. This allows us to write xyz without specifying how
the factors are grouped
Operations
● If s is a string and s = tuv for three strings t, u, and v,
○ then
○ t is a prefix of s,
○ v is a suffix of s,
○ and u is a substring of s.
○ Because one or both of t and u might be , prefixes and suffixes are special cases of
substrings.
○ The string Λ is a prefix of every string, a suffix of every string, and a substring of every string,
and every string is a prefix, a suffix, and a substring of itself.
Union:
* (Kleene closure)
L+: It is a Positive Closure that represents a set of all strings except Null or ε-strings.

L*: It is “Kleene Closure“, that represents the occurrence of certain alphabets for given language alphabets from zero to the infinite
number of times.

In which ε-string is also included.


RECURSIVE DEFINITIONS
● Recursion as a tool for defining sets: primarily, sets of numbers, sets of
strings, and sets of sets (of numbers or strings).
● A recursive definition of a set begins with a basis statement that specifies one
or more elements in the set.
● The recursive part of the definition involves one or more operations that can
be applied to elements already known to be in the set, so as to produce new
elements of the set.

You might also like