User:Addemf/sandbox/Technical Reasoning/Propositional Expressions

Now that we've seen the basic idea of abstraction and symbolization, we build a formal system around the idea.

To begin with, because it is simpler, we focus on logic at the level of propositions — so-called "propositional logic". This means that we do not focus on the quantifiers, seen in the previous lesson. Rather we focus on the operators like $$\land,\lor,\neg,\to$$.



The most important theme throughout this lesson, is the relationship between syntax and semantics.

Syntax is the "dead", mechanical, "calculational" system of symbolic computation. To take one example, everything that a computer does is syntactic.

By contrast, semantics is the study of the meaning, which metaphorically gives life those dead symbols. A computer might display symbols, simply because it was programmed to do so. But it is the human mind, reading those symbols, which gives the symbols their meaning.

Syntax
Because our current interest is in propositions, we will no longer write expressions like P(x, y, z) as we did in the previous lesson. This is a level of analysis beyond the scope of propositional analysis. We will see objects and quantifiers in the future lesson on first-order logic.

We will instead use propositional variables, like


 * P, Q, R, ...,

usually denoted by capital italics Roman letters.

From a syntactic point of view, these will be the basic "building blocks" or "atoms" which build up to more complex expressions.

Semantics
The formal definition of exactly what a propositional variable is, would probably be too technical and cause more confusion than insight at this point. Therefore let us just rely on the intuition that a propositional variable is an abstraction of any proposition.

Propositions may be true or false.

Moreover, they must be precisely one of these two options.

Therefore the abstraction of a proposition, is anything which may be true or false.

We represent this in a so-called "truth table", below.

The top row shows a propositional variable, and below it, the possible "truth-values" that it could take. These are true and false, annotated as "T" and "F" respectively.

At this moment, that might seem like a needlessly elaborate display of a simple idea. However, things are about to get complicated soon, and it will be valuable to have tables to organize our information.

Caveats
Note that the semantics we are giving here are the semantics of mathematics, but they are not exactly the same as the semantics of everyday speech.

For one thing, the semantics of everyday speech includes much more than propositions.

But also, there are some philosophical disputes about exactly what the semantics of statements are. One could make nonsensical statements, like "green is round", which seems not just false but meaningless. In general, | category mistakes of all kinds often seem neither true nor false but meaningless.

Another example is "the present king of France is bald." There is (as of writing this) no present king of France. Some philosophers argue that this sentence is technically false (see | the theory of descriptions), but many philosophers and linguists reject this analysis. There is no consensus on how to regard such a sentence.

One could go on, but let's not get distracted. Just be aware that the semantics presented here are those used in mathematical settings, and that is a very useful setting for analyzing a wide range of real-world phenomena. But these semantics are narrowly limited.

Syntax
The negation of a propositional variable, like P, is written as $$\neg P$$.

Notice that although P is a propositional variable, $$\neg P$$ is not. Rather, it is an example of what we will eventually call a propositional formula. We are not yet in a position to define this phrase exactly; but toward the end of this lesson, we will.

A propositional formula is essentially just anything that is built from propositional variables using propositional operators (negation, conjunction, disjunction, and conditional).

Moreover, notice that we may negate any propositional formula, not just variables. Therefore


 * $$\neg (\neg P)$$

and
 * $$\neg(\neg(\neg P))$$

are propositional formulas too.

Note the use of parentheses, which will become increasingly important as the complexity of propositional formulas grows. We may write $$(\neg P)$$ if we wanted to, or $$(\neg(\neg P))$$. But we also allow ourselves to omit the outer-most parentheses.

Semantics
The semantics of negation is to switch true to false, and false to true.

Therefore we write the truth table of negation like so

One often wants to juxtapose this, with the truth-table from which the negated values were derived, to help see what happened here.

Therefore we prefer to write the truth-table instead like so.

The left-most column simply records the original arrangement of Ts and Fs.

To the right of the vertical blue separator, we make a column for each symbol. These are the negation and variable.

Under the variable, we simply transcribe the original values.

Under the negation, we compute the new values. These values are special because they are the "final" or "main" values, which are the actual value that $$\neg P$$ takes, for each given value of P.

Here is the truth-table for $$\neg(\neg P)$$.

Be sure to note in which column the main values are recorded. These are in the second column, under the outer-most $$\neg$$.

Draw the truth-table for $$\neg(\neg(\neg P))$$.

We say that two propositional formulas are "equivalent" if they have the same truth-table.

