1. Why logic

Why logic?

### What is logic?
**In philosophy:** Logic was formed to "formalise correct argumentation and deduction".
**In mathematics:** Rules of logic are used to distinguish between correct and incorrect mathematical arguments (otherwise known as proofs).

Propositions

Proposition

A proposition is a **declarative sentence** of which we can meaningfully ask whether it is true $(T)$ or false $(F)$.

Sample syntax:

  • Propositional / boolean random variables:
  • Discrete random variables (finite or infinite) Given is one of "" is a proposition
  • Continuous random variables (bounded or unbounded) ; ;
Link to original

  • Notations for true: .
  • Notations for false: .

For example:

  • Today is Monday.

Not declarative:

  • Hi, how are you?

Propositional Logic

Propositional logic is the area of logic which deals with propositions, it is sometimes referred to as boolean logic.

Link to original

  • We use propositional variables, denoted as lower case letters ( or ) to denote propositions whose structure we don’t want to analyse further.
  • We build compound expressions called formulas, denoting compound propositions. They are built from logical connectives and parentheses.

We can define a formula as a compound expression made up of propositions, logical connectives and parentheses.

Link to original

2. Logical connectives

Logical Connectives

Logical connective

A logical connective is an expression used to modify a statement or combine two or more statements.

Negation

Negation

Let be a proposition. The negation of , which is denoted by , is the proposition that "it is not the case that $p$".

TF
FT

For example:

  • Let be that “Today is Tuesday”.
  • means “It is not the case that today is Tuesday”.
    • Or otherwise “Today is not Tuesday” or “It is not Tuesday today”.
Link to original

Conjuction

Conjunction

Let and be propositions. The conjunction of and , denoted by , is the proposition that "$p$ and $q$".

TTT
TFF
FTF
FFF

For example:

  • Let be that “Today is Tuesday”.
  • Let be that “It is raining today”.
  • is that “Today is Tuesday and it is raining today”.
But in English, $p \wedge q$ and $q \wedge p$ do not always mean the same thing.
- "Bob became sick and he visited the doctor."
- "Bob visited the doctor and he became sick."
 
This can be handled by dynamic conjunctions.
Link to original

Disjunction

Disjunction

Let and be propositions. The disjunction of and , denoted by , is the proposition that "$p$ (inclusive) or $q$".

TTT
TFT
FTT
FFF

For example: “Students who have taken either maths of physics A-levels are admitted.”

Exclusive OR

TTF
TFT
FTT
FFF
Link to original

Conditional Statements

Conditional statement

Let and be propositions. The conditional statement , is the proposition that "if $p$ then $q$". This is also called an implication.

TTT
TFF
FTT
FFT

For example:

  • If it is sunny today, we will go to the beach.
  • If I am elected, I’ll lower taxes.
You may encounter some weird statements which are still true.
- "If the Moon is made of green cheese then $2\times2=5$." $(F \rightarrow F)$.
- "If the Moon is made of green cheese then $2\times2=4$." $(F \rightarrow T)$.
- "If London is in the UK then $2\times2=4$." $(T \rightarrow T)$.
  This is also known as irrelevant logic.
Link to original

Biconditional Statements

Biconditional statement

Let and be propositions. The biconditional statement , is the proposition that "$p$ if and only if $q$". This is also called an bi-implication or an equivalence.

TTT
TFF
FTF
FFT
There are some implicit uses of biconditional statements in English, for example:
- If you finish your meal then you can have desert, $p \rightarrow q$.
 
But we actually mean $p \iff q$:
- You can have desert if and only if you finish your meal.
Link to original

Link to original

Link to original

3. Tautologies, Satisfiability and Consistency

Tautologies, Satisfiability and Consistency

Computing truth tables of compound formulas

Given the formula:

  • It has rows as it contains variables.
FFFTFTFTT
FFTFFTFTT
FTFTFTFTT
FTTFFTTTT
TFFTFTFFT
TFTFFTFFT
TTFTTTFFT
TTTFTFTTF

