Lecture 5: Term Orderings
Laura Kovács and Andrei Voronkov
Simple Ground Superposition Inference System
Superposition: (right and left)
s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),
Equality Resolution:
Cs=s∨C(ER),
Equality Factoring:
s=t∨t=t′∨Cs=t∨s=t′∨C(EF),
Can this system be used for efficient theorem proving?
Not really. It has too many inferences.
For example, from the clause f(a)=a we can derive any clause of the form
fm(a)=fn(a)
where m,n≥0.
Worst of all, the derived clauses can be much larger than the original clause f(a)=a.
The recipe is to use the previously introduced ingredients:
- Ordering;
- Literal selection;
- Redundancy elimination.
Atom and literal orderings on equalities
Equality atom comparison treats an equality s=t as the multiset {˙s,t}˙.
- (s′=t′)≻lit(s=t) if {˙s′,t′}˙≻{˙s,t}˙
- (s′=t′)≻lit(s=t) if {˙s′,t′}˙≻{˙s,t}˙
with ≻lit being an induced ordering on literals.
Ground Superposition Inference System Sup≻,σ
Let σ be a well-behaved literal selection function.
Superposition: (right and left)
s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),
where
1234l≻rs[l]≻tl=r is strictly greater than any literal in C,(only for the superposition-right rule) s[l]=t is greater than or equal to any literal inD.
Equality Resolution:
Cs=s∨C(ER),
Equality Factoring:
s=t∨t=t′∨Cs=t∨s=t′∨C(EF),
where
12s≻t⪰t′s=t is strictly greater than any literal in C.
Extension to arbitrary (non-equality) literals
- Consider a two-sorted logic in which equality is the only predicate symbol.
- Interpret terms as terms of the first sort and non-equality atoms as terms of the second sort.
- Add a constant ⊤ of the second sort.
- Replace non-equality atoms p(t1,…,tn) by equalities of the second sort p(t1,…,tn)=⊤.
For example, the clause
p(a,b)∨¬q(a)∨a=b
becomes
p(a,b)=⊤∨q(a)=⊤∨a=b
Binary resolution inferences can be represented by inferences in the superposition system
We ignore selection functions.
C1∨C2A∨C1¬A∨C2(BR)
C1∨C2⊤=⊤∨C1∨C2(ER)A=⊤∨C1A=⊤∨C2(Sup)
🎬 Animation: Review first-order resolution with the unifier and resolvent kept visible.
Exercise
Positive factoring can also be represented by inferences in the superposition system.
Simplification Ordering
When we deal with equality, we need to work with term orderings.
Consider a strict ordering ≻ on signature symbols, such that ≻ is well-founded.
The ordering ≻ on terms is called a simplification ordering if
- ≻ is well-founded;
- ≻ is monotonic: if l≻r , then s[l]≻s[r];
- ≻ is stable under substitutions: if l≻r , then lθ≻rθ.
One can combine the last two properties into one:
2a. If l≻r , then s[lθ]≻s[rθ].
A General Property of Term Orderings
If ≻ is a simplification ordering, then for every term t[s] and its proper subterm s we have s⊁t[s]. Why?
Consider an example.
f(a)=af(f(a))=af(f(f(a)))=a
Then both f(f(a))=a and f(f(f(a)))=a are redundant.
The clause f(a)=a is a logical consequence of {f(f(a))=a,f(f(f(a)))=a}; but is not redundant.
Exercise: Show that {f(a)=a,f(f(f(a)))=a} is unsatisfiable, by using superposition with redundancy elimination.
How to “come up” with simplification orderings?
Term Algebra
Term algebra TA(Σ) of signature Σ :
- Domain: the set of all ground terms of Σ .
- Interpretation of any function symbol f or constant c is defined as:
fTA(Σ)(t1,…,tn)CTA(Σ)⇔def⇔deff(t1,…,tn);C.
Knuth-Bendix Ordering (KBO), Ground Case
Let us fix
- Signature Σ , it induces the term algebra TA(Σ).
- Total ordering ≫ on Σ, called precedence relation;
- Weight function w:Σ→N.
Weight of a ground term t is
∣g(t1,…,tn)∣=w(g)+i=1∑n∣ti∣
g(t1,…,tn)≻KBh(s1,…,sm) if
-
∣g(t1,…,tn)∣>∣h(s1,…,sm)∣ (by weight) or
-
∣g(t1,…,tn)∣=∣h(s1,…,sm)∣
and one of the following holds:
- 2.1 g≫h (by precedence) or
- 2.2 g=h and for some 1≤i≤n we have t1=s1,…,ti−1=si−1 and
ti≻KBsi (lexicographically).
Example
w(a)=1w(b)=2w(f)=3w(g)=0
∣f(g(a),f(a,b))∣=∣3(0(1),3(1,2))∣=3+0+1+3+1+2=10
The Knuth-Bendix ordering is the main ordering used in Vampire and all other resolution and superposition theorem provers.
Knuth-Bendix Ordering (KBO), Ground Case: Summary
Let us fix
- Signature Σ , it induces the term algebra TA(Σ).
- Total ordering ≫ on Σ, called precedence relation;
- Weight function w:Σ→N.
Weight of a ground term t is
∣g(t1,…,tn)∣=w(g)+i=1∑n∣ti∣g(t1,…,tn)≻KBh(s1,…,sm) if
-
∣g(t1,…,tn)∣>∣h(s1,…,sm)∣ (by weight) or
-
∣g(t1,…,tn)∣=∣h(s1,…,sm)∣
and one of the following holds:
- 2.1 g≫h (by precedence) or
- 2.2 g=h and for some 1≤i≤n we have t1=s1,…,ti−1=si−1 and
ti≻KBsi (lexicographically).
Weight Functions, Ground Case
A weight function w:Σ→N is any function satisfying:
- w(a)>0 for any constant a∈Σ;
- if w(f)=0 for a unary function f∈Σ, then f≫g for all functions g∈Σ with f=g.
That is, f is the greatest element of Σ wrt ≫.
As a consequence, there is at most one unary function f with w(f)=0.
Exercise
Consider a KBO ordering ≻ such that inverse≫times by precedence.
Consider the literal:
inverse(times(x,y))=times(inverse(y),inverse(x)).
Compare, w.r.t ≻, the left- and right-hand side terms of the equality when:
- weight(inverse)=weight(times)=1;
- weight(inverse)=0 and weight(times)=1.
Same Property as for BRσ
The conclusion is strictly smaller than the rightmost premise:
s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),s[r]=t∨C∨Dl=r∨Cs[l]=t∨D(Sup),
where
- l≻r
- s[l]≻t,
- l=r is strictly greater than any literal in C,
- s[l]=t is greater than or equal to any literal in D.
New redundancy
Consider a superposition with a unit left premise:
s[r]=t∨Dl=rs[l]=t∨D(Sup),
Note that we have
l=r,s[r]=t∨D⊨s[l]=t∨D
and we have
s[l]=t∨D≻s[r]=t∨D
If we also have s[l]=t∨D≻l=r,
then the second premise is redundant and can be removed.
This rule (superposition plus deletion) is sometimes called demodulation (also rewriting by unit equalities).
Exercise
Consider the KBO ordering ≻ generated by:
- the precedence f≫a≫b≫c
and
- the weight function w with w(f)=w(a)=w(b)=w(c)=1.
Consider the set S of ground formulas:
a=b∨a=cf(a)=f(b)b=c
Apply saturation on S using an inference process based on the ground superposition calculus Sup≻,σ (including the inference rules of ground binary resolution with selection).
Show that S is unsatisfiable.
Challenge: Show that S is unsatisfiable such that during saturation only 4 new clauses are generated.