Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

Formal Methods in Software Engineering

Lecture 5
I N S T R U C T O R : Z A RTA S H A K I R A N
First Order Logic in FM
(PREDICATE LOGIC)
Why Predicate logic
 But unfortunately, in propositional logic, we ca n only represent the facts, which are either true or
false.

 PL is not sufficient to represent the complex sentences or natural language statements.

 The propositional logic has very limited expressive power.

 Proposition is constant declarative statement that can result in either true or false.

 One of the limitation of propositional logic is that it only argue about the individual value but does not
allow us to argue the set of values
Predicate logic
🠶 First-order logic statements can be divided into two parts:
• Subject: Subject is the main part of the statement.
• Predicate: A predicate can be defined as a relation, which binds two atoms together in a
statement.
🠶 Consider the statement: "x is an integer.", it consists of two parts, the first part x is the
subject of the statement and second part "is an integer," is known as a predicate.
Example:
Consider the statement
“x is greater than 10” Or “X is an even number”
The above statement has 2 parts
1. The first part is “Variable x”. It is the subject of the statement.
2. The second part is the “Is GREATER THAN 10” that refers to a property that the subject can have is
called the ‘’predicate’’
We can denoted the statement “x” is greater tham”10” by the notation p(x)

P(x) is called the propositional function at x


Once a value has been assigned to the variable x, the statement p(x) becomes a propositional and has a truth
value
Element of Predicate
Example:
Quantifiers
1. All birds have wings.
2. Some men are tall.
3. For every integer x,y,z is non-negative integers
4. The above statements involve certain words: ”ALL” “Some” “For every” that are associated with the
idea of a quantity such words are called Quantifiers
The Following are quantifiers that can be use with a predicate;
Existential ∃: There exists some elements or For some the elements including itself.
Universal ∀: For every element or For all the elements obviously including itself.
Quantifier “All” is called universal quantifier and it is denoted by “ ∀”
The symbol “∀” represent the following have some meaning
Quantifiers
Universal ∀:For every element or For all the elements obviously including itself.
Quantifier “All” is called universal quantifier and it is denoted by “ ∀”
The symbol “∀” represent the following have some meaning
For ALL, For every, Every thing ,Each Thing
Existential Quantifiers ∃:There exists some elements or For some the elements including itself.
The Quantifier “some” is called Existential Quantifier. and it is denoted by “∃”
The following phrases have some meanings
There exists, There is at least, There is an
Represent the Statement in symbolic form using
Quantifiers
Write down the Quantified statement in symbolic form.
I. All monkey have Tails.
II. No monkey has a tail.
III. Some people who trust others are rewarded
Let Us Consider
M(x): x is a monkey
T(x): x has a tail
I. For all x, If x is a monkey than x has a tail
∀x(M(x) ⇒T(x))
For all x, If x is a monkey the x has no tail
∀x(M(x) ⇒ ¬T(x))
∃x(p(x)^T(x)^R(x)
Example:
Example:
"Every student in the university has taken a mathematics course."

Let's define our predicates:

S(x): x is a student.

C(x): x is a mathematics course.

T( x,y): Student x has taken course y.


Solution:
Using these predicates, we can express the statement as a logical formula.

Solution: We want to express that for every student x, there exists a course y such that x has
taken y and y is a mathematics course.

The formal representation using predicate logic would be:

∀x(S(x)→∃y(C(y)∧T(x,y)

This formula can be read as "For all x, if x is a student, then there exists a y such that y is a
mathematics course and x has taken y."
Example:
"Every user in the system must have at least one assigned role."

Let's define our predicates:

U(x): x is a user.

R(x): x is a role.

A(x,y): User x is assigned the role y.

Using these predicates, we can express the requirement as a logical formula.


Solution:
We want to express that for every user x, there exists a role y such that x is assigned y.

The formal representation using predicate logic would be:

∀x(U(x)→∃y(R(y)∧A(x,y)

This formula can be read as "For all x, if x is a user, then there exists a y such that y is a role, and
x is assigned y."
Example:
"There exists an employee in the database who is a manager."

Let's define our predicates:

E(x): x is an employee.

M(x): x is a manager.
Solution:
Using these predicates, we can express the requirement as a logical formula.

Solution: We want to express that there exists an employee x who is a manager.

The formal representation using predicate logic would be:

∃x(E(x)∧M(x)
This formula can be read as "There exists an x such that x is an employee and x is a manager."
Predicate Logic
Predicate and Operators
Predicate and Truth Table

You might also like