Precedence of logical operators

We have to use parantheses to not create confusion, for example can have two different truth tables depending on how you parse it. To reduce the number of brackets, we agree takes priority, for example means .

Propositional satisfiability

Tautology

A tautology (otherwise known as valid) is a formula that is true under all [[Interpretation|interpretations]], every row in a truth table of a tautology makes it true.

We can denote a tautology by , where is a formula which is a tautology.

TFT
FTT
Given the set of formulas, $\Delta = \{ A_1, A_2, A_3 \}$, provided $\Delta \models \varphi$:
 
$$
	\begin{aligned}
		\Delta &\models \varphi \\
		A_1, A_2, A_3 &\models \varphi \\
		A_1 \land A_2 \land A_3 &\models \varphi \\
		A_1 , A_2 &\models A_3 \rightarrow \varphi \\
		A_1 &\models A_2 \rightarrow (A_3 \rightarrow \varphi) \\
		\emptyset &\models A_1 \rightarrow (A_2 \rightarrow (A_3 \rightarrow \varphi)) \\
	\end{aligned}
$$
Link to original

Contradiction

A contradiction is a formula that is false under all [[Interpretation|interpretations]].

TFF
FTF
Link to original

Satisfiable

A formula is satisfiable if there is an interpretation $v$ that makes the formula $F$ true. We say satisfies .

TF
FT

A set of propositional formulae is satisfiable if there is an interpretation $v$ satisfying every formula in $S$.

Link to original

Consistency

Consistent

A collection of formulas is consistent if: ?

  • Not only each and every formula in the collection is satisfiable.
  • It is possible to find a truth table assignment with the propositional variables in them that make all of the formulas true at the same time.
Link to original

Given the following specifications:
- Message is stored in buffer or it is trasmitted. $p\vee q$
- Message is not stored in buffer. $\neg p$
- Message is stored in buffer then it is trasmitted. $p \rightarrow q$
 
|  $p$  |  $q$  | $p \vee q$ | $\neq p$ | $p\rightarrow q$ |
|:-----:|:-----:|:----------:|:--------:|:----------------:|
|   T   |   T   |     T      |    F     |        T         |
|   T   |   F   |     T      |    F     |        F         |
|  *F*  |  *T*  |   **T**    |  **T**   |      **T**       |
|   F   |   F   |     F      |    T     |        T         |
Link to original

4. Logical equivalence

Logical equivalence

Logically equivalent

Two formulae that have the same truth values in all possible cases are logically equivalent, denoted by .

For example, and .

TTFTT
TFFFF
FTTTT
FFTTT

This is not a logical connective but just a shorthand.

and are logically equivalent if and only if the formula is a [[Tautology|tautology]].

Link to original

List of well-known equivalences

You do not need to memorise these for the exam.

{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[19],
	"scale":1.5
}
Link to original

5. Logically correct arguments

Logically correct arguments

Argument

An argument is a sequence of [[Proposition|propositions]].

You can read ”, therefore ”.

Link to original

Logically correct

An argument is logically correct if in every situation that makes all premises true, the conclusion is true as well.

Link to original

Situation

A situation is a row in the truth table of $p_1, p_2, .., p_n, q$ or otherwise a possible assignment for the propositional variables in $p_1, p_2, .., p_n, q$.

Link to original

Examples

{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[21,22],
	"scale":1.5
}

Rules of inference

Inference rule

An inference rule is a representation of a valid step in a formal proof, indicating the conditions that must be satisfied before a conclusion can be obtained in the proof.

A rule will be presented in the form:

are the premises or conditions of the rule, and is the conclusion.

Informally, “if are true, then is also true.”

Alternatively, we use the syntax:

Link to original

We can always use a truth table to decide whether an argument is correct. This can be very tedious.

If we consider different variables, the truth table requires rows.

Instead, we can establish the correctness of simple argument forms using rules of inference, and then use them to construct more complicated correct arguments.

