Course notes for CS-1382: Discrete Computational Structures. Texas Tech University, Whitacre College of Engineering. Spring 2023.
Key Topics:
Logic is the basis of all mathematical reasoning, and of all automated reasoning. To understand mathematics, we must understand what makes up a correct mathematical argument, that is, a proof. Many people find it surprising how important proofs are in computer science.
Propositional logic is a branch of mathematical logic which studies the logical relationships between propositions taken as a whole, and connected via logical connectives.
A proposition is a declarative sentence (a statement) that is either true or false, but not both.
We use letters to denote propositional variables (or sentential variables)—variables that represent propositions—just as letters are used to denote numerical variables. The conventional letters used for propositional variables are , , , , … .
The truth value of a proposition is true, denoted by T, if it is a true proposition, and the truth value of a proposition is false, denoted by F, if it is a false proposition.
Propositions that cannot be expressed in terms of simpler propositions are called atomic propositions. The area of logic that deals with propositions is called the propositional calculus or propositional logic.
New propositions, called compound propositions, are constructed from existing propositions using logical operators or logical connectives.
Conditional statements (also called an implication) are formed by combining two statements. The statement asserts that is true on the condition that holds.
Converse, contrapositive, and inverse statements can be formed from the conditional statement .
A conditional statement and its contrapositive are equivalent. The converse and inverse of a conditional statement are equivalent, but neither is equivalent to the original statement.
Biconditional statements express that two propositions have the same truth value.
Biconditionals are not always explicit in natural language. In particular, the “if and only if” construction used in biconditionals is rarely used in common language. Instead, biconditionals are often expressed using an “if, then” or an “only if” construction.
We can use the five introduced logical connectives to build up complicated compound propositions involving any number of propositional variables. We can use truth tables to determine the truth values of these compound propositions. Use a separate column to find the truth value of each compound expression that occurs in the compound proposition as it is built up.
Example: For the compound proposition
the truth table is
T | T | F | T | T | T |
T | F | T | T | F | F |
F | T | F | F | F | T |
F | F | T | T | F | F |
Generally, parentheses are used to specify the order in which logical operators in a compound proposition are to be applied. However, to reduce the number of parenthesis, the following rules of precedence are applied.
Operator | Precedence |
---|---|
1 | |
2 | |
3 | |
4 | |
5 |
A bit is a symbol with two possible values, 0
(zero) and 1
(one), and can be used to represent a truth value. Customarily, a 1
bit represents true and a 0
bit represents false. A variable is called a Boolean variable if its value is either true or false.
Computer bit operations correspond to the logical connectives. The notation OR, AND, and XOR correspond to the operators , , and respectively.
A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string. We can extend bit operations to bit strings. We define the bitwise OR, bitwise AND, and bitwise XOR of two strings of the same length to be the strings that have as their bits the OR, AND, and XOR of the corresponding bits in the two strings, respectively.
Statements in mathematics and the sciences and in natural language are often imprecise or ambiguous. To make such statements precise, they can be translated into the language of logic.
Translating sentences into compound statements removes ambiguity and allows us to apply the rules of inference.
System and software engineers take requirements in natural language and produce precise and unambiguous specifications that can be used as the basis for system development.
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.
Puzzles that can be solved using logical reasoning are known as logic puzzles.
A logic circuit receives input signals as bits [0 (off) or 1 (on)] and produces output signals as bits.
Cf. Logic gates
An important step used in a mathematical argument is the replacement of a statement with another statement with the same truth value.
A compound proposition that is always true, no matter what the truth values of the propositional variables that occur in it, is called a tautology. A compound proposition that is always false is called a contradiction. A compound proposition that is neither a tautology nor a contradiction is called a contingency.
Examples of a tautology and a contradiction
T | F | T | F |
F | T | T | F |
Compound propositions that have the same truth values in all possible cases are called logically equivalent.
The compound propositions and are called logically equivalent if is a tautology (if and only if the columns giving their truth values agree).
For example, and are logically equivalent
T | T | F | T | T |
T | F | F | F | F |
F | T | T | T | T |
F | F | T | T | T |
because the truth values of and agree.
Logical equivalences
Equivalence | Name |
---|---|
Identity laws | |
Domination laws | |
Idempotent laws | |
Double negation law | |
Commutative laws | |
Associative laws | |
Distributive laws | |
De Morgan’s laws | |
Absorption laws | |
Negation laws |
The two logical equivalences known as De Morgan’s laws are particularly important. They tell us how to negate conjunctions and how to negate disjunctions.
The negation of a disjunction is the conjunction of negations of the component propositions.
The negation of a conjunction is the disjunction of negations of the component propositions.
The extended version of De Morgan’s laws can be written concisely as
A compound proposition is satisfiable if there is an assignment of truth values to its variables that makes it true (that is, when it is a tautology or a contingency). When no such assignments exist, that is, when the compound proposition is false for all assignments of truth values to its variables, the compound proposition is unsatisfiable.
Propositional logic cannot adequately express the meaning of all statements in mathematics and in natural language. A more powerful type of logic called predicate logic can be used to express the meaning of a wide range of statements in mathematics and computer science in ways that permit us to reason and explore relationships between objects.
The statement ” is greater than 3” has two parts.
The predicate refers to a property that the subject of the statement can have. We can denote the statement ” is greater than 3” by , where denotes the predicate and is the variable.
For example, if denotes the statement ””, then is true because . However, is false because .
Quantification expresses the extent to which a predicate is true over a range of elements. In English, the words all, some, many, none, and few are used in quantifications. The area of logic that deals with predicates and quantifiers is called the predicate calculus.
Statement | When true? | When false? |
---|---|---|
is true for every . | There is an for which is false. | |
There is an for which is true. | is false for every . |
Many mathematical statements assert that a property is true for all values of a variable in a particular domain. Such a statement is expressed using universal quantification. The domain must always be specified when a universal quantifier is used; without it, the universal quantification of a statement is not defined.
The universal quantification of is the statement ” for all values of in the domain.”
The notation
read “for all ”, denotes the universal quantification of .
Many mathematical statements assert that there is an element with a certain property. Such statements are expressed using existential quantification. With existential quantification, we form a proposition that is true if and only if is true for at least one value of in the domain.
The existential quantification of is the proposition “There exists an element in the domain such that .”
The notation
read “for some ”, denotes the existential quantification of .
When the domain of a quantifier is finite, quantified statements can be expressed using propositional logic. When the elements of the domain are
Negation of a universal quantifier
Negation of an existential quantifier
Example: Express the statement “Every student in this class has studied calculus.”
Example: Express the statement “Some student in this class has visited Mexico.”
A nested quantifier is where one quantifier is within the scope of another. The rules studied in Section 1.4 can help to use them.
The statement says that for every real number there is a real number such that .
The order of the quantifiers is important, unless all the quantifiers are universal quantifiers or all are existential quantifiers.
Example: Let be the statement . The quantifications and have the same meaning and both are true.
Example: Let be the statement . The quantification is false because no matter what value of that is chosen, there is only one value of for which . However, the quantification is true because given any value of , there is a value of for which .
Express the negation of a statement so that no negation precedes a quantifier by successively applying De Morgan’s laws for quantifiers. Doing so moves the negation inside all the quantifiers.
Before we study mathematical proofs, we will look at arguments that involve only compound propositions. We will define what it means for an argument involving compound propositions to be valid. Then we will introduce a collection of rules of inference in propositional logic. These rules of inference are among the most important ingredients in producing valid arguments.
After studying rules of inference in propositional logic, we will introduce rules of inference for quantified statements. Finally, we will show how rules of inference for propositions and for quantified statements can be combined.
An argument in propositional logic is a sequence of propositions. All but the final proposition in the argument are called premises and the final proposition is called the conclusion. An argument is valid if the truth of all its premises implies that the conclusion is true.
An argument form in propositional logic is a sequence of compound propositions involving propositional variables. An argument form is valid if no matter which particular propositions are substituted for the propositional variables in its premises, the conclusion is true if the premises are all true.
Using a truth table to show that an argument form is valid can be a tedious approach. Instead, we can first establish the validity of some relatively simple argument forms, called rules of inference. These rules of inference can be used as building blocks to construct more complicated valid argument forms.
Rule of Inference | Tautology | Name |
---|---|---|
Modus ponens | ||
Modus tollens | ||
Hypothetical syllogism | ||
Disjunctive syllogism | ||
Addition | ||
Simplification | ||
Conjunction | ||
Resolution |
When there are many premises, several rules of inference are often needed to show that an argument is valid.