Because we haven't yet, and cannot yet, state the definition of "propositional formula" then we won't yet try to state a formal definition of "equivalent formulas".

However, even at this intuitive and pre-formal stage of explanation, it should be clear that P and $$\neg(\neg P)$$ are equivalent formulas. This is because the "main" column of the truth-table for each, is

What formula is equivalent to $$\neg P$$?

The following code prints the truth-table using SymPy. (Recall that you must run the "front-matter" described in the lesson on Python, before running code cells like the one below.)

Line 1 generates the truth-table in SymPy. You don't need to worry about how it does this.

Line 2 prints the header row, using the variable x instead of P since SymPy already has x as a variable.

Line 3 starts a for-loop to print all of the rows of the table.

Line 4 gives the command to print the current row. But in SymPy truth tables, each row has two pieces of information. Therefore we use  and   to extract each piece of information. We place a bar between them in the print command, so that it almost looks like the vertical separator in a table.

Note that the print-out uses  and   instead of truth-values   and.

Use SymPy to print the truth-table of $$\neg(\neg P)$$.

Make the print-out of the truth-table a little prettier by writing a function which, given an input list of values 0 or 1, turns it into a corresponding list of  and.

Call this function.

If the function is written correctly, it will cause to return.

Then run the cell

Syntax
For any two propositional variables, say P and Q, their conjunction is $$P\land Q$$.

Again note the importance of parentheses when formulas become complex. Without parentheses


 * $$\neg P\land Q$$

has two equally valid readings. Either


 * $$\neg(P\land Q)$$

or


 * $$(\neg P)\land Q$$

Moreover, we will see in the section on semantics, that the two formulas have different meaning. It is quite important that we syntactically distinguish between the two expressions, so that the syntax can express the different meanings.

Semantics
The semantics of conjunction is that the conjunction should be true when both conjuncts are true, and false otherwise. This is given in the truth-table below.

Notice the need for four rows now, because there are two variables, each of which could be T or F. Therefore the full set of possibilities for the pair of variables, P and Q, are: TT, TF, FT, or FF. These are rows 1, 2, 3, and 4, respectively.

In general, every time there is an extra variable, the number of rows doubles. Therefore, if a table requires three variables then it requires $$2\cdot 4 = 8$$ rows.

Complete the following list of all triples of truth-values for three variables.

The list is generated by starting from TTT.

Then take the right-most truth-value and flip it. If that value was T then we have the subsequent row.

If that value was F then proceed left to the next value and repeat the process.

TTT

TTF

TFT

TFF

FTT

[row 6: What goes here?]

[row 7: What goes here?]

FFF

How many rows are in a truth-table for four variables?

List the first eight rows, using the algorithm of the previous exercise.

As an exercise in reading the truth-table for conjunction, check that you understand:

When P is F and Q is T then $$P\land Q$$ is F.

We may summarize this by writing $$F\land T = F$$. Similarly we may summarize the first row of the truth-table by writing $$T\land T=T$$, and so on.

Use the previous problem, Double Negation Equivalence, to prove that $$P\land Q$$ is equivalent to $$Q\land P$$.

(This is fact is called the "commutativity" of conjunction.)

Here I will produce the truth-table for $$(\neg P)\land Q$$, and show you the sequence by which I populate it with values.

First, draw the basic table and copy the values from the left two columns over to any variables.

''Step 1. Transcribe.''

Next, compute the first available operator's column. In this case, we cannot compute the $$\land$$ but we can compute the $$\neg$$, so we start here.

Values are bolded to indicate that they are the values from which the new values are computed, using the negation rule.

Values are highlighted in pink to indicate the most recently computed column.

''Step 2. Column 3''

Next, use the values under the negation and under Q to compute $$\land$$. Note again the bolded values to see how the values under $$\land$$ were computed.

''Step 3. Column 5''

Note that this last column, column 5, is the "final" value for the proposition.

In the presentation above, we computed entire columns all at once. This can be nice because it is fast.

However, because this can be confusing, let's just take one row and focus on its computation. Selecting somewhat randomly, let's focus on the second row.

To understand how this row was computed, one can write the steps as:


 * $$\begin{aligned}

\neg(T)\land F & \quad \text{ transcribe}\\ =F\land F &\quad \text{ compute the negation}\\ = F &\quad \text{ compute the conjunction} \end{aligned}$$

Draw the truth-table for $$\neg(P\land Q)$$.

