Skip to main content

Predicate logic 1st level

· 4 min read
Strider

Predicate logic is the extended form of propositional logic and a branch of mathematical logic. This is used to check and describe things better in the core logically.

What is propositional logic?

Propositional logic is also a branch of formal logic. I do not intend to go into the history of it and the reason why it exists etc...

Let's just get started.

A few propositional formulas:

  • 3<53 < 5
  • If wet and humid then it rains
  • x<yx < y
  • true
  • false
  • cc

These are all examples of propositional formulas. Even a constant is a propositional formula.

Connecting propositional formulas

You can also connect single formulas with each other with junctors.

SymbolDescription
\wedgeConjuction (Logical AND)
\veeDisjunction (Logical OR)
¬\negNegation (Invert)
\rightarrowImplication (If \rightarrow Then)
\LeftrightarrowEquivalence (ABA \Leftrightarrow B)

This can be used to build the following propositional formulas with, for example:

  • 3<5true3 < 5 \wedge true
  • ¬falsetrue\neg false \wedge true
  • x<ycx < y \vee c

The truth values are defined for propositional formulas as in the following figure. Note here 0 = False and 1 = True.

table.png

Suppose we get the formula A¬BA \wedge \neg B. We apply the truth values of each subexpression from the upper truth table. Then we can form a new truth table with it, which refers to our formula. The whole thing then looks like in the picture below.

table2.png

So far so good. Let's move on to the topic of predicate logic level 1. Here it is somewhat different than with the propositional logic, well what does different mean, it is extended. Here the following additions come into play:

Quantifiers, Functors and variables

  • Quantifiers \forall (For all ...), \exist (There exists at least one...)
  • Variables xx, yy, ...
  • Functors ff these simply represent functions as variables.
  • Predicates e.g. male, wet, hasmoney ...

The quantifier thing is always written like this:

x:wet(x)\forall x : wet(x).
Translated: For all xx it is true that they are wet.
Let GG the set of all dresses, then xG:wet(x)\forall x \in G : wet(x).
Translated: For all xx element clothes it is true that they are wet.

x:wet(x)\exist x : wet(x).
Translated: There exists at least one xx for which it is true that it is wet.
Let GG the set of all dresses, then xG:wet(x)\exist x \in G : wet(x).
Translated: There exists at least one xx element of clothes for which it is true that it is wet.

Complex predicate logic statements

If we want to say for example that: "All people have a car", it would look like this:

First we formulate this as a sentence: "For all m element humans at least one car exists so that everyone has a car".

In predicate logic: Let P the set of people, C the set of cars, then pPcC:p\forall p \in P \exist c \in C: p has a car cc

If we now turn the quantifiers around, this statement comes out.

Also we formulate this as a sentence: "There exists at least one car for all m element humans so that is valid one car belongs to all people".

In predicate logic: Let P the set of people, A the set of cars, then cCpP:c\exist c \in C \forall p \in P: c belongs to pp

Learnings?

What do we learn from this? Exactly the quantifiers are not interchangeable, otherwise the wrong statement is made.

If we now want to negate the wrong expression or the wrong formula, we must first swap the quantifiers and then negate the rest of the statement.

cCpP:c\exist c \in C \forall p \in P: c belongs to pcCpP:cp \rightarrow \forall c \in C \exist p \in P: c does not belong to pp.

The statement here would then be: "For all a element cars there exists at least one m element human so that car a does not belong to human m".

Colloquially: "Not every human has the same car".

That is already in the rough the predicate logic. Of course there is more you can do with it, but that will come in the prolog posts.

I hope I could give a small insight into the predicate logic of the first stage 😄.