Introduction to Propositional and First Order Logic

## **Part 1** ~ What is language?

「The limits of my language are the limits of my world.」
*~ Ludwig Wittgenstein*
Language is all around us. Words are all around us. Every word has a meaning attached to it, a definition. But sometimes a word or phrase can have multiple meanings. If I said “the pilot was good but the power went out” it would be bad for a TV show and horrible for a plane ride. Sometimes too, the same meaning has multiple words to describe it. As a case in point think of the thousands of ways to say "hello" based on your language! There are estimated to be over 3,000 languages, so for this single idea there are 3,000 ways to describe it.

Natural language, the language *we* use to communicate, is inherently full of double meaning and ambiguity. There is always a gap between what is said and what is meant, and this gap is meant to be bridged by intuition, context, and common sense. But in mathematics, we take nothing for granted. Common sense isn’t enough to prove something is true in mathematics. Like a court case that requires real evidence, we need mathematical evidence. The lawyers of mathematics have furnished this evidence. So what is?

The evidence something in math is true lies in the *language of mathematics*, but this language can’t be like natural language. It can’t be vague. It must be *so* precise and *so* formal that we know exactly what we’re talking about when we put down a 'word', or string of symbols. This language is logic. But what is logic?

## **Part 2** ~ What is logic?[Part I:Propositions]

「What is logic? Baby don't hurt me, don't hurt me, no more.」
*~ Haddaway in Parallel Universe*
The basis of mathematical logic lies in what is called a proposition. But what is a proposition? When you hear the word proposition, you may be thinking of it in the context of asking someone for something. Namely, “I have a proposition for you, a proposal” But is *this* what mathematicians mean when they speak of propositions? No. To a mathematician, a proposition is a declarative statement which is either true or false. Examples of propositions would be statements such as “3 + 3 = 9” and “the Washington Monument is 555 feet tall”. While you may say that only one of these propositions is true, both of them are propositions because they both are only either true or false. Statements which are not propositions are iffy statements like “a random number between 1 and 10 will be prime”. If the number is randomly chosen then sometimes it will be prime, but sometimes it will not. This statement has no clear true or false value, so it is not a proposition.

In logic, we do something similar to algebra. In algebra, we use letters as variables, to stand in for numbers that we do not know. So too, in the logic of propositions, or propositional logic, we frequently use capital English letters as variables, to stand in for propositions which could be anything.

```
Propositions: A, B, C, D, E, F, . . .
Not Propositions: 😋, ♣, ﬕ, ☎, . . .

```

These propositions are the building blocks, or bricks, of logic. Now a brick wall needs mortar to stand up, otherwise it would be loose bricks which come tumbling down. So what do we use to connect these bricks - these propositions? This is the logical connective, or the glue, the mortar, that connects propositions. What are they and how do they work?

Well remember that a proposition is only true or false. We can write out all possible values very easily, there’s just two of them.

Truth Values of a Proposition

But now think - how many different ways could we manipulate these truth values? Maybe we want to flip every value, turn the true into the false and the false into the true. This gives us a new proposition which is always the opposite of the proposition it’s built from. To be specific, the proposition “not A”, denoted either with a tilde ~ or with the bent pipeline ¬ will always be the opposite of A.

Negation Operator

If A is true then not A will be false and if A is false then not A will be true. If propositions were coins, then flipping the coin would be like finding out if the proposition is true or false, and finding the negation of this would be like turning the already flipped coin over. For example, the proposition “3 + 3 = 9” is false, but the negation of this proposition is *true*, because true is the opposite of false.

But is this the only way to change around the truth values of a single proposition? There are two possible truth values, and each one of these we could map to either a true or false value, meaning there are 2 to the power of 2, or 4, possible ways we can change a single proposition. I’ve covered negation, but there are three other ways.

There is the always true operator, denoted with a T for truth, which forms a new proposition that is always true regardless of whether the proposition it is based on is true or false. For example, if I said “a thirty foot penguin has been found stalking the plains of the Gobi desert” you know this is obviously false, but if we apply the always true operator, the new proposition will always be true. This does not mean the original proposition has somehow become true, but only that we formed a new proposition from this always true operator. Every time you use an operator you get another proposition.

Always True Operator

There is the always false operator, denoted with an F for false. It forms propositions that are always false regardless of whether the proposition it is based on is true or false. For example, if I said “the sky is blue” you know this is obviously true, but if we apply the always false operator, the new proposition will always be false.

