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:
- If wet and humid then it rains
- true
- false
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.
Symbol | Description |
---|---|
Conjuction (Logical AND) | |
Disjunction (Logical OR) | |
Negation (Invert) | |
Implication (If Then) | |
Equivalence () |
This can be used to build the following propositional formulas with, for example:
The truth values are defined for propositional formulas as in the following figure. Note here 0 = False and 1 = True.
Suppose we get the formula . 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.
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 (For all ...), (There exists at least one...)
- Variables , , ...
- Functors these simply represent functions as variables.
- Predicates e.g. male, wet, hasmoney ...
The quantifier thing is always written like this:
.
Translated: For all it is true that they are wet.
Let the set of all dresses, then
.
Translated: For all element clothes it is true that they are wet.
.
Translated: There exists at least one for which it is true that it is wet.
Let the set of all dresses, then
.
Translated: There exists at least one 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 has a car
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 belongs to
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.
belongs to does not belong to .
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 😄.