For example, Modus ponens (the rule of detachment).

Examples

Should practice trying to justify these!
There will be no exam Q in this module for building these, no need to memorise.
{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[24],
	"scale":1.5
}
Link to original

6. Predicate logic basics

Predicate logic basics

Statements involving variables such as:

  • Printer is networked to computer .

Are quite often found in different places but these statements are neither true or false. As well as this, the variables and are not propositional variables but instead denote entities, which are things or objects.

We can formalise "" as where is a variable and is the predicate (property), which in this case is that it is “greater than 3”.

  • By assigning a value (a concrete entity) to the variable, becomes a proposition that has a truth value.
    • means is greater than T
    • means is greater than F
  • We typically use upper case letters () to denote predicates.

To formalise a statement such as "", we use the predicate , where:

  • and are variables.
  • is the predicate connecting two things (otherwise called a binary predicate).
    • “the first number is the sum of the second number and
Link to original

7. Quantifiers

Quantifiers

Quantification is another way of creating a proposition from , it expresses the extent to which a predicate is true over a range of entities, called the domain.

Universal quantifier, .

Universal quantifier

The universal quantification of for a particular domain, denoted by , is the proposition "$P(x)$ is true for all values of $x$ from the domain". $\forall$ means "For all".

  • The truth value of might change if domain changes.
  • Domain must always be specified when universal quantifier is used.

For example, take is "":

  • For the domain of positive integers, .
  • For the domain of all integers, .

To say “Everyone does not like Jane”, we write that for every , does not like Jane:

In general, the notation for universal quantifiers is $(\forall x)(\phi)$ where $\phi$ is a formula in which $x$ and possible other variables may appear.

Link to original

Rules of inference ()

Universal instantiation

A universal instantiation means for each and every entity $c$ in the domain we have a correct inference rule of the form: $$\boxed {\begin{array}{c}\underline{\forall xP(x)} \\P(c)\end{array}}$$

For example,

By universal instantiation, given the premise , we may derive the conclusion , where is any object in the domain:

If holds for all the elements of the domain, it holds in particular for the element as well. Universal instantiation can be seen as -elimination.

Link to original

Universal generalisation

A universal generalisation is $$ \boxed{\begin{array}{c} \underline{P(c) \textsf{ for any arbitrary entity } c \textsf{ in the domain}} \\ \forall x P(x)\end{array}} $$

By universal generalisation, given the premise takes place for a generic object of the domain, we may derive :

The object in the premise of must not be specific but arbitrary, i.e. we cannot make any assumption about other than it comes from the domain. Universal generalisation can be seen as .

Link to original

Existential quantifier, .

Existential quantifier

The existential quantification of for a particular domain, denoted by , is the proposition that "there exists a value for $x$ in the domain such that $P(x)$ is true".

  • The truth value of might change when domain changes.
  • Domain must always be specified when used.

For example, take is "":

  • If the domain is all integers, then it is true.
    • We simply need to give one example, such as then is true.
  • If the domain is the positive integers, then it is false.

To say “(at least one) car is yellow”, we write that for some , is yellow:

In general, the notation for existential quantifiers is $(\exists x)(\phi)$, where $\phi$ is a formula in which $x$ and possible other variables may appear..

Link to original

Rules of inference ()

Existential generalisation

An existential generalisation means that for every entity in the domain, we have a correct inference rule of the form $$ \boxed{ \begin{array}{c} \underline{P(c)} \\ \exists x P(x) \end{array} } $$

For example:

By existential generalisation, given that is known to hold for a particular object of the domain, we may derive :

This can be seen as .

Link to original

There are also deMorgan laws for quantifiers.

{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[32],
	"scale":1.5,
	"rect":[40, 260, 40, 400]
}
Link to original

8. Theorems and proofs

Theorems and proofs

Theorem

A theorem is when a proposition can be shown to be true and is important enough.

Link to original

