The document presents an overview of computational logic topics covered at the SRM Institute of Science and Technology, including first order logic, scope and bound, substitutions, semantics, and interpretations of formulas. It explains key concepts such as free and bound variables, the semantics of first order logic structures, and state-models, illustrating these with examples. Additionally, it contrasts the properties of first order languages with propositional languages, addressing satisfiability and validity of formulas.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
COMPUTATIONAL LOGIC
Dr.J.Faritha Banu
SRM IST- Ramapuram
2.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Topics Covered in this Presentation are
Scope and Bound in First Order Logic
Substitutions
Semantics of FL
Interpretation and Valuation of FL
Satisfiability and Validity
Metatheorems
3.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Scope and Bound
Scope: In a formula (∀𝑥 𝛼) or (∃𝑥 𝛼), the scope of a quantifier is the formula 𝛼.
Example 1 : In the formula ∃x(Pxy ∧∀y Qy)
Scope of ∃ is ∃x(Pxy ∧∀y Qy)
Scope of ∀ is the formula ∀y Qy
Bound: An occurrence of a variable x in 𝛼 is a bound occurrence iff this occurrence is within the
scope of some quantifier of the same variable.
more than one occurrence of quantifiers using that variable, then this occurrence of the variable
is said to be bound by the rightmost among all these occurrences of quantifiers.
Free Variable: An occurrence of a variable in a formula is called a free occurrence or free
variable if it is not bound.
A formula having no free variables is called a closed formula or a sentence. A formula that is
not closed is called an open formula.
4.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Scope and Bound
Example 2: In the formula ∀x(∀yPxyz ∧ ∀xQx → ∃zPzzz) find the scope of quantifier
Scope of first ∀ is the whole formula
Scope of second ∀ is the formula ∀yPxyz
Scope of third ∀ is the formula ∀xQx
Scope of ∃ is the formula ∃zPzzz
Example 3: ∃x(Px ∧ Qx → ¬Px ∨ Qy)
Scope of ∃ is the formula ∃x(Px ∧ Qx → ¬Px ∨ Qy)
Free Variable : y
Example 4: ∃x ( (Px ∧ Qx) → (¬Px ∨ Qy) )
Scope of ∃ is the formula ∃x ( (Px ∧ Qx) → (¬Px ∨ Qy) )
All occurrences of x are bound by this ∃x , Free variable : y
Here, x is a bound variable and y is a free variable
The formula is not a sentence; it is an open formula.
5.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Scope and Binding
Example 5: In the formula ∀x (∃y P(x,y) ∧ ∀y (¬P (x,y) ∨ P(x,y) ) )
Scope of ∃ is the formula ∃y P(x,y)
Scope of second occurrence of ∀ is the formula ∀y (¬P (x,y) ∨ P(x,y) )
Scope of first occurrence of ∀ is the formula (∃y P(x,y) ∧ ∀y (¬P (x,y) ∨ P(x,y) ) )
First two occurrences of y are bound by ∃y;
Third, fourth, and fifth occurrences of y are bound by ∀y.
All occurrences of x are bound by ∀x.
All occurrences of all variables are bound. Therefore ,The formula is a sentence.
6.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Substitutions
In substitution, We write [x/t] for the substitution of the free variable x by the term t,
For a formula X,
X[x/t] denotes the resulting formula is obtained by replacing each free
occurrence of 𝑥 in formula X with 𝑡.
substitution must NOT affect bound occurrences of the variable.
Only free occurrences of a variable can be substituted by a term.
Such substitutions are sometimes called admissible substitutions.
7.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Substitutions
Example for substitution:
1. (Px→Qx)[x/t] = Pt →Qt ( both are free variable)
2. (∀xPxy)[x/t] = ∀xPxy (not replaced x by t because no free var x it is bound)
3. ∀x(Pxy[x/t]) = ∀xPty ( here after replacement only its bound )
4. ∀x∃y((Px∧Qyx)→Rzy[y/t]) = ∀x∃y(Px∧Qyx)→Rzt (here after replacement only its bound)
5. ∀x∃y((Px∧Qyx)→Rzy)[y/t] = ∀x∃y(Px∧Qyx)→Rzy (all y is bound) So no replacement
8.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Substitutions
When writing natural deduction proofs in predicate logic, it is often useful to replace a variable
in a formula with a term.
Suppose that the following sentences are true:
(∀𝑥 (Fish(𝑥) → Swim(𝑥))) (1)
Fish(Nemo) (2)
To conclude that Nemo can swim, we need to replace every occurrence of the variable x in the
implication (Fish(𝑥) → Swim(𝑥)) by the term Nemo.
This gives us (Fish(Nemo) → Swim(Nemo)) (3)
By modus ponens on (2) and (3),
we conclude that Swim(Nemo).
Formally, we use substitution to refer to the process of replacing 𝑥 by Nemo in the formula (∀𝑥
(Fish(𝑥) → Swim(𝑥))).
9.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Semantics of FL
Interpretation of first order formulas starts with fixing a nonempty set as the domain or universe
of that interpretation.
All constants are interpreted as certain elements in the domain.
All function symbols are interpreted as partial functions on the domain.
All predicates are interpreted as relations over the domain.
An assignment l, which associates variables to elements of the universe or domain of an
interpretation is called a valuation (or a variable assignment function).
(Do not confuse this with the boolean valuation of propositions)
Ex: Soumya is younger than her father.
While assigning x to ‘Soumya’, you had taken l(x) = Soumya, l(f (x)) = Soumya’s father.
φ( f ) = ‘father of’, l( f (x)) = φ( f (l(x)).
10.
An interpretation isa pair I = (D, φ)
Domain/ Universe of I Mapping
Function symbols partial functions
Predicates relations over the
domain
φ : P ∪ F → R
Collection of all relations and functions
0-ary n-ary
φ(P) - objects φ(P) ⊆ Dn
0-ary
φ(f) : Dn→ D
n-ary
Constant, Name
Dn is n-ary relations/
functions in D
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Semantics of FL
11.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Interpretation of FL
An interpretation is a pair I = (D,φ), where D is a nonempty set, called the domain or universe of I, and φ
is a function associating function symbols with partial functions on D and predicates with relations on D.
Further, φ preserves arity, that is,
(a) If P is a 0-ary predicate (a propositional variable), then φ(P) is a sentence in D, which is either true or
false.
(b) If P is ≈, then φ(P) is the equality relation on D, expressing “same as”, that is, φ(P) = {(d,d) : d ∈ D}.
Ex:Father (rajiv) ≈ Father (Sanjay)
(c) If P is an n-ary predicate for n≥1, other than ≈, then φ(P) is an n-ary relation on D, a subset of Dn.
(d) If f is a 0-ary function symbol (a constant, a name), then φ( f ) is an object in D; that is, φ( f ) ∈ D.
(e) If f is an n-ary function symbol, n≥1, then φ( f ) :Dn→D is a partial function of n arguments on D.
12.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Valuation under the interpretation I
A valuation under the interpretation I = (D, φ) is a partial function l that assigns terms to elements
of D, which is first defined for variables and then extended to terms satisfying:
1. If f is a 0-ary function symbol, then l(f) = φ(f).
2. If f is an n-ary function symbol and t1, . . . , tn are terms, then l(f(t1, . . . , tn)) = φ(f)(l(t1),
. . . , l(tn)).
3. A valuation l′ is called equivalent to a valuation l along the variable x iff l(y) = l′(y) for all
variables y = x.
4. For a valuation l, a variable x, and an object c ∈ D, we write l[x ↦ c] as
l[x ↦ c](x) = c; and for y ≠ x, l [x ↦ c](y) = l(y).
13.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
STATE
A state I l is a triple (D, φ, l ), where I = (D, φ) is an interpretation
and l is a valuation under I.
We read Il ⊨ X as
I l satisfies X or as Il verifies X or as Il is a state-model of X
Two states Il and Il′ are said to be equivalent along the variable x iff
the valuations l and l′ are equivalent along the variable x.
14.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Equivalent
Two formulas A, B are equivalent, written as A ≡ B iff every state-model of A is
also a state-model of B and vice versa.
That is, A ≡ B iff for every interpretation I and every valuation l under I, we have
either
Il ⊨ A and I l ⊨ B, or
Il ⊭ A and I l ⊭ B
15.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Semantics Comparison of FL and PL
First order Language Propositional Language
• Satisfiable
:
• Model:
• Valid:
State-model, might/might not have a model
For every valuation l under I, the state Il is a
state-model of A.
For every I and for every l under that I, the
state-model Il ⊨ A
• Model
• I(A) = 1
• Each I is its model
16.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
EXAMPLE Consider the formulas Pxy and Pc f (c) along with the following
interpretations I, J and valuations l, m :
I = (N,φ), Where J = (H,ψ), where
N is the set of all natural numbers, H is the set of all human beings
φ(P) = ‘is less than’, ψ(P) = ‘is a brother of’,
φ(c) = 0, ψ(c) = Rajiv,
φ( f ) = ‘successor function’, ψ( f ) = ‘mother of’,
l(x) = 0, l(y) = 1. m(x) = Rajiv, m(y) = Sanjay.
As we know, Rajiv and Sanjay are the grand sons of Pandit Jawaharlal
Nehru. Determine whether (a) I l ⊨ Pxy
(b) I l ⊨ Pc f (c)
(c) Jm ⊨ Pxy (d) Jm ⊨ Pc f (c).
17.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Observe that f is a unary function symbol, and it is associated with the functions ‘successor of’ and
‘mother of’, which take only one argument. Similarly, P is a binary predicate, and it is associated with
binary relations ‘less than’ and ‘is a brother of’.
(a) To check whether the state I l = (N,φ, l) is a state-model of Pxy,
we see that I l ⊨ Pxy
iff (l (x), l (y)) ∈ φ(P)
iff (0,1) ∈ ‘less than’
0 < 1 is true in Natural numbers. Therefore, I l ⊨ Pxy .
Suppose l(x) = 2 and l(y) = 4 Suppose l(x) = 6 and l(y) = 3
iff (l (x), l (y)) ∈ φ(P) iff (l (x), l (y)) ∈ φ(P)
iff (2,4) ∈ ‘less than’ iff (6,3) ∈ ‘less than’
2 < 4. is true in N. Therefore, I l ⊨ Pxy . 6 < 3. is not true in N. Therefore, I l ⊭ Pxy .
18.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
(b) I l ⊨ Pc f (c)
iff ( l(c), l(f (c)) ) ∈ φ(P)
( φ(c), φ( f (l(c)) )∈ φ(P)
iff (0, successor of 0) ∈ φ(P)
iff (0, 1) ∈ is less than
0 < 1 is true in N. Therefore I l ⊨ Pc f (c)
(c) Jm ⊨ Pxy
iff (m(x),m(y)) ∈ ψ(P)
iff (Rajiv, Sanjay) ∈ ‘is a brother of’
Rajiv is a brother of Sanjay. This latter sentence is true. Hence Jm ⊨ Pxy.
19.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
(d) Jm ⊨ Pc f(c)
iff (m(c),m( f (c))) ∈ψ(P)
iff (ψ(c),ψ( f )(ψ(c))) ∈ψ(P)
iff (Rajiv, mother of Rajiv) ∈ ‘is a brother of’
This results in the following
Rajiv is a brother of his own mother,
The above is not true. Thus, Jm ⊭ Pc f (c).
20.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
SATISFIABILITY AND VALIDITY
Let A be a formula. We say that A is satisfiable iff some state satisfies it; A is valid iff each state
satisfies it;
A is satisfiable iff some state satisfies I l ⊨ A.
Let Σ be a set of formulas, I an interpretation, and l a valuation under I. The state I l is a state-model
of (or satisfies, or verifies) the set Σ, written as I l ⊨ Σ, iff for each X ∈ Σ, I l ⊨ X.
The set Σ is called satisfiable iff Σ has a state-model, i.e., iff for some interpretation
I and for some valuation l under I, the state I l is a state-model of Σ.
21.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Example A = ∀xPxf(x) satisfiable?
I = (N, P′, f′), where P′ is the ‘less than’ relation and f′ is the function ‘plus 5’,
i.e., f′(n) = n+5. Let l be a valuation with l (x) = 3.
The state I l ⊨ ∀xPxf(x)
iff for each n ∈ N, I l [x↦n] ⊨Pxf(x).
l [x↦n] = l [x↦3] maps x to 3
I l [x↦3] ⊨Pxf(x)
iff 3 < 3+5
Since 3 < 3+5 is true in N,
So, I l[x↦3] ⊨Pxf(x) Satisfiable
If l (x) = 10, also the formula satisfies, for that matter if we consider any other value ∈ N, the formula
satisfies. I interprets the formula as “Each natural number n is less than n + 5”
22.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Example A = ∀xPxf(x) satisfiable?
Since N is an infinite set, we have infinite models for the formula
In order to check if the formula is invalid we need to identify the a state that may falsify the
formula.
J = (N, P~, f′), where P~ is the ‘greater than’ relation. f′ is function ‘plus 5’
J l ⊨ Pxf(x) iff for each n ∈ N, I l [x↦n] ⊨Pxf(x).
l [x↦3] ⊨Pxf(x) iff 3 > 3+5
As 3 ≯3+5
J l ⊭ Pxf(x) is Invalid
J interprets the formula as “Each natural number n is greater than n + 5
23.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Metatheorems:
1. Relevance Lemma
Let A be a formula, VA be the set of all free variables of A, I = (D, φ) be an interpretation and l , l′
be valuations under I such that l(x) = l′(x) for every x ∈ VA. Then I l ⊨ A iff I l′ ⊨ A
2. Relevance Lemma for Sentences
Let A be a sentence, and let I be an interpretation.
(1) I ⊨ A iff I l ⊨ A for some valuation l under I. (2) Either I ⊨ A or I ⊨ ¬A.
An interpretation may neither satisfy an open formula nor satisfy its negation.
3. Monotonicity
Let Σ and Γ be sets of formulas and let X be a formula. Suppose that Σ ⊆ Γ.
If Σ ⊨ X, then Γ ⊨ X. If Σ is satisfiable, then Γ is satisfiable
24.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
Metatheorems:
4. Deduction Theorem
Let Σ be a set of formulas, and let X, Y be formulas. Then, Σ ⊨ X → Y iff Σ ∪ {X} ⊨ Y .
5. Reductio ad absurdum:
Let Σ be a set of formulas and let X be a formula.
Σ ⊨ X iff Σ ∪ {¬X} is unsatisfiable.
Σ ⊨ ¬X iff Σ ∪ {X} is unsatisfiable.
25.
SRM INSTITUTE OFSCIENCE AND TECHNOLOGY
RAMAPURAM CAMPUS, CHENNAI-600 089
References
1. Arindama Singh," Logics for Computer Science", PHI Learning Private
Ltd,2nd Edition, 2018
2. Wasilewska & Anita, "Logics for computer science: classical and non-
classical", Springer, 2018
3. Huth M and Ryan M, Logic in Computer Science: Modeling and Reasoning
about systems‖, Cambridge University Press, 2005
4. Dana Richards & Henry Hamburger, "Logic And Language Models For
Computer Science", Third Edition, World Scientific Publishing Co. Pte.
Ltd,2018