Identify a final value in its truth-table, which does not match one of the final values for the truth-table of $$(\neg P)\land Q$$.

Conclude that $$\neg(P\land Q)$$ and $$(\neg P)\land Q$$ have different semantics.

Show that $$P\land (Q\land R)$$ is equivalent to $$(P\land Q)\land R$$. This fact is called the "associativity" of conjunction.

Use this fact, without computing any more truth-tables, to argue that $$P\land (Q\land (R\land S))$$ is equivalent to $$(P\land Q)\land(R\land S)$$.

The associativity of conjunction, shown in the exercise above, demonstrates that a sentence does not need parentheses when it is formed only from conjunction. We might interpret


 * $$P\land Q\land R$$

as either $$(P\land Q)\land R$$ or $$P\land (Q\land R)$$. But because these are equivalent, then it is not important which one we mean when we write the un-parenthesized version.

Therefore we will write $$P\land Q\land R$$ without additional parentheses. Likewise we may write $$P\land Q\land R\land S$$ without parentheses, because any way of parenthesizing it will always be equivalent to every other way.

And so on, we may omit parentheses when a sentence is constructed only from conjunction, with any number of variables.

In SymPy one can generate the truth-table for $$(\neg P)\land Q$$ with the following cell.

Now use SymPy to print the truth-table of $$\neg(P\land(\neg Q))$$.

Syntax
The syntax for disjunction is almost identical to that of conjunction.

For "P or Q" we write $$P\lor Q$$.

Semantics
The semantics of disjunction, are that the disjunction is true when one or the other disjunct is true. This is reflected in the truth-table

Note that a somewhat simpler rule to remember is that $$P\lor Q$$ is F when both disjuncts are F. Otherwise it is T.

Show that $$\neg(P\lor Q)$$ and $$(\neg P)\lor Q$$ are not equivalent.

The proof should very similar to that given for conjunction and negation, earlier.

Decide whether parentheses are needed for a sentence constructed only from the disjunction operator.

The answer should be decided in a process nearly identical to the one above for conjunction.

Investigate whether $$P\land (Q\lor R)$$ is equivalent to $$(P\land Q)\lor R$$.

Use this to decide whether parentheses are needed for propositions constructed only from conjunction and disjunction.

The logical law of De Morgan's states that


 * $$\neg(P\land Q) \equiv (\neg P)\lor (\neg Q)$$

and
 * $$\neg(P\lor Q) \equiv (\neg P)\land (\neg Q)$$

This shows an important relationship between these three operators, $$\neg, \land,\lor$$.

Prove both of these claims of equivalence.

Consider the sentence
 * "2 is not odd and prime."

Part 1.

Is this sentence true?

Part 2.

Consider the sentence's abstraction


 * "t is not $$O(t)$$ and $$P(t)$$."

Which symbolization seems most correct for the intended meaning of the original sentence? Either


 * $$(\neg O(t)) \land P(t)$$

or
 * $$\neg(O(t)\land P(t))$$

?

Hint: There is a subtle difference between what is communicated by the sentence "2 is not odd and prime" and the sentence "2 is not odd and is prime". It is precisely the difference between the two symbolizations.

Here is code that prints the truth-table for disjunction in SymPy.

Use SymPy to print the truth-tables of the following.
 * $$\neg (P\lor Q)$$
 * $$(\neg P)\lor Q$$
 * $$(P\land Q)\lor((\neg P)\land (\neg Q))$$

Syntax
The conditional symbol is $$\to$$, a binary operator. Therefore the syntax for the conditional "if P then Q" is


 * $$ P\to Q$$

Semantics
The semantics of the conditional are given by the truth-table

A simple way to describe this is: The conditional is true when the antecedent is false, or the consequent is true.

Why would this be the semantics of the conditional? For negation, conjunction, and disjunction, the reasons for the semantics are probably close to self-evident. But this rule for the conditional may seem not to obviously match what we think of when we think "If P then Q."

The important idea that we mean to capture in the semantics of the conditional, is the "flow of truth" from the antecedent (P) to the consequent (Q).

Notice that, in this table, P is true on the first two rows. Where Q is true (row 1), we say that the conditional is true. This is because, apparently, in a sense the truth of P successfully flowed to Q.

On the other hand, where P is true and Q is false (row 2), it seems that the flow of truth from P to Q was unsuccessful. Therefore the conditional is marked false here.

