Computational Logic Automated Deduction Fundamentals

Elements of First-Order Predicate Logic

First Order Language:

• An alphabet consists of the following classes of symbols:
1. variables denoted by (infinite)
2. constants denoted by
3. functors denoted by
4. predicate symbols denoted by
5. connectives, which are: (negation), (disjunction), (conjunction), (implication) and (equivalence),
6. quantifiers, which are: (there exists) and (for all),
7. parentheses, which are: ( and ) and the comma, that is: ,''.

• Each functor and predicate symbol has a fixed arity, they are often represented in form, e.g. f/3.

• A constant can be seen as a functor of arity 0.

• Propositions are represented by a predicate symbol of arity 0.

Important: Notation Convention Used

(A bit different from standard notational conventions in logic, but good for compatibility with LP systems)

$$Variables: start with a capital letter or a _'' (X, Y, _a, _1)$$
Atoms, functors, predicate symbols: start with a lower case letter or are enclosed in ' ' (f, g, a, 1, x, y, z, 'X', '_1')

Terms and Atoms

We define by induction two classes of strings of symbols over a given alphabet.

$$The class of terms: • a variable is a term, • a constant is a term, • if is an -ary functor and are terms then is a term.$$
The class of atoms (different from LP!):
• a proposition is an atom,
• if is an -ary pred. symbol and are terms then is an atom,
• true and false are atoms.

$$The class of Well Formed Formulas (WFFs): • an atom is a WFF, • if and are WFFs then so are and , • if is a WFF and is a variable then and are WFF.$$
Literal: positive or negative (non-negated or negated) atom.

Examples

Examples of Terms

$$Given: • constants: a, b, c, 1, spot, john... • functors: f/1, g/3, h/2, +/3... • variables: X, L, Y...$$
Correct: spot, f(john), f(X), +(1,2,3), +(X,Y,L), f(f(spot)), h(f(h(1,2)),L)
$$Incorrect: spot(X), +(1,2), g, f(f(h)) Examples of Literals$$
Given the elements above and:
• predicate symbols: dog/1, p/2, q/0, r/0, barks/1...
$$Correct: q, r, dog(spot), p(X,f(john))...$$
Incorrect: q(X), barks(f), dog(barks(X))

Examples (Contd.)

Examples of WFFs
$$Given the elements above$$
Correct: q, q r, r q, dog(X) barks(X), dog(X) , p(X,Y), X (dog(X) barks(X) q), Y (dog(Y) bark(Y))

