Send
Close Add comments:
(status displays here)
Got it! This site "creationpie.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. Note: This appears on each machine/browser from which this site is accessed.
Two-valued logic: Operators
1. Relating values
Remember the following.
true is always true,
true can never be false,
false is always false, and
false can never be true.
2. Operators
Here are two simple operators.
"Eqv" means "is equal to" (equivalence)
"Neqv" means "is not equal to" (nonequivalence)
These operators are relational operators as they relate quantities, as opposed to being logical operators (and, or, not, imply, etc.).
3. True expressions (formulas)
The following are
true expressions.
true
true Eqv true
true Neqv false
false Eqv false
false Neqv true
4. False expressions (formulas)
The following are
false expressions.
false
true Neqv true
true Eqv false
false Neqv false
false Eqv true
5. Logical operations
There are three primary logical operations.
Logical negation (i.e., Not, "Not", etc.) means not.
Logical conjunction (i.e., And, "And", etc.) means both.
Logical disjunction (i.e., Or, "Or", etc.) means one or the other or both.
Some other common logical operations include the following.
Logical equivalence or equals (i.e., Eqv, "Eqv", etc.) means both operands are the same.
Logical nonequivalence or exclusive or (i.e., Xor, "Xor", etc.) means both operands are different.
6. Logical negation
7. Logical negation
Logical negation returns the opposite of the operand.
Not True is False
Not False is True
Some other symbols for
Not:
¬ (math notation)
! (C-based languages)
not (Python, Lua, Pascal, etc.)
8. Sets and Venn diagram
Logical negation (i.e., "
Not") is related to the complement operation of sets.
9. Complement
Here is a mathematical definition of complement.
Question: What is the opposite of not in?
10. Opposite of not in
The opposite of not in is in
"in" is the opposite of "out".
"out" is the meaning of "not in".
So, "in" is the opposite of "not in".
See how easy it is to get mixed up, if you are not careful. Remember not to forget that!
11. Self-reference
Is the following sentence
true or
false?
This sentence is false.
This is a self-referential statement since it refers to itself.
Self-referential statements can cause logical problems (i.e., paradoxes).
Is "
no" your answer to this question? Answer either "
yes" or "
no".
12. Logical conjunction
The English word
"conjuction" comes, through French, from the Latin word
"coniungere" ≈ "join".
The logical
conjunction or
intersection of two operands is true if (and only if) both operands are true. The logical conjunction "
and" is the
same as the natural language "
and".
Example: To graduate, you must take and pass
both MA101 (Math 101)
and EN101 (English 101) and some others, ignored here. That is, you must take both courses to graduate.
Conjunction can be extended to any number of operators. There are other logical operators for two-valued logic that are not needed here.
13. Conjunction
The
conjunction of two planets happens when the two planets are both in-line with the sun.
Example:
Conjunction of Venus and the Earth.
14. Twins
Conjoined twins are born joined at some part of their body.
15. Pleiades and Orion
Job 38:31 Canst thou bind the sweet influences of Pleiades, or loose the bands of Orion? [kjv]
συνηκας δε δεσμον πλειαδος και φραγμον ωριωνος ηνοιξας [lxx]
… coniungere … Pliadis … Arcturi … [v]
The logical
conjunction of two operands is true if (and only if) both operands are true. The English word
"conjuction" comes, through French, from the Latin word
"coniungere" ≈ "join".
The
LXX (Septuagint) uses the word "
and" for
conjunction while the English uses "
or" for
disjunction. Most translations use the word "
or" or omit any use of "
and" or "
or" (e.g., the
NIV (New International Version)).
16. Job 38:31
KJV: Canst thou bind the sweet influences of Pleiades, or loose the bands of Orion?
Hebrew: התקשר מעדנות כימה או משכות כסיל תפתח׃
Greek: συνηκας δε δεσμον πλειαδος και φραγμον ωριωνος ηνοιξας
Latin: numquid coniungere valebis micantes stellas Pliadis aut gyrum Arcturi poteris dissipare
Wycliffe: Whether thou schalt mowe ioyne togidere schynynge sterris Pliades, ethir thou schalt mowe distrie the cumpas of Arturis?
Luther: Kannst du die Bande der sieben Sterne zusammenbinden, oder das Band des Orion auflösen?
17. Pleiades and Orion
18. Logical conjunction
Logical expressions deal with how the logical values
True and
False are combined.
False And False is False
False And True is False
True And False is False
True And True is True
Some other symbols for
And:
∧ (math notation), ∩ (set notation, intersection)
&& (C-based languages , & is the bitwise conjunction)
and (Python, Lua, Pascal, etc.)
19. Conjunction
The
conjunction or
intersection of
A & B or
A and B is
true=
1 if
both of
A and
B are true=
1, else the result is
false=
0.
20. Conjunction
The word "
and" is a conjunction in that both parts (on either side) are needed.
Example: You need to buy milk
and cookies at the store.
Distribute as follows.
You need to buy milk at the store and
you need to buy cookies at the store.
You need to do both.
21. Sets and Venn diagram
Logical
conjunction (i.e., "
And", "
&", etc.) is related to the
intersection operation of sets.
Here is a mathematical definition of set intersection.
Note how the set intersection operator "
∩" and the logical conjunction symbol "
∧" are related. They are wide at the bottom and narrow/close at the top. This did not just happen. They are related.
22. And operator
|
A B | A & B
-----------
0 0 | 0 0 0
0 1 | 0 0 1
1 0 | 1 0 0
1 1 | 1 1 1
Here is the extended truth table using 0 for false and 1 for true.
|
Here is a tree diagram for the conjunction of logical values A and B. Values flow up the tree.
|
The result (under the operator "&") is true or 1 only if both A and B are 1 or true.
|
23. Short circuit evaluation: Nothing is something
Short circuit evaluation comes from the idea that, logically, the conjunction of
A and
B is
false if either
A is
false or
B is
false.
If one evaluates
A and it is
false, one need not even look at
B to determine that the conjunction is
false.
If one evaluates
B and it is
false, one need not even look at
A to determine that the conjunction is
false.
The order does not matter!
This follows a general principle in computer science and logic and reasoning that there are times when one can determine that one need not even bother (spend time) looking (which takes time and resources).
24. Logical disjunction
Logical disjunction is true if either or both operands are true.
False Or False is False
False Or True is True
True Or False is True
True Or True is True
Some other symbols for
Or:
∨ (math notation), ∪ (set notation, union)
|| (C-based languages , | is the bitwise conjunction)
or (Python, Lua, Pascal, etc.)
25. Sets and Venn diagram
Logical disjunction (i.e., "
Or") is related to the intersection operation of sets.
26. Set union
Here is a mathematical definition of set union
27. Natural language
Logical disjunction is not the same as the natural language "
or", which is an exclusive "
or" and not an inclusive "
or".
Question: Would you like a piece of pie or a piece of cake?
28. Pie or cake
A logical answer is, "
Yes", That is, I would like either a piece of pie, or a piece of cake, or both. I'll take both.
The natural language answer is to pick one of the two, but not both.
As a consequence, you must always be careful when using the word "
or".
29. Exclusive or
The logical "or" is logical disjunction.
The natural language "or" is an exclusive "or", or nonequivalence.
30. Query
The query command is something like "
find all pages that contain the specified text".
Search engines on the Internet allow logical operations to be used to limit the search criteria.
Question: When might we need more than two values for logical questions?
31. Multi-valued logic
In a modal dialog box, the user may need to decide between yes, no, and some other choices.
A program that requests a user response to a question. Very often, the valid responses are
yes,
no, and
escape (gracefully avoid the question).
32. Multi-valued logic
Determining the sign of an integer, which can be
positive,
negative, or
zero (neither positive nor negative).
How many choices were there for Paul Revere's famous ride?
33. Disjunction
How do you reply what asked
if you would like a piece of pie
or a piece of cake?
Exclusive "or": Pick one and only one.
Inclusive "or": Pick one or both. I will take both.
Most people are used to
exclusive "or".
Computer programmers take the
"or" as a "
logical" or "
inclusive"
"or". The
negation of a conditional (statement) is needed with an
inclusive "or" in order to address the
something else of the conditional (statement).
34. End of page