But what about the rows at which P is false (rows 3 and 4)? Well, since P is not true then we don't require truth to "flow" toward Q in this scenario. In this case, Q may be true or false, independent of P, and still the conditional should be true.

Consider the sentence "If a natural number is divisible by 4 then it's divisible by 2." This is a true sentence.

Now consider the instance in which the number is 3. The sentence, specialized for this instance, would be "If 3 is divisible by 4 then it is divisible by 2." This should still be a true sentence, because 3 is not divisible by 4. In cases where the antecedent is false, we still recognize the conditional as true.

Part 1.

Show that $$P\to Q$$ is equivalent to $$(\neg P)\lor Q$$ and also equivalent to $$(\neg Q)\to (\neg P)$$.

Part 2.

Show that $$P\to Q$$ is not equivalent to $$Q\to P$$.

Part 3.

Decide whether $$P\to (Q\to R)$$ is equivalent to $$(P\to Q)\to R$$.

Part 4.

Decide whether $$P \to Q$$ is equivalent to $$(\neg P)\to(\neg Q)$$.

Part 5.

Draw the truth-table for $$(P\to Q)\land (Q\to P)$$.

Argue that if the formula above is true then P and Q must have the same truth-value.

An Emphatic Caveat
The semantics that we give here for the conditional are, as I've also said at the beginning, the semantics of the conditional in mathematical settings.

It is especially important not to confuse the semantics for this mathematical conditional, with the semantics of every kind of conditional sentence. The conditional given by the truth-table is called the | material conditional.

Some conditional sentences expression causation, like
 * "If you put a magnet next to iron, then there will be an attractive force between them."

This kind of conditional sentence very much does not have the semantics given by the truth-table above.

There are also counter-factual conditionals, like
 * "If Franz Ferdinand hadn't been killed Europe wouldn't have gone to war."

Again, the semantics of such a sentence are not at all like the semantics of the truth-table.

Later in this course we will discuss causation further, although we will not discuss counter-factuals. To see a wide-ranging discussion of the semantics of conditionals, one could consult A Philosophical Guide to Conditionals by Bennett.

Natural Language Antecedent and Consequent
Especially when it comes to the conditional, the way that our natural language expresses logical structure can be very subtle and tricky.

Consider for example, the fact that fire can only exist in the presence of oxygen, fuel, and heat. Each is a "necessary" condition but no one of them is sufficient.

It is therefore correct to say
 * "One can make fire only if oxygen is present."

But equivalently, this is the same as the fact,
 * "If there is fire then oxygen is present."

This illustrates the fact that the presence of the word "only" reverses the antecedent and consequent in a conditional sentence.

Therefore the abstraction
 * "If P then Q."

has the familiar symbolization,
 * $$P\to Q$$

Also
 * "Q, if P."

has the same symbolization
 * $$P\to Q$$

This makes it seem like the word "if" indicates which clause is the antecedent. And this is usually true.

But the abstraction
 * "Q only if P."

has symbolization
 * $$Q\to P$$

Biconditional
The above helps to understand the phrase, common in English and especially common in the sciences, "if and only if". For example, one might say "Fire is present under normal conditions, if and only if there is oxygen, fuel, and heat."

Clearly this is just shorthand for the more explicit expression,
 * "If fire is present under normal conditions then there is oxygen, fuel, and heat; and only if fire is present under normal conditions then there is oxygen, fuel, and heat."

We might abstract this sentence as
 * "P if and only if Q and R and S."

Then we would symbolize this as
 * $$(P\to (Q\land R\land S))\land ((Q\land R\land S)\to P)$$

Since such expressions tend to be quite long and in some way, repetitive, we use the symbol $$\leftrightarrow$$ to express "if and only if".

Therefore, to symbolize the abstraction above, we merely write
 * $$P\leftrightarrow(Q\land R\land S)$$

Propositional Formulas
Now that we can talk about all of the symbols of propositional logic, we are in a position to define the precise definition of a propositional formula.

The following definition is quite technical, and for some students this may be hard to process. However, the intuitive idea of what a propositional formula is, should already be clear.

The following are several propositional formulas. They are just the kinds of things we made truth-tables for, earlier.


 * $$ (P\to (\neg Q))$$
 * $$ ((P\land Q)\land (P\lor Q))$$

Now these formulas have extra surrounding parentheses, unlike how we wrote them earlier. These parentheses are unnecessary for us to read and understand the formula, but having them makes it easier to state a formal definition as we do below.