Always False Operator

Then there is the simplest of these four operators, which is just the identity operator. It simply returns the truth value of the proposition it's based on. It is the proposition itself.

Identity Operator

Now the four operators I've covered *are* actually logical connectives, it's just that they only work on one proposition and do not connect more propositions together. These are called *unary* (or "one-like") connectives. It's like putting a glob of mortar on a brick. So now let's grab another brick and deal with *binary* (or "two-like") connectives, or operators which change the truth value of two propositions to make a new proposition. Recall that with connectives, every new jumble of propositions and connectives is still just one new proposition.

With two propositions A and B, you can use the wedge symbol ∧ or ampersand symbol & to denote the *and* connective, A∧B or A&B. This proposition is true *when and only when* the two propositions A and B are both true. If either A or B is false then A∧B will not be true.

And Connective

The logical meaning of "and" is equivalent to the linguistic meaning. It means both things A and B must be true for the statement "A *and* B" to be true.

Another extremely common binary connective is the *or* connective, denoted with a v sign ∨. A∨B is to be read as "A *or* B" and forms a proposition which is true if either A or B is true. If they are both true then A∨B still returns true.

Or Connective

We can note that some propositions formed from the combination of existing connectives are true no matter what, such as "A or not A".

Proving A∨¬A is Always True
 A∨¬A | True | True

Propositions with this unusual property of being true no matter what truth values their component propositions are, are called *tautologies*. In the Greek this means "repeating what has been said." If someone repeats something to you and you already know it, you might go "but everyone knows that." This is the essence of a tautology. Like a statement so obvious that everyone is assumed to know it, it is a mathematical statement which is true right off the bat. Tautologies are true because of their *logical form*, or the *way* the propositions and connectives are put together.

Another tautology is TA, where T is the unary connective we discussed earlier.

So far we've covered the and, or connectives. There are two more binary connectives that appear frequently in mathematics, and they are the *implication* and *biconditional* connectives. The implication connective is denoted with a right pointing arrow ⇒ and A⇒B is to be read "A implies B". This means that A⇒B is true only when A is true and B is true, or when A is false and B is either true or false. It is never true when A is true and B is false, because the connective ⇒ mirrors the way real world implication happens, and hence it's name. But how so?

Let's say you had a dog. They are a nice dog. But they are also a dog that loves to eat. If they whimper at you and give you the look where they put their chin up and the eyes get all big, then that implies they are hungry. Let's say this is always true, because you know your dog well. There is no situation in which your dog will beg then not be hungry, but there might be situations where your dog *does not* beg and yet is still hungry. After all, there are other ways to beg than to whimper and maybe the dog won't go through the whole show each time. We can make a chart showing the possibility and impossibility of these scenerios:

Canine Implication Chart

The implication connective itself is purely mathematical. It does not literally assume these values because implication works in this way, but it's only named after implication. The connective is the same thing as the hungry dog scenerio but with the names switched out:

Implication Connective

The last connective which appears very frequently in mathematics is the biconditional ⇔. A⇔B is true *when and only when* A and B are both true or both false. It is called the biconditional because *both* propositions are *conditional* upon eachother. A⇔B is equivalent to (A⇒B)∧(B⇒A).

Biconditional Connective

At this point we run into the issue of connective completeness. With two propositions there are two truth values each can assume and hence four possible states for the two propositions. Each of these states can be mapped to either true or false when constructing a binary connective, so that there are 24 = 16 such connectives. But we've only listed *four*, what about the other 12?

The same way that we can build every atom from basic subatomic particles instead of having to devise a new type of particle for each element or molecule, we can build *every* binary connective using just three - the negation ¬ the and connective ∧, and the or ∨. How so? Well consider the *form* of a binary connective. We have a mapping of every possible state of A and B to a new set of states, the values of AcB, where c is some connective. We can write the possible states of A and B in the form of pairs:

(True, True), (True, False), (False, True), (False, False)
Each of these can either lead to a true or false when figuring out AcB. We can introduce a third new slot in each of these pairs where this third slot will stand for the value of AcB for the truth values of A and B given. So for example, if we were using the biconditional connective ⇔ we'd be able to write it out as the following set of *triplets* (when you bunch three things in the same parenthesis):

(True, True, True), (True, False, False), (False, True, False), (False, False, True)
We can replace the comas with the word "or" which can then be replaced with ∨:

(True, True, True) or (True, False, False) or (False, True, False) or (False, False, True)
(True, True, True) ∨ (True, False, False) ∨ (False, True, False) ∨ (False, False, True)
Next we can convert the triples into As and Bs using the ¬ and ∧ connectives. Something like (True,False,False) would turn into ¬(A∧¬B) because we are saying that A∧¬B is false when A is true and B is false. This is a specific set of truth values, but there are three triples to deal with:

(A∧B) ∨ ¬(A∧¬B) ∨ ¬(¬A∧B) ∨ (¬A∧¬B)

(A∧B)∨¬(A∧¬B)∨¬(¬A∧B)∨(¬A∧¬B) is equivalent to A⇔B and is thus the three connective encoded form of A⇔B. The proof we may do this for *any* binary connective follows the same lines:

Every binary connective c consists of a set of all possible truth values of the propositions A and B with a third value equal to AcB for the given values of A and B. Let's label this third value in the form un since it's **u**nknown and could be for any connective:

(True, True, u1), (True, False, u2), (False, True, u3), (False, False, u4)
We may again replace the comas with "or" then ∨. You may wonder why we don't just use ∧, as it seems more natural to say "and" when listing things than it does words like "or". This is because if we used ∧, then the resulting proposition would *only* hold true if every single case held true, or if the proposition was such that every combination of truth values was always true. The tautological case. There is only one such connective for every set of n-ary connectives (connectives that join n-propositions), so this wouldn't work. "Or" works because it includes "and" but doesn't *limit* us to "and" in it's handing of these cases.

(True, True, u1) or (True, False, u2) or (False, True, u3) or (False, False, u4)
(True, True, u1) ∨ (True, False, u2) ∨ (False, True, u3) ∨ (False, False, u4)
Now we can rewrite this. un(A) is to be understood as simply "(A)" if un is true, but "¬(A)" if un is false.

u1(A∧B) ∨ u2(A∧¬B) ∨ u3(¬A∧B) ∨ u4(¬A∧¬B)
When the values of un are determined for a case by case basis, it can be seen that the entire expression would only be made of propositions and the three basic connectives ¬, ∧, and ∨. And those parenthesis signs. Actually, about those. We need them to avoid ambiguity, but in some cases we don't. You may have noticed that an expression like ¬(A∧B) is written as is instead of as ¬A∧B. Why is this? It is because of *binding strength*, which is the same thing as order of operations for algebra but for logic. Just as you solve using PEMDAS (Parenthesis, Exponents, Multiplication, Division, Addition, Subtraction) *in that order*, so too we evaluate propositions in the order of ¬, ∧, ∨, ⇒, and ⇔. This means something like ¬A∨B∧C is treated the same as (¬A)∨(B∧C).

So, all 16 connectives can be formed through ¬, ∧, and ∨. But to take this a step further, we can actually form all 16 through just *one* connective! The way to do this is to reduce ¬, ∧, and ∨ down to the *nand* connective ↑. A↑B is the same as ¬(A∧B), and is defined like so:

Nand Connective

Now we can take ¬, ∧, and ∨ and reduce it to ↑ like so:

Reducing ¬A to Nothing But A and ↑
 ¬A | False | True

As the connectives ¬, ∧, and ∨ can each be reduced down to a form with ↑, it shows that ↑ is sufficient for handling all binary connectives. Not just binary connectives though, but *all* connectives! The next type of connective after the binary would be the ternary connectives. They join three propositions with two truth values each. The number of ternary connectives would therefore be the number of ways to map the 23 possible states of these three propositions to a true or false value for each state. This is 223 = 28 = 256, meaning there are 256 ternary propositions!

We can prove that ternary connectives and connectives with *any* arity can be described through the fundamental connectives ¬, ∧, and ∨ like so. First, we write every possible state of the propositions A1, A2, A3, . . . An (corresponding to an n-arity connective) in n-tuplets (groups of n things in parenthesis) like so:

(True, True,. . .True, True), (True, True,. . .True, False), . . .(False, False,. . .False, False)
There are 2n such n-tuples. Now let's add in the output of this n-ary connective un for a given set of proposition values. This will be the (n + 1)th slot:

(True, True,. . .True, True, u1), (True, True,. . .True, False, u2), . . .(False, False,. . .False, False, u2n)
Lastly we can rewrite this using logical connectives and un(A), which again is to be interpreted as "(A)" if un is true and "¬(A)" if un is false.

