SmithLogo

CSC 250

Theory of Computation

Smith Computer Science



Lecture Notes 02: Intro to Logic and Proofs


Outline

This class we'll discuss:




Bird's eye view

Remember: we will have to convert real-life problems to language (symbols, operators, delimiters, quantifiers,...) so we can talk about them, and hopefully solve them, in the abstract.

So... we must agree on some rules about symbol manipulation and drawing conclussions. That is why we'll discuss how to argue a point in such a way that it leaves no room for "comebacks"/"clapbacks"/"retaliation", etc ... in short: in such a way it does not leave the door open for a counter argument.




Logic and Logical Thinking



Activity 1 [2 minutes]: What is Logic and logical thinking?
One possible answer:
(Wait; then Click)

The process of obtaining a conclusion from a set of propositions taken to be true.



Two Examples

  1. Easy one:
    • Dogs are better than Cats (Proposition or Premise A)
    • Cats are better than Parrots (Proposition or Premise B)
    • Therefore: Dogs are better than Parrots (Proposition or Conclusion C)

    Note that since we've determined that "All Dogs are better than Parrots"
    we can now use this as another proposition.


  2. A Difficult one:
    • If Yak barks, I can't work
    • If I can't work, students are assigned no homework
    • If students have no homework, students are happy
    • Students are happy
    • Therefore: \( ??? \)
we'll analyze these and more examples using some structure.

Activity 2 [2 minutes]: if we just use English to analyze the material, what could go wrong?
One possible answer:
(Wait; then Click)

Ambiguity!.

Example:

If a waiter asks: "Would you like a burger or a hotdog?"
You could answer: "Yes".

Where is the linguistic issue in this exchange?

Other issues: language artifacts, like contronyms (dust, clip, fast), or
homonyms ( "Buffalo buffalo buffalo Buffalo buffalo").



We need to use some structure to keep track of and operate with propositions that are unambiguous.

For this, we'll use some agreed-upon terminology.

As an alternative mode of visualizing the concepts, whenever possible,
we'll make use of Venn Diagrams.




Terminology



Propositional Logic

The process by which we can combine propositions, in a logical computation, to obtain valid conclusions
OR
with which we can detect errors in the logical computation and refute a conclusion.



Activity 3 [2 minutes]: how do we combine propositions?




Logical Operators

In this section we'll discuss logical operators, which are rules that indicate the resulting effect on a proposition or a set of propositions when operated upon.



Negation

The negation operator, symbol: \( \neg \), AKA NOT, is a unary operator and it refers to the opposite truth value of a proposition.

We can show the effect of this operator using a table:

p ¬p
True False
False True
   another view:   
p ¬p
1 0
0 1


Negation

Example: I am not Swedish.
Note: other symbols you might see are: \( \neg p \text{, } \sim{p} \text{, } \bar p \text{, } !p \).



Conjunction

The conjunction operator, symbol: \( \wedge \), AKA AND, is a binary operator; it is true if and only if both of its operands are true.

We can show the effect of this operator using a table:

p q p∧q
False False False
False True False
True False False
True True True
   another view:   
p q p∧q
0 0 0
0 1 0
1 0 0
1 1 1


Conjunction
Note that we're labeling on the outside for clarity, but the label refers to the interior of each circle

Example: I am walking and chewing gum.
Note: other symbols you might see are: \( p \wedge q \text{, } p\cdot q \text{, } p\&q \).



Disjunction

The disjunction operator, symbol: \( \lor \), AKA OR is a binary operator; it is true if any of its operands is true.

We can show the effect of this operator using a table:

p q p∨q
False False False
False True True
True False True
True True True
   another view:   
p q p∨q
0 0 0
0 1 1
1 0 1
1 1 1


Disjunction

Example: I want a burger or a hotdog.
Note: other symbols you might see are: \( p\lor q \text{, } p+ q \text{, } p\mid q \).



Exclusive Disjunction

The exclusive disjunction operator, symbol: \( \oplus\), AKA XOR is a binary operator; it is true if its operands are different.

We can show the effect of this operator using a table:

p q p\( \oplus \)q
False False False
False True True
True False True
True True False
   another view:   
p q p\( \oplus \)q
0 0 0
0 1 1
1 0 1
1 1 0


Exclusive Disjunction

