Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Two-valued logic: Operators
1. Two-valued logic: Operators
2. Relating values

Remember the following.
true is always true,
true can never be false,
false is always false, and
false can never be true.
3. 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.).
4. True expressions (formulas)
The following are
true expressions.
true
true Eqv true
true Neqv false
false Eqv false
false Neqv true
5. False expressions (formulas)
The following are
false expressions.
false
true Neqv true
true Eqv false
false Neqv false
false Eqv true
6. 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.
7. Logical negation
8. 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.)
9. Sets and Venn diagram

Logical negation (i.e., "
Not") is related to the complement operation of sets.
10. Complement
Here is a mathematical definition of complement.

Question: What is the opposite of not in?
11. 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.
12. 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".
13. Conjunction
The conjunction of two planets happens when the two planets are both inline with the sun.
Example: Conjunction of Venus and the Earth.
14. Logical conjunction
A logical conjuction is true of both operands are true.
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.)
15. Natural language
Logical conjunction is the same as the natural language "and".
The natural language "and" is the same as the logical "and".
Example: To graduate, you must take and pass both CS201 and CS340 (and some others, ignored here)
That is, you must take both courses.
16. Sets and Venn diagram

Logical conjunction (i.e., "
And") is related to the intersection operation of sets.
17. Set intersection
Here is a mathematical definition of set intersection.
18. 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.)
19. Sets and Venn diagram

Logical disjunction (i.e., "
Or") is related to the intersection operation of sets.
20. Set union
Here is a mathematical definition of set union

21. 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?
22. 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".
23. Exclusive or
The logical "or" is logical disjunction.
The natural language "or" is an exclusive "or", or nonequivalence.
24. 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?
25. 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).
26. 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?
27. End of page
28. Multiple choice questions for this page
53 questions omitted (login required)