Application of Proposition Logic
Application of Proposition Logic
for the operators ∧, ∨, and ⊕, the tables shown in Table below for
By replacing true by a one and false by a zero in the truth tables
the notation OR, AND, and XOR for the operators ∨, ∧, and ⊕, as
the corresponding bit operations are obtained. We will also use
Page 1 of 15
DEFINITION: A bit string is a sequence of zero or more bits. The
length of this string is the number of bits in the string.
EXAMPLE: 101010011 is a bit string of length nine.
EXAMPLE: Find the bitwise OR, bitwise AND, and bitwise XOR of
the bit strings 01 1011 0110 and 11 0001 1101.
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these
strings are obtained by taking the OR, AND, and XOR of the
corresponding bits, respectively. This gives us
01 1011 0110
11 0001 1101
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
System Specifications
Translating sentences in natural language (such as English) into
logical expressions is an essential part of specifying both
hardware and software systems. System and software engineers
take requirements in natural language and produce precise and
unambiguous specifications that can be used as the basis for
Page 2 of 15
system development. Example below shows how compound
propositions can be used in this process.
EXAMPLE: Express the specification “The automated reply
cannot be sent when the file system is full” using logical
connectives.
Solution: One way to translate this is to let p denote “The
automated reply can be sent” and q denote “The file system is
full.” Then ¬p represents “It is not the case that the automated
reply can be sent,” which can also be expressed as “The
automated reply cannot be sent.”
Consequently, our specification can be represented by the
conditional statement q →¬p.
System specifications should be consistent, that is, they should
not contain conflicting requirements that could be used to derive
a contradiction. When specifications are not consistent, there
would be no way to develop a system that satisfies all
specifications.
EXAMPLE: Determine whether these system specifications are
consistent:
“The diagnostic message is stored in the buffer or it is
retransmitted.”
“The diagnostic message is not stored in the buffer.”
“If the diagnostic message is stored in the buffer, then it is
retransmitted.”
Solution: To determine whether these specifications are
consistent, we first express them using logical expressions.
Let p denote “The diagnostic message is stored in the buffer” and
let q denote “The diagnostic message is retransmitted.”
The specifications can then be written as
Page 3 of 15
p ∨ q, ¬p, and p → q. An assignment of truth values that makes all
three specifications true must have p false to make ¬p true.
Because we want p ∨ q to be true but p must be false, q must be
true. Because p → q is true when p is false and q is true, we
conclude that these
specifications are consistent, because they are all true when p is
false and q is true.
We could come to the same conclusion by use of a truth table to
examine the four possible assignments of truth values to p and q.
Do the system specifications in the Example above remain
consistent if the specification “The diagnostic message is not
retransmitted” is added?
Solution: By the reasoning in Example above, the three
specifications from that example are true only in the case when p
is false and q is true. However, this new specification is ¬q, which
is false when q is true. Consequently, these four specifications are
inconsistent.
Boolean Searches
Logical connectives are used extensively in searches of large
collections of information, such as indexes of Web pages. Because
these searches employ techniques from propositional logic, they
are called Boolean searches.
In Boolean searches, the connective AND is used to match records
that contain both of two search terms, the connective OR is used
to match one or both of two search terms, and the connective
NOT (sometimes written as AND NOT ) is used to exclude a
particular search term.
Page 4 of 15
Most Web search engines support Boolean searching techniques,
which usually can help find Web pages about particular subjects.
For instance, using Boolean searching to find Web pages about
universities in New Mexico, we can look for pages matching NEW
AND MEXICO AND UNIVERSITIES. The results of this search will
include those pages that
contain the three words NEW, MEXICO, and UNIVERSITIES. This
will include all of the pages of interest, together with others such
as a page about new universities in Mexico. (Note that in Google,
and many other search engines, the word “AND” is not needed,
although it is understood, because all search terms are included
by default. These search engines also support the use of
quotation marks to search for specific phrases. So, it may be
more effective to search for pages matching “New Mexico” AND
UNIVERSITIES.)
Next, to find pages that deal with universities in New Mexico or
Arizona, we can search for pages matching (NEW AND MEXICO
OR ARIZONA) AND UNIVERSITIES. (Note: Here the AND operator
takes precedence over the OR operator. Also, in Google, the
terms used for this search would be NEW MEXICO OR ARIZONA.)
The results of this search will include all pages that contain the
word UNIVERSITIES and either both the words NEW and MEXICO
or the word ARIZONA. Again, pages besides those of interest will
be listed.
Finally, to find Web pages that deal with universities in Mexico
(and not New Mexico), we might first look for pages matching
MEXICO AND UNIVERSITIES, but because the results of this search
will include pages about universities in New Mexico, as well as
universities in Mexico, it might be better to search for pages
matching (MEXICO AND UNIVERSITIES) NOT NEW. The results of
this search include pages that contain both the words MEXICO
and UNIVERSITIES but do not contain the word NEW. (In Google,
and many other search engines, the word “NOT” is replaced by
the symbol “-”. In Google, the terms used for this last search
would be MEXICO UNIVERSITIES -NEW.)
Page 5 of 15
Logic Puzzles
Puzzles that can be solved using logical reasoning are known as
logic puzzles. Solving logic puzzles is an excellent way to
practice working with the rules of logic. Also, computer programs
designed to carry out logical reasoning often use well-known logic
puzzles to illustrate their capabilities. Many people enjoy solving
logic puzzles, published in periodicals, books, and on the Web, as
a recreational activity.
EXAMPLE: Raymond Smullyan posed many puzzles about an
island that has two kinds of inhabitants, knights, who always tell
the truth, and their opposites, knaves, who always lie. You
encounter two people A and B. What are A and B if A says “B is a
knight” and B says “The two of us are
opposite types?”
Solution: Let p and q be the statements that A is a knight and B is
a knight, respectively, so that ¬p and ¬q are the statements that
A is a knave and B is a knave, respectively.
We first consider the possibility that A is a knight; this is the
statement that p is true. If A is a knight, then he is telling the
truth when he says that B is a knight, so that q is true, and A and
Page 6 of 15
A compound proposition is satisfiable if there is an assignment
of truth values to its variables that makes it true. When no such
assignments exists, that is, when the compound proposition is
false for all assignments of truth values to its variables, the
compound proposition is unsatisfiable.
Note that a compound proposition is unsatisfiable if and only if its
negation is true for all assignments of truth values to the
variables, that is, if and only if its negation is a tautology.
When we find a particular assignment of truth values that makes
a compound proposition true, we have shown that it is satisfiable;
such an assignment is called a solution of this particular
satisfiability problem. However, to show that a compound
proposition is unsatisfiable, we need to show that every
assignment of truth values to its variables makes it false.
Although we can always use a truth table to determine whether a
compound proposition is satisfiable, it is often more efficient not
to, as Example below demonstrates.
EXAMPLE: Determine whether each of the compound
propositions is satisfiable
a) (p ∨¬q) ∧ (q ∨¬r) ∧
b) (r ∨¬p), (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r),
c) (p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) ∧(p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r).
Solution: Instead of using truth table to solve this problem, we will
reason about truth values.
Note that (p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) is true when the three-
variable p, q, and r have the same truth value. Hence, it is
satisfiable as there is at least one assignment of truth values for
p, q, and r that makes it true.
Similarly, note that (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r) is true when at
least one of p, q, and r is true and at least one is false.
Page 7 of 15
Hence, (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r) is satisfiable, as there is at
least one assignment of truth values for p, q, and r that makes it
true.
Finally, note that for
(p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) ∧ (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r) to be
true,
(p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) and (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r) must
both
be true. For the first to be true, the three variables must have the
same truth values, and for the second to be true, at least one of
three variables must be true and at least one must be false.
However, these conditions are contradictory. From these
observations we conclude that no assignment of truth values to p,
q, and r makes
(p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) ∧ (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r) true.
Hence, it is unsatisfiable.
Applications of Satisfiability
Many problems, in diverse areas such as robotics, software
testing, computer-aided design, machine vision, integrated circuit
design, computer networking, and genetics, can be modeled in
terms of propositional satisfiability. For example, propositional
satisfiability is applied to model Sudoku puzzles.
SUDOKU A Sudoku puzzle is represented by a 9 × 9 grid made
up of nine 3 × 3 subgrids, known as blocks. For each puzzle,
some of the 81 cells, called givens, are assigned one of the
numbers 1, 2, . . . , 9, and the other cells are blank. The puzzle is
solved y assigning a number to each blank cell so that every row,
every column, and every one of the nine 3 × 3 blocks contains
each of the nine possible numbers.
Page 8 of 15
Note that instead of using a 9 × 9 grid, Sudoku puzzles can be
based on
n2 × n2 grids, for any positive integer n, with the n2 × n2 grid
made up of n2 n × n subgrids.
Sudoku puzzles designed for entertainment have two additional
important properties. First, they have exactly one solution.
Second, they can be solved using reasoning alone. Many
strategies based on logic and mathematics have been devised for
solving Sudoku. One of the ways that have been developed for
solving Sudoku puzzles with the aid of a computer, which depends
on modeling the puzzle as a propositional satisfiability problem.
Using the model, particular Sudoku puzzles can be solved using
software developed to solve satisfiability problems. Currently,
Sudoku puzzles can be solved in less than 10 milliseconds this
way. It should be noted that there are many other approaches for
solving Sudoku puzzles via computers using other techniques
Page 9 of 15
Logic Circuits
Propositional logic can be applied to the design of computer
hardware.
A logic circuit (or digital circuit) receives input signals p1, p2, .
. . , pn, each a bit [either 0 (off) or 1 (on)], and produces output
signals s1, s2, . . . , sn, each a bit. In this section we will restrict
our attention to logic circuits with a single output signal; in
general, digital circuits may have multiple outputs.
Page 10 of 15
symbol is P ∨ Q:
(4) NAND gate: outputs a 0 if both P and Q are 1 and 1 otherwise.
The
symbol is ∼ (P ∧ Q): Also, denoted by P|Q; where | is called a
Scheffer
stroke.
(5) NOR gate: output a 0 if at least one of P or Q is 1 and 1
otherwise. The
symbol is ∼ (P ∨ Q) or P ↓ Q; where ↓ is a Pierce arrow.
OR Gate
Page 11 of 15
AND Gate
The Boolean expression of AND gate is Y = A.B
NOT Gate
Page 12 of 15
The three gates (OR, AND and NOT), when connected in various
combinations, give us basic logic gates such as NAND, NOR gates,
which are the universal building blocks of digital circuits.
NAND Gate
This basic logic gate is the combination of AND and NOT gate.
The Boolean expression of NAND gate is
Page 13 of 15
NOR Gate
This gate is the combination of OR and NOT gate.
Exercise:
Page 14 of 15
1. Find the output of each of these combinatorial circuits.
c)
AND gates that produces the output (p ∧¬r) ∨ (¬q ∧ r) from input
2. Construct a combinatorial circuit using inverters, OR gates, and
bits p, q, and r.
Page 15 of 15