70. Propositional forms
The letters $P$ and $Q$ in the DeMorgan Laws are called propositional variables. They are like variables in algebra except that you substitute propositions or predicates for them instead of numbers. Don’t confuse propositional variables with the variables which occur in predicates such as “$x < y$”. The variables in predicates are of the type of whatever you are talking about, presumably numbers in the case of “$x < y$”. Propositional variables are of type “proposition”: they vary over propositions in the same way that $x$ and $y$ in the statement “$x < y$” vary over numbers.
70.1.1 Worked Exercise Write the result of substituting $x = 7$ for $P$ and $x \neq 5$ for $Q$ in the expression $\neg P \vee (P \wedge Q)$.
Answer $x \neq 7\vee (x = 7\wedge x \neq 5)$.
70.2 Variables in Pascal
Pascal does not have variables or expressions of type proposition. It does have Boolean variables, which have TRUE and FALSE as their only possible values.
An expression such as ‘$X < Y$’ has numerical variables, and a Boolean value — TRUE or FALSE, so it might correctly be described as a proposition (assuming the program has already given values to $X$ and $Y$). However, if $B$ is a Boolean variable, an assignment statement of the form $B\colon = X < Y$ sets $B$ equal to the truth value of the statement ‘$X < Y$’ at that point on the program; $B$ is not set equal to the proposition ‘$X < Y$’. If $X$ and $Y$ are later changed, changing the truth value of ‘$X < Y$’, the value of $B$ will not automatically be changed.
70.2.1 Example The following program prints TRUE. Here B is type BOOLEAN and X is of type INTEGER:
X := 3;
B := X < 5;
X:= 7;
PRINT(B);
70.3 Propositional forms
Meaningful expressions made up of propositional variables and logical connectives are called propositional forms or propositional expressions. The expressions in DM.1 and DM.2 are examples of propositional forms. Two simpler ones are
$$P \vee \neg P \tag{70.1}$$
and
$$\neg P \vee Q \tag{70.2}$$
70.3.1 Substituting in propositional forms If you substitute propositions for each of the variables in a propositional form you get a proposition.
You may also substitute predicates for the propositional variables in a propositional form and the result will be a predicate.
70.3.2 Example If you substitute the proposition “$3 < 5$” in formula (70.1) you get (after a little rewording) “$3 < 5$ or $3\geq 5$” which is a proposition (a true one, in fact).
If you substitute $x < 5$ for $P$ in formula (70.1) you get “$x < 5$ or $x \geq 5$”, which is true for any real number $x$. This is not surprising because formula (70.1) is a tautology (discussed later).
If you substitute $x < 5$ for $P$ and $x \neq 6$ for $Q$ in $\neg P \vee Q$ you get “$x \geq 5$ or $x \neq 6$”, which is true for some $x$ and false for others.
70.3.3 Remarks
a) This would be a good time to reread Section 12.1.4. Propositional forms are a third type of expression beside algebraic expressions and predicates. In an algebraic expression the variables are some type of number and the output when you substitute the correct type of data for the variables is a number. In a predicate the output is a proposition: a statement that is either true or false. And now in propositional forms the variables are propositions and when you substitute a proposition for each propositional variable the output is a proposition.
b) We have not given a formal definition of “meaningful expression”. This is done in texts on formal logic using definitions which essentially constitute a context-free grammar.
Pages 104–105 of the book (PDF).