A proof of a theorem, , is a sequence of propositions ending with :

Such that each and every of the premises is:

  • Either an axiom.
  • Or can be obtained from earlier premises in the sequence by a logically correct argument.

It is said that theorem follows from the axioms.

How are theorems stated

Many theorems assert that a property holds for all entities in a domain. The precise statement must include a universal quantifier, standard convention in mathematics is to omit it.

  • The statement “if , where is a positive integer, then
  • Means that “for all positive integers , if , then
Link to original

9. Direct and indirect proofs

Direct and indirect proofs

Direct Proofs

Used to prove theorems of the form :

  • We choose an arbitrary entity from the domain.
    • Must be arbitrary, not specific but in the domain.
    • We need to use a pointer to refer to it.
    • We can pick any symbol to refer to it.
  • Then we prove the conditional statement for the arbitrary by a direct proof:
    • Assume is true, use axioms, definitions and previously proven theorems, with inferences, to show that then must also be true.
  • We can then apply the rule of universal generalisation.

For example, given the theorem “If is an odd integer, then is odd”, the proof is:

  • Let be an arbitrary integer.
  • Assume is odd.
  • Since is odd, let .
  • Hence,
  • must be odd if is an odd integer.

Indirect Proof

For example, show that at least of any dates in the calendar must fall on the same day of the week. We can try a proof by contradiction, which does not prove a result ‘directly’.

  • Let be “at least of chosen dates fall on the same day of the week”.
  • Suppose that is true, that means “at most of chosen dates fall on the same day of the week”.
  • We know that there are 7 days of the week, this implies at most dates could have been chosen, as for each of the days of the week, at most of the chosen dates could fall on that day.
  • So, if is the statement that ” dates are chosen” then we found that .
  • Using as a premise, we reached a contradiction by showing .
  • We find that is a contradiction, it will always be false.
  • As is true (our premise), can only be false when is false, hence is true.
Link to original

10. Mistakes in proofs

Mistakes in proofs

Example 1

{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[38],
	"scale":1.5
}

Example 2

{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[39],
	"scale":1.5
}
Link to original

11. Proofs by induction

Proofs by induction

To prove a property is true for all positive integers , we:

  • Basis step: Prove that is true.
  • Inductive step: Prove that the conditional statement is true for all positive integers .

To complete the inductive step of a proof by induction,

  • assume that is true for an arbitrary positive integer
  • show that under this assumption, must also be true

The inductive hypothesis (IH) is the assumption that is true.

Example

Show that for every positive integer, , that .

  • Basis step: is true, because .
  • Inductive step: For the inductive hypothesis, we assume that holds for an arbitrary positive integer .

\begin{aligned} \boxed{1 + 2 + … + (k + 1)} &= (1 + 2 + … + k) + (k + 1) \ &\stackrel{\textsf{by IH}}{=} \frac{k(k+1)}{2} + (k + 1) \ &= \frac{k(k + 1) + 2(k + 1)}{2} \ &= \frac{(k + 2)(k + 1)}{2} \ &= \boxed{ \frac{ (k + 1)((k + 1) + 1) }{2} } \end{aligned}

Link to original

12. The Simple Two Colour Theorem

The Simple Two Colour Theorem

title: Not on exam!
{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[43,44],
	"scale":1.5
}
Link to original

13. All horses have the same colour

All horses have the same colour

title: Not on exam!
{
	"url":"[FC1W1 Lecture Slides.pdf](https://git.is.horse/insert/university/obsidian-notes/-/raw/9d95afcbbdb7a4c77ca9f62b32e35c6f31e269e7/University/Year%201/Semester%201/4CCS1FC1%20Foundations%20of%20Computing%201/Week%201.%20Intro%20to%20propositional%20logic%20and%20proofs/FC1W1%20Lecture%20Slides.pdf)",
	"page":[45],
	"scale":1.5
}

Take , substitute into inductive step, find no overlap.

Link to original

15 items under this folder.