Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Topic: Logical operation.
Algebra of logic
Academic Subject: Medical Information Science
Faculty: Foreign Student Training (Medcine)
Module No 2: Medical knowledge and decision making in medicine and
dentistry.
Objectives• Understand the main logic operations
• Learn how to construct the table of truth
• Learn main logic rules
• Understand the relationship between
Boolean logic and digital computer
circuits
Olenets Svitlana
Introduction
• In the latter part of the
nineteenth century, George
Boole incensed philosophers
and mathematicians alike
when he suggested that
logical thought could be
represented through
mathematical equations.
– How dare anyone suggest
that human thought could be
encapsulated and
manipulated like an
algebraic formula?Olenets Svitlana
Introduction
• In the middle of the twentieth
century, computers were commonly
known as “thinking machines” and
“electronic brains.”
– Many people were fearful of them.
• Nowadays, we rarely ponder the
relationship between electronic
digital computers and human logic.
Computers are accepted as part of
our lives.
– Many people, however, are still
fearful of them.
Olenets Svitlana
• Computers, as we know
them today, are
implementations of
Boole’s Laws of Thought.
– John Atanasoff and
Claude Shannon were
among the first to see
this connection.
Introduction
The true-false nature of Boolean logic
makes it compatible with binary logic
used in digital computers.
Electronic circuits can produce Boolean
logic operations.
Olenets Svitlana
Boolean Algebra
Boolean algebra is a mathematical system for the
manipulation of variables that can have one of two values.
– In formal logic, these values are:
“true” and “false”
– In digital systems, these values are:
“on” and “off”
1 and 0
“high” and “low”
Olenets Svitlana
Introduction: PL?
• In Propositional Logic (a.k.a Propositional
Calculus or Sentential Logic), the objects are
called propositions
• Definition: A proposition is a statement that is
either true or false, but not both
Olenets Svitlana
Types of statements
• A simple expression
• Expression of the structure can be simple or
composite.
• The content expression contained either a
communication or statement of the existing
world. This expression is simple. For
example, "the diagnosis of myocardial
infarction", "the patient is observed cardiac
arrhythmia"
Olenets Svitlana
• Composite expression (logical function)
• From simple statements by ligaments AND,
OR and NOT are formed composite
expression, called logic functions. Simple
expression of which is formed a compound,
called logical arguments. The sentence "The
patient feels severe pain in the jaw, the
mouth does not close on their own, it's hard
to swallow and speak" is a composite
expression (logic function "AND").
Olenets Svitlana
Alphabet logic statements• In modern logic is a special part of the complex
expression - the logic statements. In the logic
expression using an artificial language that has
such significant means (alphabet logic statements):
• Variable expression of logic - A, B, C, D, ...
(propositional variables) denote the simple
expression.
• Signs of logical connectors: Δ - conjunction ; ∇ -
disjunction ; ⇒ - implication ; ⇔ - equality; ⌐ -
negation;
Olenets Svitlana
Propositions: Examples
• The following are propositions
– Today is Monday M
– The grass is wet W
– It is raining R
• The following are not propositions
– C++ is the best language Opinion
– When is the pretest? Interrogative
– Do your homework Imperative
Olenets Svitlana
Introduction: Proposition
• Definition: The value of a proposition is
called its truth value; denoted by
– T or 1 if it is true or
– F or 0 if it is false
• Opinions, interrogative, and imperative are not
propositions
• Truth tablep
0
1
Olenets Svitlana
Logical connectives• Connectives are used to create a compound
proposition from two or more propositions– Negation (denote or !)
– And or logical conjunction (denoted )
– Or or logical disjunction (denoted )
– XOR or exclusive or (denoted )
– Implication (denoted or )
Biconditional (denoted or )
We define the meaning (semantics) of the logical connectives using truth tables
Olenets Svitlana
Logical Connective: Negation
• p, the negation of a proposition p, is also a
proposition
• Examples:
– Today is not Monday
– It is not the case that today is Monday, etc.
• Truth tablep p
0 1
1 0
Olenets Svitlana
Logical Connective: Logical And
• The logical connective And is true only when both of the
propositions are true. It is also called a conjunction
• Examples
– It is raining and it is warm
– (2+3=5) and (1<2)
– Schroedinger’s cat is dead and Schroedinger’s is not dead.
• Truth tablep q pq
0 0
0 1
1 0
1 1
p q pq
0 0 0
0 1 0
1 0 0
1 1 1
Olenets Svitlana
Logical Connective: Logical Or
• The logical disjunction, or logical Or, is true if one or
both of the propositions are true.
• Examples
– It is raining or it is the second lecture
– (2+2=5) (1<2)
– You may have cake or ice cream
• Truth table p q pq pq
0 0 0
0 1 0
1 0 0
1 1 1
p q pq pq
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
Olenets Svitlana
Logical Connective: Exclusive Or
• The exclusive Or, or XOR, of two propositions is true when
exactly one of the propositions is true and the other one is false
• Example
– The circuit is either ON or OFF but not both
– Let ab<0, then either a<0 or b<0 but not both
– You may have cake or ice cream, but not both
• Truth table
p q pq pq pq
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 1
p q pq pq pq
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
Olenets Svitlana
Logical Connective: Implication (1)
• Definition: Let p and q be two propositions. The
implication pq is the proposition that is false when
p is true and q is false and true otherwise
– p is called the hypothesis, antecedent, premise
– q is called the conclusion, consequence
• Truth tablep q pq pq pq pq
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
p q pq pq pq pq
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 1
Olenets Svitlana
Logical Connective: Implication (2)
• The implication of pq can be also read as– If p then q
– p implies q
– If p, q
– p only if q
– q if p
– q when p
– q whenever p
– q follows from p
– p is a sufficient condition for q (p is sufficient for q)
– q is a necessary condition for p (q is necessary for p)
Olenets Svitlana
Exercise: Which of the following implications is
true?
• If -1 is a positive number, then 2+2=5
• If -1 is a positive number, then 2+2=4
• If x = 0, then x+1 = 0
True. The premise is obviously false, thus no matter what the
conclusion is, the implication holds.
True. Same as above.
False
Olenets Svitlana
Logical Connective: Biconditional (1)
• Definition: The biconditional pq is the
proposition that is true when p and q have the
same truth values. It is false otherwise.
• Note that it is equivalent to (pq)(qp)
• Truth tablep q pq pq pq pq pq
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 1
p q pq pq pq pq pq
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
Olenets Svitlana
Logical Connective: Biconditional (2)
or equivalence
• The biconditional pq can be equivalently read as
– p if and only if q
– p is a necessary and sufficient condition for q
– if p then q, and conversely
– p iff q (Note typo in textbook, page 9, line 3)
• Examples
– x>0 if and only if x2 is positive
– The alarm goes off iff a burglar breaks in
– You may have pudding iff you eat your meat
Olenets Svitlana
Truth Tables
• Truth tables are used to show/define the
relationships between the truth values of
– the individual propositions and
– the compound propositions based on them
p q pq pq pq pq pq
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
Olenets Svitlana
Constructing Truth Tables
• Construct the truth table for the following
compound proposition
(( p q ) q )
p q pq q (( p q ) q )
0 0 0 1 1
0 1 0 0 0
1 0 0 1 1
1 1 1 0 1
Olenets Svitlana
Precedence of Logical Operators
• As in arithmetic, an ordering is imposed on the use of logical operators in compound propositions
• However, it is preferable to use parentheses to disambiguate operators and facilitate readability
p q r (p) (q (r))
• To avoid unnecessary parenthesis, the following precedenceshold:
1. Negation ()
2. Conjunction ()
3. Disjunction ()
4. Implication ()
5. Biconditional ()
Olenets Svitlana
Usefulness of Logic
• Logic is more precise than natural language
– You may have cake or ice cream.
• Can I have both?
– If you buy your air ticket in advance, it is cheaper.
• Are there or not cheap last-minute tickets?
• For this reason, logic is used for hardware and software specification
– Given a set of logic statements,
– One can decide whether or not they are satisfiable (i.e., consistent), although this is a costly process…
Olenets Svitlana
Terminology:
Tautology, Contradictions, Contingencies
• Definitions– A compound proposition that is always true, no matter
what the truth values of the propositions that occur in it is called a tautology
– A compound proposition that is always false is called a contradiction
– A proposition that is neither a tautology nor a contradiction is a contingency
• Examples– A simple tautology is p p
– A simple contradiction is p p
Olenets Svitlana
Logical Equivalences: Example 1
• Are the propositions (p q) and (p q)
logically equivalent?
• To find out, we construct the truth tables for
each: p q pq p pq
0 0
0 1
1 0
1 1
The two columns in the truth table are identical, thus we conclude that
(p q) (p q)
Olenets Svitlana
Boolean Algebra
• Digital computers contain circuits that implement
Boolean functions.
• The simpler that we can make a Boolean function, the
smaller the circuit that will result.
– Simpler circuits are cheaper to build, consume less
power, and run faster than complex circuits.
• With this in mind, we always want to reduce our
Boolean functions to their simplest form.
• There are a number of Boolean identities that help us to
do this.
Olenets Svitlana
Boolean Algebra
• Most Boolean identities have an AND (product) form as
well as an OR (sum) form. We give our identities using
both forms. Our first group is rather intuitive:
Olenets Svitlana
Boolean Algebra
• Our second group of Boolean identities should be
familiar to you from your study of algebra:
Olenets Svitlana
Boolean Algebra
• Our last group of Boolean identities are perhaps the most
useful.
• If you have studied set theory or formal logic, these laws
are also familiar to you.
Olenets Svitlana
Boolean Algebra
• We can use Boolean identities to simplify the function:
as follows:
Olenets Svitlana
• We have looked at Boolean functions in abstract terms.
• In this section, we see that Boolean functions are
implemented in digital computer circuits called gates.
• A gate is an electronic device that produces a result based
on two or more input values.
– In reality, gates consist of one to six transistors, but digital
designers think of them as a single unit.
– Integrated circuits contain collections of gates suited to a
particular purpose.
Logic Gates
Olenets Svitlana
• The three simplest gates are the AND, OR, and NOT gates.
• They correspond directly to their respective Boolean operations, as you can see by their truth tables.
Logic Gates
Olenets Svitlana
Logic Gates
• Gates can have multiple inputs and more than one output.
– A second output can be provided for the complement of the operation.
– We’ll see more of this later.
Olenets Svitlana
Sequential Circuits
Olenets Svitlana
Methods of presentation logic
functions• Logical functions (complex expression) can set in three ways: verbal, tabular
and analytical.
• I. In the verbal mode of presentation affects the function of words and
description should clearly identify all cases where logical arguments take
their possible values: F and T. For example, the function is and if any two
arguments equal and, in other cases F.
• II. Tabular method feeder logic function is a truth table. here with method,
using verbal descriptions, up table, which takes into account all possible
combination of values of logical arguments and function values for each
combination .
• III. Analytical method - a record of the logical functions as an equation that
reach out truth table. Output logic equation is of particular interest because
electronic circuits that apply in computing, built on the basis of pre-
compiled logic equations.Olenets Svitlana
Venn diagrams
• A Venn diagram is a representation of a Boolean
operation using shaded overlapping regions. There
is one region for each variable, all circular in the
examples here. The interior and exterior of
region x corresponds respectively to the values 1
(true) and 0 (false) for variable x. The shading
indicates the value of the operation for each
combination of regions, with dark denoting 1 and
light 0 (some authors use the opposite
convention).
Olenets Svitlana
The AND operator
(both, all)
• rivers AND salinity
• dairy products AND export
AND Europe
Olenets Svitlana
The OR operator
(either, any)
• fruit OR vegetables
• fruit OR vegetables OR cereal
from CSIRO AustraliaOlenets Svitlana
The NOT operator
• fruit NOT apples
Olenets Svitlana
Write out logic statements using
Boolean operators for these.
• You have a buzzer in your car that sounds when
your keys are in the ignition and the door is open.
• You have a fire alarm installed in your house.
This alarm will sound if it senses heat or smoke.
• There is an election coming up. People are
allowed to vote if they are a citizen and they are
18.
• To complete an assignment the students must do a
presentation or write an essay.
Olenets Svitlana
• Computers are implementations of Boolean logic.
• Boolean functions are completely described by truth
tables.
• Logic gates are small circuits that implement Boolean
operators.
• The basic gates are AND, OR, and NOT.
– The XOR gate is very useful in parity checkers and
adders.
Conclusion
Olenets Svitlana