# Logic for Computer Scientists/Propositional Logic/Semantics

## Definition 3 (Semantics of propositional logic)Edit

For the semantics of our formal language of propositions we do not refer to a specific intended interpretation. Moreover we only are interested in truth values. We assume an initial assignment of truth values to atomic formulae and based on this, we define the truth value of more complex formulae. The set of truth values is the set ${\displaystyle \{true,false\}}$ . An assignment for a set ${\displaystyle D}$  of atomic formulae is a function

${\displaystyle {\mathcal {A}}|D}$ ${\displaystyle \to \{true,false\}}$ . Let ${\displaystyle E}$  be the set of formulae containing ${\displaystyle D}$ , i.e ${\displaystyle E\supseteq D}$  and exactly those formulae which can be constructed from ${\displaystyle D}$  according to the definition of the syntax. Then the extension of ${\displaystyle {\mathcal {A}}}$  on ${\displaystyle E}$ , ${\displaystyle {\mathcal {A}}_{E}|E\to \{true,false\}}$ , is given as:

• ${\displaystyle A\in D}$  : ${\displaystyle {\mathcal {A}}_{E}(A)={\mathcal {A}}(A)}$
• ${\displaystyle {\mathcal {A}}_{E}((F\land G))={\begin{cases}\;\;\,true&{\text{if }}{\mathcal {A}}_{E}(F)=true{\text{ and }}{\mathcal {A}}_{E}(G)=true\\\;\;\,false&otherwise\end{cases}}}$
• ${\displaystyle {\mathcal {A}}_{E}((F\lor G))={\begin{cases}\;\;\,true&{\text{if }}{\mathcal {A}}_{E}(F)=true{\text{ or }}{\mathcal {A}}_{E}(G)=true\\\;\;\,false&otherwise\end{cases}}}$
• ${\displaystyle {\mathcal {A}}_{E}(\lnot F)={\begin{cases}\;\;\,true&{\text{if }}{\mathcal {A}}_{E}(F)=false\\\;\;\,false&otherwise\end{cases}}}$

In the following we will omit the index ${\displaystyle E}$  to indicate the extension of an assignment ${\displaystyle {\mathcal {A}}}$ . Note that this is the right place to name formulae of type ${\displaystyle (F\land G)}$  as conjunctions, formulae of type ${\displaystyle (F\lor G)}$  as disjunctions and formulae of type ${\displaystyle \lnot F}$  as negations.

The following is an example evaluation by means of the definition of ${\displaystyle {\mathcal {A}}}$ : Assume as given ${\displaystyle {\mathcal {A}}(A)=true,{\text{ }}{\mathcal {A}}(B)=true}$  and ${\displaystyle {\mathcal {A}}(C)=false}$ , then

${\displaystyle {\mathcal {A}}(\lnot ((A\land B)\lor C))}$

${\displaystyle {\text{ }}={\begin{cases}\;\;\,true&{\text{ if }}{\mathcal {A}}((((A\land B))\lor C))=false\\\;\;\,false&\;otherwise\end{cases}}}$
${\displaystyle {\text{ }}={\begin{cases}\;\;\,false&{\text{ if }}{\mathcal {A}}((((A\land B))\lor C))=true\\\;\;\,true&\;otherwise\end{cases}}}$
${\displaystyle {\text{ }}={\begin{cases}\;\;\,false&{\text{ if }}{\mathcal {A}}((((A\land B))))=true{\text{ or }}A(C)=true\\\;\;\,true&\;otherwise\end{cases}}}$
${\displaystyle {\text{ }}={\begin{cases}\;\;\,false&{\text{ if }}{\mathcal {A}}((((A\land B))))=true\\\;\;\,true&\;otherwise\end{cases}}}$
${\displaystyle {\text{ }}={\begin{cases}\;\;\,false&{\text{ if }}{\mathcal {A}}(A)=true{\text{ and }}{\mathcal {A}}(B)=true\\\;\;\,true&\;otherwise\end{cases}}}$
${\displaystyle {\text{ }}=false}$

## Definition 4Edit

Let ${\displaystyle {\mathcal {A}}}$  be an assignment and ${\displaystyle F}$  a formula. ${\displaystyle {\mathcal {A}}}$  is called assignment for ${\displaystyle F}$ , if ${\displaystyle {\mathcal {A}}}$  is defined for every subformula of ${\displaystyle F}$ . If ${\displaystyle {\mathcal {A}}}$  is an assignment for ${\displaystyle F}$  and ${\displaystyle {\mathcal {A}}(F)=true}$  we call ${\displaystyle {\mathcal {A}}}$  a model for ${\displaystyle F}$  and we write ${\displaystyle {\mathcal {A}}\models F}$  If ${\displaystyle {\mathcal {A}}}$  is an assignment for ${\displaystyle F}$  and ${\displaystyle {\mathcal {A}}(F)=false}$ , we write ${\displaystyle {\mathcal {A}}\nvDash F}$ .

