0% found this document useful (0 votes)
35 views23 pages

Formal Methods in Software Engineering: (FMSE)

This document discusses first-order logic (FOL). FOL allows reasoning about properties that are shared by many objects through the use of variables. It contains predicates, which resemble functions that can be true or false, as well as quantifiers and variables. FOL formulas are built from atomic formulas using rules that correspond to logical connectives like negation and conjunction, or quantifiers like exists. The semantics of FOL involve interpreting formulas over a domain of objects.

Uploaded by

lets play
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views23 pages

Formal Methods in Software Engineering: (FMSE)

This document discusses first-order logic (FOL). FOL allows reasoning about properties that are shared by many objects through the use of variables. It contains predicates, which resemble functions that can be true or false, as well as quantifiers and variables. FOL formulas are built from atomic formulas using rules that correspond to logical connectives like negation and conjunction, or quantifiers like exists. The semantics of FOL involve interpreting formulas over a domain of objects.

Uploaded by

lets play
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Formal Methods in Software Engineering

(FMSE)

Lecture # 5

(Lecture # 5 ) FMSE 1 / 23
First Order Logic

Philosophers have developed First Order Logic to overcome the


limitations of propositional logic. Actually First Order Logic is an
advanced form of propositional logic.

Its domain of variables is usually very large and infinite, and


distinguished from propositional logic by its use of quantified variables.

It additionally covers the predicates, which resembles a function that


may either be true or false.

First Order Logic allows reasoning about properties that are shared by
many objects through the use of variables.

(Lecture # 5 ) FMSE 2 / 23
First Order Logic or Predicate Logic

In traditional grammar, a predicate is one of the two main parts of a


sentence the other being the subject, which the predicate modifies.

“Sky is blue” Sky acts as the subject, and is blue acts as the
predicate.

Brother(Ali, Ahmad), lessThan(2, 3)


The predicate is much like a verb phrase.

In linguistic semantics, a predicate is an expression that can be true of


something

(Lecture # 5 ) FMSE 3 / 23
First Order Logic

First-order logic (FOL) is the logic to speak about objects, which are
the domain of discourse (variables range over individuals) or universe.

Objects Example: FMSE, John, CS102, etc.

FOL is concerned about properties of these objects and relations over


objects.

FOL contains predicates, quantifiers and variables.


Relations/Predicates Example: isMan(John),
hasClass(FMSE, CS102), isKindOf(apple, fruit)

FOL has functions including constants that denote objects.

Example; Philosopher(a) → Scholar(a)


(Lecture # 5 ) FMSE 4 / 23
FOL Quantifiers

logical connectives: ¬, ∨, ∧, ⇒, ⇔

Quantifiers:
Universal: ∀x, King(x) ∧ Greedy(x) ⇒ Evil(x)

Existential: ∃y : (isFather (y , John))

Evil king john rules England in 1200


Objects: John, England, 1200
Property: evil, king
Relation: ruled

(Lecture # 5 ) FMSE 5 / 23
Properties of Quantifiers

∀x∀y is the same as ∀y ∀x

∃x∃y is the same as ∃y ∃x

∃x∀y is the same as ∀y ∃x

Quantifiers Daulity:
∀x Likes(x, IceCream) ≡ ¬∃x¬ Likes(x, IceCream)

∃x Likes(x, MangoIceCream) ≡ ¬∀x¬ Likes(x, MangoIceCream)

(Lecture # 5 ) FMSE 6 / 23
Properties of Quantifiers

Equivalence
∃xP is equivalent to ¬∀x¬P

¬∃x¬P is equivalent to ∀xP

∃x¬P is equivalent to ¬∀xP

¬∃x¬P is equivalent to ∀x¬P

(Lecture # 5 ) FMSE 7 / 23
FOL Formulas

The set of formulas (also called well-formed formulas or wffs) is inductively


defined by the following rules:

1 Predicate symbols. If P is an n−ary predicate symbol and t1 , . . . , tn


are terms then P(t1 , . . . , tn ) is a formula.
2 Equality. If the equality symbol is considered part of logic, and t1
and t2 are terms, then t1 = t2 is a formula.
3 Negation. If ϕ is a formula, then ¬ϕ is a formula.
4 Binary connectives. If ϕ and ψ are formulas, then (ϕ → ψ is a
formula. Similar rules apply to other binary logical connectives.
5 Quantifiers. If ϕ is a formula and x is a variable, then ∀xϕ (for all
x, ϕ holds) and ∃xϕ (there exists x such that ϕ are formulas.

(Lecture # 5 ) FMSE 8 / 23
Expressing Facts in FOL

Lucy is a professor

All professors are people.

John is the dean.

Deans are professors.

Everyone is a friend of someone.

(Lecture # 5 ) FMSE 9 / 23
Knowledge base in FOL

Lucy is a professor — isProf(lucy)

All professors are people. — ∀x(isProf (x) → isPerson(x))

John is the dean. — isDean(John)

Deans are professors. — ∀x(isDean(x) → isProf (x))

Everyone is a friend of someone. — ∀x(∃y (isFriendOf (y , x)))

Question: Is John no friend of Lucy? ¬isFriendOf (John, lucy )?

(Lecture # 5 ) FMSE 10 / 23
(Lecture # 5 ) FMSE 11 / 23
Knowledge Engineering Steps

Identify the task.

Assemble the relevant knowledge.

Decide on a vocabulary of predicates, functions, and constants.

Encode general knowledge about the domain.

Encode a description of the specific problem instance.

Pose queries to the inference procedure and get answers.

Debug the knowledge base.

(Lecture # 5 ) FMSE 12 / 23
(Lecture # 5 ) FMSE 13 / 23
(Lecture # 5 ) FMSE 14 / 23
(Lecture # 5 ) FMSE 15 / 23
(Lecture # 5 ) FMSE 16 / 23
Syntax of First Order Logic

Syntax determines which collection of symbols are legal expression.

In First Order Logic, we use Greek letters like ϕ, ψ, χ, Γ, θ etc (instead


of using p, q, r as used in Propositional Logic).

In FOL, two types of legal expressions are used.

1 Every variable and constant is a term and term represents objects.

2 If f is an n−ary function and t1 , . . . , tn are terms, then f (t1 , . . . , tn ) is


also a term.

(Lecture # 5 ) FMSE 17 / 23
(Lecture # 5 ) FMSE 18 / 23
Primitive symbols are ¬, ∧, ∃.

Every formula in FOL is built from atomic formula by repeated


application of three rules.

Each rule corresponds to a primitive symbol.

These three rules are listed below:

1 If ϕ is a formula then so is ¬ϕ.

2 If ϕ and ψ are formulas the so is ϕ ∧ ψ .

3 If ϕ is a formula, then so is ∃xϕ for any variable x.

(Lecture # 5 ) FMSE 19 / 23
(Lecture # 5 ) FMSE 20 / 23
FOL Semantics

(Lecture # 5 ) FMSE 21 / 23
FOL Semantics

(Lecture # 5 ) FMSE 22 / 23
Thanks!

(Lecture # 5 ) FMSE 23 / 23

You might also like