$$Incorrect: q , p More about WFFs • Allow us to represent knowledge and reason about it • Marcus was a man man(marcus) • Marcus was a pompeian pompeian(marcus) • All pompeians were romans X pompeian(X) roman(X) • Caesar was a ruler ruler(caesar) • All romans were loyal to Caesar or they hated him X roman(X) loyalto(X,caesar) hate(X,caesar) • Everyone is loyal to someone X Y loyalto(X,Y) • We can now reason about this knowledge using standard deductive mechanisms. • But there is in principle no guarantee that we will prove a given theorem. Towards Efficient Automated Deduction • Automated deduction is search. • Complexity of search: directly dependent on branching factor at nodes (exponentially!). • It is vital to cut down the branching factor: • Canonical representation of nodes (allows identifying identical nodes). • As few inference rules as possible. Towards Efficient Automated Deduction (Contd.) Clausal Form • The complete set of logical operators ( ,...) is redundant. • A minimal (canonical) form would be interesting. • It would be interesting to separate the quantifiers from the rest of the formula so that they did not need to be considered. • It would also be nice if the formula were flat (i.e. no parenthesis). • Conjunctive normal form has these properties [Davis 1960]. Deduction Mechanism • A good example: Resolution - only two inference rules ( Resolution rule and Replacement rule). Classical Clausal Form: Conjunctive Normal Form • General formulas are converted to: • Set of Clauses. • Clauses are in a logical conjunction. • A clause is a disjunction of the form. • The are negated or non-negated atoms. • All variables are implicitly universally quantified: i.e. if are the variables that appear in a clause it represents the formula: • Any formula can be converted to clausal form automatically by: 1. Converting to Prenex form. 2. Converting to conjunctive normal form (conjunction of disjunctions). 3. Converting to Skolem form (eliminating existential quantifiers). 4. Eliminating universal quantifiers. 5. Separating conjunctions into clauses. • The unsatisfiability of a system is preserved. Substitutions • A substitution is a finite mapping from variables to terms, written as where • the variables are different, • for . • A pair is called a binding. • and . • If then is called ground. • If is a bijective mapping from variables to variables then is called a renaming. • Examples: • (ground) • (renaming) Substitutions (Contd.) • Substitutions operate on expressions, i.e. a term, a sequence of literals or a clause, denoted by . • The application of to (denoted ) is obtained by simultaneously replacing each occurrence in of by , . • The resulting expression is called an instance of . • If is a renaming then is called a variant of . • Example: Composition of Substitutions • Given and their composition is defined by removing from the set those pairs for which , as well as those pairs for which . • Example: if and then . • For all substitutions and and an expression i) ii) . • is more general than if for some we have . • Example: more general than Unifiers • If , then • is called a unifier of and • and are unifiable • A unifier of and is called a most general unifier (mgu) if it is more general than any other unifier of and . • If two atoms are unifiable then they have a most general unifier. • is idempotent if . • A unifier of and is relevant if all variables appearing either in or in , also appear in or . • If two atoms are unifiable then they have an mgu which is idempotent and relevant. • An mgu is unique up to renaming. Unification Algorithm • Non-deterministically choose from the set of equations an equation of a form below and perform the associated action. 1. replace by 2. where halt with failure 3. delete the equation 4. where t is not a variable replace by the equation 5. where and X has another occurrence in the set of equations 5.1 if X appears in t then halt with failure 5.2 otherwise apply to every other equation • Consider the set of equations : • (1) produces • then (1) yields • (3) produces • now only (5) can be applied, giving • No step can be applied, the algorithm successfully terminates. Unification Algorithm revisited • Let and be two formulas: 1. while : 2.1 find leftmost symbol in s.t. the corresponding symbol in is different 2.2 let and be the terms in and starting with those symbols (a) if neither nor are variables or one is a variable occurring in the other halt with failure (b) otherwise, let be a variable the new is the result of 2. end with being an m.g.u. of and Unification Algorithm revisited (Contd.) • Example:  Element  • Example:  Element  Resolution with Variables • It is a formal system with: • A first order language with the following formulas: • Clauses: without repetition, and without an order among their literals. • The empty clause . • An empty set of axioms. • Two inference rules: resolution and replacement. Resolution with Variables (Contd.) • Resolution:  : : where • and are unifiable with substitution • is a renaming s.t. and have no variables in common • is the m.g.u. of and The resulting clause is called the resolvent of and . • Replacement: where • and are unifiable atoms • is the m.g.u. of and Basic Properties • Resolution is correct - i.e. all conclusions obtained using it are valid. • There is no guarantee of directly deriving a given theorem. • However, resolution (under certain assumptions) is refutation complete: if we have a set of clauses and it is inconsistent then resolution will arrive at the empty clause in a finite number of steps. • Therefore, a valid theorem (or a question that has an answer) is guaranteed to be provable by refutation. To prove p'' given : 1. Negate it (). 2. Construct . 3. Apply resolution steps repeatedly to K. • Furthermore, we can obtain answers by composing the substitutions along a path that leads to (very important for realizing Greene's dream!). • It is important to use a good method in applying the resolution steps - i.e. in building the resolution tree (or proof tree). • Again, the main issue is to reduce the branching factor. Proof Tree • Given a set of clauses the proof tree of is a tree s.t. : • the root is • the branch from the root starts with the nodes labeled with • the descendent nodes of are labeled by clauses obtained from the parent clauses using resolution • a derivation in is a branch of the proof tree of • The derivation is denoted as Proof Tree (Contd.) • Example: part of the proof tree for K, with: Characteristics of the Proof Tree • It can be infinite: • Even if it is finite, it can be too large to be explored efficiently • Aim: determine some criteria to limit the number of derivations and the way in which the tree is explored strategy • Any strategy based on this tree is correct: if appears in a subtree of the proof tree of , then can be derived from and therefore is unsatisfiable General Strategies • Depth-first with backtracking: First descendant to the left; if failure or then backtrack General Strategies (Contd.) • Breadth first: all sons of all sibling nodes from left to right General Strategies (Contd.) (Contd.) • Iterative deepening • Advance depth-first for a time. • After a certain depth, switch to another branch as in breadth-first. • Completeness issues / possible types of branches: • Success (always finite) • Finite failure • Infinite failure (provably infinite branches) • Non-provably infinite branches Linear Strategies • Those which only explore linear derivations • A derivation is linear if • is obtained by resolution or replacement using • is obtained by resolution or replacement using • Examples: Characteristics of these Strategies 1 If can be derived from by using resolution with variables, it can also be derived by linear resolution 2 Let be where is a satisfiable set of clauses, i.e. cannot be derived from by using resolution with variables. If can be derived from by using resolution with variables it can also be derived by linear resolution with root .$$
From (1), if the strategy is breadth first, it is complete.

$$From (2), if we want to prove that is derived form then we can apply linear resolution to .$$
Depth first with backtracking is not complete:

Input Strategies

 Those which only explore input derivations A derivation is input if is obtained by resolution or replacement using is obtained by resolution or replacement using at least a clause in
 Example:

Input Strategies

• In an input derivation, if does not appear in any derivation of a successor clause, it can be eliminated from the derivation without changing the result

• If appears in the derivation of , can be allocated in position

• As a result, we can limit ourselves to linear input derivations without losing any input derivable clause

• Let be where is derived by using resolution with variables, is a negative Horn clause and all clauses in are positive Horn clauses. There is an input derivation with root finishing in and in which the replacement rule is not used (Hernschen 1974)

• A Horn clause is a clause in which at most one literal is positive:
• it is positive if precisely one literal is positive
• it is negative if all literals are negatives

• As a result, in those conditions, a breadth first input strategy is complete, and a depth first input strategy with backtracking is complete if the tree is finite.

Ordered Strategies

• We consider a new formal system in which:
1. clauses are ordered sets
2. ordered resolution of two clauses

where is a positive literal and is a negative literal is possible iff and are unifiable ( is a renaming, s.t. and have no variables in common)

3. the resolvent of and is where is an m.g.u of and

• Let be a set of clauses s.t. is derived by using resolution with variables, is a negative Horn clause and all clauses in are positive Horn clauses with the positive literal in the first place. There is a sorted input derivation with root arriving at .

• In this context a sorted linear input with:
• breadth first: is complete
• depth first with backtracking: is complete if the tree is finite

Last modification: Wed Nov 22 23:29:13 CET 2006 <webmaster@clip.dia.fi.upm.es>