A formula ${\displaystyle F}$  is called satisfiable, iff there is a model for ${\displaystyle F}$ , otherwise ${\displaystyle F}$  is called unsatisfiable. ${\displaystyle F}$  is called valid (or a tautology) iff every assignment for ${\displaystyle F}$  is a model. We write ${\displaystyle \models F}$  rsp. ${\displaystyle \nvDash F}$ .

## Theorem 1Edit

A formula ${\displaystyle F}$  is valid, iff ${\displaystyle \lnot F}$  is unsatisfiable.

Proof: ${\displaystyle F}$  is a tautology

iff every assignment for ${\displaystyle F}$  is a model for ${\displaystyle F}$

iff every assignment for ${\displaystyle F}$  (which is of course, also an assignment for ${\displaystyle \lnot F}$ ) is not a model for ${\displaystyle \lnot F}$

iff ${\displaystyle \lnot F}$  has no model

iff ${\displaystyle \lnot F}$  is unsatisfiable.

## Definition 5 (Consequence)Edit

A formula ${\displaystyle G}$  is called a consequence of the formulae ${\displaystyle F_{1},\cdots ,F_{k}}$ , if for every assignment ${\displaystyle {\mathcal {A}}}$  for ${\displaystyle G}$  and ${\displaystyle F_{1},\cdots ,F_{k}}$  holds: if ${\displaystyle {\mathcal {A}}}$  is a model for ${\displaystyle F_{1},\cdots ,F_{k}}$ , then ${\displaystyle {\mathcal {A}}}$  is a model for ${\displaystyle G}$ . We write ${\displaystyle \{F_{1},\cdots ,F_{k}\}\models G}$ .

The following theorem is a simple consequence from definitions:

## Theorem 2Edit

${\displaystyle G}$  is called a consequence of the formulae ${\displaystyle F_{1},\cdots ,F_{k}}$ ,

iff ${\displaystyle ((\bigwedge _{i=1}^{k}~F_{i})\to G)}$  is a tautologie

iff ${\displaystyle ((\bigwedge _{i=1}^{k}~F_{i})\land ~\lnot G)}$  is unsatisfiable.

Obviously the validity of a formula depends only of the assignments for its atomic subformulae: If ${\displaystyle {\mathcal {A}}}$  and ${\displaystyle {\mathcal {A}}'}$  are assignments for ${\displaystyle F}$  and if they yield the same value for every occurring atomic subformulae, then ${\displaystyle {\mathcal {A}}(F)={\mathcal {A}}'(F)}$  holds. As a consequence we can state, that it suffices for a test of the validity of a formula ${\displaystyle F}$  to check the infinitely many assignments of its atomic subformulae. Such a check can be depicted easily in a tableau of the following form, where ${\displaystyle F}$  is an arbritrary formula, containing ${\displaystyle n}$  distinct atomic formulae ${\displaystyle {\mathcal {A}}_{i}}$ .

${\displaystyle {\mathcal {A}}_{1}}$  ${\displaystyle \cdots }$  ${\displaystyle {\mathcal {A}}_{n-1}}$  ${\displaystyle {\mathcal {A}}_{n}}$  ${\displaystyle F}$
${\displaystyle {\mathcal {A}}_{1}}$  false ${\displaystyle \cdots }$  false false ${\displaystyle {\mathcal {A}}_{1}(F)}$
${\displaystyle {\mathcal {A}}_{2}}$  false ${\displaystyle \cdots }$  false true ${\displaystyle {\mathcal {A}}_{2}(F)}$
${\displaystyle {\mathcal {A}}_{2}n}$  true ${\displaystyle \cdots }$  true true ${\displaystyle {\mathcal {A}}_{n}(F)}$

When applying this procedure it might me helpful to introduce intermediate results for subformulae, as done in the following example.

${\displaystyle A}$  ${\displaystyle B}$  ${\displaystyle \lnot A}$  ${\displaystyle A{\text{ }}\to {\text{ }}B}$  (${\displaystyle \lnot {\text{ }}A{\text{ }}\to {\text{ }}(A{\text{ }}\to {\text{ }}B}$  ))
false false true true true
false true true true true
true false false false true
true true false true true

Note that we just have depicted an algorithm to check the validity of a formula. Assume the Formula contains ${\displaystyle n}$  atomic subformulae, then our just constructed tableaux contain ${\displaystyle 2^{n}}$  lines. To estimate the costs for such an exponential algorithm, assume that the computation of one line takes 1 micro-second. Is ${\displaystyle F}$  contains only 100 atomic subformulae the computation of the tableau would take ${\displaystyle 2^{100}}$  micro-seconds.

## Truth TablesEdit

The problem whether a propositional formula is satisfiable is called SAT and the corresponding tautology problem is called TAUT.

SAT is an NP-complete problem, and hence it is not known whether SAT is tractable or not. Whether TAUT is in NP is still an open problem. For TAUT we know, that it is in NP iff NP is closed under complementation. SAT and TAUT, both, play a prominent role in the study of complexity theory, in particular with respect to the question whether ${\displaystyle P=NP}$ .

## ProblemEdit

#### Problem 1 (Propositional)Edit

Compute truth tables for the following formulae. Decide for each formula whether it is valid (a tautology), satisfiable or unsatisfiable.