But to understand how a given expression is or is not a formula, we build it up in steps. The first step is to have a set of variables, which are the most basic formulas.

For example, consider the set of variables,


 * $$\mathcal F_0 = \{P,Q,R\} $$

From this we can construct the set of all formulas which are a negation of a variable. (Soon we will rigorously define these symbols and expressions, but I want to show their use first.)


 * $$(\neg \mathcal F_0) = \{(\neg P),(\neg Q),(\neg R)\}$$

And the set of all conjunctions of variables.


 * $$\begin{aligned}

(\mathcal F_0\land \mathcal F_0) = \{&(P\land P),(P\land Q),(P\land R),\\ &(Q\land P),(Q\land Q),(Q\land R),\\ &(R\land P),(R\land Q),(R\land R)\} \end{aligned}$$

We may similarly compute all of the disjunctions and conditionals, written as $$(\mathcal F_0\lor\mathcal F_0)$$ and $$(\mathcal F_0\to \mathcal F_0)$$.

If we group these all together, we get the set of all formulas which are "of complexity at most 1".


 * $$\begin{aligned}

\mathcal F_1 = \mathcal F_0\cup &(\neg \mathcal F_0) \\ &(\mathcal F_0\land \mathcal F_0) \\ &(\mathcal F_0\lor\mathcal F_0)\\ &(\mathcal F_0\to \mathcal F_0) \end{aligned}$$ If we compute this union, it has the elements,
 * $$\begin{aligned}

\{&P,Q,R,\\ &(\neg P),(\neg Q),(\neg R),\\ &(P\land P),(P\land Q),(P\land R),\\ & \dots \\ & (P\lor P),(P\lor Q),(P\lor R),\\ & \dots \\ & (P\to P),(P\to Q),(P\to R)\} \end{aligned}$$

Note that this set contains 3 + 3 + 9 + 9 + 9 = 33 elements.

We then proceed to the formulas of complexity at most 2, in a similar way. This time we compute $$(\neg \mathcal F_1)$$. This is the set of all negations of formulas in $$\mathcal F_1$$.

Because $$(\neg\mathcal F_1)$$ has 33 elements, we won't try to list them. We would also want to compute $$(\mathcal F_1\land\mathcal F_1)$$ which would contain $$33^2 = 1089$$ elements, so we want to list them even less!

But in short, the formulas of complexity at most 2 is the set
 * $$\begin{aligned}

\mathcal F_2 = \mathcal F_1\cup &(\neg \mathcal F_1) \\ &(\mathcal F_1\land \mathcal F_1) \\ &(\mathcal F_1\lor\mathcal F_1)\\ &(\mathcal F_1\to \mathcal F_1) \end{aligned}$$

This set will have a total of $$33+33+33^2+33^2+33^2 = 3333$$ elements.

And continuing in the same way, we may construct $$\mathcal F_3,\mathcal F_4$$, and so on.

We the define the set of all propositional formulas as the union of all of these sets.

Set $$\mathcal F_0=\{P, Q\}$$.

Compute $$(\neg \mathcal F_0)$$ and $$(\mathcal F_1)$$.

Then repeat the exercise if $$\mathcal F_0 = \{P\}$$.

This bottom-up construction of all formulas makes it easy to demonstrate that an expression is a formula. For example, we can show that $$((\neg P)\lor Q)$$ is a formula, by the following argument.

First, $$P\in \mathcal F_0$$ and therefore $$(\neg P)\in\mathcal F_1$$.

Second, $$Q\in\mathcal F_0$$ and therefore $$Q\in \mathcal F_1$$.

Finally, because $$(\neg P)\in \mathcal F_1$$ and $$Q\in\mathcal F_1$$, therefore $$((\neg P)\lor Q)\in\mathcal F_2$$.

This last shows that $$((\neg P)\lor Q)$$ is a formula, because it occurs in one of the sets $$\mathcal F_n$$ for some $$0\le n$$.

Show that $$((\neg P)\land(Q\to R)$$ is a formula.

Also show that $$\neg P$$ is not a formula.

Technically $$\neg P$$ is not a formula. In order to be a formula it must have the final surrounding parentheses, $$(\neg P)$$.

However, these final surrounding parentheses are only useful in having a simple definition of a formula, and are not actually important for humans to read the formula.

Therefore, we will write formulas without the final surrounding parentheses. We will just understand that, technically, the final parentheses need to be there, but for simplicity we omit them.