Exercises 1: First-Order Logic (Formalisations, Substitutions

Problem 1.1: Signature for a Theory
Group Theory:
F = {f , e}, P = {eq}
Properties, e.g.:
I
∀x, y , z(eq(f (f (x, y ), z), f (x, f (y , z)))) (f associative)
I
∀x(eq(f (e, x), x) (left neutral)
I
∀x∃y (eq(f (y , x), e)) (left inverse)
I
∀x, y , z(eq(f (y , x), e) ∧ eq(f (z, x), e) → eq(y , z))
(The inverse is unique)
Problem 1.2: Signature for Partial Orders
.
P = {≤, =}
F = {}
.
Axioms for =:
.
(reflexivity) (∀x)x = x
.
.
(symmetry) (∀x)(∀y )(x = y → y = x)
.
.
.
(transitivity) (∀x)(∀y )(∀z)((x = y ∧ y = z) → x = z)
.
Here for ≤: ∀x; ∀y (x = y → x ≤ y )
Axioms for ≤:
(reflexivity) (∀x)x ≤ x
.
(antisymmetry) (∀x)(∀y )((x ≤ y ∧ y ≤ x) → x = y )
(transitivity) (∀x)(∀y )(∀z)((x ≤ y ∧ y ≤ z) → x ≤ z)
.
For a strict partial order < we do not need =. Replace first and
second axiom by irreflexivity:
(∀x)¬(x < x)
Problem 1.3: Number of subformulas (Notation)
Number of subformulas ≥ cardinality of set of subformulas.
Simply assume:
Each leaf of the formula is a different propositional variable.
Notation: Let φ denote a formula
I
#U (φ) is number of unary operators (¬, ∀, ∃)
I
#B (φ) is number of binary operators (∧, ∨, →)
I
#For (φ) number of subformulas in (∧, ∨, →)
Let nφ denote the number of connectives and quantifiers in φ:
nφ = #U (φ) + #B (φ)
Claim: #For (φ) = 2 × #B (φ) + #U (φ) + 1
Problem 1.3: Number of subformulas (Proof)
Proof: (by induction over n)
nφ = n = 0: φ is atomic formula and #For (φ) = 2 × 0 + 0 + 1 = 1
nφ = n
n < nφ :
Case 1: φ = (Qx | ¬) ψ
#B (ψ) = #B (φ)
(1)
#U (ψ) = #U (φ) − 1
(2)
⇒ nψ < nφ
#For (φ) = #For (ψ) + 1 =I.H.
2 × #B (ψ) + #U (ψ) + 1 + 1 =(1),(2)
2 × #B (φ) + (#U (φ) − 1) + 1 + 1 =
2 × #B (φ) + #U (φ) + 1
Problem 1.3: Proof – Case 2
nφ = n
n < nφ :
Case 2: φ = ψ1 ◦ ψ2
#B (φ) = #B (ψ1 ) + #B (ψ2 ) + 1
(3)
#U (φ) = #U (ψ1 ) + #U (ψ2 )
(4)
⇒ nψ1 < nφ , nψ2 < nφ
#For (φ) = #For (ψ1 ) + #For (ψ2 ) + 1
=I.H.
(2 × #B (ψ1 ) + #U (ψ1 ) + 1) + (2 × #B (ψ2 ) + #U (ψ2 ) + 1) +1
|
{z
} |
{z
}
#For (ψ1 )
#For (ψ2 )
= 2 × (#B (ψ1 ) + #B (ψ2 ) + 1) + (#U (ψ1 ) + #U (ψ2 )) + 1
=(3),(4) 2 × #B (φ) + #U (φ) + 1
Question: Where do we assume that the formula is fully
bracketed?
Problem 2.1: Free Substitution
1. σ := {x/c, y /f (c, g (x))} and
ϕ := ∀x(p(g (x), f (x, y )) ∨ q(x))
σ not free
2. σ := {x/f (g (x), c)} and
ϕ := ∃y (p(x, y ) → ∃z∀x(r (f (z, c), f (c, x))))
σ is free
3. σ := {y /g (x), z/g (y )} and
ϕ := p(x, y ) → ∀x(q(f (x, z)) ∨ ∃y (q(f (x, y ))))
σ is free
Problem 2.2: Composition of Substitutions
Lemma
For any term t and any substitutions σ, τ : t(στ ) = (tσ)τ .
Proof.
t = x (x ∈ var ):
(xσ)τ = (σ(x))τ = τ (σ(x)) = (τ ◦ σ)(x) = x(τ ◦ σ) = x(στ )
t is constant: trivial
Induction Step: t = f (t1 , . . . , tn ):
(tσ)τ = (f (t1 , . . . , tn )σ)τ = f (t1 σ, . . . , tn σ)τ = f ((t1 σ)τ, . . . , (tn σ)τ )
=I .H. f (t1 (στ ), . . . , tn (στ )) = f (t1 , . . . , tn )(στ )
Problem 2.2: Composition of Substitutions (Cnt’d)
Counterexample (for formula):
φ := (∀x)p(x, y ), σ := {y /f (x)}, τ := {x/c}:
φ(στ ) = (∀x)p(x, f (c)) because στ = {y /f (c), x/c}
(φσ)τ = (∀x)p(x, f (x)) x is “captured” after σ
Theorem
If σ is free for φ and τ is free for φσ, then φ(στ ) = (φσ)τ .
Proof.
1. φ atomic formula: trivial (similar to previous slide)
2. φ := ψ1 ◦ ψ2 : (ψ1 ◦ ψ2 )(στ ) = ψ1 (στ ) ◦ ψ2 (στ )
As σ free for φ, τ free for φσ ⇒ σ free for ψ1 , ψ2 (τ similar)
⇒I .H. ψ1 (στ ) ◦ ψ2 (στ ) = (ψ1 σ)τ ◦ (ψ2 σ)τ ) = ((ψ1 σ) ◦ (ψ2 σ))τ =
((ψ1 ◦ ψ2 )σ)τ
3.φ := (Qx)ψ: By assumption, σ free for Qxψ, τ free for (Qxψ)σ
⇒
Hence, σx free for ψ and τx free for ψσx ⇒I .H. (ψσx )τx = ψ(σx τx )
Left to show: ψ(σx τx ) = ψ(στ )x
Problem 2.2: Composition of Substitutions (Cnt’d)
Proof.
Left to show: ψ(σx τx ) = ψ(στ )x
Let Y be an occurrence of any free variable in ψ. Sufficient:
(Y σx )τx = Y (στ )x
1. x = Y : X
2. x 6= Y : Y σx = Y σ and Y (στ )x = Y (στ )
x 6∈ Y σ because σ free for Qxφ. Hence (Y σ)τ = (Y σ)τx
We get:
Y (σx τx ) =lemma (Y σx )τx = (Y σ)τx = (Y σ)τ = Y (στ ) = Y (στ )x
And thus: ((Qxφ)σ)τ = (Qx(φσx ))τ = Qx((φσx )τx ) =
Qx(φ(σx τx )) = Qx(φ(στ )x ) = (Qxφ)(στ )
Problem 3.1: Weapons& Words
isDifferent(x,y):
1. ∀x(¬isDifferent(x, x))
2. ∀x∀y (isDifferent(x, y ) ↔ isDifferent(y , x))
Then
weapon(stick) ∧ weapon(stone) ∧ isDifferent(stick, stone)
ensures that at least two different weapons exist.
Alternative:
∃x, y (weapon(x) ∧ weapon(y ) ∧ isDifferent(x, y ))
Problem 3.2: Formalisation of the Intermediate Value
Theorem
Theorem
Let f be a continuous function on [a, b].
Then f takes on every value within
[min(f (a), f (b)), max(f (a), f (b))].
Assumption: f (a) < f (b)
Reformulation of the theorem:
Theorem
Let f be a continuous function on [a, b] such that f (a) ≤ f (b) .
For all v ∈ [min(f (a), f (b)), max(f (a), f (b))] There exists
z ∈ [a, b] such that f (z) = v .
Symbols:
F = {f , a, b, v } where f is the function and a, b are constants
P = {leq, inInv, continuous}, α(leq) = 2, α(inInv) =
3, α(continuous) = 2
Problem 3.2: Cnt’d
Intended meaning:
leq(x, y ) represents x ≤ y
inInv(a, x, b) expresses a ≤ x ≤ b
continuous(a, b) expresses f is continous in [a, b]
Properties of predicates
leq is total order:
I
∀xleq(x, x) reflexivity
I
∀x, y (¬leq(x, y ) → leq(y , x)) antisymmetry
I
∀x, y , z(leq(x, y ) ∧ leq(y , z) → leq(x, z)) transitivity
inInv:
∀l, x, u(leq(l, x) ∧ leq(x, u) → inInv(l, x, u))
Formalization
continuous(a, b) ∧ leq(f (a), f (b)) →
∀v (inInv(f (a), v , f (b)) → ∃z(inInv(v , f (z), v )))
Problem 3.2: Cnt’d
Formalizing continuous(a, b):
∀v (inInv(f (a), v , f (b))
Continuity (right-sided, f (x) > v ):
I
I
“Readable” version:
∀x((a ≤ x ≤ b ∧ v < f (x)) →
∃δ(δ < x ∧ ∀y (δ < y ≤ x → f (y ) > v )))
Formal version:
∀x((inInv(a, x, b) ∧ ¬leq(f (x), v )) →
∃δ(¬leq(x, δ)∧
∀y ((¬leq(y , δ) ∧ leq(y , x)) → ¬leq(f (y ), v ))))
(similar: left-sided, f (x) < v )
Problem 3.2: Cnt’d
Proof Idea: For an arbitrary v ∈ [f (a), f (b)], consider supremum
sup of {x|f (x) < v , a ≤ x ≤ b}. Show that f (sup) = v .
Density: ∀x, y (¬leq(y , x) → ∃z(leq(x, z) ∧ leq(z, y ))
sup is supremum (closedness):
I
“Readable” version:
∀x(sup < x ≤ b → f (x) > v )∧
∀x(x < sup → ∃δ(x < δ ≤ b ∧ f (δ) ≤ v )
I
Formal version:
∀x((¬leq(x, sup) ∧ leq(x, b)) → ¬leq(f (x), v ))∧
∀x(¬leq(sup, x) → ∃δ(leq(δ, b) ∧ ¬leq(δ, x) ∧ leq(f (δ), v ))
Problem 4.1: Unify
Let s, t, u, v , w , x, y , z denote variables, a, b, c, d constant symbols
and f , g , h be function symbols (of arity ≥ 1) and p, q, r be
predicate symbols.
T is a set of formulas. Check if the formulas in T can be unified.
If they are unifiable provide an mgu and the unified formula.
1. T = {q(f (f (x, y ), x)), q(f (f (g (c), z), g (z)))}
?
{q(f (f (x, y ), x)) = q(f (f (g (c), z), g (z)))} {}
?
{f (f (x, y ), x) = f (f (g (c), z), g (z))} {}
?
?
{f (x, y ) = f (g (c), z), x = g(z)} {}
?
{f (g (z), y ) = f (g (c), z)} {x/g (z)}
?
?
{g (z) = g (c), y = z} {x/g (z)}
?
?
{z = c, y = z} {x/g (z)}
?
{y = c} {x/g (c), z/c}
{} {x/g (c), z/c, y /c}
Problem 4.1: Unify
1. mgu = {x/g(c), z/c, y/c, },
mgu(T) = {q(f(f(g(c), c)), g(c))}
?
2. T = {p(x, y ), p(x, f (y , x))}
{p(x, y ) = p(x, f (y , x))} {}
?
?
{x = x, y = f (y , x)} {}
not unifiable
3. T = {p(u, f (x, f (y , x))), p(f (y , c), f (g (z), f (g (z), c)))}
?
{p(u, f (x, f (y , x))) = p(f (y , c), f (g (z), f (g (z), c)))} {}
?
?
{u = f(y, c), f (x, f (y , x)) = f (g (z), f (g (z), c)))} {}
?
{f (x, f (y , x)) = f (g (z), f (g (z), c)))} {u/f (y , c)}
?
?
{x = g(z), f (y , x) = f (g (z), c)} {u/f (y , c)}
?
{f (y , g (z)) = f (g (z), c)} {u/f (y , c), x/g (z)}
?
?
{y = g (z), g (z) = c} {u/f (y , c), x/g (z)}
not unifiable
Problem 4.2: Modifying Robinson
while s1 6= t1 { // ( Trivial )
let s 0 , t 0 be first sub-terms where s1 , t1
differ; // ( Trivial , Decompose )
i f (neither of s 0 , t 0 is variable) { return >; // ( Clash )
} else {
let x be a variable; // ( Orient )
let t be the other term;
i f (x occurs in t ) { return >; // ( Occur Check )
} e l s e { // ( Variable Elimination )
σ := σ{x/t} ∪ {x/t};
T := T {x/t};
} } }
Modification: Removing occur check and to ensure termination
when replacing variable do not consider same position twice.
This modification leads to wrong success for f (x), f (f (x)) with
’unifier’ {x/f (x)}.
Problem 4.3: Partial Order on TΣ / ∼
Define the relation t ≤ t 0 (“more general than”) on first-order
terms to hold if tσ = t 0 for some σ. Now, define an equivalence
relation t ∼ t 0 iff t ≤ t 0 and t 0 ≤ t on TΣ .
Lift ≤ to TΣ / ∼ via: [t] ≤ [t 0 ] iff t ≤ t 0 for all t ∈ [t], t 0 ∈ [t 0 ].
Prove that ≤ is a partial order on TΣ / ∼.
Proof.
1. (reflexivity): X (directly from definition of ∼)
2. (antisymmetric): assume [t] 6= [t 0 ] and [t] ≤ [t 0 ] then there exist
s ∈ [t], s 0 ∈ [t 0 ] such that sσ = s 0 , but there is no τ with s 0 τ = s
⇒ [t 0 ] 6≤ [t]
3. (transitivity): [s] ≤ [t] (1), [t] ≤ [u] (2) show that [s] ≤ [u]:
Let s1 ∈ [s], u1 ∈ [u] and t1 ∈ [t]. From our assumptions (1) and
(2) we get: exist σ, τ with s1 σ = t1 and t1 τ = u1 ⇒
s1 (στ ) = (s1 σ)τ = t1 τ = u1