u1(A1∧A2∧. . .∧An) ∨ u2(A1∧A2∧. . .∧¬An) ∨ . . . ∨ u2n(¬A1∧¬A2∧ . . . ∧¬An)
This final expression is composed solely of ¬, ∧, and ∨ when assessed for a specific n-ary connective. In turn, this can be reduced completely to ↑, so that every connective can be formed using propositions and ↑. For the sake of convenience however, we will not be reducing everything down to ↑ but will be using the five basic connectives covered in the logical order of operations.

There is also an interesting thing about logical connectives, and it has to do with tautologies - propositions always true no matter what truth values their composite propositions take on. As you involve more and more propositions, it becomes harder and harder to figure out if what you have is a tautology or not. Something like A∨¬A is so obvious that you don't even need to know logic to understand why statements in the form "this-and-such or not this-and-such" are always true. But other statements involving dozens, maybe *hundreds* of different propositions and connectives are harder to figure out. As it turns out, the difficulty in figuring out whether they are tautologies are not increases *exponentially* compared to the number of symbols required. What does this mean though?

Well, any computation you do can be broken up into a bunch of little parts. When you add, you go through column by column and carry the digits if necessary. You'll notice the amount of time it takes you to add two numbers is roughly proportional to the length of the two numbers in question. If you had to add 339 and 991 you'd have only three columns to go through and of course a bit of carrying to do. But if you *multiply* two numbers you now have to multiply every number of the first by every number of the second. The time it takes you (assuming every multiplication takes place in a roughly equal time) is proportional to the number of digits in the first number multiplied by the number of digits in the second number. So this means multiplication takes longer than addition in the sense that the time it takes you to do addition is *linearly* proportional on the size of the numbers in question, but the time it takes you to do multiplication is *quadratically* proportional on the size of the numbers in question.

If we took any number and cubed it, the length of time it takes us to find the cube is roughly proportional to the cube of the number of digits. Let's say we have an operation of mathematics that takes a certain number N as an input and spits out another number as an output. If the time it takes to do this, given all steps take equal time, can be related to N in such a way that the time is a polynomial function of N, then the operation is said to run in P-time, or polynomial time. As it turns out, *there is no such way* to relate the length of a proposition in symbols (N) and the time it will take to find out if it's a tautology! It takes an exponential amount of time to determine!

This is important because it shows *why* propositions form the basis of mathematics and why logical languages based on them are so powerful. The rules to form propositions may be simple, but their nature is very complex and unintuitive. Propositions which remain true no matter what are important when it comes to building up mathematical theories. But how do we go from true and false propositions to proving actual results in mathematics?

For that we need *another level* of logic building on what we already have.

## **Part 2** ~ What is logic?[Part II:Predicates, Quantifiers, and Variables]

「Logic will get you from A to B. Imagination will take you everywhere.」
*~ Albert Einstein*
Propositional logic is good because it allows us to form *tautologies* and *inferences* (statements which always follow from prior ones), which form the basis for mathematical theories. But more is needed. In mathematics we deal with different types of objects, and some of these are infinite, like the natural number line {0,1,2,3,. . .}. How do we make meaningful statements about the infinite in a finite amount of space when there's an infinite number of things to talk about? For example, let's say we had the proposition "2 is prime". This is true. "1 is prime" is not true. We can try to form a "theory" of prime numbers by listing off these propositions and joining them with ∧. "2 is prime" ∧ "3 is prime" ∧ "5 is prime" . . . The only issue is we were never allowed to make these compound propositions *infinitely* long! There's no way to fit all these primes into one logical sentence! We need a way to range over an infinite number of objects, which is impossible when we're confined to just propositional logic. For this we need the *predicate*, which is a function that takes in an object or set of objects as an input and spits out "true" or "false" as an output.

The objects allowed inside a predicate make up the *domain of discourse*, or *thing we're talking about*. The thing we're talking about in number theory is of course the natural numbers. The thing we're talking about in complex analysis is the set of complex numbers. A predicate is denoted by some letter followed by parenthesis and *variables* separated by comas, where variables stand in for things in the domain of discourse. We can write the prime predicate as P(n), and thus we can *hold* the infinite set of primes in this one predicate by saying that n is a prime whenever P(n) is true and not if P(n) is false.