Example: No equivalent in the english language... or is there? (** suspenseful music **)
Note: other symbols you might see are: \( p\nleftrightarrow q \text{, } p\veebar q \text{, } p\not\equiv q \).




Compound Propositions

We can combine these building blocks to make arbitrarily complicated propositions:

\[ (p \wedge ¬q) \lor (\neg p \wedge q) \]

Activity 4 [2 minutes]: What is this saying?



More operators: Implication

Implication, symbol \(\rightarrow\), AKA IMPLIES, is a binary operator that states that:
IF p is true, then q must also be true

We can show the effect of this operator using a table:

p q p\( \rightarrow \)q
False False True
False True True
True False False
True True True


Think of the whole statement as a promise;
You only "tag" it as FALSE when you break the promise.


Rows 3 and 4 are the "normal" ones:
But what is happening in rows 1 and 2?
Rows 1 and 2 are True because they "technically" are not breaking the promise. We call the Truth value of these statements "Vacuous Truths"


Examples: The left of the \(\rightarrow\) operator in an implication is called the antecedent, and the sentence to the right is called the consequent.

The best way to remember the way implication works is with this statement:
The truth value of an implication is false if and only if its antecedent is true and its consequent is false; otherwise, the truth value is true.

Activity 5 [2 minutes]: Can you draw the Venn Diagram for this one?
(Wait; then Click)

Implication



More operators: If and only if

If and only if, symbol \(\Leftrightarrow\), AKA IFF, is a binary operator that states that:
IF p is true, then q must also true, and IF q is true, then p must also true!

We can show the effect of this operator using a table:

p q p\( \rightarrow \)q p\( \leftarrow \)q p\( \Leftrightarrow \)q
False False True True True
False True True False False
True False False True False
True True True True True


Activity 6 [2 minutes]: Can you draw the Venn Diagram for this one?

If you look at the p, q, and p\( \Leftrightarrow \)q columns, you might see something that looks familiar


One possible answer:
(Wait; then Click)

if and only if




Inference

Inference is the process of obtaining logical consequences from premises.

Let's use an example:

if and only if


Activity 7 [2 minutes]: What can you infer if you do not hear a honk?

You can assume that
  we have a driver behind us;
  the driver saw the sign;
  they have a working horn
  people in this town take bumper stickers seriously



Symbolic manipulation

For some problems, holding the information in our head and making sense of it is quite hard.
Luckily, we have been building a symbolic language that can take the place of "thoughts that make sense so far" so that
we can continue doing our logical computation.



Precedence

We have accumulated some symbols:

when several of the same operator are in a row (i.e. \(a ∧ b ∧ c\)), evaluate from left to right.