1. ${\displaystyle (A\land B)\land (B\to C)}$
2. ${\displaystyle (A\land B)\leftrightarrow (\lnot A\lor \lnot B)}$
3. ${\displaystyle (\lnot A\lor \lnot (\lnot B\lor A))\lor A}$
4. ${\displaystyle (A\to (B\land C))\leftrightarrow ((A\to B)\land (A\to C))}$
5. ${\displaystyle (A\lor (B\land A))\land ((C\lor \lnot C)\to \lnot A)}$
6. ${\displaystyle ((C\lor B)\land (C\lor \lnot B))\land \lnot C}$
7. ${\displaystyle \lnot (\lnot A\lor \lnot (\lnot B\lor \lnot A))}$
8. ${\displaystyle (A\to (B\to A))}$
9. ${\displaystyle (A\lor (B\land A))\land ((C\lor \lnot C)\to \lnot A)}$
10. ${\displaystyle ((A\lor \lnot B)\lor ((\lnot A\land \lnot C)\land B))\leftrightarrow ((A\lor \lnot C)\lor \lnot B)}$
11. ${\displaystyle \lnot (A\land \lnot (B\land \lnot C))}$

#### Problem 2 (Propositional)Edit

"What is the secret of your long life?" a 100-year old man was asked. He answered: "I apply the following diet rules very strictly: If I drink no wine at dinner then I have always fish. Whenever I take fish and wine for dinner, it is without garlic. If I have garlic or wine I avoid fish"

1. Formalize these rules with the help of propositional logic.
2. Try to simplify the advice of the 100-year old man.

#### Problem 3 (Propositional)Edit

Define the following functions recursively by induction over the construction of propositional formulae:

1. ${\displaystyle \alpha (F)}$ : Set of atomic formula in ${\displaystyle F}$
2. ${\displaystyle \beta (F)}$ : Number of the binary junctors ${\displaystyle \land }$  and ${\displaystyle \lor }$  in ${\displaystyle F}$

Note: For

${\displaystyle F}$  = ${\displaystyle (\lnot (A\lor B)\lor C)}$  ${\displaystyle \land }$  ${\displaystyle ((\lnot A\lor B)\land C)}$

${\displaystyle \alpha (F)=\{A,B,C\}}$  and ${\displaystyle \beta (F)=5}$  holds.

#### Problem 4 (Propositional)Edit

Given the formulae ${\displaystyle F_{n}}$ = ${\displaystyle A_{1}}$  ${\displaystyle {\stackrel {\cdot }{\vee }}\cdots {\stackrel {\cdot }{\vee }}A_{n}}$ , in which ${\displaystyle A_{1},\dots ,A_{n}}$  are atomic formulae (${\displaystyle n\geq 1}$ ) where ${\displaystyle {\stackrel {\cdot }{\vee }}}$  denotes exclusive or. Prove for all ${\displaystyle n\in \mathbb {N} }$ : A suitable assignment ${\displaystyle {\mathcal {A}}}$  for ${\displaystyle F_{n}}$  is a model for ${\displaystyle F_{n}}$  (i.e. ${\displaystyle {\mathcal {A}}\models F_{n}}$ ) iff ${\displaystyle {\mathcal {A}}(A_{i})=1}$  halds for an odd number of ${\displaystyle {\mathcal {A}}_{i}}$  (${\displaystyle 1\leq i\leq n}$ ).

#### Problem 5 (Propositional)Edit

In the following we investigate formulae, in which only atoms ${\displaystyle A_{1},\dots ,A_{n}}$  occur.

1. How many of such formulae with different truth tables exist at most?
2. Is there for every truth table a formula? If yes, please indicate a construction!

#### Problem 6 (Propositional)Edit

If the colonel was not in the room during the murder then he cannot know the weapon of the murderer. The butler lies or he knows the murderer. If Lady Barntree is the murderer then the colonel was in the room during the murder or the butler lies. The butler knows the murderer or the colonel was not in the room during the murder. The policeman concludes that Lady Barntree is the murderer. Give propositional variables for every statement of the argumentation. Write the argumentation as a set ${\displaystyle M}$  of propositional formulae of the prerequisites and the conclusion as a propositional formula ${\displaystyle F}$ .

#### Problem 7 (Propositional)Edit

Formalize the following expressions and then simplify the corresponding formulae and the verbal propositions.

1. It is not true that his mother is English and his father French.
2. It is not true that he is studying physics but not mathematics.
3. It is not true that the wages are going down and the prices are going up.
4. It is not true that it is not cold or rainy.

#### Problem 8 (Propositional)Edit

The professor proposes to make a new conception for the lunch in the University restaurant:

1. There must be bread with every lunch if there is no dessert.
2. If bread and dessert are served then is be no soup.
3. If soup is served then there is no bread.

Help the management to fulfill the wishes of the professor. For this

1. formalize the three propositions (as implications, disjunctions/conjunctions) and combine them into one logical formula.
2. Give a truth table for this logical formula. Is there a model for the formula?
3. Give a colloquial verbalization for the assignment.