User:Addemf/sandbox/Scientific Reasoning for Non-scientists/Examples of Logical Problems

In this lesson we'll look at a collection of ideas which the study of logic will clarify at the end of this course.

Point 9 Repeating


Many students are told that "0.9 repeating", which we may write as 0.999..., is the same as 1. A large rate of people who hear this, find it hard to make sense of. Some people are even certain that it must be false.

Near the middle of this course, we will hopefully resolve every question about the matter.

i
Students often also learn about the number, $$i=\sqrt{-1}$$. Paradoxically, they also hear that it is not possible to take the square-root of a negative number, and that i is "imaginary".

So why do we study i? In what sense does it exist? Are we always free to make up any numbers that we want?

Proofs
You've probably heard that the sum of the interior angles of a triangle always equals 180°.

But why?

Below is a quick animated proof, which is explained below.

Suppose you have any triangle, $$\Delta ABC$$.

Mark its angles as $$\alpha,\beta,\gamma$$ respectively. We wish to show that $$\alpha+\beta+\gamma=180^\circ$$.

To do so, draw the line through one of the vertices which is parallel to the opposite side. Call this line $$\ell$$.

In the animation, the chosen vertex is C and the opposite side is $$\overline{AB}$$.

This now creates two new angles at C. In the animation, one of them can be described as $$\angle ACD$$.

Because the base and $$\ell$$ are parallel, then by the famous "Alternate Interior Angles Theorem", we have $$\angle A$$ is congruent to $$\angle ACD$$. Hence in the animation, this new angle is also marked with $$\alpha$$.

The same argument applies to the remaining angle, which is marked with $$\beta$$ the same as $$\angle B$$.

Now if you consider angles $$\alpha,\beta,\gamma$$ all marked on one side of the line $$\ell$$, these must sum to 180° since this is the total angle on one side of any line.

Now for one thing, if you're thinking to yourself "that is super cool!" then you are absolutely correct.

But the proof is based on a few statements, and we could ask "Well, but what is the proof of that?"

For instance, we just assumed that there is a line which runs through C and is parallel to $$\overline{AB}$$. How do we know that this is true?

Well, it certainly seems obvious. But we might think "Every statement needs a proof -- it is not enough to just seem obvious."

Well, even the principle that "every statement needs a proof" may seem good at first glance. But if you think about it, this would imply the need for any statement to have an infinity of proofs. Because the statement would need a proof in terms of other statements -- but then those other statements need their own proofs -- and then the statements in those need their own proofs. And so on to infinity.

We just have to pick some statements which will be accepted without further justification. But which statements will we select, and why?

Arguments
Even very simple arguments, when you take them apart and try to understand how the principles of logic work, are often very complex.

Therefore, at least to begin with, we will start with some "toy" over-simplified arguments.

Morality
I emphasize again that the following example is not presented as a correct argument, nor as an incorrect argument.

The argument below is only presented as an over-simplified example, in order to give us a good starting place.

Later on, we may choose to elaborate this and other arguments. With enough elaboration, the arguments may approach an accurate representation of the arguments that people actually give.

1. It is always wrong to kill an innocent person. 2. A fetus is always an innocent person. 3. Therefore it is always wrong to kill a fetus.

Is this argument correct? It depends on exactly what we mean by "correct" when it comes to arguments.

This argument certainly is valid, although it may or may not be sound. A valid argument is one which makes no logical mistakes. If we assume the truth of its premises, then the conclusion must follow from those assumptions.

In this argument, sentences (1.) and (2.) are premises. If those are true, then (3.) must be true. This exhibits the idea of a "valid" argument.

However, we might still resist the argument by denying the truth of its premises. One might even deny the truth of just one of the premises, or both. If one decides that any premise is false, then one regards the argument as "unsound".

As with every example on this page, we will have more to say about this later in the course.

Science
Here, again, is a toy over-simplified argument:

1. We visibly see the sun rise in the east and settle in the west. 2. Therefore the earth must be at the center of the orbit of the sun. 3. Besides, if the earth moved around the sun, we should feel that motion all the time. 4. Because we do not feel the earth move, therefore the earth must be stationary.

And consider this counter-argument:

1. If the earth revolved on an axis then it would appear, from our position on it, the same as it would would if the sun orbited the earth. 2. Therefore the appearance of the sun's motion is no evidence at all, because both possibilities lead to the same observation. 3. We do not feel the earth move because of the enormity of its radius. With such a large radius, the centripetal acceleration that we feel is very small. 4. Moreover, the acceleration due to gravity is many times larger than the acceleration of centripetal motion. Therefore the centripetal acceleration is imperceptible in the presence of such a larger force. 5. Therefore the earth revolves on an axis.

These kinds of arguments are noticeably different from the mathematical and philosophical examples.

Physics arguments are much messier. The general rules, by which physicists make inferences, are much less clear.

That is perhaps very striking! We often think of physics as very precise and clear.

Physics is more precise than other fields of study. However, mathematical reasoning alone is not enough to analyze physics arguments.

Instead, for science, we need a logic of empiricism, which we discuss toward the end of the course. Probability and statistics will feature heavily in this analysis.

Pseudo-code
Let us consider the following algorithm which adds together all of the elements of a list of numbers.

It does so by means of a "for-loop", which we will study more later. But for now, just imagine that lines (2. - 2.1.) of the code below sequentially takes each element of out of the list, and adds it to a "partial sum".

Let  be the list of numbers. 1. Initialize a variable,, to zero. 2. For each element of the list, call it : 2.1. Reassign. 3. Return.

This algorithm is written in "pseudo-code".

Pseudo-code is not a programming language. Rather, it is a specification of an algorithm in such a way that the idea should be easy to implement in any language.

For example, the algorithm above is implemented in Python as follows.

Therefore if one runs the following Python program, it will print the sum of the list. In this specific example, it prints 30.

But this function could quite easily be implemented in Java or C. With only a bit of awkwardness they could be implemented in very different languages like Haskell or OCaml.

The task of summing a list is quite simple, which is why I chose it for an initial example. The simplicity of the task makes it easy to see that the algorithm is "correct".

To say that the algorithm is correct means that "it does what we claim it does". In this case, the algorithm is correct if, for any input list of numbers, its return value is the sum of the list.

But as things grow more complex, our algorithms may seem correct and yet may fail to be correct.

To see an example incorrect algorithm, consider the task of sorting a list of numbers. That means we would like to take a list like  and transform it into the list.

How could we write pseudo-code to perform this task? Here is an attempt, although it may be a little too obviously incorrect:

Let the list of numbers be. 1. If the first element of  is larger than the second, then swap them in. 2. Return.

We can implement this algorithm in Python with the following. Note that Python is "zero-indexed" so that writing  accesses the first element (read "zeroth element" when zero-indexing) of the list.

This Python function had to be a little more specific and precise than the very rough pseudo-code given earlier. Python does not have a built-in "swap" operation.

Instead, what one can do in Python is to fetch and assign coordinates in a list. When you write  you fetch the value at index zero, which is the first element. Therefore in the line  this fetches the value at index 0 and allows us to refer to it with the variable. Note that this does not change the list at all; it only allows us to refer to its first element by reference to the  variable.

When you write  this fetches the value from index 1 and places it at index 0. For example, suppose the list   is. Then performing the line  would cause   to now be.

Therefore, to summarize what happens in the "if-block" of the Python program: It makes  refer to the first element, which we will need later. Next it assigns the second element to become the first element. Finally, using, it makes the "old" first value become the "new" second value.

In effect, this swaps the first and second value.

However, this is somewhat obviously an incorrect algorithm, because it only sorts the first two elements. If the remaining elements are still unsorted, then it has failed to perform the task of sorting the list.

Proofs of Correctness
These two algorithms, one for summing a list and one for sorting a list, are a little too simple. We can see everything plainly. The first algorithm is plainly correct and the second is plainly incorrect.

However, when algorithms become hundreds of lines long, involving more and more complex data structures and design patterns, we will not be able to talk about these things in such simple language. I will not be able to explain or convince you, in colloquial language, whether the program is correct or incorrect.

Therefore, we will need a systematic treatment of the logic of programs, in order to give proofs of their correctness or incorrectness. Exactly how we do this, will be explored later in this course.