(There are a couple of cases where this is not true, but we won't look at those here)



Curious Constructions: Tautology


Activity 8 [4 minutes]: What can you tell about the following proposition?

\[ (p \lor q) \wedge (\neg q) \rightarrow p \]

Answer below

Enter the password to proceed:






p q p ∨ q ¬q (p ∨ q) ∧ (¬q) (p ∨ q) ∧ (¬q) →p
0 0 0 1 0 1
0 1 1 0 0 1
1 0 1 1 1 1
1 1 1 0 1 1


A Tautology is an assertion that is always true.
In its most basic form, it is: \[ q \lor \neg q \]



Curious Constructions: Contradiction


Activity 9 [1 minute]: What can you tell about the following proposition?

\[ q \wedge \neg q \]

answer:
(Wait; then Click)

This proposition is always false!




A Convincing Argument

In spoken English we talk of "making a point".

We usually "grant" said point when the person has made a convincing argument or revealed an unforeseen truth.

As we mentioned before, using English leaves you exposed to ambiguity, contradictions, or language artifacts.

In propositional logic, we can create a convincing argument using propositional logic by chaining together a series of boolean statements until we get to the desired conclusion.



A Logic puzzle

Aleks, Benita, Chas, and Dora are quadruplets, and they’ve all been invited to a birthday party. Unfortunately the quadruplets don’t get along very well:

Activity 10 [4 minutes, if we have time]: What is the largest possible number that will go to the party?




Proofs

We will see a very high-level intro to three types of proofs:



Direct proof deduction

To quote Wikipedia: "Deductive reasoning goes in the same direction as that of the conditionals, and links premises with conclusions. If all premises are true, the terms are clear, and the rules of deductive logic are followed, then the conclusion reached is necessarily true."

Example:



Proof by Contradiction

Start by assuming (taking as a true proposition) the opposite of what you wish to prove.
Follow the normal rules of propositional logic and if:



Example:
Let's say we want to prove that: "there is no smallest rational number greater than 0"
Using proof by contradiction, we say:



Proof by Contrapositive

If we take an implication proposition as true, there is another proposition we can extract from it by performing some manipulations:

To obtain the contrapositive of a proposition, we:

So if we have have the proposition \( p \rightarrow q \), then, the steps are:

So, both \( p \rightarrow q \) and \( \neg q \rightarrow \neg p \) are true.

Example:
Let's say we accept that: "For any integer k, if 3k + 1 is even, then k is odd."

We could represent this symbolically: An example of a full proof by contrapositive would be:

Proof: We will prove the contrapositive of this claim, i.e. that for any integer k, if k is even, 3k + 1 is odd.
Suppose that k is an integer and k is even. Then, k = 2m for some integer m.
Then 3k + 1 = 3(2m) + 1 = 2(3m) + 1.
Since m is an integer, so is 3m. If we say n = 3m, Then 2(3m) + 1 = 2n + 1, which is an odd number.
This means 3k + 1 = 2(3m)+1 = 2n + 1 = an odd number, which is what we needed to show.

Example from the University of Illinois Urbana-Champaign, CS173


Activity 11 [4 minutes, if we have time]:
Prove the following statement: "Theorem: For any \(n \in \mathbb{Z}\), if \(n^2\) is even, then \(n\) is even."




Logical Errors

Activity 12 [4 minutes, if we have time]:
What is wrong with this statement:

If the weather is stormy, we can’t go swimming.
If we can’t go swimming, we won’t go to the beach.
We aren’t at the beach.
Therefore, the weather must be stormy.



Converse

The converse of an implication is is the result of inverting the direction of the implication, so if:
\( p \rightarrow q \)

The converse would be:
\( q \rightarrow p \)

The error would be in believing that just because an implication is true, its converse is too.

Example:
"Petting dogs makes me happy.
"I am happy, therefore I am petting a dog"
OR (Jordan's example!) "Being happy makes me pet dogs."



Inverse

The inverse of an implication is is the result of inverting (negating) its propositions while maintaining the direction of the implication, so if:
\( p \rightarrow q \)

The inverse would be:
\( \neg p \rightarrow \neg q \)

The error would be in believing that just because an implication is true, its inverse is too.

Example:
"Petting dogs makes me happy.
"I am not petting a dog, therefore I must not be happy"

Activity 12 [4 minutes, if we have time]:
Think about the following "puzzle":

A prosecutor in Logic Court (which is totally a thing) says to the defendant:
"If you committed the crime, then you must have had an accomplice" (this is known).
The defendant hotly denies that the implication is true.

Therefore, the jury (being apt logicians) convicts the defendant.

Explain what happened in this story.






Homework


[Due for everyone]: Go over any exercises we did not do in class (participation opportunity next class!)
Bring me questions and be ready to work in groups.

Before next Week's Thursday 09/15 at midnight EST


Note: (we'll normally try to do Assign: Wednesday; Due: Next Tuesday)
[Due for everyone] Problem Set 1



Submitting Assignments in Latex using Overleaf

Overleaf is an online LaTeX editor.

What is LaTeX? you ask.
From https://www.latex-project.org/:

"LaTeX is a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation. LaTeX is the de facto standard for the communication and publication of scientific documents."

a lot of geeks like me (and you, soon enough)


How to Learn LaTeX?

I will provide templates for every Assignment where you only need to fill-in what your answer is. Whether it is text-only, text with mathematical symbols, equations, or even diagrams, there is a way to do it in overleaf.

Follow this Oveleaf guide to learn LTeX in 30 minutes.

Overleaf has a set of quicklinks on the right side that have most (if not all) of what you'll need. Some of the most important things are the symbols!.

Later on, we'll use the FSM designer to make nice digrams like the ones shown below.

How to get started with A1?

I gave you a template in Moodle. The template is a Zip of a tex file, which holds the latex source code for A1. What you do is 1) download the zip, and 2) without unzipping, upload it to Overleaf (additional help/tutorials will be linked in mModle).


Overleaf lets you add a little bit of metadata info to a document to make it look better: