Logic

See disclaimer about the slides.
See learning objectives and sources.

Proposition (definition)

A statement either true or false.

Proposition (examples pos. and neg.)

Today is Monday.
3 = 7.
What time is it?
Give me some chocolate.

Connectives

Operators that make propositions from other proposition, e.g., "today is monday AND 3 = 7."

connectives_1.jpg

Connectives are defined by truth tables. Show meaning during lecture.

truth-table_1.jpg

Propositional calculus

Evaluate the following propositions for all the assignments of $A$ and $B$:
$A \land (\lnot B)$
$A \to (B \lor A)$
$A \oplus (A \land B)$
(show method/computation during lecture).

Problems

How many distinct connectives with 1 or 2 arguments there can be?
Which connectives are there in you favorite programming language?
What are their attributes (identifier, precedence, associativity)?
How are they evaluated?

An application

This is for testers. Consider the following fragment of code (in which language?):
	if (x && y) || (!x && y) {
	  function_1();
        } else {
	  function_2();
        } 
determine the assignments (of $x$ and $y$) that execute function_1 and those that execute function_2.
Can you simplify the code (tricky)?

Tautology, Contradiction, Contingency

Tautology: proposition true for any assignment.
Contradiction: proposition false for any assignment.
Contingency: proposition not above.

Example of tautology: $p \lor \lnot p$.
Example of contraction: $p \land \lnot p$.
(show why during lecture).

Logical Equivalence

Two propositions that have the same value for all assignments, e.g., $p \to q \equiv \lnot p \lor q$.
Some famous equivalences are the De Morgan's Laws:
$\lnot (p \lor q) ≡ \lnot p \land \lnot q$
$\lnot (p \land q) ≡ \lnot p \lor\lnot q$
(prove equivalence during lecture).

Conditional Propositions

The expression $p \to q$ is called conditional
$p$ is the antecendent or hypothesis
$q$ is the consequent or conclusion
$q \to p$ is called converse
$\lnot q \to \lnot p$ is called contrapositive
A conditional and its contrapositive are logically equivalent.
(prove equivalence during lecture).

Predicate

A statement contaning variables, e.g., $x = 7$.
The truth typically depends on the assignment of the variables.
Each variable is intended of the appropriate type.
Variables are quantified (either ''for all'' or ''there exists'') not discussed in this course.

Proofs

Axioms: assumed propositions.
Undefined terms: primitive/assumed concepts.
Definitions: concepts from other concepts.
Theorem: proposition with proof.

Classes of Proofs

Direct
Indirect (contrapositive)
Exhaustive
Contradiction

Example

If $x$ is even, then $x^2$ is even.
If $x^2$ is odd, then $x$ is odd.
There is a prime number between 20 and 25.
The product of two of the numbers $65^{1000} − 8^{2001} + 3^{177}$, $79^{1212} − 9^{2399} + 2^{2001}$, and $24^{4493} − 5^{8192} + 7^{1777}$ is nonnegative.
(show proofs during lecture).

Rules of inference

Argument: sequence of propositions $p_1,p_2,\ldots p_n$ (hypotheses) followed by proposition $q$ (conclusion).
Valid argument: $q$ is true whenever $p_1,p_2,\ldots p_n$ are true.
Rule of inference: simple valid argument (show with table).
Some examples:

$\frac { \begin{array}{@{}c@{}} \mbox{$p \to q$} \\[-1ex] \mbox{$p$} \end{array}} {\mbox{$\therefore ~ q$}}$ modus ponens

$\quad\quad \vdots$

$\frac { \begin{array}{@{}c@{}} \mbox{$p \lor q$} \\[-1ex] \mbox{$\lnot p \lor r$} \end{array}} {\mbox{$\therefore q \lor r$}}$ resolution