Paper - I Discrete Mathematics
Paper - I Discrete Mathematics
(PRIDE)
PERIYAR UNIVERSITY
SALEM - 636 011.
1
Prepared by :
Dr. I. LAURENCE AROQUIARAJ
Assistant Professor
Department of Computer Science
Periyar University
Periyar Palkalai Nagar
Salem – 636 011.
2
M.Sc. COMPUTER SCIENCE
FIRST YEAR
PAPER – I : DISCRETE MATHEMATICS
UNIT-I
Mathematical logic connectives-negation-conjunction-disjunction
statement formulas and truth tables: Well-formed formulas-tautologies-
equivalence of formulas –duality law-normal forms: Disjunction Normal Form-
principal Disjunction Normal Form-principal conjunction Normal Form.
UNIT-II
Theory of inference Validity using truth table-The predicate Calculus-
predicates, Statement function, variables and Quantifiers-inference Theory of
predicates Calculus: Valid formulae and equivalence.
UNIT-III
Relations and functions Relation and ordering-relation-properties of
Binary relation in a ser-functions-Definition and introduction-composition of
functions-inverse functions-Binary and n-Array operations-Hashing functions-
Natural Numbers - peano Axioms and Mathematical induction-Cardinality.
UNIT-IV
Lattices and Boolean algebra Lattices and partially Ordered Sets-
Definition and Example-Some properties of Lattices-Lattices of Algebra
system-sub lattices-Direct product and Homomorphism-Boolean function-
Boolean forms and Free Boolean Algebra-Values of Boolean Expression and
Boolean Function.
UNIT-V
Languages and finite state machines Grammars and Languages:
Discussion Of grammars-Formal Definition of language-Finite state machines-
Introductory Sequential Circuit-Equivalence-of finite State Machines-Finite
State Acceptors and Regular Grammars.
3
TEXT BOOK:
1. J.P. Trembley and R. Manohar, Discrete Mathematical structures with
Applications to computer science, Tata McGraw Hill, New Delhi, 1997.
REFERENCE BOOK:
1. James C. Abbott, sets, Lattices and Boolean algebra, Allyn and Bacon,
inc.Boston.1969.
2. J.E. Hopcropt and J.D. Ullman, Formal Languages and Their Relations
to Automata, Addtion-weslypub.comp.Reading Mass, 1969.
3. H.G. Flegg, Boolean algebra and its Applications, john Wiley and sons
inc. New York, 1974.
4
M.Sc. COMPUTER SCIENCE
FIRST YEAR
PAPER – I : DISCRETE MATHEMATICS
CONTENTS
UNIT TITLE
1.1 Mathematical logic connectives
1.2 Negation
1.3 Conjunctions
I 1.4 Disjunction statement formulas and truth tables
1.5 Well defined formulas-tautologies-equivalence of
formula
1.6 Duality law-normal forms
1.7 Disjunction normal forms
2.1 Theory of inference Validity using truth table
2.1.1 Definition1
2.1.2 Definition2
2.2 The Predicate Calculus
II
2.3 Predicates
2.4 Statement Function
2.5 Variables And Quantifiers
2.6 Inference Theory of predicates Calculus
3.1 Relations and functions Relation and ordering
3.1.1 Notation
3.1.2 Properties
3.1.3 Injective and surjective function
3.2 Composition of functions
III
3.3 Inverse functions
3.3.1 Inverse graph function
3.4 Hashing functions
3.5 Peano Axioms And Mathematical Induction
3.6 Cardinality
5
4.1 Lattices and Boolean algebra Lattices and
partially Ordered Sets
4.2 Definition and Example
4.3 Some properties of Lattices
4.4 Lattices of Algebra system-sub lattices
IV
4.5 Direct product and Homomorphism
4.6 Boolean function
4.7 Boolean forms and Free Boolean Algebra
4.8 Values of Boolean Expression and Boolean
Function.
5.1 Discussion of grammars
5.2 Formal Definition of language
5.3 Finite state machines
V
5.4 Introductory Sequential Circuit
5.5 Equivalence-of finite State Machines
5.6 Finite State Acceptors and Regular Grammars
6
UNIT - I
In this chapter:
Mathematical logic connectives
Negation
Conjunctions
Disjunction statement formulas and truth tables
Well defined formulas-tautologies-equivalence of formula
Duality law-normal forms
Disjunction normal forms
Principal disjunction normal form
Principal conjunction normal from
Mathematical logic connectives:
The notions of a statement and of its truth value have already been
introduced. In the case of simple statement, their truth values are airy obvious.
However, it is possible to construct rather complicated statements from simpler
statements by using certain connecting word or expressions known as sentential
connectives. We define these connectives in this section and then develop
methods to determine the truth values of statements that are formed by using
them. Various properties of these statements’ and some relationships between
them are also discussed. In addition, we show that the statements along with the
connectives define an algebra that satisfies a set of properties. These properties
enable us to do some calculations by using statements as objects.
The statements that we consider initially are simple statements called
atomic or primary statements. As already indicates, new statements can be
formed from atomic statements through the use of sentential connectives. The
resulting statements are called molecular or compound statements. Thus the
atomic statements are those called molecular or composed statements. Thus the
atomic statements are those which do not have any connectives.
This dual use of the same symbol to denote either a define statement,
caked a constant, or an arbitrary statement, called a variable, does not cause any
confusion as its use will be clear from the context. The truth values of “P” are
the truth value of the actual statement which is represents. is should be
emphasized that when “P” is used as a statements variable, it has no truth value
and as such does not represent a statement in symbolic logic. Let P:it is raining
today, Q: it is snowing and let R be a statements variables whose possible
replacements are P and Q. if no replacement for R is specified. It remain a
statement variable and has no truth table. On other hand, the truth values of P
and Q can be determined because they are statements.
7
Negation:
The negation of a statement us generally formed by introducing the
word “not” at a proper place in the statement or by prefixing the statement with
the phrase” it is not the case that. If “P” denotes a statement, then the negation
of “P” is written as “¬P” and read as “not P”. If the truth value of “P” is T. then
the truth value of “¬P” if F. Also if the negation is summarized by table1.2.
Notice that we have not used the quotation marks to denote the names
of the statements in the table. This practice is in keeping with the on adopted
separate line. From now on we shall drop the quotation marks even within the
text when we use symbolic names for the statements, except in the case where
this practice may lead to confusing. We now illustrate the formation of the
negation of a statement.
Consider the statement
P: London is a city.
Then ¬P is the statement
¬P: it is not the case the London is a city>
Normally ¬P can be written as
¬P: London is a city.
Although the two statement “it is not the case that London is a city” and
“ London is not a city” are not identical, we have translate both of them by ¬P.
the reason is that both these statements have the same meaning in English. A
given statement in the object language is denoted by a symbol, and it may
correspond to several statements in English. This multiplicity happens because
in a natural language one can express oneself in a variety of ways.
As an illustration, if a statement is
P: I want to my class yesterday.
Then ¬P is any one of the following, I did not go to my lass yesterday.
Table1.2 negation
P ¬P
T F
F T
I was absent from my class yesterday.
It is not the case that I went to my class yesterday.
The symbol”¬” has been used here to denote the negation. Alternate
symbols used us called are” “a bar, or “NOT” so that ¬P is written as P, P, or
8
NOT P. Note that a negation is called a connective which operates on a single
statement or a variable. The word “operation” will be explained in it. For the
present it is sufficient to note that an operation on statements generates other
statements..We have chosen”¬”to denote negation because this symbol is
commonly used in the textbooks on logic and also in several programming, one
of which will be used here.
Conjunction:
The conjunction of two statements P and Q is the statement P and Q is the
statement P ^ Q which is read as “P and Q”. The statement P ^ Q has the truth
value T Whenever both P and Q the truth value T; otherwise it has the truth
value F. The conjunction is defined by table1.3.
Examples 1
form the conjunction of
P: It is raining today.
Q: There are 20 tables in this room.
Normally, in our everyday language the conjunction “and” is used
between two statements which have some kind of relation. Thus a statement” It
is raining today and 2+2=4” sounds odd, but in logic it is a perfectly acceptable
statement formed from the statement”. It is raining today “and “2+2=4”.
Example 2
In order to write it as a conjunction of two statements, it is necessary
first to paraphrase the stamen as Jack went up the hill and Jill went up the hill.
Table1.4.conjunction
P Q P^ Q
T T T
T F F
F T F
F F F
If we now write
P: Jack went up the hill.
Q: Jill went up the hill
Then the given statement can be written in symbolic form as P ^ Q.
So far we have seen that the symbol we have seen that the symbol ^ is
used as a translation of the connective “and” appearing in English. However,
the connective “and” is sometimes used in a different sense, and in such cases it
9
cannot be translated by the symbol ^ defined above. In order to see this
difference, consider the statements:
1. Roses are red and violet are blue.
2. He opened the book and started to read.
3. Jack and Jill are cousins.
In statement (1) the conjunction “and” is used in the same as the symbol
^. In (2) the word “and” is used in the sense of “and then”, because the action
described in “he started to read” occur after the action described in “he opened
the book”. In (3) the word “and” is not conjunction. Note that our definition of
conjunction is symmetric as far as P and Q are concerned; that is to say, the
truth values of P ^ Q and Q P are the same for specific values of P and Q.
Obviously the truth value of (1) will not change if we write it.
Disjunction:
The disjunction of two statement P and Q is the statement P Q which
is read as “ P or Q”. The statement P Q has the truth value fondly when both
p and Q have the truth value F; otherwise it is true. The disjunction is defined
by table1.5.
10
“inclusive OR”. In (3) the “or” is used for indication an approximate number of
animals, and it is not used as a connective.
From the definition of disjunction it is clear that ˅ is “inclusive OR”.
The symbol ˅ comes from the Latin word “vel” which is the “inclusive OR”, it
is not necessary to introduce a new symbol for exclusive OR”, since there are
other ways to express it, in terms of the symbols already defined. We
demonstrate this point. Normally in our everyday language, the definition
“or” is used between two statements which have some kind some kind of
relationship between them. It is not necessary in logic that there be any
relationship between them according to the definition of disjunction. The truth
value of P ˅ Q depends only upon the truth values of P and Q.As before, it
may be necessary to paraphrase given statements in English before they can be
translated into symbolic form. Similarly, translations of statements from
symbolic logic into statements in English may require paraphrasing in order to
make them grammatically acceptable.
Disjunction Statement Formulas and Truth tables
We have defined the connectives ¬, and so far. Other connectives
will be defined subsequently. We shall occasionally distinguish between two
types of Statements in our symbolic language. Those statements which do not
contain any connectives are called atomic or primary or simple statements. On
the other hand, those statements which contain on or more primary statements
and some connectives are called molecular or composite or compound
statements. As an example, let P and Q be any two statements. Some of the
compound statements formed by using P and Q are
P Q( P Q) (P)P (Q)
The compound statements given above are statement formulas derived
from the statement variable P and Q, therefore, P and Q may be called the
components of the statement formulas. Observe that in addition to the
connectives we have also used parentheses in some cases in order to make the
formula unambiguous, we discuss the rule of s constructing statement formulas.
Recall that a statement formula has no truth value. It is only when the
statement variable in a formula are replaced by definite statements that we get
statement. This Statement has a truth value which depends upon the truth value
of the statements used in replacing variables’. In the construction of formulas,
the Parentheses will be used in the same sense in which they are used in
elementary arithmetic or algebra or sometimes in a computer programming
language. This usage means that the expressions in the innermost parentheses
are simplified first. With this convention in mind ¬(PQ)means the negation of
11
P Q. Similarly (PQ) (QR)means the disjunction of PQ and QR.
((PQ)R) (¬P) means the conjunction of ¬P and (PQ)R, while
(PQ)R means the disjunction of P Q and R.
Example1 Construct the truth table for the statement formula P¬Q
Solution: it is necessary to consider all possible truth values of P and
Paths values are entered in the first columns of the table 1.6.for both methods.
In the table which is arrived at by method 1, the truth values ¬Q are entered in
the third column, and the truth values of P ¬Q are entered in the fourth
column. In method 2, as given in table1.6.,a column is drawn for each
statement as well as for the connectives that appear. The truth values are
entered step by step. The step numbers at the bottom of the table show the
sequence followed in arriving at the final step.
Table1.6.method 1
P Q ¬Q P ¬Q
T T F T
T F T T
F T F F
F F T T
Table1.7.method 2
P Q P ¬ Q
T T T T F T
T F T T T F
F T F F G T
F F F T T F
STEP
NUMBER 1 3 2 1
12
Table1.8 method 1
P ¬P P ¬P
T F F
F T F
Table1.8.1 Method 2
P P ¬ P
T T F F T
F F F T F
Step
Number 1 3 2
1
EXERCISES:
1. Using the statements
R: Mark is rich.
H: Mark is happy.
Write the following statements in symbolic form:
a) Mark is poor but happy.
b) Mark is rich or unhappy.
c) Mark is neither rich nor happy.
d) Mark is poor or he is both rich and unhappy.
2. Construct the truth tables for the following formulas.
a) (P Q)
b) (P Q)
c) P ( P Q)
d) P (Q P)
e) ( P Q) (P Q) ( P Q) (P Q)
3. Given the truth values of P and Q as T and those of R and S as F, find the
truth values of the following:
a) P (Q R)
b) ( P (Q R)) (( P Q) ( R S ))
13
Well-formed formulas-etiologies-equivalence of formulas
A propositional variable is similar to any real variable you see in
mathematics. For example x is a variable that can take any mathematical value.
Similarly, a propositional variable, says P, can take any proposition as a value.
The proposition as a value is called a propositional constant.
Definition:
Wffs produce a proposition. To construct a WFF for predicate logic, following
rules are applicable:
(A) ‘True’ (T) and ‘False’ (F) are wffs.
(B) A propositional constant (i.e. a specific proposition) and each
propositional variable are wffs.
(C) If P and Q are wffs then so are ¬P, P Q, P V Q, P→Q and P ↔ Q.
(D) If x is a variable (representing objects of the universe of discourse) and P
is a wff then so are ∀P and ∃P. (These are the existential quantifiers and
will be focused upon in separate section).
(E) A string of propositional variables is a wff if and only if it is obtained by
a finite number of applications of (A) – (D).
Truth table for a Well Formed Formula
If A is a WFF consisting of n propositional variables, then the table
giving all possible truth values for the WFF A obtained by replacing these
propositional variables by arbitrary truth values is called the truth table for A.
If WFF A has n propositional variables then there will be 2n possible
combinations of truth values for these and hence 2n rows in the truth table for
wff A.
Example:
Construct the truth table for the following:
(P ∨ Q) → ((P ∨ R) → (R ∨ Q))
Solution: let’s denote the above wff by A. A contains 3 propositional variables;
hence there will be 23=8. Rows in the truth table of A as obtained below:
P Q R P∨Q P∨R R∨Q (P ∨ R) A
→ (R ∨Q)
F F F F F F T T
F F T F T T T T
F T F T F T T T
F T T T T T T T
14
T F F T T F F F
T F T T T T T T
T T F T T T T T
T T T T T T T T
Tautology and Contradiction
(a) Tautology: A WFF α is said to be a Tautology if in its truth table all the
values in last column are T (True) only.
(b) Contradiction: A WFF α is said to be a Contradiction if in its truth table
all the values in last column are F (False) only.
Equivalence of Well Formed Formulas
Two Wffs α and β are said to be equivalent (or logically equivalent) if
the formula α ↔ β is a tautology. When α and β are equivalent, we write α ≡ β.
Example:
Prove the equivalence of following:
P ≡ (P ∨ Q) ∧ (P ∨ ¬Q)
Solution:
Let α denote P
And β denote (P ∨ Q) ∧ (P ∨ ¬Q)
Then we need to prove that α ↔ β is a tautology. This can be done with the
help of following truth table:
F F T F T F T
F T F T F F T
T F T T T T T
T T F T T T T
As we can see that the last column of the table (values for α ↔ β)
contains the truth values T (True) only, this implies that α ↔ β is a tautology
and hence the equivalence holds.
15
Logical identities
Definition:
Logical identities are certain equivalences which can be used to
simplify other complex Wffs. The procedure for doing so is based on the
following paradigm that if a WFF β is part of another WFF α and β is
equivalent to β’ then, it can be replaced by β’ in α and the resulting WFF will
still be equivalent to α. All the logical identities can be proved by the
equivalence proof method described above. Some commonly useful logical
identities are listed in the below:
1. Idempotent laws
P ∨ P ≡ P, P ∧ P ≡ P
2. Commutative law
P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
3. Associative law
P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R,
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
4. Distributive law
P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R),
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
5. Absorption law
P ∨ (P ∧ Q) ≡ P,
P ∧ (P ∨ Q) ≡ P
6. De Morgan’s law
¬ (P ∨ Q) ≡ ¬P ∧ ¬Q,
¬ (P ∧ Q) ≡ ¬P ∨ ¬Q
7. Double negation
P ≡ ¬ (¬P)
8. P ∨ ¬P ≡ T, P ∧ ¬P ≡ F
9. P ∨ T ≡ T, P ∨ F ≡ P, P ∧ T ≡ P, P ∧ F ≡ F,
10. P → Q ≡ ¬P ∨ Q
11. (P → Q) ∧ (P → ¬Q) ≡ ¬P
12. Contra positive
P → Q ≡ ¬Q → ¬P
(NOTE: Try to remember as many identities as you can. These are a real
help in the exams.)
16
Example:
We’ve proven the following equivalence by method of truth table above:
P ≡ (P ∨ Q) ∧ (P ∨ ¬Q) now let’s prove the same by using logical identities.
Solution:
Taking the R.H.S.:
R.H.S. ≡ (P ∨ Q) ∧ (P ∨ ¬Q)
≡ P ∨ (Q ∧ ¬Q) (Distributive Law)
≡P∨F
≡P
≡ L.H.S.
DUALITY NORMAL FORMS:
The formal mathematical definition of a relational database includes the
concept of “Normal Forms.” Each of the Forms is designed to logically address
potential problems in referring to and working with information stored in a
database. A database is said to be in one of the Normal Forms if it satisfies the
rules required by that Form. It also will not suffer from any of the problems
addressed by the Form.
DISJUNCTION NORMAL FORM:
The conjunction of two statements P and Q is the statement
which is read as “ P and Q”.The statement has the truth table value
Twhen ever both P and Q have the truth table T. Otherwise, it has the truth
value F. The conjunction is defined by Tables 1.2.2.
Examples 1: form the conjunction of
P: it is raining today.
Q: There are 20 tables in this room.
Normally, in our everyday language the conjunction “and” is used
between two statements which have some kind of relation. Thus a statement “It
is raining today and 2+2=4” sounds odd, but in logic it is a perfectly acceptable
statement formed from the statements “It is raining today” and 2+ 2=4.”
Example 2:
Translate in to symbolic form the statement Jack Jill went up the hill.
Solution in order to write it as conjunction of two statements, it is necessary
first to paraphrase the statement as jack went up the hill.
17
Table1.2.2
P Q ˄
T T T
T F F
F T F
F F F
P: jack went up the hill
Q: jill went up the hill.
Then the given statement can be written in symbolic form as ˄
So far we have seen that the symbol ˄ is used as a translation of the
connective and appearing in English. However, the connectives “and” is
sometimes used in different sense, and in such cases is cannot be translate by
the symbol ˄ defined above. In order to see this difference, consider the
statements:
Roses are red and violets are blue.
He opened the book and started to read.
Jack and Jill are cousins.
A disjunctive normal form (DNF) is a standardization (or
normalization) of a logical formula which is a disjunction of
conjunctive clauses; it can also be described as an OR of ANDs, a sum of
products, or (in philosophical logic) a cluster concept. As a normal form, it is
useful in automated theorem proving. A logical formula is considered to be in
DNF if and only if it is a disjunction of one or more conjunctions of one or
more literals.
A DNF formula is in full disjunctive normal form if each of its
variables appears exactly once in every clause. As in conjunctive normal
form (CNF), the only propositional operators in DNF are and, or, and not.
The not operator can only be used as part of a literal, which means that it can
only precede a propositional variable. For example, all of the following
formulas are in DNF:
∧ ∧ ∨ ∧ ∧
∧ ∨
But and also
∧ A
However, the following formulas are NOT in DNF:
18
∨ — NOT is the outermost operator
∨ ∧ ∨ — an OR is nested within an AND
Converting a formula to DNF involves using logical equivalences, such
as the double negative elimination, De Morgan's laws, and the distributive law.
All logical formulas can be converted into disjunctive normal form.
However, in some cases conversion to DNF can lead to an exponential
explosion of the formula. For example, in DNF, logical formulas of the
following form have 2n terms:
∨ ∧ ∨ ∧ ∧ ∨
Any particular Boolean function can be represented by one and only
one full disjunctive normal form, one of the two canonical forms.
An important variation used in the study of computational
complexity is k-DNF. A formula is in k-DNF if it is in DNF and each clause
contains at most k literals. Unlike the corresponding subclasses of conjunctive
normal form for k>=3, there is no easy algorithm to convert an arbitrary
instance of a formula in DNF to k-DNF.
1.2 CONJUNCTIVE NORMAL FORM:
In conjunctive normal form (CNF) or clausal normal form .it is
a conjunction of clauses, where a clause is a disjunction of literals; otherwise
put, it is an AND of ORs. As a normal form, it is useful in automated theorem
proving. It is similar to the product of sums form used in circuit theory.
All conjunctions of literals and all disjunctions of literals are in CNF, as
they can be seen as conjunctions of one-literal clauses and conjunctions of a
single clause, respectively. As in the disjunctive normal form (DNF), the only
propositional connectives a formula in CNF can contain are and, or, and not.
The not operator can only be used as part of a literal, which means that it can
only precede a propositional variable or a predicate symbol.
In automated theorem proving, the notion "clausal normal form" is often
used in a narrower sense, meaning a particular representation of a CNF formula
as a set of sets of literals.
Examples:
All of the following formulas in the variables A, B, C, D, and E are in
conjunctive normal form:
∧ ∨
∨ ∧ ∨ ∨ ∧ ∨
∨
∧
19
The last formula is in conjunctive normal form because it can be seen as
the conjunction of the two single-literal clauses A and B. Incidentally; the last
two formulas are also in disjunctive normal form.
The following formulas are not in conjunctive normal form:
∨
∧ ∨
∧ ∨ ∧
Every formula can be equivalently written as a formula in conjunctive
normal form. In particular this is the case for the three non-examples just
mentioned; they are respectively equivalent to the following three formulas,
which are in conjunctive normal form:
∧
∨ ∧ ∨
∧ ∨ ∧ ∨
1.3 PRINCIPAL CONJUNCTIVE NORMAL FORM
In order to prove theorems automatically, you must first convert logical
formulas (or the negation of the statement of the theorem) into conjunctive
normal form. Disjunctive normal form is where the logical expression looks
like
∧ ∧ ∧
Where each of the' s is a clause -- an expression of the form
∨ ∨
Where, each of the Ti s is either a variable or the negation of a variable. Using
de Morgan's Laws and distributive of over , it is possible to
convert any expression into conjunctive normal form.
General rules for converting expressions to conjunctive normal form:
Replace operators of the form , , , ≠, →, and ≤ by their equivalents in
terms of and :
Table: 1.3.1
pq p q
pq p q
20
pq (p q) ( p q)
p≠>q ( p q)
p<≠q p q
21
Then we “import” ¬, so that the ‘¬’ sign appears only attached to
propositional letters. How? We saw earlier (exercise 21) that 15It doesn’t much
matter since the question hardly ever arises.
Tautology and validity:
¬ (A ∧ B) and ¬A ∨ ¬B are logically equivalent; and ¬(A ∨ B) and ¬A
∧ ¬B are logically equivalent; So ¬(A ∧ B) can be rewritten as ¬A ∨ ¬B and
¬(A ∨ B) can be rewritten as ¬A ∧ ¬B. There is also: ¬ (A → B) is logically
equivalent to A ∧ ¬B so ¬(A → B) can be rewritten as A ∧ ¬B; The effect of
these rewritings is to “push the negations inwards” or—as we say—import
them. Then we can use the two distributive laws to turn formula into CNF or
DNF
DNF A ∨ (B ∧ C) (A ∨ B) ∧ (A ∨ C) (2.1) means that A∨ (B∧C)
and (A∨B)∧(A∨C) are logically equivalent, so A ∨ (B ∧ C) can be rewritten as
(A ∨ B) ∧ (A ∨ C). The use this to “push ∨ inside ∧” if we want to put the
formula into CNF or A ∧ (B ∨ C) (A ∧ B) ∨ (A ∧ C) (2.2)
Which means that A ∧ (B ∨ C) and (A ∧ B) ∨ (A ∧ C) are logically
equivalent so A ∧ (B ∨ C) can be rewritten as (A ∧ B) ∨ (A ∧ C). We use this
to “push ∧ inside ∨” if we want the formula in DNF Two further simplifications
are allowed: 1.
We can replace B ∧ (A ∨ ¬A) by B; 2. We can replace B ∨ (A ∧ ¬A) by
B. (because B ∧(A∨ ¬A) is logically equivalent to B, and B ∨(A∧ ¬A) is
logically equivalent to B). Here are some examples: 1. (p ∨ q) → r convert the
‘→’: ¬(p ∨ q) ∨ r import ‘¬’ (¬p ∧ ¬q) ∨ r and it is now in DNF. Then
distribute ‘∨’ over ‘∧’ to obtain (¬p ∨ r) ∧ (¬q ∨ r)
p → (q ∧ r) convert the ‘→’: ¬p ∨ (q ∧ r) and it is now in DNF.
Then distribute ‘∨’ over ‘∧’ to obtain (¬p ∨ q) ∧ (¬p ∨ r) which is now in CNF.
(p∨ q) ∧ (¬p ∨ r) is in CNF. To get it into DNF we have to distribute the
‘∧’ over the ‘∨’. (Match ‘A’ to ‘p∨q’, match ‘B’ to ‘¬p’ and ‘C’ to ‘r’ in ‘A ∧
(B ∨ C) ((A ∧ B) ∨ (A ∧ C))’.) ((p∨ q) ∧ ¬p) ∨ ((p ∨ q) ∧ r) and then
distribute again in each disjunctive: ((p ∧ ¬p) ∨ (q ∧ ¬p)) ∨ ((p ∧ r) ∨ (q ∧ r))
Now p ∧ ¬p is just ⊥. . . ((⊥∨ (q ∧ ¬p)) ∨ ((p ∧ r) ∨ (q ∧ r)) and ⊥∨ (q ∧ ¬p) is
just q ∧ ¬p: ((q ∧ ¬p) ∨ ((p ∧ r) ∨ (q ∧ r)) finally dropping beckets because ‘∨’
is associative . . . (q ∧ ¬p) ∨ (p ∧ r) ∨ (q ∧ r) Note that in CNF (DNF) there is
no requirement that every conjunct (disjunctive) has to contain every letter.
In DNF inconsistencies vanish: the empty disjunction is the false; in
CNF tautologies vanish: the empty conjunction is the true. (Recall what we
were saying on page 40 about the empty conjunction and the empty
disjunction.)
22
Finally, by using CNF and DNF we can show that any truth-functional
connective whatever can be expressed in terms of ∧, ∨ and ¬. Any formula is
equivalent to the disjunction of the rows (of the truth-table) in which it comes
out true. We illustrated this earlier 2.4.3 with the expression A ( B C ) .
Exercise:
1. Construct a circuit diagram for a simple elevator control circuit which
operates as follows. When a person pushes the button to summon the
elevator to a after, elevator responds to this request unless it is already
answering a previous call to another floor. In this latter case, the
request is ignored. Assume that are only three floors in the building.
2. For the formula (P ∨ Q ) ∧ (¬R ∧ ¬P),draw a corresponding circuit
diagram using (a) NOT, AND, and OR gates;(b) NAND gates only.
3. Show the following
( P Q) P Q ( P Q) P Q
4. Write a formula which is equivalent to the formula
P (Q R)
5. And contains the connectives NAND ( ) only. Obtain an equivalence
formula which contains the connective NOR ( ) only.
6. Show that P P Q R and R P P Q.
7. Show that the set , is functionally complete.
8. A connective denoted by
.
is defined by truth table 1.2, show
that ,
is functionally complete.
*
23
(b) ( P Q)
(c) ( P Q)
(d) ( P
Q)
(e) ( P Q)
(f) ( P Q)
12. Obtain the principal conjunction normal forms of (a),(b),(c),and (d).
13. Obtain the product of sums canonical forms of the following
formulas.
a) ( P Q R) (P R Q) (P Q R)
(S P R Q ) ( S P R Q ) (S P R Q )
b)
(Q P R S ) ( P S R Q )
c) ( P Q) (P Q) ( P Q)
d) ( P Q) (P Q R)
14. Obtain the principal disjunctive and conjunctive normal forms of the
following formulas.
(a) (P Q) ( P
Q)
(b) Q ( P Q)
(c) P (P (Q (Q R)))
(d) ( P (Q R)) (P (Q R))
(e) P ( P (Q P))
(f) (Q P) (P Q)
15. Which of the above formulas are tautologies?
16. Show the validity of the following arguments, for which the premise
are given on the left and the conclusion on the right.
(a) ( P Q), Q R, R
(b) ( A B) ( A C ), ( B C ), D A
(c) J (M N ), ( H G) J , H G
(d) P Q, (Q R) R, (P S )
(e) ( P Q) R, R S , S
24
17. Derive the following, using rule CP if necessary.
(a) P Q, Q R, R S P S
(b) P, P (Q ( R S )) Q S
(c) P Q P ( P Q)
(d) ( P Q) R ( P Q) R
(e) P (Q R), Q ( R S ) P (Q S )
18. Show that the following sets of premises are inconsistent.
(a) P Q, P R, Q R, P
(b) A ( B C ), D ( B C ), A D
Hence show that p Q, P R, Q R, P M and
A ( B C ), D ( B C), A D P
19. Show the following (use indirect method if needed).
(a) ( R Q), R S , S Q, P Q P
(b) S Q, S R, R, R
Q P
20. Show the following, using the system given in the formulas
(a) P (P Q)
(b) P P Q R
R P P Q
25
NOTES
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
26
UNIT - II
In this chapter:
Theory of inference validity using truth table
Definition1
Definition2
The predicate calculus
Predicates
Statement function
Variables and quantifiers
Inference theory of predicates calculus
2.1 THEORY OF INFERENCE VALIDITY USING TRUTH TABLE:
2.1.1 Definition 1
A proposition is a statement which has a definite truth value (either true
or false). We also use the term Proposition informally when distinguishing
Propositions, Theorems, Corollaries, and Lemmata. A Theorem is usually a big
result you have to work hard for proposition is a little theorem which probably
follows fairly quickly from definitions. A Lemma is a technical result mostly
sued in proving other theorems. A Corollary is a result which follows quickly
from a Theorem or Proposition. Since all of the statements of Theorems,
Propositions, Lemata, and Corollaries are sentences with determinate truth
value, all are propositions. In fact, they are all propositions which are true! In
classical mathematics, unlike real life, all of our statements are propositions.
Since they take on only the truth values T and F, we can define connectives by
saying what they do to truth values:
2.1.2 Definition 2
The connectives and written , or written , not written , implies
written , and iff written are defined by the truth tables
Table: 2.1.1
p q p q p q p p q p q
T T T T F T T
T F F T F F F
F T F T T T F
F F F F T T T
27
Proposition 1.1 Any truth function in two variables can be expressed using
, and ¬.
Proposition 1.2 Any truth function in two variables can be expressed
using and ¬.
Proposition 1.3 Any truth function in two variables can be expressed
using and ¬.
Proposition 1.4 Any truth function in two variables can be expressed
using and ¬.
Proposition 1.5 Any truth function in two variables can be expressed using
only the connective p | q whose truth table is given by
Table: 2.1.2
P Q
T T T
T F F
F T F
F F F
Proposition 1.6 Any truth function in n variables can be written in
either disjunctive normal form (as a disjunction “or” of terms which are “ands”
of variables and negations of variables) or conjunctive normal form (an “and”
of terms which are “ors” of variables and negations of variables).
These results collectively give what is called functional completeness of
the connectives sufficient to express all possible truth functions. Switching
theory modifies these results to design logic circuits which use a minimum of
components or a minimum depth to the expression (for fast execution).
Looking at the truth tables we can derive some standard rules of
inference. The premises are listed above the line and the conclusions below.
Look at the truth tables to see that if all of the premises get a truth value of T
then so do the conclusions. In logic this is called soundness of the rules of
inference.
Proposition 1.7 The following rules of inference always transform true
premises to true conclusions:
p, p q
1. Modus Ponens q
2. Contra positive p q p q
3. Argument from cases p q, p r, q r r
28
4. Indirect proof: p / p This tells us that we can prove a statement
by showing that its negation is impossible.
The standard form of direct argument uses what is called the deduction
theorem: to prove p q it suffices to show that q follows from p. From truth
tables the soundness of this form of argument can be seen from the fact
that p q is true if p is false or if both p and q are true. The deduction
theorem in logic says that if we have a proof starting with a premise p and
leading to a conclusion q then we can transform it into a proof from no
premises leading to p q .
2.2 THE PREDICATE CALCULUS
Predicate calculus, also called Logic Of Quantifiers that part of modern
formal or symbolic logic which systematically exhibits the logical relations
between sentences that hold purely in virtue of the manner in which predicates
or noun expressions are distributed through ranges of subjects by means of
quantifiers such as “all” and “some” without regard to the meanings or
conceptual contents of any predicates in particular.
Such predicates can include both qualities and relations; and, in a
higher-order form called the functional calculus, it also includes functions,
which are “framework” expressions with one or with several variables that
acquire definite truth-values only when the variables are replaced by specific
terms.
The predicate calculus is to be distinguished from the propositional
calculus, which deals with unanalyzed whole propositions related by
connectives (such as “and”, “if . . . then” and “or”).
2.3 PREDICATES:
There are two competing notions of the predicate in theories
of grammar. The first concerns traditional grammar, which tends to view a
predicate as one of two main parts of a sentence, the other part being
the subject; the purpose of the predicate is to complete an idea about the
subject, such as what it does or what it is like.
He second notion was derived from work in predicate calculus
(predicate logic, first order logic) and is prominent in modern theories of syntax
and grammar. In this approach, the predicate of a sentence mostly corresponds
to the main verb and any auxiliaries that accompany the main verb; whereas
the arguments of that predicate (e.g. the subject and object noun phrases) are
outside the predicate.
Consider the following statements:
x > 3, x = y + 3, x + y = z
29
The truth value of these statements has no meaning without specifying
the values of x, y, z.
However, we can make propositions out of such statements.
A predicate is a property that is affirmed or denied about the subject (in
logic, we say “variable” or “argument”) of a statement.“ x|{z} Subject is
greater than 3”| {z } predicate terminology: affirmed = holds = is true; denied =
does not hold = is not true.
We introduce a (functional) symbol for the predicate, and put the
subject as an argument to the functional symbol): P (x)
Examples:
Father(x): unary predicate
Brother(x,y): binary predicate
Sum(x,y,z): ternary predicate
P(x,y,z,t): n-ary predicate
Discussion
Recall from the introduction to logic that the sentence x + 2 = 2x" is not
a proposition, but if we assign a value for x then it becomes a proposition. The
phrase x + 2 = 2x" can be treated as a function for which the input is a value of
x and the output is a proposition.
Another way we could turn this sentence into a proposition is to
quantify its variable. For example, for every real number x, x + 2 = 2x" is a
proposition (which is, in fact, false, since it fails to be true for the number x =
0).
This is the idea behind propositional functions or predicates. As stated
above a predicate is a property or attribute assigned to elements of a particular
set, called the universe of discourse. For example, the predicate x + 2 = 2x",
where the universe for the variable x is the set of all real numbers, is a property
that some, but not all, real numbers possess.
In general, the set of all x in the universe of discourse having the
attribute P (x) is called the truth set of P. That is, the truth set of P is
fx 2 UjP (x)g:
Example of a Propositional Function.
Example 1.1. The propositional function P (x) is given by x > 0" and the
universe of discourse for x is the set of integers. To create a proposition from P,
we may assign a value for x. For example,
setting x = 3, we get P ( 3): 3 > 0", which is false. setting x = 2, we get
P (2):
30
2 > 0", which is true.
Discussion
In this example we created propositions by choosing particular values for x.
Here are two more examples:
Example 1.2. Suppose P (x) is the sentence x has fur" and the universe of
discourse for x is the set of all animals. In this example P (x) is a true statement
if x is a cat. It is false, though, if x is an alligator.
Example .1.3. Suppose Q(y) is the predicate y holds a world record," and
the universe of discourse for y is the set of all competitive swimmers. Notice
that the universe of discourse must be defined for predicates. This would be a
different predicate if the universe of discourse is changed to the set of all
competitive runners.
Moral: Be very careful in your homework to specify the universe of discourse
precisely!
Quantifiers: A quantifier turns a propositional function into a proposition
without assigning specific values for the variable. There are primarily two
quantifiers, the universal quantifier and the existential quantifier.
Definition: The universal quantification of P (x) is the proposition
P (x) is true for all values x in the universe of discourse."
Notation: For all x P (x)" or For every x P (x)" is written
8xP (x):
Definition: The existential quantification of P (x) is the proposition
There exists an element x in the universe of discourse such that P (x) is
true."
Notation: There exists x such that P (x)" or There is at least one x such that P
(x)" is written
9xP (x):
Discussion
As an alternative to assigning particular values to the variable in a
propositional function, we can turn it into a proposition by quantifying its
variable. Here we see the two primary ways in which this can be done, the
universal quantifier and the existential quantifier.
In each instance we have created a proposition from a propositional
function by binding its variable.
31
Example 2.1.1.
Suppose P (x) is the predicate x + 2 = 2x, and the universe of discourse
for x is the set f1; 2; 3g. Then 8xP (x) is the proposition. For every x in f1; 2;
3g x + 2 = 2x. This proposition is false.
9xP (x) is the proposition| There exists x in f1; 2; 3g such that x + 2 =
2x." This proposition is true.
Exercise 1.2. Let P (n; m) be the predicate mn > 0, where the domain for
m and n is the set of integers. Which of the following statements are true?
(1) P ( 3; 2)
(2) 8mP (0; m)
(3) 9nP (n; 3)
Converting from English.
Example1.4. Assume
F (x): x is a fox.
S(x): x is sly.
T (x): x is trustworthy.
and the universe of discourse for all three functions is the set of all animals.
Everything is a fox: 8xF (x)
All foxes are sly: 8x[F (x)
! S(x)] If any fox is sly,
then it is not
trustworthy:
8x[(F (x) ^ S(x)! :T (x)] , :9x[F (x) ^ S(x) ^ T (x)]
Discussion
Notice that in this example the last proposition may be written
symbolically in the two ways given. Think about the how you could show they
are the same using the logical equivalences in Module 2.2.
Additional Definitions:
An assertion involving predicates is valid if it is true for every element
in the universe of discourse.
An assertion involving predicates is satiable if there is a universe and
an interpretation for which the assertion is true. Otherwise it is un
satiable.
The scope of a quantifier is the part of an assertion in which the
variable is bound by the quantifier.
32
Discussion
You would not be asked to state the definitions of the terminology
given, but you would be expected to know what is meant if you are asked a
question like. Which of the following assertions are satiable?"
Examples.1.3.
If the universe of discourse is U = f1; 2; 3g, then
(1) 8xP (x) , P (1) ^ P (2) ^ P (3)
(2) 9xP (x) , P (1) _ P (2) _ P (3)
Suppose the universe of discourse U is the set of real numbers.
(1) If P(x) is the predicate x > 0, then 8xP(x) is false, since P(0) is false.
(2) If P(x) is the predicate x = 3x4=0, then 9xP(x) is true, since P(1) is true.
(3) If P (x) is the predicate x2 + x + 1 = 0, then 9xP (x) is false, since there
are no real solutions to the equation x2 + x + 1 = 0.
(4) If P (x) is the predicate If x 6= 0, then x 2 1', then 8xP (x) is false, since P
(0:5) is false.
Exercise: 1.4. In each of the cases above give the truth value for the
statement if each of the 8 and 9 quantizes are reversed. Multiple Quantifiers are
read from left to right.
Example: 1.5. Suppose P (x; y) is xy = 1", the universe of discourse for
x is the set of positive integers, and the universe of discourse for y is the set of
real numbers.
(1) 8x8yP (x; y) may be read and For every positive integer x and for
every real number y, xy = 1. This proposition is false.
(2) 8x9yP (x; y) may be read and For every positive integer x there is a
real number y such that xy = 1. This proposition is true.
(3) 9y8xP (x; y) may be read and There exists a real number y such that,
for every positive integer x, xy = 1. This proposition is false.
Discussion
Study the syntax used in these examples. It takes a little practice to
make it come out right. Ordering Quantifiers the order of quantifiers is
important; they may not commute.
For example,
(1) 8x8yP (x; y) , 8y8xP (x; y), and
(2) 9x9yP (x; y), 9y9xP
(x; y), but
(3) 8x9yP (x; y) 6, y98xP (x; y).
33
Discussion
The lesson here is that you have to pay careful attention to the order of
the quantizes. The only cases in which commutatively holds are the cases in
which both quantize are the same. In the one case in which equivalence does
not hold,
8x9yP (x; y) 6, y98xP (x; y);
there is an implication in one direction. Notice that if 9y8xP (x; y) is true, then
there is an element c in the universe of discourse for y such that P (x; c) is true
for all x in the universe of discourse for x. Thus, for all x there exists a y,
namely c, such that P (x; y). That is, 8x9yP (x; y). Thus,
9y8xP (x; y) 8x9yP (x; y):
Notice predicates use function notation and recall that the variable in
function notation is really a place holder. The statement 8x9yP (x; y) means the
same as 8s9tP (s; t). Now if this seems clear, go a step further and notice this
will also mean the same as 8y9xP (y; x). When the domain of discourse for a
variable is deemed it is in fact dining the domain for the place that variable is
holding at that time.
Here are some additional examples:
Example 1.6. P (x; y) is x is a citizen of y." Q(x; y) is x lives in y." The
universe of discourse of x is the set of all people and the universe of discourse
for y is the set of US states.
(1) All people who live in Florida are citizens of Florida.
8x (Q(x; Florida) ! P (x; Florida))
(2) Every state has a citizen that does not live in that state.
8y9x (P (x; y) ^: Q(x; y))
Example 1.7. Suppose R(x; y) is the predicate x understands y," the
universe of discourse for x is the set of students in your discrete class, and the
universe of discourse for y is the set of examples in these lecture notes. Pay
attention to the differences in the following propositions.
(1) 9x8yR(x; y) is the proposition and There exists a student in this class
who un-distends every example in these lecture notes."
(2) 8y9xR(x; y) is the proposition and for every example in these lecture
notes there is a student in the class who understands that example."
(3) 8x9yR(x; y) is the proposition and Every student in this class
understands at least one example in these notes."
(4) 9y8xR(x; y) is the proposition and There is an example in these notes
that every student in this class understands."
34
Exercise 1.8. Each of the propositions in Example 3.9.2 has a slightly
different meaning. To illustrate this, set up the following diagrams: Write the
five letters A; B; C; D; E on one side of a page, and put the numbers 1 through
6 on the other side. The letters represent students in the class and the numbers
represent examples. For each of the propositions above draw the minimal
number of lines connecting people to examples so as to construct a diagram
representing a scenario in which the given proposition is true.
Notice that for any chosen pair of propositions above, you can draw
diagrams that would represent situations where the two propositions have
opposite truth values. Exercise 3.9.2. Give a scenario where parts 1 and 2 in
Example 3.9.2 have opposite truth values.
Exercise .1.9.Let P (x; y) be the predicate 2x + y = xy, where the
domain of discourse for x is fu 2 Zju 6= 1g and for y is fu 2 Zju 6= 2g.
Determine the truth value of each statement. Show work or briefly explain.
(1) P ( 1; 1)
(2) 9xP (x; 0)
(3) 9yP (4; y)
(4) 8yP (2; y)
(5) 8x9yP (x; y)
(6) 9y8xP (x; y)
(7) 8x8y[((P (x; y)) ^ (x > 0)) ! (y > 1)]
Unique Existential.
Definition 2.1.1. The unique existential quantification of P (x) is the
proposition and There exists a unique element x in the universe of discourse
such that P (x) is true."
Notation: There exists unique x such that P (x)" or There is exactly one
x P (x)" is written
9!xP (x):
Discussion
Continuing with Example 3.9.2, the proposition 8x9!yR(x; y) is the
proposition Every student in this class understands exactly one example in
these notes (but not necessarily the same example for all students)."
Exercise 2.1.2. Let P (n; m) be the predicate mn 0, where the domain for
m and n is the set of integers. Which of the following statements are true?
(1) 9!n8mP (n; m)
(2) 8n9!mP (n; m)
35
(3) 9!mP (2; m)
Exercise 2.1.3. Repeat Exercise 3.9.1 for the four propositions 8x9!yR(x; y),
9!y8xR(x; y), 9!x8yR(x; y), and 8y9!xR(x; y).
Remember: A predicate is not a proposition until all variables have been
bound either by quantification or by assignment of a value!
De Morgan's Laws for Quantifiers.
:8xP (x),
9x:P (x)
:9xP (x),
8x:P (x)
Discussion
The negation of a quantified statement are obtained from the De
Morgan's Laws in Module 2.1.
So the negation of the proposition. Every sh in the sea has gills," is the
propositions there is at least one sh in the sea that does not have gills."
If there is more than one quantifier, then the negation operator should
be passed from left to right across one quantifier at a time, using the
appropriate De Morgan's Law at each step. Continuing further with Example
3.9.2, suppose we wish to negate the proposition Every student in this class
understands at least one example in these notes." Apply De Morgan's Laws to
negate the symbolic form of the proposition:
:(8x9yR(x; y)), 9x(:9yR(x; y)), 9x8y:R(x; y)
The rest proposition could be read .It is not the case that every student
in this class understands at least one example in these notes." The goal,
however, is to and an expression for the negation in which the verb in each
predicate in the scope of the quantifiers is negated, and this is the intent in any
exercise, quiz, or test problem that asks you to negate the proposition ... ."
Thus, a correct response to the instruction to negate the proposition. Every
student in this class understands at least one example in these notes" is the
proposition .There is at least one student in this class that does not understand
any of the examples in these notes."
Exercise 2.1.4. Negate the rest of the statements in Example 3.9.2.
It is easy to see why each of these rules of negation is just another form
of De Mor-gan's Law, if you assume that the universe of discourse is nite: U =
fx1; x2; :::; xng. For example,
8xP (x) , P (x1) ^ P (x2) ^ ^ P (xn)
36
so that :
8xP (x) , :[P (x1) ^ P (x2) ^ ^ P (xn)], [:P (x1) _ :P (x1) _ _ :P (x1)], 9x:P (x)
If U is an arbitrary universe of discourse, we must argue a little
differently: Suppose :8xP (x) is true. Then 8xP (x) is false. This is true if and
only if there is some c in U such that P (c) is false. This is true if and only if
there is some c in U such that: P (c) is true. But this is true if and only if 9x:P
(x).
The argument for the other equivalence is similar.
Exercise 2.1.5. Suppose S(x; y) is the predicate x saw y," L(x; y) is the
predicate x liked y," and C(y) is the predicate y is a comedy." The universe of
discourse of x is the set of people and the universe of discourse for y is the set
of movies. Write the following in proper English. Do not use variables in your
answers.
(1) 8y:S(Margaret; y)
(2) 9y8xL(x; y)
(3) 9x8y[C(y)! S(x; y)]
(4) Give the negation for part 3 in symbolic form with the negation
symbol to the right of all quantifiers.
(5) State the negation of part 3 in English without using the phrase "it is
not the case."
Exercise 2.1.5. Suppose the universe of discourse for x is the set of all
FSU students, the universe of discourse for y is the set of courses offered at
FSU, A(y) is the predicate y is an advanced course," F (x) is x is a freshman," T
(x; y) is x is taking y," and P (x; y) is x passed y." Use quantifiers to express the
statements
(1) No student is taking every advanced course.
(2) Every freshman passed calculus.
(3) Some advanced course(s) is (are) being taken by no students.
(4) Some freshmen are only taking advanced courses.
(5) No freshman has taken and passed linear algebra.
Here is a formidable example from the calculus. Suppose a and L are
xed real numbers, and f is a real-valued function of the real variable x. Recall
the rigorous definition of what it means to say the limit of f(x) as x tends to a is
L":
lim f(x) = L ,
x!a
37
for every > 0 there exists > 0 such that, for every x,
if 0 < jx aj < , then jf(x) Lj < :
Here, the universe of discourse for the variables , , and x is understood
to be the set of all real numbers.
What does it mean to say that lim f(x) 6= L? In order to figure this out, it is
x!a
useful to convert this proposition into a symbolic proposition. So, let P ( ; ; x)
be the predicate 0 < jx aj < " and let Q( ; ; x) be the predicate jf(x) Lj < ." (It is
perfectly OK to list a variable in the argument of a predicate even though it
doesn't actually appear!) We can simplify the proposition somewhat by
restricting the universe of discourse for the variables and to be the set of
positive real numbers. The definition then becomes
8 9 8x[P ( ; ; x) ! Q( ; ; x)]:
Use De Morgan's Law to negate:
:[8 9 8x[P ( ; ; x) ! Q( ; ; x)]] , 9 8 9x[P ( ; ; x) ^ :Q( ; ; x)];
and convert back into words:
There exists > 0 such that, for every > 0 there exists x such that,
0 < jx aj < and jf(x) Lj :
Distributing Quantifiers over Operators.
(1) 8x[P (x) ^ Q(x)] , 8xP (x) ^ 8xQ(x), but
(2) 8x[P (x) _ Q(x)] 6, xP8(x) _ 8xQ(x).
(3) 9x[P (x) _ Q(x)] , 9xP (x) _ 9xQ(x), but
(4) 9x[P (x) ^ Q(x)] 6, xP9(x) ^ 9xQ(x):
Discussion
Here we see that in only half of the four basic cases does a quantifier
distribute over an operator, in the sense that doing so produces an equivalent
proposition.
Exercise:2.1.7.
In each of the two cases in which the statements are not equivalent,
there is an implication in one direction. Which direction? In order to help you
analyze these two cases, consider the predicates P (x) = [x 0] and Q(x) = [x <
0], where the universe of discourse is the set of all real numbers.
38
Exercise: 2.1.8
Write using predicates and quantifiers.
(1) For every m; n 2 N there exists p 2 N such that m < p and p < n.
(2) For all nonnegative real numbers a, b, and c, if a2 + b2 = c2, then a + b
(3) There does not exist a positive real number a such that a + a1 < 2:
(4) Every student in this class likes mathematics.
(5) No student in this class likes mathematics.
(6) All students in this class that are CS majors are going to take a 4000
level math course.
Exercise 2.1.9:
Give the negation of each statement in example using predicates and
quantifiers with the negation to the right of all quantifiers.
Exercise 2.2.1:
Give the negation of each statement in example using an English
sentence. The competition between these two concepts has generated confusion
concerning the use of the term predicate in theories of grammar. This article
considers both of these notions.
2.4 STATEMENT FUNCTIONS
A statement function is a procedure defined by a single statement in the
same program unit in which the procedure is referenced. It takes the following
form:
fun ([d-arg [, d-arg]...]) = expr
fun:
Is the name of the statement function.
d-arg:
Is a dummy argument. A dummy argument can appear only once in any list of
dummy arguments, and its scope is local to the statement function.
expr
Is a scalar expression defining the computation to be performed.
Named constants and variables used in the expression must have been
declared previously in the specification part of the scoping unit or made
accessible by use or host association.
If the expression contains a function reference, the function must have
been defined previously in the same program unit. A statement function
reference takes the following form:
fun ([a-arg [, a-arg]...])
39
fun
Is the name of these statement function.
a-arg
Is an actual argument.
s
Variables and quantifiers
Exercise 1
Convert the sentence “No child wants a toothache” into a sentence of the
form “It is not the case that...” Find an existential quantifier in your
sentence.
Exercise 2
What would you have to do to show that a statement about one variable
with an existential quantifier is false? Correspondingly, what would you
have to do to show that a statement about one variable with a universal
quantifier is true?
As Exercise 1 points out, English has many different ways to express
quantifiers. For example, the sentences, “All hammers are tools”, “Each
sandwich is delicious”, “No one in their right mind would do that”, “Somebody
loves me”, and “Yes Virginia, there is a Santa Claus” all contain quantifiers.
For Exercise 2, we can say “It is not the case that there is a child who wants a
toothache.” Our quantifier is the phrase “there is.”
To show that a statement about one variable with an existential
quantifier is false we have to show that, every element of the universe makes
the statement (such as m2 > m) false. Thus to show that the statement “There is
an x in [0, 1] with x2 > x” is false, we have to show that every x in the interval
makes the statement x2 > x false. Similarly, to show that a statement with a
universal quantifier is true, we have to show that the statement being quantified
is true for every member of our universe. We will give more details about how
to show a statement about a variable is true or false for every member of our
universe later in this section.
Mathematical statements of theorems, lemmas, and corollaries often
have quantifiers. For example in Lemma 2.5 the phrase “for any” is a
quantifier, and in Corollary 2.6 the phrase “there is” is a quantifier.
40
VARIABLES AND QUANTIFIERS
2.5 QUANTIFIERS:
Quantification is a construct that specifies the quantity of specimens in
the domain of discourse that satisfy an open formula. For example, in
arithmetic, it allows the expression of the statement that every natural number
has a successor. A language element which generates quantification (such as
"every") is called a quantifier.
The resulting expression is a quantified expression, it is said to
be quantified over the predicate (such as "the natural number x has a
successor") whose free variable is bound by the quantifier. In formal languages,
quantification is a formula constructor that produces new formulas from old
ones.
The semantics of the language specifies how the constructor is
interpreted. Two fundamental kinds of quantification in predicate
logic are universal quantification and existential quantification. The traditional
symbol for the universal quantifier "all" is "∀", a rotated letter "A", and for
the existential quantifier "exists" is "∃", a rotated letter "E".
Example:
Let S = {2, 4, 6} and D = {2, 4, 5}.
∀x ∈ S, x is even.
2 are even, 4 are even, 6 are even, so true by exhaustion.
∀x ∈ D, x is even. A counterexample is x = 5, so false.
∃X∈ S s.t. x is even. Take x = 4, so true.
∃X∈ S s.t. x is not even. 2 is even, 4 is even, 6 is even, so false by exhaustion
2.6 VARIABLES:
A simple statement function of one variable is defined to be an
expression consisting of a predicate symbol and an individual variable. Such a
statement function becomes a statement when the variable is replaced by the
name of any object.
We have no means at all in our symbolism to express generalities. We
can say that Pedro is a doctor, and we can say that Pedro is wealthy, but we
cannot say that everyone is a doctor, or that every doctor is wealthy. Nor can
we deny that everyone is a doctor, or say that some doctor isn't wealthy. We
cannot even express these claims. In order to express generalities we will
introduce quantifiers and variables.
41
Any small letter from 'i' to 'z' is a variable. Small letters between 'I' and
'z' with numerical subscripts are also variables (though they will not be used in
this chapter). The universal quantifier is '∀'. The existential quantifier is '∃'.
A quantifier phrase is a quantifier followed by a variable:
∀x ∀z ∀s ∃x ∃z ∃s
Example 1 Q: Every good boy does ¯ne.
Symbolic translation: 8x 2 G, x does ¯ne.
Negation: 9x 2 G, x does not do ¯ne.
Rewrite the negation in words: There are some good boys that do not done.
Q Q
Examples
P: There is a broken chair in this room.
Symbolic translation: 9x 2 C, x is broken. Where C is the set of chairs in
this room.
Negation: 8x 2 C, x is not broken.
Rewrite the negation in words: All chairs in this room are not broken."
Or, we might say, \No chair in this room is broken."
P P ( P )
42
- Implication
P Q P Q
T T T
T F F
F T T
F F T
The phrases,
P implies Q
If P then Q
Q if P
Q is implied by P
Q is true whenever P is true
P only if Q
can be translated symbolically into:
P Q . In the implication P Q , P is the antecedent or hypothesis and Q
is the consequence or conclusion.
The Converse of P Q is Q P .
The Contra positive of P Q is (Q) (P) .
Example 3. P: it is sunny
Q: there is a ball game
The implication.
P implies Q: If it is sunny then there is a ball game.
Its inverse:
Q implies P: If there is a ball game then it is sunny. In this case, we could also
say, There is a ball game only if it is sunny.
Its contra positive:
not Q implies not P: If there is no ball game then it is not sunny. There is a ball
game only if it is sunny.
The implication, P Q , and its contra positive, (Q) (P) , have the
same truth value. Lets look at the truth table.
P Q P Q (Q) (P) P Q
T T F F F T
43
T F F T T F
F T T F F T
F F T T T T
Example 11. Show ( P Q) has the same truth value as P (Q)
Example 12. P: If x < 0 then jxj = ¡x.
Negate P.
Example 13. Q: f(x) = f(y) implies x = y.
Negate Q.
P Q is said to be vacuously true when P is false. For example, If a
snowball survives in hell, I will give everyone an A.
Example 14. Use a truth table to prove that
((P ) Q) ^ (Q ) R)) ) (P ) R)
For the following two examples, let O be the odd integers and E be the
even integers.
Example 15. Determine if the following is true or false. xy 2 O , (x
2 O ^ y 2 O)
Example 16. Determine if the following is true or false. xy 2 E , (x
2 E ^ y 2 E)
If and only if statements. , - If and only if.
P Q P,Q
T T T
T F F
F T F
F F T
The phrases,
² P if and only if Q
² If P then Q and if Q then P
² P ) Q is the only if" part
² Q ) P is the if" part
can be translated symbolically into: P , Q.
44
2.7 VALID FORMULAS AND EQUIVALENCE:
The formulas of the predicate calculus are assumed to contain statement
variables, predicates, and object variables. The object variables are assumed to
belong to a set called the universe of discourse or the domain of the object
variable. Such a universe may be finite or infinite. The term 'variable'
includes constants as a special case. In a predicate formula, when all the object
variables are replaced by definite names of objects and the statement variables
by statements, we obtain a statement which has a truth value T or F.
The formulas of predicate calculus as given here do not contain
predicate variables. They contain predicates; i.e., every predicate letter is
intended to be a definite predicate, and hence is not available for substitution.
Let A and B be any two predicate formulas defined over a common
universe denoted by the symbol E. If, for every assignment of object names
from the universe of discourse E to each of the variables appearing in A and B,
the resulting statements have the same truth values, then the predicate formulas
A and B are said to be equivalent to each other over E. This idea is symbolized
by writing AÛB over E. If E is arbitrary, then we say that A and B are
equivalent, that is AÛ B.
It is possible to determine by truth table methods whether a formula is
valid in E, where E is a finite universe of discourse. This method may not be
practical when the number of elements in E is large. It is impossible when
the number of elements in E is infinite.
Formulas of the predicate calculus that involve quantifiers and no
free variables are also formulas of the statement calculus. Therefore,
substitution instances of all the tautologies by these formulas yield
any number of special tautologies.
Consider the tautologies of the statement calculus given by P ∧ P, P
∧Q P ∨ x)S(x) for P and Q
45
2.8 INFERENCE THEORY OF PREDICATE CALCULUS:
The method of derivation involving predicate formulas uses the rules of
inference given for the statement calculus and also certain additional rules
which are required to deal with the formulas involving quantifiers. Using of
rules P and T remain the same. If the conclusion is given in the form of a
conditional, we shall use the rule of conditional proof called CP.
In order to use the equivalences and implications, we need some rules
on how to eliminate quantifiers during the course of derivation. This
elimination is done by the rules of specification, called rules US and ES. Once
the quantifiers are eliminated and the conclusion is reached. It may happen that
the desired conclusion is quantified. In this case we need rules
of generalization called rules UG and EG which can be used to attach
a quantifier.
Rule US (Universal Specification)
From (x)A(x) one can conclude A(y).
Rule ES (Existential Specification)
given premise and also not free in any prior step of the derivation. These
requirements can easily be met by choosing a new variable each time ES is
used.
Rule EG (Existential Generalization) :
y)A(y).
Rule UG (Universal Generalization) :
From A(x) one can conclude (y)A(y) provided that x is not free in any
of the given premises and provided that if x is free in a prior step which
resulted from use of ES, then no variables introduced by that use of ES appear
free in A(x).
Example1:
Show that (x) (H(x) M(x)) ∧ H(s) M(s).
46
Solution:
{1} (1) (x)(H(x) M(x)) Rule P
{1} (2) H(s) M(s) Rule US, (1)
{3} (3) H(s) Rule P
{1, 3} (4) M(s) Rule T, (2), (3), I11
Examples:
Let us consider the following assumptions: "If it rains today, then we
will not go on a canoe today. If we do not go on a canoe trip today, then we
will go on a canoe trip tomorrow. Therefore (Mathematical symbol for
"therefore" is ), if it rains today, we will go on a canoe trip tomorrow". To
make use of the rules of inference in the above table we let be the
proposition "If it rains today", be "We will not go on a canoe today" and let
be "We will go on a canoe trip tomorrow". Then this argument is of the form:
pq
qr
pr
Example 2
Let us consider a more complex set of assumptions: "It is not sunny
today and it is colder than yesterday". "We will go swimming only if it is
sunny", "If we do not go swimming, then we will have a barbecue", and "If we
will have a barbecue, then we will be home by sunset" lead to the conclusion
"We will be home by sunset." Proof by rules of inference: Let P be the
proposition "It is sunny today", the proposition "It is colder than
yesterday", r the proposition "We will go swimming", s the proposition "We
will have a barbecue", and the proposition "We will be home by sunset".
Then the hypotheses become p q, r p, r sands t. and. s t.
Using our intuition we conjecture that the conclusion might be t .Using the
Rules of Inference table we can proof the conjecture easily:
Step Reason
1. p q Hypothesis
3. r p Hypothesis
47
Modus tollens using Step 2 and
4. r
3
5.
Hypothesis
r s
7. s t Hypothesis
Exercises:
1. Which of the following are statements?
(a) ( x)( P( x) Q( x)) R
(B) ( x)( P( x) Q( x)) (x)S ( x)
(c) ( x)( P( x) Q( x)) S ( x)
2. Indicates the variable that are free and bound, Also show the scope of the
quantifiers.
(a) ( x)( P( x) R( x)) ( x) P( x) Q( x)
(b) ( x)( P( x) (x)Q( x)) (( x) P( x) Q( x))
48
(c) (x)( P( x) Q( x)) T , Where P( x) : x 2, Q( x) : x 0, and T is any
tautology, with the universe if discourse as{1}.
Show that P( x) ( x)Q( x) (x)( P( x) Q( x)).
5. Explain why the following steps in the derivations are not correct.
(a) (1) ( x) P( x) Q( x) ,(2) P( x) Q( x)
( x) P( x) Q( x)
(b)
P( y ) Q( x)
( x)( P( x) Q( x))
(c)
P(a) P(b)
( x) P( x) (x)(Q( x) R( x)))
(d) P(a) (x)(Q( x) R(a))
49
9. Given the premise ( x)(y) P( x, y), find the mistake in the following
derivation.
(a) ( x)(y) P( x, y)
(b) (y) P( z, y)
(c) P(z,w)
(d) ( x) P( x, w)
10. Are the following conclusions validly derivable from the premises given?
(a) ( x)( P( x) Q( x)), (y) P( y)
(b) (x)( P( x) Q( x))
(c) (x)( P( x) Q( x)), Q(a)
50
NOTES
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
51
UNIT - III
IN THIS CHAPTER:
Relations and functions relation and ordering
Notation
Properties
Injective and surjective function
Composition of functions
Inverse functions
Inverse graph function
Peano axioms and mathematical induction
Arithmetic
Hashing functions
Cardinality
3.1 RELATIONS AND FUNCTION RELATION AND ORDERING:
Relation: a function is a relation between a set of inputs and a set of
permissible outputs with the property that each input is related to exactly one
output. An example is the function that relates each real number x to its
square x2. The output of a function f corresponding to an input x is denoted
by f(x) (read "f of x").
In this example, if the input is −3, then the output is 9, and we may
write f(−3) = 9. Likewise, if the input is 3, then the output is also 9, and we may
write f(3) = 9. (The same output may be produced by more than one input, but
each input gives only one output.) The input variable(s) are sometimes referred
to as the argument(s) of the function.
The input and output of a function can be expressed as an ordered pair,
ordered so that the first element is the input (or tuple of inputs, if the function
takes more than one input), and the second is the output. In the example
above, f(x) = x2, we have the ordered pair (−3, 9). If both input and output
are real numbers, this ordered pair can be viewed as the Cartesian
coordinates of a point on the graph of the function.
The first elements in the ordered pairs (the x-values), form
the domain. The second elements in the ordered pairs (the y-values), form
the range. Only the elements "used" by the relation constitute the range.
A second example of a function is the following: the domain is chosen
to be the set of natural numbers (1, 2, 3, 4, ...), and the co domain is the set
of integers (..., −3, −2, −1, 0, 1, 2, 3, ...). The function associates to any natural
52
number n the number 4−n. For example, to 1 it associates 3 and to 10 it
associates −6.
A third example of a function has the set of polygons as domain and the
set of natural numbers as co domain. The function associates a polygon with its
number of vertices. For example, a triangle is associated with the number 3, a
square with the number 4, and so on.
The term range is sometimes used either for the co domain or for the set of all
the actual values a function has. To avoid ambiguity this article avoids using
the term.
Figure: 2.1.3
The above diagram represents a function with domain {1, 2, 3}, co
domain {A, B, C, D} and set of ordered pairs {(1,D), (2,C), (3,C)}. The image
is {C, D}.
Figure: 2.1.4
3.1.1 Notation:
A function f with domain X and co domain Y is commonly denoted by
f : X Y
Or
X
f
Y
53
In this context, the elements of X are called arguments off. For each
argument x, the corresponding unique y in the co domain is called the
function value at x or the image of x under f. It is written as f(x). One says
that f associates y with x or maps x to y. This is abbreviated by
y f (x)
A general function is often denoted by f. Special functions have names,
for example, the signum function is denoted by sign. Given a real number x, its
image under the signum function is then written as sign(x). Here, the argument
is denoted by the symbol x, but different symbols may be used in other
contexts. For example, in physics, the velocity of some body, depending on the
time, is denoted v(t). The parentheses around the argument may be omitted
when there is little chance of confusion, thus: sin x; this is known as prefix
notation.
In order to denote a specific function, the notation (an arrow with a
bar at its tail) is used. For example, the above function reads
f :N Z
x 4 x
The first part can be read as:
"f is a function from N (the set of natural numbers) to Z (the set of integers)" or
"f is a Z-valued function of an N-valued variable".
The second part is read:
"x maps to 4−x."
In other words, this function has the natural numbers as domain,
the integers as co domain. Strictly speaking, a function is properly defined only
when the domain and co domain are specified. For example, the formula f(x) =
4 − x alone (without specifying the codomain and domain) is not a properly
defined function. Moreover, the function
g:Z Z
x 4 x
(With different domain) is not considered the same function, even
though the formulas defining f and g agree, and similarly with a different co
domain. Despite that, many authors drop the specification of the domain and co
domain,
Especially if these are clear from the context. So in this example many
just write f(x) = 4 − x. Sometimes, the maximal possible domain is also
2
x 5 x 6
understood implicitly: a formula such as f ( x) may mean that the
54
domain of f is the set of real numbers x where the square root is defined (in this
case x ≤ 2 or x ≥ 3).
To define a function, sometimes a dot notation is used in order to
emphasize the functional
nature of an expression without assigning a special symbol to the variable. For
2
instance, a() stands for the function x ax 2 , f (U )du stands for the
a
integral function f (U )du , and so on.
x a
PROPERTIES:
If A is any subset of the domain X, then f(A) is the subset of the co
domain Y consisting of all images of elements of A. We say the f(A) is
the image of A under f. The image of f is given by f(X). On the other hand,
the inverse image (or pre-image, complete inverse image) of a subset B of the
co domain Y under a function f is the subset of the domain X defined by
∈ ∈
So, for example, the pre-image of {4, 9} under the squaring function is
the set {−3,−2,2,3}. The term range usually refers to the image, but sometimes
it refers to the co domain.
By definition of a function, the image of an element x of the domain is
always a single element y of the co domain. Conversely, though, the pre-image
of a singleton set (a set with exactly one element) may in general contain any
number of elements.
For example, if f(x) = 7 (the constant function taking value 7), then the
pre-image of {5} is the empty set but the pre-image of {7} is the entire domain.
It is customary to write f−1 (b) instead of f−1 ({b}), i.e.
∈
This set is sometimes called the fiber of b under f.
Use of f(A) to denote the image of a subset A ⊆ X is consistent so long
as no subset of the domain is also an element of the domain. In some fields
(e.g., in set theory, where ordinals are also sets of ordinals) it is convenient or
even necessary to distinguish the two concepts;
The customary notation is f [A] for the set {f(x): x ∈ A}. Likewise, some
authors use square brackets to avoid confusion between the inverse image and
the inverse function. Thus they would write f−1 [B] and f−1 [b] for the pre-image
of a set and a singleton.
55
3.1.2 Injective and surjective functions:
A function is called injective (or one-to-one, or an injection) if f(a)
≠ f(b) for any two different elements a and b of the domain. It is
called surjective (or onto) if f(X) =Y. That is, it is surjective if for every
element y in the codomain there is an x in the domain such that f(x) = y.
Finally f is called bi-junctive if it is both injective and surjective.
The above "color-of-the-shape" function is not injective, since two
distinct shapes (the red triangle and the red rectangle) are assigned the same
value. Moreover, it is not surjective, since the image of the function contains
only three, but not all five colors in the codomain.
3.2 IDENTITY FUNCTION:
The unique function over a set X that maps each element to itself is
called the identity function for X, and typically denoted by idX. Each set has its
own identity function, so the subscript cannot be omitted unless the set can be
inferred from context. Under composition, an identity function is "neutral":
if f is any function from X to Y, then
56
That is, the two possible compositions of f and f−1 need to be the
respective identity maps of X and Y. As a simple example, if f converts a
temperature in degrees Celsius C to degrees Fahrenheit F, the function
converting degrees Fahrenheit to degrees Celsius would be a suitable f−1.
9
f (C ) c 32
5
1 5
f
( F ) ( F 32)
9
Such an inverse function exists if and only if f is bijective. In this
case, f is called invertible. The notation g o f (or, in some texts, just gf )
and f−1 are akin to multiplication and reciprocal notation. With this analogy,
identity functions are like the multiplicative identity, 1, and inverse functions
are like reciprocals (hence the notation).
TYPES OF FUNCTIONS:
i) Real-Valued Functions
A real-valued function f is one whose co domain is the set of real
numbers or a subset thereof. If, in addition, the domain is also a subset of the
real’s, f is a real valued function of a real variable. The study of such functions
is called real analysis. Real-valued functions enjoy so-called point wise
operations. That is, given two functions
f, g: X → Y
Where Y is a subset of the real’s (and X is an arbitrary set), their (point
wise) sum f+g and product f ⋅ g are functions with the same domain and co
domain. They are defined by the formulas:
57
Further types of functions:
There are many other special classes of functions that are important to
particular branches of mathematics, or particular applications. Here is a partial
list:
Differentiable, integral
Polynomial, rational
Algebraic, transcendental
Odd or even
Convex, monotonic
Polymorphic, geomorphic, entire
Vector-valued
Computable
Properties of binary relation in a set:
A binary relation R is usually defined as an ordered triple (X, Y, G)
where X and Y are arbitrary sets (or classes), and G is a subset of the Cartesian
product X × Y. The sets X and Y are called the domain (or the set of departure)
and codomain (or the set of destination), respectively, of the relation, and G is
called its graph.
The statement (x,y) ∈ G is read "x is R-related to y", and is denoted by X
r y or R(x,y). The latter notation corresponds to viewing R as the characteristic
function on × Y for the set of pairs of G.
The order of the elements in each pair of G is important: if a ≠ b,
then aRb and bRa can be true or false, independently of each other. Resuming
the above example, the prime 3 divides the integer 9, but 9 don’t divide 3.
A relation as defined by the triple (X, Y, G) is sometimes referred to as
a correspondence instead. In this case the relation from X to Y is the
subset G of X × Y, and "from X to Y" must always be either specified or implied
by the context when referring to the relation. In practice correspondence and
relation tend to be used interchangeably.
For simplicity we adopt the following convention: X will have the type
set; x, y, z will have the type any; P, R will have the type Relation. We now
define several new predicates. Let us consider R, X. The predicate
R is reflexive in X is defined by x ∈ X implies hx, xi ∈ R.The predicate
R is i reflexive in X is defined by x ∈ X implies not hx, xi ∈ R.The predicate
R is symmetric in X Is defined byx∈ X & y ∈ X &hx, yi∈ R implies hy, xi ∈ R
The predicate x∈ X & y ∈ X &hx, yi∈ R &hy, xi ∈ R implies x = y.
The predicate R is asymmetric in X is defined by x∈ X & y ∈ X &hx,
yi∈ R implies not hy, xi ∈ R The predicate R is connected in X is defined by
58
x∈ X & y ∈ X & x 6= y implies hx, yi∈ R or hy, xi ∈ R. The predicate R is
strongly connected in X is defined by x∈ X & y ∈ X implies hx, yi∈ R or hy,
xi ∈ R The predicate R is transitive in X is defined by x∈ X & y ∈ X & z ∈
X &hx, yi∈ R &hy, zi∈ R implies hx, zi∈ R.
We now state several propositions:
(1) R is reflexive in X iff for x st x ∈ X holds hx, xi ∈ R,
(2) R is reflexive in X iff for x st x ∈ X holds not hx, xi ∈ R,
(3) R is symmetric in X
iff for x,yst x ∈ X & y ∈ X &hx, yi∈ R holds hy, xi ∈ R,
(4) R is ant symmetric in X
iff for x,yst x ∈ X & y ∈ X &hx, yi∈ R &hy, xi ∈ R holds x = y,
(5) R is asymmetric in X
iff for x,yst x ∈ X & y ∈ X &hx, yi∈ R holds not hy, xi ∈ R,
(6) R is connected in X
iff for x,yst x ∈ X & y ∈ X & x 6= y holds hx, yi∈ R or hy, xi ∈ R,
(7) R is strongly connected in X
iff for x,yst x ∈ X & y ∈ X holds hx, yi∈ R or hy, xi ∈ R,
(8) R is transitive in X
iff for x,y,zst x ∈ X & y ∈ X & z ∈ X &hx, yi∈ R &hy, zi∈ R holds hx,
zi∈ R.
We now define several new predicates. Let us consider R. The predicate
R is reflexive is defined by R is reflexive in field R. The predicate R is
reflexive is defined by R is reflexive in field R. The predicate R is symmetric
is defined by R is symmetric in field R. The predicate R is anti-symmetric is
defined by R is anti-symmetric in field R. The predicate R is asymmetric is
defined by R is asymmetric in field R. The predicate R is connected is defined
by R is connected in field R. The predicate R is strongly connected is defined
by R is strongly connected in field R. The predicate R is transitive is defined by
R is transitive in field R.
We now state a number of propositions:
(9) R is reflexive iff R is reflexive in field R,
(10) R is reflexive iff R is reflexive in field R,
(11) R is symmetric iff R is symmetric in field R,
(12) R is ant symmetric iff R is ant symmetric in field R,
(13) R is asymmetric iff R is asymmetric in field R,
59
(14) R is connected iff R is connected in field R,
(15) R is strongly connected iff R is strongly connected in field R,
(16) R is transitive iff R is transitive in field R,
(17) R is reflexive iff△ field R ⊆ R,
(18) R is reflexive iff△ (field R) ∩ R = Ø ,
(19) R is ant symmetric in X iff R \ △ X is asymmetric in X,
(20) R is asymmetric in X implies R ∪△ X is anti symmetric in X,
(21) R is anti symmetric in X implies R \ △ X is asymmetric in X,
(22) R is symmetric & R is transitive implies R is reflexive,
(23) △ X is symmetric &△ X is transitive,
(24) △ X is anti symmetric&△ X is reflexive,
(25) R is reflexive& R is transitive implies R is asymmetric,
(26) R is asymmetric implies R is reflexive& R is ant symmetric,
(27) R is reflexive implies R˜ is reflexive,
(28) R is reflexive implies R˜ is reflexive,
(29) R is reflexive implies dom R = dom (R˜) &rng R = rng (R˜),
(30) R is symmetric iff R = R˜,
(31) P is reflexive & R is reflexive implies P ∪ R is reflexive & P ∩ R is
reflexive,
(32) P is reflexive& R is reflexive implies P ∪ R is reflexive& P ∩ R is
reflexive,
(33) P is reflexive implies P \ R is reflexive,
(34) R is symmetric implies R˜ is symmetric,
(35) P is symmetric & R is symmetric implies P ∪ R is symmetric & P ∩ R
is symmetric & P \ R is symmetric,
(36) R is asymmetric implies R˜ is asymmetric,
(37) P is asymmetric & R is asymmetric implies P ∩ R is asymmetric,
(38) P is asymmetric implies P \ R is asymmetric,
(39) R is ant symmetric iff R ∩ (R˜) ⊆△ (Dom R),
(40) R is ant symmetric implies R˜ is ant symmetric, Properties of Binary
Relations 89
(41) P is ant symmetric implies P ∩ R is ant symmetric& P \ R is ant
symmetric,
(42) R is transitive implies R˜ is transitive,
60
(43) P is transitive & R is transitive implies P ∩ R is transitive,
(44) R is transitive iff R · R ⊆ R,
(45) R is connected iff [: field R, field R:] \ △ (field R) ⊆ R ∪ R˜,
(46) R is strongly connected implies R is connected & R is reflexive,
(47) R is strongly connected iff [: field R, field R:] = R ∪ R˜.
Example:
: Let R be the binary relation “less” (“N
{(0,1), (0,2), … (1,2), (1,3), … }
(4, 7) ∈ R
Normally, we write: 4 < 7
Additional Examples: Here are some binary relations over A={0,1,2}
Ø (nothing is related to anything)
A×A (everything is related to everything)
eq = {(0,0), (1,1),(2,2)}
less = {(0,1),(0,2),(1,2)}
FUNCTION:
A function [1] is a relation between a set of inputs and a set of
permissible outputs with the property that each input is related to exactly one
output. An example is the function that relates each real number x to its
square x2. The output of a function f corresponding to an input x is denoted
by f(x) (read "f of x"). In this example, if the input is −3,
Then the output is 9, and we may write f(−3) = 9. Likewise, if the input
is 3, then the output is also 9, and we may write f(3) = 9. (The same output may
be produced by more than one input, but each input gives only one output.) The
input variable(s) are sometimes referred to as the argument(s) of the function.
Examples:
For an example of a function, let X be the set consisting of four shapes:
a red triangle, a yellow rectangle, a green hexagon, and a red square; and
let Y be the set consisting of five colors: red, blue, green, pink, and yellow.
Linking each shape to its color is a function from X to Y: each shape is linked to
a color (i.e., an element in Y), and each shape is "linked", or "mapped", to
exactly one color. There is no shape that lacks a color and no shape that has
two or more colors. This function will be referred to as the "color-of-the-shape
function".
The input to a function is called the argument and the output is called
the value. The set of all permitted inputs to a given function is called
61
the domain of the function, while the set of permissible outputs is called the co
domain.
Thus, the domain of the "color-of-the-shape function" is the set of the
four shapes, and the co domain consists of the five colors. The concept of a
function does not require that every possible output is the value of some
argument, e.g. the color blue is not the color of any of the four shapes in X.
A second example of a function is the following: the domain is chosen
to be the set of natural numbers (1, 2, 3, 4 ...), and the co domain is the set
of integers (..., −3, −2, −1, 0, 1, 2, 3 ...). The function associates to any natural
number n the number 4−n. For example, to 1 it associates 3 and to 10 it
associates −6.
A third example of a function has the set of polygons as domain and the
set of natural numbers as co domain. The function associates a polygon with its
number of vertices. For example, a triangle is associated with the number 3, a
square with the number 4, and so on.
The term range is sometimes used either for the co domain or for the set
of all the actual values a function has. To avoid ambiguity this article avoids
using the term.
Figure: 2.1.5
Notation:
A function f with domain X and co domain Y is commonly denoted by
f : X Y
or
X
f
Y
In this context, the elements of X are called arguments of f. For each
argument x, the corresponding unique y in the co domain is called the
62
function value at x or the image of x under f. It is written as f(x). One says
that f associates y with x or maps x to y. This is abbreviated by
y f (x)
A general function is often denoted by f. Special functions have names,
for example, the signum function is denoted by sgn. Given a real number x, its
image under the signum function is then written as sgn(x). Here, the argument
is denoted by the symbol x, but different symbols may be used in other
contexts.
For example, in physics, the velocity of some body, depending on the
time, is denoted v(t). The parentheses around the argument may be omitted
when there is little chance of confusion, thus: sin x; this is known as prefix
notation.
In order to denote a specific function, the notation (an arrow with a
bar at its tail) is used. For example, the above function reads
f :N Z
x 4 x
The first part can be read as:
"f is a function from N (the set of natural numbers) to Z (the set of integers)"
or
"f is a Z -valued function of an N -valued variable".
The second part is read:
"x maps to 4−x."
In other words, this function has the natural numbers as domain,
the integers as co domain. Strictly speaking, a function is properly defined only
when the domain and co domain are specified. For example, the formula f(x) =
4 − x alone (without specifying the co domain and domain) is not a properly
defined function. Moreover, the function
g:Z Z
x 4 x
(With different domain) is not considered the same function, even
though the formulas defining f and g agree, and similarly with a different co
domain.
Despite that, many authors drop the specification of the domain and co
domain, especially if these are clear from the context. So in this example many
just write f(x) = 4 − x. Sometimes, the maximal possible domain is also
understood implicitly: a formula such as f ( x) x 5x 6 may mean that
2
63
the domain of f is the set of real numbers x where the square root is defined (in
this case x ≤ 2 or x ≥ 3).
To define a function, sometimes a dot notation is used in order to
emphasize the functional nature of an expression without assigning a special
symbol to the variable. For instance, a(.) 2 stands for the function,
x ax 2 , a F (u )du stands for the integral function x ax f (u )du , and so on.
Properties:
There are a number of general basic properties and notions. In this
section, f is a function with domain X and co domain Y.
Image and pre-image
Figure2.1.6
The graph of the function f(x) = x3 − 9x2 + 23x − 15. The interval A =
[3.5, 4.25] is a subset of the domain, thus it is shown as part of the x-axis
(green). The image of A is (approximately) the interval [−3.08, −1.88]. It is
obtained by projecting to the y-axis (along the blue arrows) the intersection of
the graph with the light green area consisting of all points whose x-coordinate
is between 3.5 and 4.25. The part of the (vertical) y-axis shown in blue.
The pre-image of B = [1, 2.5] consists of three intervals. They are
obtained by projecting the intersection of the light red area with the graph to
the x-axis.
If A is any subset of the domain X, then f (A) is the subset of the co
domain Y consisting of all images of elements of A. We say the f(A) is
the image of A under f. The image of f is given by f(X). On the other hand,
the inverse image (or pre-image, complete inverse image) of a subset B of the
co domain Y under a function f is the subset of the domain X defined by
f 1 ( B) x X : f ( x) B
64
So, for example, the pre-image of {4, 9} under the squaring function is
the set {−3,−2,2,3}. The term range usually refers to the image, but sometimes
it refers to the co domain.
By definition of a function, the image of an element x of the domain is
always a single element y of the co domain. Conversely, though, the pre-image
of a singleton set (a set with exactly one element) may in general contain any
number of elements. For example, if f(x) = 7 (the constant function taking
value 7), then the pre-image of {5} is the empty set but the pre-image of {7} is
the entire domain. It is customary to write f−1(b) instead of f−1({b}), i.e
f 1 (b) x X : f ( x) b
This set is sometimes called the fiber of b under f.
Use of f(A) to denote the image of a subset A ⊆ X is consistent so long
as no subset of the domain is also an element of the domain. In some fields
(e.g., in set theory, where ordinals are also sets of ordinals) it is convenient or
even necessary to distinguish the two concepts.
The customary notation is f [A] for the set {f(x): x ∈ A }. Likewise,
some authors use square brackets to avoid confusion between the inverse image
and the inverse function. Thus they would write f−1[B] and f−1[b] for the pre-
image of a set and a singleton.
3.1.3 Injective and subjective functions
A function is called injective (or one-to-one, or an injection) if f(a)
≠ f(b) for any two different elements a and b of the domain. It is
called subjective (or onto) if f(X) =Y. That is, it is subjective if for every
element y in the co domain there is an x in the domain such that f(x) = y.
Finally f is called objective if it is both injective and subjective. This
nomenclature was introduced by the Bourbaki group.
The above "color-of-the-shape" function is not injective, since two
distinct shapes (the red triangle and the red rectangle) are assigned the same
value. Moreover, it is not subjective, since the image of the function contains
only three, but not all five colors in the codomain.
65
Function composition
Figure: 2.1.7
A composite function g(f(x)) can be visualized as the combination of
two "machines". The first takes input x and outputs f(x). The second takes f(x)
and outputs g(f(x)).
The function composition of two functions takes the output of one
function as the input of a second one. More specifically, the composition
of f with a function g: Y → Z is the function g f : X Z defined by
( g f )( x) g ( f ( x)).
That is, the value of x is obtained by first applying f to x to
obtain y = f(x) and then applying g to y to obtain z = g(y). In the notation, g f
, the function on the right, f, acts first and the function on the left, g acts second,
reversing English reading order. The notation can be memorized by reading the
notation as "g of f" or "g after f".
The composition g o f is only defined when the co domain of f is
the domain of g. Assuming that, the composition in the opposite
order f o g need not be defined. Even if it is, i.e., if the co domain of f is
the co-domain of g, it is not in general true that
g o f f o g
That is, the order of the composition is important. For example,
suppose f(x) = x2 and g(x) = x+1. Then g(f(x)) = x2+1, while f(g(x)) = (x+1)2,
which is x2+2x+1, a different function.
66
3.4 IDENTITY FUNCTION
The unique function over a set X that maps each element to itself is
called the identity function for X, and typically denoted by idX. Each set has its
own identity function, so the subscript cannot be omitted unless the set can be
inferred from context. Under composition, an identity function is "neutral":
if f is any function from X to Y, then
foid x f ,
id Y of f
Restrictions and extensions
Informally, a restriction of a function f is the result of trimming its
domain. More precisely, if S is any subset of X, the restriction of f to S is the
function f|S from S to Y such that f|S(s) = f(s) for all s in S. If g is a restriction
of f, then it is said that f is an extension of g.
The overriding of f: X → Y by g: W → Y (also called overriding union)
is an extension of g denoted as (f ⊕ g): (X ∪ W) → Y. Its graph is the set-
theoretical union of the graphs of g and f|X \ W. Thus, it relates any element of
the domain of g to its image under g, and any other element of the domain
of f to its image under f. Overriding is an associative operation; it has the empty
function as an identity element. If f|X ∩ W and g|X ∩ W are point wise equal (e.g.,
the domains of f and g are disjoint), then the union of f and g is defined and is
equal to their overriding union. This definition agrees with the definition of
union for binary relations.
Inverse Function
An inverse function for f, denoted by f−1, is a function in the opposite
direction, from Y to X, satisfying
1
fof id Y , f 1o f id x
That is, the two possible compositions of f and f−1 need to be the
respective identity maps of X and Y.
As a simple example, if f converts a temperature in degrees Celsius C to
degrees Fahrenheit F, the function converting degrees Fahrenheit to degrees
Celsius would be a suitable f−1.
9
f (C ) C 32
5
5
f 1 ( F ) ( F 32)
9
Such an inverse function exists if and only if f is objective. In this
case, f is called invertible. The notation g º J (or, in some texts, just gJ)
67
and f−1 are akin to multiplication and reciprocal notation. With this analogy,
identity functions are like the multiplicative identity, 1, and inverse functions
are like reciprocals (hence the notation).
3.5 COMPOSITION OF FUNCTIONS:
In mathematics function composition is the point wise application of
one function to the result of another to produce a third function. For instance,
the functions f : X → Y and g : Y → Z can be composed to yield a function
which maps x in X to g(f(x)) in Z.
Intuitively, if z is a function of y, and y is a function of x, then z is a
function of x. The resulting composite function is denoted g ∘ f : X → Z, defined
by (g ∘ f )(x) = g(f(x)) for all x in X. The notation g ∘ f is read as "g circle f ", or
"g round f ", or "g composed with f ", "g after f ", "g following f ", or "g of f", or
"g on f ". Intuitively, composing two functions is a chaining process in which
the output of the first function becomes the input of the second function.
Given a function f(x), you would plug a number or another variable in
for x. You could even get fancy and plug in an entire expression for x. For
example, given f(x) = 2x + 3, you could find f(y2 – 1) by plugging y2 – 1 in
for x to get f(y2 – 1) = 2(y2 – 1) + 3 = 2y2 – 2 + 3 = 2y2 + 1.
In function composition, you're plugging entire functions in for the x. In
other words, you're always getting "fancy". But let's start simple. Instead of
dealing with functions as formulas, let's deal with functions as sets
of (x, y) points:
Let f = {(–2, 3), (–1, 1), (0, 0), (1, –1), (2, –3)} and
let g = {(–3, 1), (–1, –2), (0, 2), (2, 2), (3, 1)}.
68
Now I'll work in steps, keeping in mind that, while I may be used to
doing things from the left to the right (because that's how we read),
composition works from the right to the left (or, if you prefer, from the inside
out).
So I'll start with the x = 1. I am plugging this into f(x), so I look in the
set of f(x) points for a point with x = 1. The point is (1, –1). This tells me
that f(1) = –1, so now I have: Copyright © Elizabeth Stapel-2011 All Rights
Reserved
(g o f )(1) = g( f(1)) = g(–1)
Working from the right back toward the left, I am now plugging x = –
1 (from "f(1) = –1") into g(x), so I look in the set of g(x) points for a point
with x = –1. That point is (–1, –2). This tells me that g(–1) = –2, so now I have
my answer:
(g o f )(1) = g( f(1)) = g(–1) = –2
Note that they never told us what the formulas, if any were,
for f(x) or g(x); we were only given a list of points. But this list was sufficient
for answering the question, as long as we keep track of our x- and y-values.
Let f = {(–2, 3), (–1, 1), (0, 0), (1, –1), (2, –3)} and
let g = {(–3, 1), (–1, –2), (0, 2), (2, 2), (3, 1)}.
69
result you get after composing two other functions) will have a restricted
domain, or at least a domain that is more restricted than you might otherwise
have expected.
This will be more important when we deal with composing functions
symbolically later. Another exercise of this type gives you two graphs, rather
than two sets of points, and has you read the points (the function values) from
these graphs.
Given f(x) and g(x) as shown below, find ( f o g)(–1).
f(x): g(x):
Figure: 2.1.8
In this case,
I will read the points from the graph. I've been asked to find ( f o g)(–1)
= f(g(–1)). This means that I first need to find g(–1). So I look on the graph
of g(x), and find x = –1. Tracing up from x = –1 to the graph of g(x), I arrive
at y = 3. Then the point (–1, 3) is on the graph of g(x), and g(–1) = 3.
Now I plug this value, x = 3, into f(x). To do this, I look at the graph
of f(x) and find x = 3. Tracing up from x = 3 to the graph of f(x), I arrive at y =
3. Then the point (3, 3) is on the graph of f(x), and f(3) = 3.
Then ( f o g)(–1) = f(g(–1)) = f(3) = 3.
70
Given f(x) and g(x) as shown in the graphs below, find ( g o f )(x) for
integral values of xon the interval –3 < x < 3.
f(x): g(x):
Figure: 2.1.9
This is asking me for all the values of (g o f )(x) = g( f(x)) for x = –3, –2,
–1, 0, 1, 2, and 3. So I'll just follow the points on the graphs and compute all
the values:
(g o f )(–3) = g( f(–3)) = g(1) = –1
I got this answer by looking at x = –3 on the f(x) graph, finding the
corresponding y-value of 1on the f(x) graph, and using this answer as my
new x-value on the g(x) graph. That is, I looked at x = –3 on the f(x) graph,
found that this led to y = 1, went to x = 1 on the g(x) graph, and found that this
led to y = –1. Similarly:
(g o f )(–2) = g( f(–2)) = g(–1) = 3
(g o f )(–1) = g( f(–1)) = g(–3) = –2
(g o f )(0) = g( f(0)) = g(–2) = 0
(g o f )(1) = g( f(1)) = g(0) = 2
(g o f )(2) = g( f(2)) = g(2) = –3
(g o f )(3) = g( f(3)) = g(3) = 1
You aren't generally given functions as sets of points or as graphs,
however. Generally, you have formulas for your functions. So let's see what
composition looks like in that case.
Suppose you are given the two functions f (x) = 2x + 3 and g(x) = –x2 +
5. Composition means that you can plug g(x) into f (x). This is written as
"( f o g)(x)", which is pronounced as "f-compose-g ofx". And "( f o g)(x)"
means " f (g(x))". That is, you plug something in for x, then you plug that value
into g, simplify, and then plug the result into f.
71
The process here is just like what we saw on the previous page, except
that now we will be using formulas to find values, rather than just reading the
values from lists of points.
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find (g o f )(1).
When I work with function composition, I usually convert "( f o g)(x)"
to the more intuitive " f (g(x))" form. This is not required, but I certainly find it
helpful. In this case, I get:
(g o f )(1) = g( f(1))
This means that, working from right to left (or from the inside out), I am
plugging x = 1 into f(x), evaluating f(x), and then plugging the result into g(x). I
can do the calculations bit by bit, like this: Since f(1) = 2(1) + 3 = 2 + 3 = 5,
and since g(5) = –(5)2 + 5 = –25 + 5 = –20, then(g o f )(1) = g( f(1)) = g(5) = –
20. Doing the calculations all together (which will be useful later on when
we're doing things symbolically), it looks like this:
(g o f )(1)= g( f (1))
= g(2( )+3) ... setting up to insert the original input
= g(2(1)+3)
= g(2+3)
= g(5)
2
=–( x) +5 ... setting up to insert the new input
=-(5)2 +5
=–25+5
= –20
Note how I wrote each function's rule clearly, leaving open parentheses
for where the input (x or whatever) would go. This is a useful technique.
Whichever method you use (bit-by-bit or all-in-one), the answer is:
(g o f )(1) = g( f (1)) = –20
I just computed (g o f )(1); the composition can also work in the other
order:
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find ( f o g)(1).
First, I'll convert this to the more intuitive form, and then I'll simplify:
( f o g)(1) = f (g(1))
Working bit-by-bit, since g(1) = –(1)2 + 5 = –1 + 5 = 4, and since f(4) =
2(4) + 3 = 8 + 3 = 11, then ( f o g)(1) = f (g(1)) = f(4) = 11. On the other hand,
working all-in-one (right to left, or from the inside out), I get this:
( f o g)(1)= f (g(1))
2
= f (–(x) +5) ... setting up to insert the original input
= f (–(1)2 +5)
72
= f (–1+5)
= f (4)
=2( x)+3 ... setting up to insert the new input
=2(4)+3
=8+3
= 11
Either way, the answer is: Copyright © Elizabeth Stapel 2002-2011
All Rights Reserved
( f o g)(1) = f (g(1)) = 11
A verbal note: "f o g" is not pronounced as "fogg" and "g o f "
is not pronounced as "goff". They are pronounced as "f-compose-g" and "g-
compose-f ", respectively. Don't make yourself sound ignorant by pronouncing
these wrongly!
As you have seen above, you can plug one function into another. You
can also plug a function into itself:
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find ( f o f )(1).
( f o f )(1)= f ( f (1))
= f (2( x)+3) ... setting up to insert the original input
= f (2(1)+3)
= f (2+3)
= f (5)
=2( x)+3 ... setting up to insert the new input
=2(5)+3
=10+3
= 13
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find (g o g)(1).
(g o g)(1) = g(g(1))
2
= g(–(x) + 5) ... setting up to insert the original input
= g(–(1)2 +5)
= g(–1+5)
= g(4)
2
= –( x) +5 ... setting up to insert the new input
= –(4)2 + 5
= –16 + 5
= –11
In each of these cases, I wrote out the steps carefully, using parentheses
to indicate where my input was going with respect to the formula. If it helps
you to do the steps separately, then calculate g(1)outside of the other g(x) as a
73
separate step. That is, do the calculations bit-by-bit, first finding g(1) = 4, and
then plugging 4 into g(x) to get g(4) = –11.
You can also evaluate compositions symbolically. It is simpler to
evaluate a composition at a point because you can simplify as you go, since
you'll always just be plugging in numbers and simplifying. Evaluating a
symbolic composition, where you're first plugging x into some function and
then plugging that function into some other function, can be much messier. But
the process works just as the at-a-number composition does, and using
parentheses to be carefully explicit at each step will be even more helpful.
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find ( f o g)(x).
In this case, I am not trying to find a certain numerical value. Instead, I
am trying to find the formula that result from plugging the formula for g(x) into
the formula for f(x). I will write the formulas at each step, using parentheses to
indicate where the inputs should go:
( f o g)(x) = f (g(x))
= f (–x2 +5)
=2(x)+3 ... setting up to insert the input formula
=2(–x2 +5)+3
=2x2 +=10+3
= –2x2 + 13
If you plug in "1" for the x in the above, you will get ( f o g)(1) = –
2(1)2 + 13 = –2 + 13 = 11, which is the same answer we got before. Previously,
we'd plugged a number into g(x), found a new value, plugged that value
into f(x), and simplified the result. This time, we plugged a formula into f(x),
simplified the formula, plugged the same number in as before, and simplified
the result.
The final numerical answers were the same. If you've done the symbolic
composition (the composition with the formulas) correctly, you'll get the same
values either way, regardless of the value you pick for x. This can be a handy
way of checking your work.
Here's another symbolic example: Copyright © Elizabeth Stapel 2002-2011
All Rights Reserved
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find (g o f )(x).
(g o f )(x)= g( f(x))
= g(2x +3)
2
= –() + 5 ... setting up to insert the input
=(2x +3)2 +5
=(4x2 +12x +9)+5
74
=4x2 –12x –9+5
=4x2 – 12x – 4
There is something you should note from these two symbolic examples.
Look at the results I got:
( f o g)(x)=2x2 +13
(g o f )(x) = –4x2 – 12x – 4
That is, ( f o g)(x) is not the same as (g o f )(x). This is true in general;
you should assume that the compositions ( f o g)(x) and (g o f )(x) are going to
be different. In particular, composition is not the same thing as multiplication.
The open dot "o" is not the same as a multiplication dot "•", nor does it mean
the same thing. While the following is true:
f(x) • g(x) = g(x) • f(x) [always true for multiplication]
...you cannot say that:
( f o g)(x) = (g o f )(x) [generally false for composition]
That is, you cannot reverse the order in composition and expect to end
up with the correct result. Composition is not flexible like multiplication, and is
an entirely different process. Do not try to multiply functions when you are
supposed to be plugging them into each other.
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find ( f o f )(x).
( f o f )(x) = f ( f (x))
= f (2x + 3)
=2(x)+3 ... setting up to insert the input
=2(2x +3)+3
=4x +6+3
= 4x + 9
Given f(x) = 2x + 3 and g(x) = –x2 + 5, find (g o g)(x).
(g o g)(x)=g(g(x))
2
=–(x) +5 ... setting up to insert the input
=–(–x2 +5)2 +5
=–(x4 –10x2 +25)+5
=–x4 +10x2 –25+5
= –x4 + 10x2 – 20
Sometimes you have to be careful with the domain and range of the
composite function.
Given f (x) = sqrt(x) and g(x) = x – 2, find the domains
of ( f o g)(x) and (g o f )(x).
75
Since f (x) involves a square root, the inputs have to be non-negative.
This means that the domain (the set of x-values) for f (x) is "all x > 0". Then,
in (g o f )(x), where I'm plugging xfirst into f (x) = sqrt(x), the domain is at least
restricted to "all x > 0". Let's see what the two compositions look like:
( f o g)(x)= f (g(x))
= f (x –2)
= sqrt(x –2)
= sqrt(x – 2)
The domain for the square root is all inputs that make "x – 2" non-
negative. That is, all x such that x – 2 > 0. Solving this for x, I get that the
domain of ( f o g)(x) is "all x > 2".
Now to do the other composition:
(g o f )(x)= g( f (x))
= g( sqrt(x))
=(x)–2
=( sqrt(x))–2
= sqrt(x) – 2
The domain for this is all inputs that make the square root defined.
Since there is only "x" inside the square root, then:
The domain of (g o f )(x) is "all x > 0".
If your initial functions are just plain old polynomials, then their
domains are "all x", and so will be the domain of the composition. It's pretty
much only if your dealing with denominators (where you can't divide by zero)
or square roots (where you can't have a negative) that the domain ever becomes
an issue.
You may be given exercises where you need to think about what's going
on, the order in which things are being done, and therefore the way in which
modeling functions need to be composed:
You work forty hours a week at a furniture store. You receive a $220
weekly salary, plus a 3% commission on sales over $5000. Assume that you
sell enough this week to get the commission. Given the functions f (x) =
0.03x and g(x) = x – 5000, which of ( f o g)(x)and (g o f )(x) represents your
commission?
Well, ( f o g)(x) = f(g(x)) would mean that I would take my sales x,
subtract off the $5000that didn't get the commission, and then multiply by 3%.
On the other hand, (g o f )(x) = g( f (x)) would mean that I would take my
76
sales x, multiply by 3%, and then subtract $5000from the result. This could
land me in negative numbers! (Would I owe money to my boss?)
So ( f o g)(x) does what we need it to do: ( f o g)(x) represents my
commission.
If you're not sure how the formulas are working, try plugging in
numbers that you can understand, and pay attention to what you do with those
numbers. The formula you need will be the same process. In the case of the
commission formula above, you could test the following sales values:
(0.03)($1000) (0.03)($3000)
commission $0
= $30 = $90
For each sales value, I first subtracted $5000 to see if I'd sold enough to earn
any commission at all. If I had, then I multiplied by 3%. Then I should apply
the "subtract five thousand" formula first, and then apply the "multiply by three
percent" formula last. This matches f(g(x)) = ( f o g)(x), which confirms my
earlier answer.
You make a purchase at a local hardware store, but what you've bought
is too big to take home in your car. For a small fee, you arrange to have the
hardware store deliver your purchase for you. You pay for your purchase, plus
the sales taxes, plus the fee. The taxes are 7.5% and the fee is $20.
(i) Write a function t(x) for the total, after taxes, on the purchase
amount x. Write another function f(x) for the total, including the
delivery fee, on the purchase amount x.
(ii) Calculate and interpret ( f o t)(x) and (t o f )(x). Which results in a lower
cost to you?
(iii) Suppose taxes, by law, are not to be charged on delivery fees. Which
composite function must then be used?
This sort of calculation actually comes up in "real life", and is used for
programming the cash registers. And this is why there is a separate button on
the register for delivery fees and why they're not rung up as just another
purchase.
(i) The taxes are 7.5%, so the tax function is given by t(x) = 1.075x
The delivery fee is fixed, so the purchase amount is irrelevant.
77
The fee function is given by f (x) = x + 20
(ii) Composing, I get this:
( f o t)(x) = f (t(x)) = f (1.075x) = 1.075x + 20
(t o f )(x) = t( f (x)) = t(x + 20) = 1.075(x + 20)
= 1.075x + 21.50
Then I would pay more using (t o f )(x), because I would be paying
taxes (the t(x) formula) on the delivery fee (the "+20" in the f (x) formula). I
would prefer that the delivery fee be tacked on after the taxes,
because ( f o t)(x) results in a lower cost to me.
(iii) If the state is not allowed to collect taxes on delivery fees, then:
The function to use is ( f o t)(x).
Your computer's screen saver is an expanding circle. The circle starts as
a dot in the middle of the screen and expands outward, changing colors as it
grows. With a twenty-one inch screen, you have a viewing area with a 10-inch
radius (measured from the center diagonally down to a corner). The circle
reaches the corners in four seconds. Express the area of the circle (discounting
the area cut off by the edges of the viewing area) as a function of time t in
seconds.
Since the circle's leading edge covers ten inches in four seconds, the
radius is growing at a rate of (10 inches)/(4 seconds) = 2.5 inches per second.
Then the equation of the radius r, as a function of time t, is:
r(t) = 2.5t
The formula for the area A of a circle, as a function of the radius r, is given by:
A(r ) r 2
Then the area, as a function of time, is found by plugging the radius
equation into the area equation, and simplifying the composition:
A(t ) Aor (t ) A(r (t ))
A(2.5l )
(2.5l ) 2
(6.25l 2 )
6.25 l 2
Then the function they're looking for is:
A(t ) 6.25 l 2
78
The lesson on inverse functions explains how to use function
composition to verify that two functions are inverses of each other. However,
there is another connection between composition and inversion:
Given f (x)=2x –1 and
g(x)=(1/2)x +4,
find f –1(x), g –1(x), ( f o g)–1(x),
and (g–1 o f –1)(x).
What can you conclude?
This involves a lot of steps, so I'll stop talking and just show you how it goes.
First, I need to find f –1(x), g –1(x), and ( f o g)–1(x):
Inverting f (x):
f (x)=2x –1
y =2x –1
y +1=2x
(y +1)
/2 = x
(x +1)
/2 = y
(x + 1)
/2 = f –1(x)
Inverting g(x):
g(x)=(1/2)x +4
y =(1/2)x +4
y –4=(1/2)x
2(y –4)= x
2y –8= x
2x –8= y
2x –8= g –1(x)
Finding the composed function: Copyright © Elizabeth Stapel 2002-2011 All
Rights Reserved
( f o g)(x)= f (g(x))= f ((1/2)x +4)
=2((1/2)x +4)–1
= x +8–1
=x+7
Inverting the composed function:
( f o g)(x)= x +7
y = x +7
y –7= x
x –7= y
x – 7 = ( f o g)–1(x)
79
Now I'll compose the inverses of f(x) and g(x) to find the formula
for (g o f –1)(x):
–1
(f º g)(x) = 2x2+3
We got a different result!
So be careful which function comes first.
80
Figure: 2.2.1
Properties:
The composition of functions is always associative—a property
inherited from the composition of relations. That is, if f, g, and h are three
functions with suitably chosen domains and co domains, then f ∘ (g ∘ h) = (f ∘ g)
∘ h, where the parentheses serve to indicate that composition is to be performed
first for the parenthesized functions. Since there is no distinction between the
choices of placement of parentheses, they may be left off without causing any
ambiguity.
In a strict sense, the composition g ∘ f can be built only if f's co domain
equals g's domain; in a wider sense it is sufficient that the former is
a subset of the latter. Moreover, it is often convenient to tacitly restrict f's
domain such that f produces only values in g's domain; for example, the
composition g ∘ f of the functions f : R → [−∞,+9] defined by f(x) = 9
− x2 and g : [0,+∞] → R defined by g(x) = √x can be defined on the interval
[−3,+3].
Compositions of two real functions, absolute and a cubic function, in different
orders show a non-commutatively of the composition.
The functions g and f are said to commute with each other if g ∘ f = f ∘ g.
In general, composition of functions will not be commutative. Commutatively
is a special property, attained only by particular functions, and often in special
circumstances. For example, |x| + 3 = |x + 3| only when x ≥ 0. The picture
shows another example.
The composition of one-to-one functions is always one to one.
Similarly, the composition of two onto functions is always onto. It follows that
composition of two bijections is also a bijection. The inverse function of a
composition (assumed invertible) has the property that (f ∘ g)−1 = ( g−1 ∘ f −1).[2]
Derivatives of compositions involving differentiable functions can be
found using the chain rules. Higher derivatives of such functions are given
by Faà di Bruno's formula.
81
3.6 INVERSE FUNCTION:
Let f be a function whose domain is the set X, and whose image (range)
is the set Y. Then f is invertible if there exists a function g with domain Y and
image X, with the property:
f ( x) y g ( y ) x
If f is invertible, the function g is unique, which means that there is
exactly one function g satisfying this property (no more, no less). That
function g is then called the inverse of f, and is usually denoted as f −1.
Stated otherwise, a function is invertible if and only if its inverse
relation is a function on the range Y, in which case the inverse relation is the
inverse function.
Not all functions have an inverse. For this rule to be applicable, each
element y ∈ Y must correspond to no more than one x ∈ X; a function f with this
property is called one-to-one or an injection.
If f and f −1 are functions on X and Y respectively, then both are
bisections. The inverse of an injection that is not bisection is a partial function.
That means for some y ∈ Y it is undefined,
Let us start with an example:
Here we have the function f(x) = 2x+3, written as a flow diagram:
\
Figure: 2.2.2
So the inverse of: 2x+3 is: (y-3)/2, the inverse is usually shown by
putting a little "-1" after the function name, like this:
f-1(y)
We say "f inverse of y"
So, the inverse of f(x) = 2x+3 is written:
f-1(y) = (y-3)/2
(I also used y instead of x to show that we are using a different value.)
Example:
Using the formulas from above, we can start with x=4:
82
f(4) = 2×4+3 = 11
We can then use the inverse on the 11:
f-1(11) = (11-3)/2 = 4
And we magically get 4 back again!
We can write that in one line:
f-1( f(4) ) = 4
"f inverse of f of 4 equals 4"
So applying a function f and then its inverse f-1 gives us the original
value back again:
f-1( f(x) ) = x.
3.6.1 Finding the inverse from a graph:
Your textbook probably went on at length about how the inverse is "a
reflection in the line y = x". What it was trying to say was that you could take
your function, draw the line y = x (which is the bottom-left to top-right
diagonal), put a two-sided mirror on this line, and you could "see" the inverse
reflected in the mirror. Practically speaking, this "reflection" property can help
you draw the inverse:
Draw the points and the reflection line:
Figure:2.5.6
You can see on this last picture that there is a definite graphical
relationship between the points of the function and the points of the inverse.
You can use this relationship if you're given a random graph and are told to
graph the inverse. Copyright © Elizabeth Stapel 2000-2011 All Rights
Reserved
Suppose you are given this graph:
83
Figure:2.2.5
Note that I have NOT told you what the function is!
Now draw the reflection line:
Figure:2.2.6
(It would be a good idea to use a ruler for this; you'll want to be neat!).
Now eyeball the graph, and draw the diagonals from known points on
the graph to their "reflections" on the other side of the line:
84
Figure:2.2.7
Note that the points actually ON the line y = x don't move; that is,
where the function crosses the diagonal, the inverse will cross, too.
Now draw in some plot-points:
Figure:2.2.9
Figure: 2.2.8Without ever knowing what the function was, you can draw the
inverse (the purple line).
Now suppose your function is { (1, 2), (2, 1), (3, 4), (5, 1) }. The inverse of this
function is { (2, 1), (1, 2), (4, 3), (1, 5) }. This inverse has two points, (1,
2) and (1, 5), that share a common x-value but have different y-values. This
means that the inverse is NOT a function.
Graphically, the original function looks like this:
85
Figure:2.3.1
You can find the inverse algebraically, by flipping the x- and y-coordinates, or
graphically, by drawing the line y = x...
Figure:2.3.2
...and reflecting all the points across it:
Figure:2.3.2
Note that it's perfectly okay for the inverse to "overwrite" the original
function's points! The points "(2, 1) and (1, 2)" of the inverse overwrote the
points "(1, 2) and (2, 1)" of the original function, which is why the graph is
"missing" a red dot.
86
Figure2.3.3
But you can see that the inverse is not a function: there are two points sharing
an x-value.
Figure2.3.4
There is a quick way to tell, before going to the trouble of finding the
inverse, whether the inverse will also be a function. You've seen that you sort
of "flip" .fig.2.3.4 show it.
The original function over the line y = x to get the inverse. Using this
fact, someone noticed that you can also "flip over" the Vertical Line Test to get
the Horizontal Line Test. As you can see, you can draw a horizontal line
through two of the points in the original function:
Figure.2.3.5
87
Since the original function had two points that shared the same Y-
VALUE, then the inverse of the original function will not be a function. This
means, for instance, that no parabola (quadratic function) will have an inverse
that is also a function.
In general, if the graph does not pass the Horizontal Line Test, then the
graphed function's inverse will not itself be a function; if the list of points
contains two or more points having the same y-coordinate, then the listing of
points for the inverse will not be a function. So when you're asked "Will the
inverse be a function?", if you're given a graph, draw a horizontal line; if you're
given a list of points, compare they-coordinates.
The customary method of finding the inverse is some variant of the
method I'm going to use below. Whatever method you use, make sure you do
the exact same steps in the exact same order every time, so you remember those
steps when you get to the test.
Find the inverse of y = 3x – 2.
Here's how the process works:
Figure2.3.6
Then the inverse is y = (x + 2) / 3
If you need to find the domain and range, look at the original function
and its graph. The domain of the original function is the set of all allowable x-
values; in this case, the function was a simple polynomial, so the domain was
"all real numbers". The range of the original function is all the y-values you'll
pass on the graph; in this case, the straight line goes on for ever in either
direction, so the range is also "all real numbers". To find the domain and range
of the inverse, just swap the domain and range from the original function.
88
Find the inverse function of y = x2 + 1, if it exists.
There will be times when they give you functions that don't have
inverses. From the graph, it's easy to see that this function can't possibly have
an inverse, since it violates the Horizontal Line Test:
Figure2.3.7
It is usually considered acceptable to draw the above graph, draw a
horizontal line across it that crosses the graph twice, and then say something
like "The inverse of this function is not itself a function, because of the
Horizontal Line Test". But some teachers want to see the algebra anyway. Be
sure to check with your teacher and verify what will be an acceptable answer --
and do this before the test! Copyright © Elizabeth Stapel 2000-2011 All Rights
Reserved
What will this look like when I try to find the inverse algebraically?
The Vertical Line Test says that I can't have two y's that share an x-value. That
is, each x has to have a UNIQUE corresponding y value. But look at what
happens when I try to solve for "x =":
My original function:
Well, I solved for "x =", but I didn't get a UNIQUE "x =". Instead, I've
shown that any given x-value will actually correspond to two different y-values,
one from the "plus" on the square root and the other from the "minus".
The inverse is not a function. Any time you come up with a "±" sign, you can
be pretty sure that the inverse isn't a function.
89
Find the inverse function of y = x2 + 1, x < 0.
The only difference between this function and the previous one is that
the domain has been restricted to only the negative half of the x-axis. This
restriction makes the graph look like this:
Figure:2.3.7
This function will have an inverse that is also a function. Just about any
time they give you a problem where they've taken the trouble to restrict the
domain, you should take care with the algebra and draw a nice picture, because
the inverse probably is a function, but it will probably take some extra effort to
show this. In this case, since the domain is x < 0 and the range (from the graph)
is 1 < y, then the inverse will have a domain of 1 < x and a range of y < 0.
Here's how the algebra looks:
Table 2.3.9
(The "x > 1" restriction comes from the fact that x is inside a square root.)
So the inverse is y = –sqrt(x – 1), x > 1, and this inverse is also a function.
90
Figure2.3.8 Here's the graph
Find the inverse of y = x2 + 1, x > 0, and determine whether the inverse is a
function.
You'll notice that the only difference between this and the previous
exampleis that the domain has been restricted to the positive x-axis this time.
Here's the graph.
Figure:2.3.9
Since this passes the Horizontal Line Test, I know that its inverse will
be a function. And since this graph is different from that of the previous
function, I know that the inverse must be different. Again, it is very helpful to
first find the domains and ranges. The function's domain is
x > 0; the range (from the graph) is y > 1. Then the inverse's domain will
be x > 1 and the range will be y > 0. Here's the algebra:
Table2.4.1
91
Since I already figured out the domain and
range, I know that I have to choose the
positive square root:
Figure2.4.2
Then the inverse is y = sqrt(x – 1), x > 1, and the inverse is also a function.
If you've studied function notation, you may be starting with "f(x)"
instead of "y". In that case, start the inversion process by renaming f(x) as "y";
find the inverse, and rename the resulting "y" as "f–1(x)". It's usually easier to
work with "y". Warning: This notation is misleading; the "minus one" power in
the function notation means "the inverse function", not "the reciprocal of".
Don't confuse the two.
92
Find the inverse of y = –2 / (x – 5), and determine whether the inverse is
also a function.
Since the variable is in the denominator, this is a rational function. Here's the
algebra:
Table2.4.5
93
Figure2.4.3
The domain is x > 2; the range (from the graph) is y < 0. Then the
domain of the inverse will be x < 0; the range will be y > 2. Here's the algebra:
Table2.4.6
Switch x and y:
Then the inverse y = x2 + 2 is a function, with domain x < 0 and range y > 2.
Figure: 2.4.7
94
Find the inverse f(x) = (x – 2)
/ (x + 2), where x does not equal –2. Is the
inverse a function?
First, I recognize that f(x) is a rational function. Here's its graph:
Figure: 2.4.8
The restriction on the domain comes from the fact that I can't divide by
zero, so x can't be equal to –2. I usually wouldn't bother writing down the
restriction, but its helpful here because I need to know the domain and range of
the inverse. Note from the picture (and recalling the concept of horizontal
asymptotes) that y will never equal 1. Then the domain is "x is not equal to –
2" and the range is " y is not equal to 1". For the inverse, they'll be swapped: the
domain will be "x is not equal to 1" and the range will be "y is not equal to –2".
Here's the algebra:
95
Then I switch x and y:
Since the inverse is just a rational function, then the inverse is indeed a
function.
Here's the graph:
Figure: 2.4.9
Then the inverse is y = (–2x – 2) / (x – 1), and the inverse is also a function,
with domain of all x not equal to 1 and range of all y not equal to –2. Find the
inverse of f(x) = x2 – 3x + 2, x < 1.5
With the domain restriction, the graph looks like this:
From what I know about graphing, the vertex is at (x, y) = (1.5, –0.25),
so this graph is the left-hand "half" of the parabola
Figure: 2.5.1
96
This half of the parabola passes the Horizontal Line Test, so the
(restricted) function is invertible. But how to solve for the inverse? Copyright
© Elizabeth Stapel 2000-2011 All Rights Reserved
0 = x2 – 3x + 2 –y
2
0 = x – 3x + (2 – y)
97
Figure2.5.2
However, with the domain restriction, I get this
Figure.2.5.3
The restricted function passes the Horizontal Line Test, so the inverse
will now be a function. Since the domain of the original function is –
2 < x < 0 and the range is –2 < y < 0, then the domain of the inverse will be –
2 < x < 0 and the range will be –2 < y < 0. Yes, the domains and the ranges are
identical. Here's the algebra:
98
NEGATIVE square root
here:
Figure: 2.5.4
If you use the upper-right quarter of the circle you'll get the same result;
the inverse will be identical to the function. However, if you take either of the
other two quarters, you'll get the remaining quarter as the inverse:
...and:
Figure: 2.5.5
99
Given the graph and how to find an inverse if you're given the formula.
But suppose you are given two functions and told to verify (to check) that they
are inverses of each other. How would you do that? First, you would need to
note that drawing the graphs is not a "proof". To emphasize that a picture isn't
proof, the instructions will often tell you to "verify algebraically" that the
functions are inverses. How do you do that?
If you think back to the definition of an inverse, the point of the inverse
is that it's backwards from what you started with; it takes you back to where
you started from. For instance, if the point (1, 3) is on the graph of the function,
then the point(3, 1) is on the graph of the inverse. That is, if you start with x =
1, you will go to y = 3; then you plug this into the inverse, and you'll go right
back to x = 1, where you started from.
It is this property that you use to prove (or disprove) that functions are
inverses of each other. You will compose the functions (that is, plug x into one
function, plug that function into the inverse function, and then simplify) and
verify that you end up with just "x". Here's what it looks like:
Determine algebraically whether f (x) = 3x – 2 and g(x) = (x + 2)/3 are
inverses of each other
I will plug the formula for g(x) into every instance of "x" in the formula
for f (x):
Now I will plug the formula for f (x) into every instance of "x" in the formula
for g(x) :
Both ways, I ended up with just "x", so f (x) and g(x) are inverses of
each other.
100
Determine algebraically whether f (x) = 3x – 2 and g(x) = (1/3)x + 2 are
inverses of each other.
I'll plug the formula for g(x) into every instance of "x" in the formula
for f (x):
I didn't end up with just "x", so f (x) and g(x) are not inverses of each other.
Once you've found one composition that doesn't work, you're done. You
don't have to show that the composition doesn't work the other way, either. A
close examination of this last example above points out something that can
cause problems for some students.
Since the inverse "undoes" whatever the original function did to x, the
instinct is to create an "inverse" by applying reverse operations. In this case,
since f (x) multiplied x by 3 and then subtracted 2 from the result, the instinct is
to think that the inverse would be to divide x by 3 and then to add 2 to the
result. But as you saw above, this is not correct.
Comparing this example with the previous example, you can see that
the reversed operations were correct, but that they also need to be applied in
reverse order. That is, since f (x) first multiplied x by 3 and then subtracted
off 2, the inverse first adds the 2 back on, and then divides the 3 back off.
Also, in the second example, as soon as I did not end up with "x", I
knew the functions were not inverses. I had done the composition (f o g)(x) and
had come up with something other than "x", so I didn't bother
checking (g o f )(x). In the first example, however, I checked (f o g)(x) and
came up with "x", and then I also checked (g o f )(x), too. Why? Here's an
example of why:
Determine algebraically whether f (x) = x2, and are
inverses of each other.
First, I'll plug g(x) into f (x):
101
Since I started by plugging x into g(x), then I started with non-
negative x-values. Since the absolute value of zero is zero and the absolute
value of a positive number is just itself, then, in this case, I can simplify | x | as
just "x". Then I have ( f o g)(x) = x.
Where did the absolute-value bars come from? The square root of
something squared is the technical definition of the absolute value: the square
of the value will always be positive, as will the square root, so taking the square
root of something squared always returns the positive of the original number. In
this case, the domain of g(x) was defined as non-negative, so the absolute-value
bars could be dropped above. But this isn't always the case:
Looking good so far. Now I'll plug f (x) into g(x):
Since I started by plugging x into f (x), then I was starting with any
value of x. In particular, the value of x might have been negative. Since I don't
know if x is negative or positive, then I can't remove the absolute-value bars on
the final answer, and I'm stuck with an answer of “(g o f)(x) = | x |”. So (g o f
)(x) does not simplify to x.
The answer is: g(x) and f (x) are not inverses of each other.
This is why you need to check both ways: sometimes there are fussy
technical considerations, usually involving square roots that force the
composition not to work, because the domains and ranges of the two functions
aren't compatible. In this case, if f (x) had been restricted to non-negative x,
then the functions would have been inverses. In general, though, if one
composition gives you just "x", then the other one will, too, especially if you're
not dealing with restricted domains. But you should remember to do both
compositions on tests and such, in order to get full credit.
Binary and n-array operations:
In programming, a series of objects all of which are the same size and
type. Each object in an array is called an array element. For example, you
could have an array of integers or an array of characters or an array of anything
that has a defined data type.
The important characteristics of an array are:
Each element has the same data type (although they may have different
values).
102
The entire array is stored contiguously in memory (that is, there are no
gaps between elements).
Arrays can have more than one dimension. A one-dimensional array is
called a vector ; a two-dimensional array is called a matrix.
Declaring an array:
The general syntax for an array declaration is:
<component type><variable identifier>[<integer value>];
For example, suppose we are writing a program to manipulate data
concerning the number of hours a group of 6 employees have worked in a
particular week. We might start the program with the array declaration:
int hours[6]; or better,
Constants NO_OF_EMPLOYEES = 6;
int hours[NO_OF_EMPLOYEES];
Indeed, if we are going to use a number of such arrays in our program, we can
even use a type definition:
Constants NO_OF_EMPLOYEES = 6;
typedefintHours_array[NO_OF_EMPLOYEES];
Hours_array hours;
Hours_arrayhours_week_two;
In each case, we end up with 6 variables of type "int" with identifiers
hours[0] hours[1] hours[2] hours[3] hours[4] hours[5]
Each of these is referred to as an element or component of the array.
The numbers 0, ..., 5 are the indexes or subscripts of the components. An
important feature of these 6 variables is that they are allocated consecutive
memory locations in the computer. We can picture this as:
103
hours[5] = hours[4]/2;
And use them in logical expressions, e.g.
if (number < 4 && hours[number] >= 40) { ...
A common way to assign values to an array is using a "for" or "while"
loop. The following program prompts the user for the number of hours that
each employee has worked. It is more natural to number employees from 1 to 6
than from 0 to 5, but it is important to remember that array indexes always start
from 0. Hence the program subtracts 1 from each employee number to obtain
the corresponding array index.
#include <iostream>
using namespace std;
constants NO_OF_EMPLOYEES = 6;
typedefintHours_array[NO_OF_EMPLOYEES];
int main()
{
Hours_array hours;
int count;
for (count = 1 ; count <= NO_OF_EMPLOYEES ; count++)
{
cout<< "Enter hours for employee number " << count << ":";
cin>> hours[count - 1];
}
return 0;
}
A range bound error:
In other words, C++ would have simply put the value "37" into the next
integer-sized chunk of memory located after the memory block set aside for the
array "hours". This is a very undesirable situation - the compiler might have
already reserved this chunk of memory for another variable (perhaps, for
example, for the variable "count").
Array elements can be of data types other than "int". Here's a program
that prints itself out backwards on the screen, using an array of type "char".
#include <iostream>
#include <fstream>
Using namespace std;
104
Constants MAX = 1000;
typedef char File array[MAX];
int main()
{
char character;
File array file;
int count;
ifstreamin_stream;
in_stream.open("6-1-2.cpp");
in_stream.get(character);
for (count = 0 ; ! in_stream.eof() && count < MAX ; count++)
{
file[count] = character;
in_stream.get(character);
}
in_stream.close ();
While (count > 0)
cout<< file[--count];
Return 0;
}
Arrays As Parameters In Functions
Functions can be used with array parameters to maintain a structured
design. Here is a definition of an example function which returns the average
hours worked, given an array of type "Hours array"
float average(Hours array hrs)
{
float total = 0;
int count;
for (count = 0 ; count < NO_OF_EMPLOYEES ; count++)
total += float(hrs[count]);
return (total / NO_OF_EMPLOYEES);
}
105
Sorting arrays:
Arrays often need to be sorted in either ascending or descending order.
There are many well known methods for doing this; the quick sort algorithm is
among the most efficient. This section briefly describes one of the easiest
sorting methods called the selection sort.
The basic idea of selection sort is:
For each index position I in turn:
Find the smallest data value in the array from positions I to (Length - 1),
where "Length" is the number of data values stored. Exchange the smallest
value with the value at position I.
To see how selection works, consider an array of five integer values,
declared as int a[5]; and initially in the state:
Figure
Selection sort takes the array through the following sequence of states:
Two-Dimensional Arrays
Arrays can have more than one dimension. In this section we briefly
examine the use of two-dimensional arrays to represent two-dimensional
structures such as screen bitmaps or nxm matrices of integers.
A bitmap consists of a grid of Boolean values representing the state of
the dots or pixels on a screen. "True" means "on" or that the pixel is white;
"False" means "off" or the pixel is black. Let's suppose the screen is 639 pixels
wide and 449 pixels high. We can declare the corresponding array as follows:
enum Logical {False, True};
Constint SCREEN_HEIGHT = 449;
Constint SCREEN_WIDTH = 639;
Logical screen [SCREEN_HEIGHT][SCREEN_WIDTH];
106
References to individual data elements within the array "screen" simply
use two index values. For example, the following statement assigns the value
"True" to the cell (pixel) in row 4, column 2 of the array.
screen[3][1] = True;
All of the discussion in Section 6.2 about one-dimensional arrays as
parameters in functions also applies to two-dimensional arrays, but with one
additional peculiarity. In function declarations and in the heads of function
definitions, the size of the first dimension of a multidimensional array
parameter is not given (inside the "[]" brackets), but the sizes of all the other
dimensions are given. Hence, for example, the following is a correct form for a
function which sets all the screen pixels to black:
voidclear_bitmap(Logical bitmap[][SCREEN_WIDTH], intscreen_height)
{
for (int row = 0 ; row <screen height ; row++)
for (int column = 0 ; column < SCREEN_WIDTH; column++)
bitmap[row][column] = False;
}
3.5 HASHING FUNCTIONS
A hash function maps keys to small integers (buckets). An ideal hash
function maps the keys to the integers in a random-like manner, so that bucket
values are evenly distributed even if there are regularities in the input data.
This process can be divided into two steps:
Map the key to an integer.
Map the integer to a bucket.
Taking things that really aren't like integers (e.g. complex record
structures) and mapping them to integers is icky. We won't discuss this.
Instead, we will assume that our keys are either integers, things that can be
treated as integers (e.g. characters, pointers) or 1D sequences of such things
(lists of integers, strings of characters).The following functions map a single
integer key (k) to a small integer bucket value h(k). m is the size of the hash
table (number of buckets).
Division method (Cormen) Choose a prime that isn't close to a power of 2.
h(k) = k mod m. Works badly for many types of patterns in the input data.
Knuth Variant on Division h(k) = k(k+3) mod m. Supposedly works
much better than the raw division method.
107
Multiplication Method (Cormen). Choose m to be a power of 2. Let A
be some random-looking real number. Knuth suggests M = 0.5*(sqrt(5) - 1).
Then do the following:
s = k*A
x = fractional part of s
h(k) = floor(m*x)
This seems to be the method that the theoreticians like.
To do this quickly with integer arithmetic, let w be the number of bits in a word
(e.g. 32) and suppose m is 2^p. Then compute:
s = floor(A * 2^w)
x = k*s
h(k) = x >> (w-p) // i.e. right shift x by (w-p) bits
// i.e. extract the p most significant
// bits from x
Types of Hashing Functions
1) NIST hash function competition
2) Bernstein hash
3) Fowler-Noll-Vo hash function (32, 64, 128, 256, 512, or 1024 bits)
4) Jenkins hash function (32 bits)
5) Pearson hashing (64 bits)
6) Zobrist hashing
7) Almost linear hash function
Pearson Hashing
Pearson hashing is a hash function designed for fast execution on
processors with 8-bit registers, Given an input consisting of any number of
bytes, it produces as output a single byte that is strongly dependent on every
byte of the input. Its implementation requires only a few instructions, plus a
256-byte lookup table containing a permutation of the values 0 through 255.
This hash function is a CBC-MAC that uses an 8-bit substitution
cipher implemented via the substitution table. An 8-bit cipher has negligible
cryptographic security, so the Pearson hash function is not cryptographically
strong; but it offers these benefits:
It is extremely simple. It executes quickly on resource-limited processors.
There is no simple class of inputs for which collisions (identical
outputs) are especially likely.
108
Given a small, privileged set of inputs (e.g., reserved words for
a compiler), the permutation table can be adjusted so that those inputs yield
distinct hash values, producing what is called a perfect hash function.
One of its drawbacks when compared with other hashing algorithms
designed for 8-bit processors is the suggested 256 byte lookup table, which can
be prohibitively large for a small microcontroller with a program memory size
on the order of hundreds of bytes. A workaround to this is to use a simple
permutation function instead of a table stored in program memory. However,
using a too simple function, such as T[i] = 255-i partly defeats the usability as a
hash function as anagrams will result in the same hash value; using a too
complex function, on the other hand, will affect speed negatively.
The algorithm can be described by the following pseudo code, which
computes the hash of message C using the permutation table T:
h := 0
for each c in C loop
index := h xor c
h := T[index]
end loop
return h
Zobrist hashing:
Zobrist hashing also referred to as Zobrist keys or Zobrist signatures
is a hash function construction used in computer programs that play abstract
board games, such as chess and Go, to implement transposition tables, a special
kind of hash table that is indexed by a board position and used to avoid
analyzing the same position more than once. Zobrist hashing is named for its
inventor, Albert LindseZobrist. It has also been applied as a method for
recognizing substitution alloy configurations in simulations of crystalline
materials.
Calculus of hash values:
Zobrist hashing starts by randomly generating bit strings for each
possible element of a board game, i.e. for each combination of a piece and a
position (in the game of chess, that's 12 pieces × 64 board positions, or 14 if a
king that may still castle and a pawn that may capture en passant are treated
separately). Now any board configuration can be broken up into independent
piece/position components, which are mapped to the random bitstrings
generated earlier. The final Zobrist hash is computed by combining those
bitstrings using bitwise XOR. Example pseudo code for the game of chess:
109
constant indices
white_pawn := 1
white_rook := 2
# etc.
black king := 12
functioninit_zobrist():
# fill a table of random numbers/bitstrings
table := a 2-d array of size 64×12
fori from 1 to 64: # loop over the board, represented as a linear array
for j from 1 to 12: # loop over the pieces
table[i][j] = random_bitstring()
function hash(board):
h := 0
fori from 1 to 64: # loop over the board positions
if board[i] != empty:
j := the piece at board[i], as listed in the constant indices, above
h := h XOR table[i][j]
return h
Natural numbers:
A natural number is a number that occurs commonly and obviously in
nature. As such, it is a whole, non-negative number. The set of natural
numbers, denoted N, can be defined in either of two ways:
N = {0, 1, 2, 3, ...}
N = (1, 2, 3, 4, ...}
In mathematical equations, unknown or unspecified natural numbers are
represented by lowercase, italicized letters from the middle of the alphabet. The
most common is n, followed by m, p, and q. In subscripts, the lowercase i is
sometimes used to represent a non-specific natural number when denoting the
elements in a sequence or series. However, i is more often used to represent the
positive square root of -1, the unit imaginary number. The set N, whether or not
it includes zero, is a denumerable set. Remunerability refers to the fact that,
even though there might be an infinite number of elements in a set, those
elements can be denoted by a list that implies the identity of every element in
the set. For example, it is intuitive from either the list {1, 2, 3, 4, ...} or the list
{0, 1, 2, 3, ...} that 356,804,251 is a natural number, but 356,804,251.5, 2/3,
and -23 are not. Both of the sets of natural numbers defined above are
110
denumerable. They are also exactly the same size. It's not difficult to prove this;
their elements can be paired off one-to-one, with no elements being left out of
either set. In infinite sets, the existence of a one-to-one correspondence is the
litmus test for determining cardinality, or size. The set of integers and the set of
rational numbers has the same cardinality as N. However, the sets of real
numbers, imaginary numbers, and complex numbers have cardinality larger
than that of N.
set name symbol
..., -2, -1, 0, 1, 0, 1, 2, ... integers Z
1, 2, 3, 4, ... positive integers Z-+
0, 1, 2, 3, 4, ... nonnegative integers Z-*
0, -1, -2, -3, -4, … non-positive integers Z-
-1, -2, -3, -4, … negative integers Z--
ADDITION:
One can recursively define an addition on the natural numbers by
setting a + 0 = a and a + S(b) = S(a + b) for all a, b. Here S should be read as
"successor". This turns the natural numbers (N, +) into a commutative monoid
with identity element 0, the so-called free object with one generator. This
monoid satisfies the cancellation property and can be embedded in a group (in
the mathematical sense of the word group). The smallest group containing the
natural numbers is the integers.
If 1 is defined as S(0), then b + 1 = b + S(0) = S(b + 0) = S(b). That
is, b + 1 is simply the successor of b.
MULTIPLICATION:
Analogously, given that addition has been defined, a multiplication ×
can be defined via a × 0 = 0 and a × s(b) = (a × b) + a. this turns (n*, ×) into a
free commutative monoid with identity element 1; a generator set for this
monoid is the set of prime numbers.
Relationship between addition and multiplication
Addition and multiplication are compatible, which is expressed in
the distribution law: a × (b + c) = (a × b) + (a × c). These properties of addition
and multiplication make the natural numbers an instance of a commutative
semiring. Semirings are an algebraic generalization of the natural numbers
where multiplication is not necessarily commutative. The lack of additive
inverses, which is equivalent to the fact that N is not closed under subtraction,
means that N is not a ring; instead it is a semiring (also known as a rig).
111
If the natural numbers are taken as "excluding 0", and "starting at 1",
the definitions of + and × are as above, except that they begin with a + 1
= S(a) and a × 1 = a.
Order
In this section, juxtaposed variables such as ab indicate the
product a × b, and the standard order of operations is assumed.
A total order on the natural numbers is defined by letting a ≤ b if and
only if there exists another natural number c with a + c = b. This order is
compatible with the arithmetical in the following sense: if a, b and c are natural
numbers and a ≤ b, then a + c ≤ b + c and ac ≤ bc. An important property of the
natural numbers is that they are well-ordered: every non-empty set of natural
numbers has a least element. The rank among well-ordered sets is expressed by
an ordinal number; for the natural numbers this is expressed as ω.
DIVISION:
In this section, juxtaposed variables such as ab indicate the
product a × b, and the standard order of operations is assumed.
While it is in general not possible to divide one natural number by
another and get a natural number as result, the procedure of division with
remainder is available as a substitute: for any two natural numbers
a and b with b ≠ 0 there are natural numbers q and r such that
a = bq + r and r < b.
The number q is called the quotient and r is called the remainder of
division of a by b. The numbers q and r are uniquely determined by a and b.
This Euclidean division is key to several other properties (divisibility,
algorithms (such as the Euclidean algorithm), and ideas in number theory.
3.6 PEANO AXIONSAND MATHEMATICAL INDUCTION
CARDINALITY:
In mathematical logic, the Peano axioms, also known as
the Dedekind–Peano axioms or the Peano postulates, are a set of axioms for
the natural numbers presented by the 19th century Italian mathematician
Giuseppe Peano. These axioms have been used nearly unchanged in a number
of met mathematical investigations, including research into fundamental
questions of whether number theory is consistent and complete.
The need to formalize arithmetic was not well appreciated until the
work of Hermann Grossmann, who showed in the 1860s that many facts in
arithmetic could be derived from more basic facts about the successor
operation and induction. In 1881, Charles Sanders Peirce provided
an axiomatization of natural-number arithmetic. In 1888, Richard Dedekind
112
proposed another axiomatization of natural-number arithmetic, and in 1889
Peano published a more precisely formulated version of them as a collection of
axioms in his book, The principles of arithmetic presented by a new method
The Peano axioms contain three types of statements. The first axiom
asserts the existence of at least one member of the set "number". The next four
are general statements about equality; in modern treatments these are often not
taken as part of the Peano axioms, but rather as axioms of the "underlying
logic". The next three axioms are first-order statements about natural numbers
expressing the fundamental properties of the successor operation. The ninth,
final axiom is a second order statement of the principle of mathematical
induction over the natural numbers. A weaker first-order system called Peano
arithmetic is obtained by explicitly adding the addition and multiplication
operation symbols and replacing the second-order induction axiom with a first-
order axiom schema.
ARITHMETIC:
The Peano axioms can be augmented with the predations
of addition and multiplication and the usual total (linear) ordering on N. The
respective functions and relations are constructed in second-order logic, and are
shown to be unique using the Peano axioms.
ADDITION:
Addition is a function that maps two natural numbers (two elements
of N) to another one. It is defined recursively as:
a0 a
a S (b) S (a b)
For example,
a + 1 = a + S(0) = S(a + 0) = S(a).
The structure (N, +) is a commutative semi group with identity element
0. (N, +) is also a calculative magma, and thus embeddable in a group. The
smallest group embedding N is the integers.
MULTIPLICATION:
Similarly, multiplication is a function mapping two natural numbers to
another one. Given addition, it is defined recursively as:
a.0 0,
a.s(b) a (a.b)
It is easy to see that setting b equal to 0 yields the
multiplicative identity:
a · 1 = a · S(0) = a + (a · 0) = a + 0 = a
113
Moreover, multiplication distributes over addition:
a · (b + c) = (a · b) + (a · c).
Thus, (N, +, 0, ·, 1) is a commutative semiring.
INEQUALITIES:
The usual total order relation ≤ on natural numbers can be defined as
follows, assuming 0 is a natural number:
For all a, b ∈ N, a ≤ b if and only if there exists some c ∈ N such that a + c = b.
This relation is stable under addition and multiplication: for, a, b, c N
if a ≤ b, then:
a + c ≤ b + c, and
a · c ≤ b · c.
Thus, the structure (N, +, ·, 1, 0, ≤) is an ordered semiring; because
there is no natural number between 0 and 1, it is a discrete ordered semiring.
The axiom of induction is sometimes stated in the
following strong form, making use of the ≤ order:
For any predicate φ, if
φ(0) is true, and
for every n, k ∈ N, if k ≤ n implies φ(k) is true, then φ(S(n)) is true, then for
every n ∈ N, φ(n) is true. This form of the induction axiom is a simple
consequence of the standard formulation, but is often better suited for reasoning
about the ≤ order. For example, to show that the naturals are well-ordered—
every nonempty subset of N has a least element—one can reason as follows.
Let a nonempty X ⊆ N be given and assume X has no least element.
Because 0 is the least element of N, it must be that 0 ∈ X.
For any n ∈ N, suppose for every k ≤ n, k ∉ X. Then S(n) ∉ X, for
otherwise it would be the least element of X. Thus, by the strong induction
principle, for every n ∈ N, n ∉ X. Thus, X ∩ N = ∅, which contradicts X being a
nonempty subset of N. Thus X has a least element.
Exercises:
1. Given an example of a relation which is either reflexive nor reflexive.
2. Given an example of a relation which is both symmetric and ant symmetric.
3. If relation R and S are both reflexive, show that R S and R S are also
reflexive.
4. If relations R and S are reflexive, symmetric, and transitive, show that
R S is also reflexive, symmetric and transitive.
114
5. Show whether the following relations are transitive’s:
R1 1 1 R2 1,1 , 2, 2
R3 1, 2 , 2,3 , 1,3 , 2,1
115
NOTES
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
116
UNIT - IV
In this chapter:
Lattices and Boolean algebra lattices and partially ordered sets
Lattices of algebra system
Definition and example
Some properties of lattices
Lattices of algebra system-sub lattices
Direct product and homomorphism
Boolean function
Boolean forms and free Boolean algebra
Values of Boolean expression and Boolean function.
4.1 LATTICE AND BOOLEAN ALGEBRA LATTICES AND
PARTIALLY ORDERED SETS
Partially ordered set (poset), and S⊆L is an arbitrary subset, then an
element u∈L is said to be an upper bound of S if s≤u for each s∈S. A set
may have many upper bounds, or none at all. An upper bound u of S is said to
be its least upper bound, or join, or supermom, if u≤x for each upper
bound x of S. A set need not have a least upper bound, but it cannot have more
than one. Dually, l∈L is said to be a lower bound of S if l≤s for each s∈S. A
lower bound l of S is said to be its greatest lower bound, or meet, or infimum,
if x≤l for each lower bound x of S. A set may have many lower bounds or none
at all, but can have at most one greatest lower bound.
A partially ordered set (L, ≤) is called a join-semi lattice and a meet-
semi lattice if each two-element subset {a,b} ⊆ L has a join (i.e. least upper
bound) and a meet (i.e. greatest lower bound), denoted by a∨b and a∧b,
respectively. (L, ≤) is called a lattice if it is both a join- and a meet-semi lattice.
This definition makes ∨ and ∧ binary operations. Both operations are monotone
with respect to the order: a1 ≤ a2 and b1 ≤ b2implies that a1∨ b1 ≤ a2 ∨ b2 and
a1∧b1 ≤ a2∧b2.
It follows by an induction argument that every non-empty finite subset
of a lattice has a join and a meet. With additional assumptions, further
conclusions may be possible; see Completeness (order theory) for more
discussion of this subject. That article also discusses how one may rephrase the
above definition in terms of the existence of suitable Galois
connections between related partially ordered sets — an approach of special
interest for the category theoretic approach to lattices.
117
A bounded lattice is a lattice that additionally has a greatest element 1
and a least element 0, which satisfy
0≤x≤1 for every x in L.
The greatest and least element is also called the maximum and
minimum, or the top and bottom element, and denoted by ⊤ and ⊥,
respectively. Every lattice can be converted into a bounded lattice by adding an
artificial greatest and least element, and every non-empty finite lattice is
bounded, by taking the join (resp., meet) of all elements, denoted by
a1 an (resp.)∨L= a1 …..... an Where,
L a1...............an
A partially ordered set is a bounded lattice if and only if every finite set
of elements (including the empty set) has a join and a meet. For every
element x of a poset it is trivially true (it is a vacuous truth)
that a : a and , a : a x and therefore every element of a
poset is both an upper bound and a lower bound of the empty set. This implies
that the join of an empty set is the least element 0 , and the meet of the
empty set is the greatest element. ∨ 1This is consistent with the
associatively and commutatively of meet and join: the join of a union of finite
sets is equal to the join of the joins of the sets, and dually, the meet of a union
of finite sets is equal to the meet of the meets of the sets, i.e., for finite
subsets A and B of a poset L,
( A B ) ( A) ( B )
and
( A B ) ( A) ( B )
and
( A ) ( A) ( ) ( A) 1 A
118
(so r(x)<r(y) whenever x<y) such that whenever y covers x, then r(y)=r(x)+1.
The value of the rank function for a lattice element is called its rank.
Given a subset of a lattice, H L , meet and join restrict to partial
functions – they are undefined if their value is not in the subset H. The resulting
structure on H is called a partial lattice. In addition to this extrinsic definition as
a subset of some other algebraic structure (a lattice), a partial lattice can also
be intrinsically defined as a set with two partial binary operations satisfying
certain axioms.
EXAMPLE:
Let H denote the set of all subgroups of a given group. Then the
subgroup relation ≤ is a partial ordering on H, whence (H, ≤) is a poset. One
way to illustrate a poset X graphically (at least when it is finite), is by means of
a so-called Hasse diagram. A Hasse diagram is a graph, in which the nodes
represent the different elements of X. If x ≺ y, and if there is no z ∈ X such that
x ∈ z ∈ y, we draw an edge in the graph between the nodes that represent x and
y.
Since x ∈ y, x is the smaller of the two elements x and y, we will place
the node that represents y higher up in the diagram, than the node that
represents x. A Hasse diagram for the poset (P({1, 2, 3}), ⊆) is shown in Figure
2.1. {1, 2, 3} {1, 2} {1, 3} {2, 3} {1} {2} {3} ∅ Figure 2.1 Conversely we can
use a Hasse diagram to define a partially ordering on a finite set X.
From the diagram it will easily be seen if the relation x ∈ y holds for
two given elements x, y ∈ X. This is the case, if and only if it is possible to
travel from the node that represents x to the node that represents y, only by
moving upwards in the diagram.
4.1.1 Lattices of Algebra System:
A lattice L is said to be an algebraic lattice if it is a complete
lattice and every element of L can be written as a join of compact elements.
As the name (G. Birkhoff originally coined the term) suggests, algebraic
lattices are mostly found in lattices of sub algebras of algebraic systems. Below
are some common examples.
Examples.
1. Groups. The lattice L(G) of subgroups of a group G is known to
be complete. Cyclic are compact elements of L(G). Since every
subgroup H of G is the join of cyclic subgroups, each generated by an
element h∈H, L(G) is algebraic.
119
2. Vector spaces. The lattice L(V) of subspaces of a vector space V is
complete. Since each subspace has a basis, and since each element generates a
one-dimensional subspace which is clearly compact, L(V) is algebraic.
3. Rings. The lattice L(R) of ideals of a ring R is also complete, the join
of a set of ideals of R is the ideal generated by elements in each of the ideals in
the set. Any ideal I is the join of cyclic ideals generated by elements r∈I.
So L(R) is algebraic.
4. Modules. The above two examples can be combined and generalized
into one, the lattice L(M) of sub modules of a module M over a ring.
The arguments are similar.
Topological spaces: The lattice of closed subsets of a topological space
is in general not algebraic. The simplest example is R with the open
intervals forming the sub basis. To begin with, it is not complete: the union of
closed subsets [0,1−1n], n∈N is [0,1], not a closed set. In addition, R itself is a
closed subset that is not compact.
Remarks:
Since every element in an algebraic lattice is a join of compact
elements, it is easy to see that every atom is compact: for if a is an atom in an
algebraic lattice L, and a⊆S, where S⊆L is a set of compact elements s∈L, then
each s is either 0 or a. Therefore, S consists of at most two elements 0 and a.
But S can’t be a singleton consisting of 0 (otherwise S=0≠a), so a∈S and
therefore a is compact.
The notion of being algebraic in a lattice can be generalized to an
arbitrary dcpo: an algebraic is a dcpo D such that every a∈D can be written
as a⊆C, where C is a directed set (in D) such that each element in C is compact.
4.2 SUB LATTICES:
In this section, we define a sub-lattice of a lattice, lattice
homomorphisms and lattice isomorphisms.
Definition: Let ( L,,) be a lattice and A L . Then ( A,,) is a
sublattice of ( L,,) if A is closed under and .
Note: A sublattice itself is a lattice under the same binary operations. If
A L and A is a lattice under some other pair of binary operations on A, then
it need not be a sublattice of L.
Example1
Consider the L –lattice Powon the carrier ({a,b,c}) with
operations and defined as set-theoretic intersection and union. We
represent Powby means of the following
120
Hasse diagram:
Figure4.2
The L -lattice Pow2 on the carrier ({a,b}) with operations and
defined asset-theoretic intersection and union is a sub lattice of Pow. We
represent Pow2 by means of the following Hasse diagram:
Figure 4.3
Pow2 is sub algebra of Pow, because
1. ({a,b}) = { , {a}, {b}, {a,b}} is a subset of ({a,b,c}) = { , {a},
{b}, {c},{a,b},
{b,c}, {a,c}, {a,b,c}}
2. ({a,b}) is closed with respect to intersection and union.
121
3. Intersection and union as defined in Pow restricted to ({a,b}) equal
intersection and union as defined inPow2.
Example2
Consider the L -lattice L on the carrier Three = {1,2,3}. We define
the operations in L
as follows:
( ) x, y, z Three [ x y = inf{x, y}]
( ) x, y, z Three [ x y = sup{x, y}]
We represent L by means of the following Hassel diagram:
3
1
Then the L -lattice L2 on the carrier Two= {1, 2} and an operation defined
as above is a sublattice of L, since:
Two Three
Two is closed under L and L
L Two = L2 and L Two = L2
We could define the notion of sublattice in order theoretic terms, as
follows:
Def. For any posets P1 = <P, < > and P2 = <P’, < > ,if P1 is a lattice P2 is a
sublattice of P1 iff P’ P and P1 is a lattice.
But then, the notions of sub lattice asasubalge brand asapo sets are not
equivalent. Consider the poset Pow3 = <{{a, b, c}, {a}, {b} }, <}. Pow3 is a
lattice as a po set, but it is not a sub algebra of Pow, since in Pow{a} [b}
={a,b}.
PROPOSITION 1. For each s c L, (s] is a standard sublattice of L.
Proof.[s ]in K 8 implies .sc K, yielding ( (s}, K) —— K, I [s ] I K, and Iv
(s) I v K. Thus, in (2) and (3) both the left and the right hand sides of the
equations are I » A and I v K, respectively.
Now, we are going to prove that we have indeed a generalization. To do this we
need the following
LEMMA l . For the convex sublattices A and B of the lattice L the equalities
122
hold, add here (X) denotes the ideal generated bYX.
Proof. A_
<(A) implies, obviously, both A (B)_
<(A)r(B) and(A(B) <
((A),(B))——(A)v(B).
xc(A) r (B)implies xe(ft) and xc(B),for (A)(B)——(A) in (B). Since the
ideal (A) consists of all elements of A having an upper bound in A we have
x fio for some acA. Hence x = a :xcA (B).
Let. xz(A),i.e.,x_<a for some azA, and ye(B].Then we have ,using the
convexity of (fi, (B), by y < x vj' n v y that x v y z (A,(B)). Thus, (A) v
(B] , the smallest convex sublattice containing all x v y(x z (A),y e (B)), is
contained in (A,(B]).
PROPOS ITION 2. An ideal S of a lattice€ 1JSl£II1dard if and out y
if it is a standard .iubfaiiicr.
Proof. Let us assume, first, that the ideal 5 is a standard sub lattice of L.
Then the ideals I and Kare, of course, convex sub lattices.Moreover5inK
9andIn(S,K)ZB are, clearly, satisfied. Thus we have by (2) and(3)
123
From External Direct Product of Groups is Group, the group direct
product H1×H2 is a group.
It remains to be shown that f1×f2 fulfils the morphism property.
Let g,h∈G.
Then:
= (f1×f2)(g h)
124
addition and multiplication, the main operations of Boolean algebra are
the conjunction and, denoted ∧, the disjunction or, denoted ∨, and
the negation not, denoted ¬. It is thus formalism for describing logical relations
in the same way that ordinary algebra describes numeric relations.
Boolean algebra was introduced by George Boole in his first book The
Mathematical Analysis of Logic (1847), and set forth more fully in his An
Investigation of the Laws of Thought (1854). According to Huntington the term
"Boolean algebra" was first suggested by Shaffer in 1913.
Boolean algebra has been fundamental in the development of digital
electronics, and is provided for in all modern programming languages. It is also
used in set theory and statistics.
A Boolean algebra is a mathematical structure that is similar to
a Boolean ring, but that is defined using the meet and join operators instead of
the usual addition and multiplication operators. Explicitly, a Boolean algebra is
the partial order on subsets defined by inclusion (Skiena 1990, p. 207), i.e., the
Boolean algebra b(A) of a set A is the set of subsets of A that can be obtained
by means of a finite number of the set operations union (OR), intersection
(AND), and complementation (NOT) (Comet 1974, p. 185). A Boolean algebra
also forms a lattice (Skiena 1990, p. 170), and each of the elements of b(A) is
2n
called a Boolean function. There are 2 Boolean functions in a Boolean
algebra of order n (Comet 1974, p. 186).
In 1938, Shannon proved that a two-valued Boolean algebra (whose
members are most commonly denoted 0 and 1, or false and true) can describe
the operation of two-valued electrical switching circuits. In modern times,
Boolean algebra and Boolean functions are therefore indispensable in the
design of computer chips and integrated circuits.
Figure: 4.3
Boolean algebras have a recursive structure apparent in the Hasse
diagrams illustrated above for Boolean algebras of orders n = 2, 3, 4, and 5.
These figures illustrate the partition between left and right halves of the lattice,
each of which is the Boolean algebra on n-1elements (Skiena 1990, pp. 169-
125
170). The Hasse diagram figure 4.3 for the Boolean algebra of order n is
implemented as Boolean Algebra[n] in the Wolfram Language package
Combinatorial. It is isomorphic to the n-hypercube graph.
A Boolean algebra can be formally defined as a set B of elements a, b,
... with the following properties:
1. B has two binary operations, (logical AND, or "wedge") and
(logical OR, or "vee"), which satisfy the idempotent laws
aa aa a
The commutative laws
ab ba
a b b a
and the associative laws
a (b c ) ( a b) c
a ( b c ) ( a b ) c
B Contains universal bounds (the empty set) and I (the universal set)
which satisfy
a
a a
I a a
I a I
'
B has a unary operation a a of complementation, which obeys the laws
'
aa
a a ' 1
126
1b. If a and b are in the set B , then a b is in the set B.
2a. There is an element Z (zero) such that a Z a for every element a .
2b. There is an element U (unity) such that a U a for every element a .
3a. . a b b a
3b. . a b b a
4a. . a b c ( a b) ( a c )
4b. . a (b c) ( a b) ( a c)
' '
5. For every element there is an element a such that a a U
'
and a a z
6. There are at least two distinct elements in the set B.
Huntington (1933ab) presented the following basis for Boolean algebra:
1. Commutatively: . x y yx
2. Associatively: . ( x y ) z x ( y z )
3. Huntington axiom: . ! (! ( x y )! ( x ! y )) x
H. Robbins then conjectured that the Huntington axiom could be replaced with
the simpler Robbins axiom,
! (! ( x y ) ! ( x ! y )) x
127
EXAMPLES:
We have seen throughout this section that digital logic functions can be
defined and displayed as either a Boolean Algebra expression or as a logic gate
truth table. So here are a few examples of how we can use Boolean Algebra to
simplify larger digital logic circuits.
Boolean Algebra Example No1
Construct a Truth Table for the logical functions at points C, D and Q in
the following circuit and identify a single logic gate that can be used to replace
the whole circuit.
Figure: 4.4.1
First observations tell us that the circuit consists of a 2-
input NAND gate, a 2-input EX-OR gate and finally a 2-input EX-NOR gate at
the output. As there are only 2 inputs to the circuit labelled A and B, there can
only be 4 possible combinations of the input ( 22 ) and these are: 0-0, 0-1, 1-
0 and finally1-1. Plotting the logical functions from each gate in tabular form
will give us the following truth table for the whole of the logic circuit below.
Table: 4.4.1
Inputs Output at
A B
0 0
0 1
1 0
1 1
From the truth table above, column C represents the output function
generated by the NAND gate, while column D represents the output function
from the Ex-OR gate. Both of these two output expressions then become the
input condition for the Ex-NOR gate at the output.
It can be seen from the truth table that an output at Q is present when
any of the two inputs A or Bare at logic 1. The only truth table that satisfies this
condition is that of an OR Gate. Therefore, the whole of the above circuit can
be replaced by just one single 2-input OR Gate.
Boolean Algebra Example No2
128
Find the Boolean algebra expression for the following system.
Figure 4.4.1
The system consists of an AND Gate, a NOR Gate and finally
an OR Gate. The expression for theAND gate is A.B, and the expression for
the NOR gate is A+B. Both these expressions are also separate inputs to
the OR gate which is defined as A+B. Thus the final output expression is given
as:
Figure 4.4.2
The output of the system is given as Q = (A.B) + (A+B), but the
notation A+B is the same as the De Morgan´s notation A.B, Then
substituting A.B into the output expression gives us a final output notation of Q
= (A.B)+(A.B), which is the Boolean notation for an Exclusive-NOR Gate as
seen in the previous section.
Table: 4.4.2
Inputs Intermediates Output
B A A.B A+B Q
0 0 0 1 1
0 1 0 0 0
1 0 0 0 0
1 1 1 0 1
129
Then, the whole circuit above can be replaced by just one single Exclusive-
NOR Gate and indeed an Exclusive-NOR Gate is made up of these individual
gate functions.
Boolean Algebra Example No.3
Find the Boolean algebra expression for the following system.
Figure 4.4.3
This system may look more complicated than the other two to analyze
but again, the logic circuit just consists of simple AND, OR and NOT gates
connected together.
As with the previous Boolean examples, we can simplify the circuit by
writing down the Boolean notation for each logic gate function in turn in order
to give us a final expression for the output at Q.
Figure: 4.4.4
The output from the 3-input AND gate is only at logic “1”
when ALL the gates inputs are HIGH at logic level “1” (A.B.C). The output
from the lower OR gate is only a “1” when one or both inputs B orC are at
logic level “0”. The output from the 2-input AND gate is a “1” when input A is
a “1” and inputs B or C are at “0”. Then the output at Q is only a “1” when
inputs A.B.C equal “1” or A is equal to “1” and both inputs B or C equal
“0”, A.(B+C). By using “de Morgan’s theorem” inputs B and input C cancel
out as to produce an output at Q they can be either at logic “1” or at logic “0”.
130
Then this just leaves input A as the only input needed to give an output at Q as
shown in the table below.
Table:4.4.2
Inputs Intermediates Output
0 0 0 0 1 1 1 0 0
0 0 1 0 1 1 1 1 1
0 1 0 0 0 1 1 0 0
0 1 1 0 0 1 1 1 1
1 0 0 0 1 0 1 0 0
1 0 1 0 1 0 1 1 1
1 1 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 1
Then we can see that the entire logic circuit above can be replaced by
just one single input labeled A thereby reducing a circuit of six individual logic
gates to just one single piece of wire, (or Buffer). This type of circuit analysis
using Boolean Algebra can be very powerful and quickly identify any
unnecessary logic gates within a digital logic design thereby reducing the
number of gates required, the power consumption of the circuit and of course
the cost.
SUB ALGEBRA:
In mathematics, sub algebra is a subset of algebra, closed under all its
operations, and carrying the induced operations.
"Algebra", when referring to a structure, often means a vector
space or module equipped with an additional bilinear operation. Algebras
in universal algebra are far more general: they are a common generalization
of all algebraic structures. Sub algebra can be a subset of both cases.
A sub algebra of an algebra over a commutative ring or field is a vector
subspace which is closed under the multiplication of vectors. The restriction of
the algebra multiplication makes it algebra over the same ring or field.
131
This notion also applies to most specializations, where the
multiplication must satisfy additional properties, e.g. to associative algebras or
to Lie algebras. Only for until algebras is there a stronger notion, of unital
subalgebra, for which it is also required that the unit of the subalgebra be the
unit of the bigger algebra.
EXAMPLE:
The 2×2-matrices over the reals form a unital algebra in the obvious
way. The 2×2-matrices for which all entries are zero, except for the first one on
the diagonal, form a subalgebra. It is also unital, but it is not a unital
subalgebra.
In universal algebra, a subalgebra of an algebra A is a subset S of A that
also has the structure of an algebra of the same type when the algebraic
operations are restricted to S. If the axioms of a kind of algebraic structure is
described by equational laws, as is typically the case in universal algebra, then
the only thing that needs to be checked is that S is closed under the operations.
Some authors consider algebras with partial functions. There are various
ways of defining sub algebras for these. Another generalization of algebras is to
allow relations. These more general algebras are usually called structures, and
they are studied in model theory and in theoretical computer science. For
structures with relations there are notions of weak and of induced substructures.
Example:
For example, the standard signature for groups in universal algebra is
−1
(×, ,1). (Inversion and unit are needed to get the right notions of
homomorphism and so that the group laws can be expressed as equations.
Therefore a subgroup of a group G is a subset S of G such that:
The identity e of G belongs to S (so that S is closed under the identity
constant operation);
whenever x belongs to S, so does x−1 (so that S is closed under the
inverse operation);
whenever x and y belong to S, so does x * y (so that S is closed under
the group's multiplication operation).
Note:
Let (AR, ) be an algebra over a ring R.
Let BR⊆AR such that:
∀x,y∈BR:x y∈BR
That is, that is closed in BR.
Then BR is subalgebra of AR.
132
Values of boolean expression and boolean function
A Boolean expression is a logical statement that is either TRUE or
FALSE. Boolean expressions can compare data of any type as long as both
parts of the expression have the same basic data type. You can test data to see if
it is equal to, greater than, or less than other data.
A Boolean expression can consist of Boolean data, such as the following:
BOOLEAN values (YES and NO, and their synonyms, ON and OFF,
and TRUE and FALSE)
BOOLEAN variables or formulas
Functions that yield BOOLEAN results
BOOLEAN values calculated by comparison operators
For example, assume that your code contains the following Boolean expression.
actual GT 20000
When processing this expression, Oracle OLAP compares each value of
the variable actual to the constant 20,000. When the value is greater than
20,000, then the statement is TRUE; when the value is less than or equal to
20,000, then the statement is FALSE.
When you are supplying a Boolean value, you can type either YES, ON,
or TRUE for a true value, and NO, OFF, or FALSE for a false value. When the
result of a Boolean calculation is produced, the defaults are YES and NO in the
language specified by the NLS_LANGUAGE option. The read-
only YESSPELL and NOSPELL options record the YES and NO values.
A Boolean expression is a three-part clause that consists of two items to
be compared, separated by a comparison operator. You can create a more
complex Boolean expression by joining any of these three-part expressions
with the AND and OR logical operators. Each expression that is connected
by AND or OR must be a complete Boolean expression in itself, even when it
means specifying the same variable several times.
For example, the following expression is not valid because the second
part is incomplete.
sales GT 50000 AND LE 20000
In the next expression, both parts are complete so the expression is valid.
sales GT 50000 AND sales LE 20000
When you combine several Boolean expressions, the whole expression
must be valid even when the truth value can be determined by the first part of
the expression. The whole expression is compiled before it is evaluated, so
133
when there are undefined variables in the second part of a Boolean expression,
you get an error.
Use the NOT operator, with parentheses around the expression, to
reverse the sense of a Boolean expression.
The following two expressions are equivalent.
district NE 'BOSTON'
NOT(district EQ 'BOSTON')
Exercises:
1. Show that the identities (L-1)and (L-1) follow from the identities (L-2) to
(L-4) and their duals.
2. Complete the proof of theoremby showing that in lattices
a b a b b
3. Show that in lattice if abc then a b bc ,
(a b) (b c) b (a b) (a c)
4. Show that in a lattices if a b and c d then a c b d
5. In a lattice ,show that (a b) (c d ) (a c) (b d ) ,
(a b) (b c) (c a) (a b) (b c) (c a)
6. Show that a lattice with three of fewer elements is a chain.
7. Prove that every finite subset of a lattice has an LUB and a GLB.
8. Prove inequalities (8) and (9).
9. Show that theorem is a self dual.
10. For the lattice L, given in problem of exercise, what are the
operations odd meet and join?
11. Find all the4 sub lattices of the lattice Sn , D for n=12.
12. Draw the diagram of a lattice which is the direct product of the five-
element lattices shown in fig. and a two-element chain.
13. Show that the lattices Sn , D for n=216 is isomorphic to the direct
product of lattices for n=8 and n=27.
14. Show that there exists a mapping from the five-element lattice given in
fig. a three element chain and that this mapping is order preserving. Is it a
homorphism?
134
NOTES
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
135
UNIT – V
In this chapter
Discussion of grammars
Formal definition of language
Finite state machines
Introductory sequential circuit
Equivalence-of finite state machines
Finite state acceptors and regular grammars
Acceptor state transition diagram
Regular grammar
5.1 DISCUSSION OF GRAMMARS:
A finite language can be specified by enumerating all of its sentences.
An infinite language cannot be specified by enumeration, but can be specified
by a generative device called a grammar.
A grammar is a way to specify the set of all legal sentences of a
language (i.e. to specify the set of all legal programs of a programming
language).
Grammars are defined recursively (i.e. some elements are defined in
terms of themselves). Recursive definitions are also called inductive definitions
(i.e. they induce, rather than enumerate, the set of strings).
Let’s define a simple kind of arithmetic expression, A.
Basis Rules:
A Variable is an A.
An Integer is an A.
Inductive Rules:
If E1 and E2 are A’s, so is (E1 + E2).
If E1 and E2 are A’s, so is (E1 * E2).
Examples:
x, y, 3, 12, (x + y), (z * (x + y)), ((z * (x + y)) + 12)
Not Examples:
*3, (x ++ y), x + y
5.1.1 Full Grammar for Simple Arithmetic Expressions:
Let’s define all non-terminals:
A -> V | I | (A + A) | (A * A)
V -> L | VL | VD
I -> D | ID
136
D -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
L ->x | y | z
5.1.2 Strings and Languages:
Vocabulary (V): a finite set of symbols, e.g., V = {0, 1}
String (w): a finite sequence of symbols from V, e.g., w1 = 010 andw2
= 11110
Empty String (λ): the string of length 0.Concatenation (vw): vw is string
v, then string w. wn: string w repeated n times, e.g., 03 = 000
V : all possible strings using V. Language (L): A subset of all
possible strings V .
Example: L = {1m0n | m ∈ N ∧ n ∈ N}
5.1.3 Phrase-Structure Grammars:
A phrase-structure grammar G consists of: vocabulary V , divided into
two subsets: terminal symbols T and non-terminal symbols N start symbol S ∈
N a finite set of productions P Each production has the form x → y, where x ∈
V + and y ∈ V ∗. This means we can derive string uyv from string uxz. A string
w is an element of the language generated by G if w can be derived from S by
applying a sequence of productions.
Example Grammar 1
By convention, S is the start symbol, and non-terminal symbols are in
uppercase italics.
S → AB0 Any S can be replaced with AB0
A → BB Any A can be replaced with BB
B → 01 Any B can be replaced with 01
AB → 1 Any AB can be replaced with 1
This grammar can only generate 10 and 0101010. S AB0 10
S AB0 BBB0 . . . 0101010
An equivalent grammar is S → 10 and S → 0101010.
Types of Grammars Each type imposes restrictions on all productions.
Type 0: No restrictions on productions.
Context-sensitive grammars (Type 1): The right side cannot be shorter than the
left side. Example: {1n0n1n | n ∈ N}
Context-free grammars (Type 2): The left side is exactly one non-terminal
symbol. Example: {1n0n | n ∈ N}
137
Regular grammars (Type 3): A context-free grammar where the right side can
have only one non-terminal symbol, only at the end. Example: {1m0n | m ∈ N
∧ n ∈ N}
Formal Definition of language
A formal language L over an alphabet Σ is a subset of Σ*, that is, a set
of words over that alphabet. Sometimes the sets of words are grouped into
expressions, whereas rules and constraints may be formulated for the creation
of 'well-formed expressions'.
In computer science and mathematics, which do not usually deal
with natural languages, the adjective "formal" is often omitted as redundant.
While formal language theory usually concerns itself with formal
languages that are described by some syntactical rules, the actual definition of
the concept "formal language" is only as above: a (possibly infinite) set of
finite-length strings composed from a given alphabet, no more nor less. In
practice, there are many languages that can be described by rules, such
as regular languages or context-free languages. The notion of a formal
grammar may be closer to the intuitive concept of a "language," one described
by syntactic rules. By an abuse of the definition, a particular formal language is
often thought of as being equipped with a formal grammar that describes it.
5.2 FINITE STATE MACHINE:
Definition:
A model of computation consisting of a set of states, a start state, an
input alphabet, and a transition function that maps input symbols and current
states to a next state. Computation begins in the start state with an input string.
It changes to new states depending on the transition function.
There are many variants, for instance, machines having actions
(outputs) associated with transitions (Mealy machine) or states (Moore
machine), multiple start states, transitions conditioned on no input symbol (a
null) or more than one transition for a given symbol and state (nondeterministic
finite state machine), one or more states designated as accepting
states (recognizer), etc.
The simplest type of computing machine that is worth considering is
called a ‘finite state machine’. As it happens, the finite state machine is also a
useful approach to many problems in software architecture, only in this case
you don’t build one you simulate it.
Essentially a finite state machine consists of a number of states – finite
naturally! When a symbol, a character from some alphabet say, is input to the
138
machine it changes state in such a way that the next state depends only on the
current state and the input symbol.
Notice that this is more sophisticated than you might think because
inputting the same symbol doesn’t always produce the same behavior or result
because of the change of state.
The new state depends on the old state and the input. What this means
that the entire history of the machine is summarized in its current state. All that
matters is the state that it is in and not how it reached this state. Before you
write off the finite state machine as so feeble as to be not worth considering as
a model of computation it is worth pointing out that as you can have as many
states as you care to invent the machine can record arbitrarily long histories. All
you need is a state for each of the possible past histories and then the state that
you find the machine in is an indication of not only its current state but how it
arrived in that state.
Because a finite state machine can represent any history and a reaction,
by regarding the change of state as a response to the history, it has been argued
that it is a sufficient model of human behavior i.e. humans are finite state
machines.
If you know some probability theory you will recognize a connection
between finite state machines and Markov chains. A Markov chain sums up the
past history in terms of the current state and the probability of transition to the
next state only depends on the current state. The Markov chain is a sort of
probabilistic version of the finite state machine.
5.2.1 Representing Finite State Machines
You can represent a finite state machine in a form that makes it easier to
understand and think about.
All you have to do is draw a circle for every state and arrows that show
which state follows for each input symbol.
For example, the finite state machine in the diagram below has three
states. If the machine is in state 1 then an A moves it to state 2 and a B moves it
to state 3.
139
This really does make the finite state machine look very simple and you
can imagine how as symbols are applied to it how it jumps around between
states.
What is the point of such a simple machine?
There are two good reasons for being interested in finite state machines.
The first is practical. As mentioned earlier, there are some practical
applications which are best modeled as a finite state machine.
For example, many communications protocols, such as USB can be
defined by a finite state machine’s diagram showing what happens as different
pieces of information are input. You can even write or obtain a compiler that
will take a finite state machine’s specification and produce code that behaves
correctly.
Many programming problems are most easily solved by actually
implementing a finite state machine. You set up an array or other data structure
which stores the possible states and you implement a pointer to the location that
is the current state. Each state contains a lookup table that shows what the next
state is given an input symbol. When a symbol is read in your program simply
has to look it up in the lookup table and move the pointer to the new state.
5.2.2 Finite grammars
The practical uses of finite state a machine is reason enough to be
interested in them. Every programmer should know about finite state machines
and shouldn't be afraid of implementing them as solutions to problems.
However the second good reason is perhaps more important - but it does
depend on your outlook. Finite state machines are important because they allow
us to explore the theory of computation. They help us discover what resources
are needed to compute particular types of problem. In particular finite state
machines are deeply connected with the idea of grammars and languages that
follow rules.
If you define two of the machine’s states as special – a starting and a
finishing state – then you can ask what sequence of symbols will move it from
the starting to the finishing state.
Any sequence that does this is said to be ‘accepted’ by the machine.
Equally you can think of the finite state machine as generating the sequence by
outputting the symbols as it moves from state to state. That is a list of state
changes obeyed in order, from the start to the finish state, generates a particular
string of symbols. Any string that can be generated in this way will also be
accepted by the machine.
140
The point is that the simplicity or complexity of a sequence of symbols
is somehow connected to the simplicity or complexity of the finite state
machine that accepts it.
So we now have a way to study sequences of symbols and ask
meaningful questions.
As a simple example consider the finite state machine given earlier with
state 1 as start and state 3 as finish – what sequences does it accept? Assuming
that A and B are the only two symbols available, it is clear from the diagram
that any sequence like BABAA is accepted by it.
141
INTRODUCTORY SEQUENTIAL CIRCUIT:
Figure 5.3
Combinational circuits and systems produce an output based on input
variables only. Figure 5.3 Sequential circuits use current input variables and
previous input variables by storing the information and putting back into the
circuit on the next clock (activation) cycle.
Figure above shows a theoretical view of how sequential circuits are
made up from combinational logic and some storage elements. There are two
types of input to the combinational logic; External inputs which come from
outside the circuit design and are not controlled by the circuit;
Internal inputs which a function of a previous output states are.
The internal inputs and outputs are referred to as "secondary’s" in the course
notes. Secondary inputs are state variables produced by the storage elements,
where as secondary outputs are excitations for the storage elements.
Two Main Types of Sequential Circuits
There are two types of sequential circuit, synchronous and
asynchronous. Synchronous types use pulsed or level inputs and a clock
input to drive the circuit (with restart actions on pulse width and circuit
propagation).
Figure 5.4.1
Asynchronous sequential circuits do not use a clock signal as
synchronous circuits do. Instead the circuit is driven by the pulses of the inputs.
Figure 5.4.1 You will not need to know anymore about asynchronous circuits
for this course.
142
Figure 5.5
A pulsed output (as used in the block diagrams above) is an output that
lasts for the duration of a particular input pulse but can be less in some cases.
For the clocked sequential circuits, figure.5.5 the output pulse is the same
duration as the clock pulse.
A level output refers to an output that changes state at the start of an
input pulse or clock pulse and remains in that state until the next input or clock
pulse.
Important Sequential Logic Design Issue
An important thing to note with sequential circuits is that duration of the
activating pulse should be low enough so that the secondary inputs do not
change state in same activating pulse. Allowing the clock pulse to be too long
would result in incorrect circuit function, as there will be two different
secondary input values for one clock cycle and therefore lead to potentially two
state changes in on clock. It would be beneficial to have our storage elements to
be edge triggered, as this would mean that the clock pulse can be as long as we
would like it to be and the circuit would behave in the same way. This is why
flip-flops are used as they are edge triggered storage devices.
5.3 EQUIVALENCE OF FINITE STATE MACHINES:
This section describes the technique to detect functionally equivalent
state variables in a finite state machine. It partitions the set of state variables
into classes of functionally equivalent variables. More exactly, it calculates an
equivalence relation on the set of state variables which induces this partition.
This particular equivalence relation is called the variable correspondence
relation. To guarantee its correctness, two conditions are imposed on it which
together form an inductive argument for the equivalence of the variables in the
same class of the partition.
The first condition requires that equivalent variables always have the
same initial value. The second condition requires that if equivalent variables
have the same value in the current state, they necessarily have the same value
in every next state. If these two conditions are satisfied, it can directly be
concluded that all equivalent variables necessarily have the same value in every
143
reachable state. To express the condition that a state conforms to a given
relation, the variable correspondence condition is introduced.
Definition 3
Given an equivalence relation R : VVB. Then the variable correspondence
condition RVC:BnBis the predicate that defines whether a state conforms to R, i.e.,
whether equivalent variables are indeed assigned the same value in this state:
RVC(s1, .. . ,sn) (vj,vk V : R(vj,vk)sj sk ) .
The variable correspondence relation can now be defined as follows.
Definition 4
An equivalence relation R: VV B is a variable correspondence relation iff
it satisfies the following two Conditions:
it holds in every initial state: s S0: RVC(s)
Note that the second condition in definition 4 is sufficient but not
necessary for the equivalence of two variables; it is chosen specifically because
its evaluation does not require the reachable state space. As a consequence also
non-reachable states may be taken into account by this condition, and therefore
it is not guaranteed that all equivalent variables are indeed detected.
An important question for the applicability of the variable
correspondence relation is whether there always exists a unique solution. There
may exist several variable correspondence relations for a FSM. The following
property shows that two such relations can always be combined to a single
larger relation. Because there is only a finite number of a state variable, this
means that there always exists a unique maximum variable correspondence
relation.
The method to calculate the maximum variable correspondence relation
follows directly from definition 4. It consists of a greatest fixed point
computation. The first approximation R0 is based on the first condition of
definition 4:
Since there is only a finite number of state variables, a fixed point is
reached after a finite number of iterations, i.e., at some point Rh!Rh&1. Then this
Rh is by construction the maximum variable correspondence relation. The
maximum number of iterations is | V| ) 1, because in every iteration, except the
last one, at least one new class is created.
Every Rh is an equivalence relation. Therefore it can be represented by
the partition it induces. This partition is stored explicitly. The refinement of a
relation Rh to a relation Rh&1 corresponds to splitting some classes of the
partition.
144
This is done by checking if the next-state functions of the variables in
the same class are equivalent under the variable correspondence condition; this
can be calculated with BDDs. The BDD representation of part of this condition
is constructed for every comparison of two variables; just the state variables in
the support of the (k) concerned is taken into account.
The fixed point calculation can also be implemented as follows. From
every class of equivalent variables, selected variables. This way the variable
correspondence condition is satisfied by construction and the
Where reph(s) ! (reph(s1), ... , reph(sp)). When BDDs are used to
represent the next-state functions, the main advantages of this approach are that
the BDD for the variable correspondence condition does not have to be
constructed and that less BDD variables are needed; the maximum number of
variables needed to represent state variables equals the number of classes of the
maximum variable correspondence relation. Of course it is necessary to
recalculate the BDDs for the next-state functions after every iteration; this is
not a significant drawback because BDD packages cache the results of previous
computations and therefore these recalculations are typically performed very
efficiently. Of course this technique is not restricted to BDD-based verification
methods.
After all state variables are assigned a representative variable, the
comparison of the resulting next-state functions can be done with any
combinational verification method. If the descriptions of both FSMs have
similar structures, it could be useful to apply a verification method which
exploits these similarities, such as e.g. presented.
The efficiency of the fixed point computation can be improved with the
following technique. It is based on testing the second condition of definition 4
for only a limited number of states and input vectors. A signature is calculated
for every state variable by evaluating the next-state functions for some
randomly chosen states and input vectors; of course it is necessary that the
chosen states conform to Rh.
Then every class of the partition is split into classes which only contain
state variables with the same signature. This technique is very effective to
obtain a more accurate initial approximation R0 which reduces the number of
iterations required to reach the fixed point.
The presented method can easily be extended to also detect state
variables which have opposite values in all reachable states. This requires the
following equivalence relation T: V,
V-B:T
145
All state variables equivalent under T can be given the same initial
value by selectively complementing some variables. Of course, the next-state
and output functions have to be changed accordingly. After this transformation
the presented fixed point computation can be applied to calculate the variable
correspondence relation.
The method can also be extended to detect state variables which have a
constant value in all reachable states. This requires the introduction of an extra
function which defines if a variable always has the same value or not. Then the
variable correspondence condition can be strengthened with this information
state function of a variable is constant under the variable correspondence
condition.
When the state encoding of a design has not been modified, the full
generality of sequential verification is not needed. If the correspondence
between the state variables of both descriptions is known, the problem
essentially becomes a combinational verification problem. This correspondence
is however not always obvious. If for example the implementation has been
extracted from a transistor level description, it cannot be assumed that the
correspondence can be derived from the names of the state variables. The
maximum variable correspondence relation can be used to define this type of
combinational equivalence without requiring that the correspondence between
the state variables is given explicitly.
146
Definition 6
147
Experimental Results
This section presents the results of some preliminary experiments which
have been performed with the proposed technique to detect equivalent state
variables. The method has been implemented in C++ using the BDD package
developed in our department; the sifting algorithm [13] is used to dynamically
control the variable order. All tests have been performed on a HP9000/735
workstation. The verification method has been used to compare some circuits
from the IWLS'91 benchmark set.
Every circuit is compared against an equivalent circuit from the
benchmark set; if only one implementation is available, a second
implementation has been synthesized with the logic synthesis system SIS
developed at the University of California, Berkeley. The applied
transformations only modify the combinational part of the circuits; they include
collapsing, factoring and technology mapping.
The resulting circuits are identified by adding a `c' to their name. To
avoid any coincidental similarities between the two circuit descriptions, the
order of the latches in every second description has been changed randomly.
The results are shown in table 1. Experimental results for some IWLS’91
benchmarks
The column `extraction' shows the run times and memory usage for
building the BDDs for both FSMs. These numbers are given for comparison.
Memory usage only includes the memory used by the BDD package. The
column `expl. cond.' shows the results of the algorithm which uses the
correspondence condition explicitly to calculate the maximum variable
correspondence relation. The column `impl. cond.' shows the results for the
algorithm which selects unique representatives for the state variables and thus
satisfies the correspondence condition implicitly.
This requires that the BDDs for both FSMs are recalculated after every
iteration of the fixed point calculation. The last column shows the number of
iterations required to reach the fixed point. Both algorithms use signature
calculations to obtain an initial approximation of the maximum variable
correspondence relation. Signatures are calculated by evaluating the next-state
functions for 32 vectors in parallel. This is repeated until the partition does not
change during 16 successive runs.
The results clearly demonstrate that the maximum variable
correspondence relation can be calculated very efficiently with the algorithm
that satisfies the correspondence condition implicitly. Benchmark s38584.1
with 1426 state variables is for example completely verified within 90 seconds.
The algorithm only fails to complete the calculations for the benchmark
148
s38417, for which we have not been able to build BDDs within the memory
limit of 50 Mb.
The efficiency of the algorithm is even more evident when the results
are compared to the run times and memory usage needed to build BDDs for
both circuits separately. In almost all cases it requires less memory because it
assigns the same BDD variable to equivalent state variables. Therefore more
BDD nodes can be shared by both FSMs. Another important effect of this
technique is that the variable ordering algorithm is better capable of finding a
good variable order; this is especially clear for the benchmarks with more than
50 state variables. Of course, this also leads to shorter run times. The efficiency
of the algorithm which calculates the correspondence condition explicitly is
acceptable for the smaller benchmarks with up to about 32 state variables. It is
however more sensitive to the variable order and therefore it is not sufficiently
robust for the larger benchmarks.
Table 2 gives an overview of the benchmarks for which the verification
method also detects equivalent state variables within a single circuit. The first
two columns respectively show the name of the benchmark and the total
number of state variables. The next columns show the number of state variables
that are not directly or indirectly connected to an output, the number of state
variables which have a constant value and the number of state variables which
are removed because they are duplicates of other variables.
The column `nr.unconn. vars after' shows the number of state variables
which initially seem to be directly or indirectly connected to an output, but
which become unconnected after the removal of constant and duplicate
variables. The last column gives the resulting number of state variables.
Especially for the three largest benchmarks this number is considerably less
than the total number of state variables.
The experimental results clearly demonstrate that the proposed method
forms a robust extension of any symbolic traversal algorithm. Of course, more
experiments need to be performed to test the performance gain when only some
of the state variables are equivalent and therefore the state space of the reduced
product machine has to traversed. It is however clear that the technique does
not introduce a significant overhead and can have a very positive effect on the
run time, the memory usage and the robustness of any BDD-based method for
FSM verification.
149
Table 2.Classification of the state variables for some IWLS’91 benchmarks
Nr. Nr.
Total Nr. Nr. Nr.
unconn. unconn.
Circuit nr. const. dupl. unique
vars vars
vars vars vars vars
before after
s641 19 0 4 1 0 14
s1423 74 0 0 1 0 73
s5378 164 0 0 1 0 163
s9234.1 211 66 3 13 0 129
150
[0-9]*[A-Z][a-z0-9]*
Our first task is to program a machine. Because there is no constructor
taking a regular expression directly, the problem will be solved by (1) hand-
translating the regular expression to a state transition diagram and then (2)
`programming' the machine directly from the diagram. Figure 2 shows the state
transition diagram that we will use:
Figure: 5.6.1
5.4.1 Acceptor State Transition Diagram
Note that the output portion of each label has been omitted; this is
consistent with the fact that acceptors don't produce output. We have also taken
the liberty of labeling the input portion of each arc with the terms of the regular
expression rather than drawing several arcs, each with a distinct input. This
shorthand permits one arc to stand for many arcs, thereby simplifying the
diagram. As we will see below, this shorthand is also recognized by
function trans().
Figure 2 shows only two states, which it labels symbolically. As can be
seen by the following enumeration type, however, our intent is to define a
machine with three states:
enum States{rejecting, eating digits ,accepting};
The state not shown in the diagram (rejecting) is the one the machine
will enter upon receipt of an input for which no transition has been explicitly
defined (recall the behavior of an unprogrammed machine in
If the machine enters this state, we will know that a bad character has
been encountered. We must also consider the possibility that the input is
exhausted before the machine reaches the ``accepting'' state; consider the input
``57''.
Since acceptors don't produce any output, they don't need action
routines; we therefore omit all action routine arguments, which default to zero:
Fsma(3,eating_digits); // "a" for "acceptor"
for(int c='0';c<='9';c++){
a.trans(eating_digits,c,eating_digits);
a.trans(accepting,c,accepting);
151
}
for(int c='A';c<='Z';c++){
a.trans(eating_digits,c,accepting);
}
.
.
These loops, which are tedious to write and hard to understand, can be
eliminated by using a second version of trans(), which takes a range of integers
and creates a transition for each value in the range:
a.trans (eating_digits,'0','9', eating_digits);
a.trans (eating_digits,'A','Z', accepting);
a.trans (accepting,'a','z', accepting);
a.trans (accepting,'0','9', accepting);
Unfortunately, this code is only slightly better. A third version
of trans() allows inputs to be defined by one-character regular expressions; it is
convenient when working with inputs representing printable characters, as in
this example:
a.trans(eating_digits,"[0-9]",eating_digits);
a.trans (eating_digits,"[A-Z]",accepting);
a.trans (accepting,"[a-z0-9]",accepting);
We are now ready to write check_string ():
int check_string(char* p,Fsm& a){
while(*p!=0){
a.fire(*p++);
if(a.state()==rejecting)return 0;
}
returna.state()==accepting;
}
There is a serious flaw in check string(): the function will only work
the first time it is called! The reason for this is that the function leaves the
machine in one of three possible final states; the machine needs to be reset to
the proper initial state (eating_digits) for the function to work properly on
subsequent calls. This can be accomplished in either of two ways. Calling
function go()forces a machine into an explicit state:
int check_string(char* p,Fsm& a){
152
a.go(eating_digits);
...
}
Calling function reset() causes the machine to return to the state defined as the
initial state in the constructor call:
int check_string(char* p,Fsm& a){
a.reset();
...
}
5.4.2 Regular grammar:
In theoretical computer science and formal language theory, a regular
grammar is a formal grammar that is right-regular or left-regular. Every
regular grammar describes a regular language.
A right regular grammar (also called right linear grammar) is a formal
grammar (N, Σ, P, S) such that all the production rules in P are of one of the
following forms:
B → a - where B is a non-terminal in N and a is a terminal in Σ
B → aC - where B and C are non-terminals in N and a is in Σ
B → ε - where B is in N and ε denotes the empty string, i.e. the string of length
0.
In a left regular grammar (also called left linear grammar), all rules obey the
forms
A → a - where A is a non-terminal in N and a is a terminal in Σ
A → Ba - where A and B are in N and a is in Σ
A → ε - where A is in N and ε is the empty string.
An example of a right regular grammar G with N = {S, A}, Σ = {a, b,
c}, P consists of the following rules
S → aS
S → bA
A→ε
A → cA
And S is the start symbol. This grammar describes the same language as
the regular expression a*bc*, viz. the set of all strings consisting of arbitrarily
many "a"s, followed by a single "b", followed by arbitrarily many "c"s.
153
A somewhat longer but more explicit extended right regular
grammar G for the same regular expression is given by N = {S, A, B, C}, Σ =
{a, b, c}, where P consists of the following rules:
S→A
A → aA
A→B
B → bC
C→ε
C → cC
…where each uppercase letter corresponds to phrases starting at the next
position in the regular expression.
As an example from the area of programming languages, the set of all
strings denoting a floating point number can be described by a right regular
grammar G with N = {S, A,B,C,D,E,F}, Σ = {0,1,2,3,4,5,6,7,8,9,+,-,.,e}, where
S is the start symbol, and P consists of the following rules:
S → +A A → 0A B → 0C C → 0C D → +E E → 0F F → 0F
S → -A A → 1A B → 1C C → 1C D → -E E → 1F F → 1F
S→A A → 2A B → 2C C → 2C D→E E → 2F F → 2F
A → 3A B → 3C C → 3C E → 3F F → 3F
A → 4A B → 4C C → 4C E → 4F F → 4F
A → 5A B → 5C C → 5C E → 5F F → 5F
A → 6A B → 6C C → 6C E → 6F F → 6F
A → 7A B → 7C C → 7C E → 7F F → 7F
A → 8A B → 8C C → 8C E → 8F F → 8F
A → 9A B → 9C C → 9C E → 9F F → 9F
A → .B C → eD F→ε
A→B C→ε
A regular grammar is a left or right regular grammar. Some textbooks
and articles disallow empty production rules, and assume that the empty string
is not present in languages.
154
Exercise:
1. Design a parity check machine which is to read a sequence of 0s and 1s
from an input tape. The machine is to output a 1 if the input tape contains
an even number of 1s or 0 otherwise.
2. Design a sequential machine which has one input line x in addition to a
clock input and one output line z.z is to have a value of unless the input
contains consecutive is or three consecutive 0s.z must be 1 at the time of
the third consecutive identical input.
3. A sequential circuit is to be designees which will identify a particular
sequence id input and provide an output to trigger a combinational lock.
The output of the circuit is to be 0 unless the input switches are in the
positions 010 where this position occurs at the conclusion of a sequence
of input positions 101,111,0111010.design a sequential machine will have
only one outur of 1 at the conclusions of the described sequence of switch
positions. A correct sequence may begin every time the switches are set to
101.
4. The output of a sequential machine is to be 1 and only if the last four
input symbols is the following form: Time: ti ti 1ti 2 ti 3 input symbol 1 0
1 1. Design such a machine.
5. Draw transition diagrams for the single input, single output sequential
machines whose operations are specified as follows:
6. Prove that g (Si , x) g (S j , x) for every x if and only if ( S j , x) that is if
and only is if Si S j
155
NOTES
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
156