Just as there are different types of connectives though, there are different types of predicates. *Unary* predicates are those that only use one variable for objects from the domain of discourse, while *binary* predicates are those that use two variables for objects from the domain of discourse. An example of such a binary predicate would be the "less than" operator. Given the domain of natural numbers, we might denote this with a left-pointing carrot and write it as <. I said we could write predicates like functions, but in common practice binary predicates are often written *between* their inputs. a < b would mean that a is less than b.

In the case of the naturals though, how would we define an *exact* number? The key is to force a variable inside one of these predicates to be what we want to define. For something like 0, the lowest natural number, we might say that it is "there exists an a for which there does not exist b such that b < a". But how do we turn this into pure logic? For that we need a *quantifier*, which is a way to make statements about what exists and what doesn't within what we're talking about. One quantifier is ∃, which is read as "there exists" and looks like a backwards E, E for **E**xists. It is called the *existential* quantifier. When putting predicates and quantifiers together we put the variable we're quantifying, or making an existential statement about, right after the quantifier. ∃x(P(x)) would therefore be read as "there exists an x such that P(x) is true." Now the statement "there exists an a for which there does not exist b such that b < a" can be turned into ∃a(¬∃b(b < a)).

Now let's say we wanted to express the statement that "for all numbers a, there is a higher number b." We could write this as ¬∃a(¬∃b(a < b)), as ∃a(¬∃b(a < b)) is equivalent to saying that "there exists a number a such that there exists no higher number" so the negation of *this* would be equivalent to "for all numbers a, there is a higher number b." This is well and valid. But it's hard to read intuitively, so mathematicians like to use another quantifier, ∀. This is the *universal* quantifier and ranges over *all* objects in a domain for a given variable. It is an upside down A to stand for **A**ll. For example, ∀x(P(x)) would be read as "for all x, P(x) is true". We can write "for all numbers a, there is a higher number b" as ∀a∃b(a < b). We don't have to write ∀a(∃b(a < b)) because there's no ambiguity if we leave the parenthesis out.

Something interesting is that just like how you only need a few connectives instead of every single unique one, you only need the existential quantifier *or* only the universal quantifier if you really wanted to just limit yourself to one of these. You can convert between the two like so:

∃a(Q(a)) ⇔ ¬∀a(¬Q(a))
∀a(Q(a)) ⇔ ¬∃a(¬Q(a))
To understand why this is true, consider a classroom full of students. The statement "there exist a student who wears glasses" is equivalent to the statement "it is *not* true that all students do *not* wear glasses." Likewise the statement "all students wear glasses" is equivalent to the statement "it is *not* true that there exist *no* students who wear glasses." Note that when converting one quantifier into the other we use two negations.

But hold on - these rules are for predicates with only one variable - what about binary predicates and all the others?

We can turn a binary predicate into a unary predicate by quantifying over one of the variables. For example, if we had some predicate A(a,b), we could turn it into a unary predicate by forming something like ∃a(A(a,b)). This is a unary predicate and not a binary predicate because when we quantify over a variable we are making a declarative statement which can *only* be true or false about that variable, leaving one free variable and thus a unary predicate. For example, if I said "there exist no dogs with polka dots on the planet" then the predicate would range over dogs and determine if they have polka dots, and the statement as a whole would quantify over this. Because this statement can only be true or false, it becomes a proposition. When you quantify over a variable within a predicate this variable is now said to be *bound*, as it is bound and attached to the quantifier which quantified it.

As some examples. . .

* The g within ∃g∀h(Q(g) ∧ R(g,h)) is bound.
* The g within ∃g∀g(Q(g)) is bound alright, but by two quantifiers! This double bonding isn't allowed in logic.
* The g within ∃g(R(g,h)) is bound but the h isn't.
* The g within ∃g(X(g)) ∧ F(g) is bound in one part of the expression but unbound in the other. It is unbound, and also bad form to have a variable bound in one part of the expression but unbound in the other part.

In general, a *sentence* is a statement with all variables bound. An *inference rule* is a tautologically true relation between propositions. For example, (A∧B)⇒(A∨B) is tautologically true. What is the significance of this? It means that we can split true expressions of the form A∧B into either A or B on their own and the resulting expressions will still be true. There are other inference rules. A set of sentences *assumed to be true with no prior proof* are called *axioms*, and every mathematical theory is made up from a set of basic axioms. The axioms together with the inference rules allow mathematicians to derive truths within that theory.