Lecture Notes Representation and Interaction

@lecture @logic @resolution @FOL @Horn @CNF @Prolog @reasoning

Lecture 1

Introduction

About agent-based representation and interaction.

Representation: of knowledge, beliefs,desires, intention; reason with them; and interact with multiple agents.

Course will cover various forms of modal logic, preferences and utility theory, and argumentation theory.

BDI-agents

Desire can be seen as a goal, defined on a longer amount of time. However, these agents are more elaborate due to the inclusion of beliefs, which will change the expression of desires/ actions taken towards them. Desires are fixed, but can become impossible given beliefs about the world.

Based on formal modal logic, deliberation used to form intentions. Means-end reasoning to form plans.

Intention: committed desire to act; commitment to a way of action, in light of desires and beliefs.

Deliberation/intention are triggered by events (also in the environment).

This course deals with symbolic AI agents; logic based.

Beliefs, desires, and intentions are particular points or possible (future) worlds in a time tree, with a single past and branching future.

Logic and Resolution

Basic definitions:

  • Satisfiability: there is some interpretation M under which $\phi$ is true, $M \vDash \phi$.
  • If is not satisfiable or inconsistent if there is no such possible interpretation M, i.e.
  • Formula is valid (a tautology) if for all $M: M \vDash \phi$.
  • A formula is entailed if when a conjunction of formulas (a "theory") $\Gamma$, $\phi$ also must hold, i.e. for all $M: M \vDash \Gamma$ then $M \vDash \phi$.

Double turnstile $\Vdash$ for semantic notions. Single turnstile $\vdash$ for syntactical manipulation (i.e. derivation).

Deductive system

Def deductive system: set of axioms and rules of inference for deriving theorems.

Notation: $\phi$ can de deduced from theory $\Gamma$ if $\phi$ can be proven using deduction system S: $\Gamma \vdash_{S} \phi$

Deductive system is sound if from a syntactic logical consequence, we can also semantically deduce the consequence. I.e. everything that is valid syntactically, also holds semantically. I.e. all the systems theorems are tautologies.

The system is complete if a semantic consequence implies that this consequence also follows syntactically. I.e. completeness means that every valid formula is provable. We are speaking here of semantic completeness.

Both sound and complete: only valid formulas are provable. I.e. there are no valid formulas that cannot be proved (completeness), and everything that can be proven is valid (soundness).

A deductive system is refutation-complete: if in a system a set of formula's leads to an inconsistency (semantic), then this inconsistency can syntactically be derived. Note that completeness as such is defined on valid formula's, whereas refutation-completeness specifically is defined on inconsistencies, i.e. one can syntactically check that indeed a formula is false.

Resolution

Reasoning with formulas in clausal form, i.e. a series of disjunctions of atomic formulas (negations included). The result of the rule is called the (binary) resolvent.

If you have an atom with its complementary literal in two formula's, you can exclude them to reach the resolvent disjunction.

Example:

Given: $$V={\neg P \lor Q, \neg Q, P}$$ 1) $$\neg P \lor Q, \neg Q$$ 2) $$\frac{\neg P \lor Q, \neg Q}{\neg P}$$ 3) $$\frac{\neg P, P}{\bot}$$ 4) So $$V \vdash_{R} \bot$$

N.B. Not that this resolution is not unique! You could do the derivation in a different order.

The previous example shows that V is inconsistent and this derivation is called a refutation. Since nothing is valid syntactically, we get soundness for free.

If instead set V is consistent, then the contradiction does not syntactically follow. Q: The slides claim that this implies refutation-completeness, but why?

If a theory is inconsistent, then resolution will always terminate in a syntactical contradiction (for clausal form formulas, not in first-order logic in general!). Resolution rule is sound and complete for clausal form formulas.

SLD Resolution for Horn clauses

def Horn clause: clausal form formula with one positive literal.

SLD Resolution: Selective Linear Definite resolution; the basic inference rule used in logic programming.

Exercise:

Prove P from $\Gamma$ with resolution, where $\Gamma = {R \lor \neg T, T, P \lor neg R}$.

Lecture 2: Extension to FOL

Learn all equivalences by heart, slide 21/42. Includes association rules and De Morgan rules etc.

Example question: Prove equivalence of give counterexample.

See the reader for exercises.

Conversion of FOL formulas to clausal normal form

1) CONVERT TO NEGATION NORMAL FORM: ELIMINATE IMPLICATIONS AND MOVE NEGATIONS INWARDS 2) Make sure each bound variable has unique name 3) "Skolemize": replace existential quantifiers by terms with function symbols of previously universally quantified; See slide. 4) Use distributive laws to reach conjunctive clausal normal form (conjunction of disjunctions). 5) Drop universal quantifiers.

Slide 32: what do you notice about the unifiers?

From substitution 3 you can get to 2 and 1, but not the other way around. It is more general than s1 and s2. This allows more general derivation of statements. From this most general unifier (mgu) all other unifiers can be derived.

Slide 35: The sigma's for the substitution in the FOL resolution rule do not have to be the same. I do not know why though.

Lecture 3: Prolog

Algorithm = Logic + Control.

FOL is not decidable, but subsets are. Prolog uses Horn clauses, which are sound and complete.

What (Horn Clauses); How (SLD resolution).

However, Prolog is sound but not always complete (due to some implementation choices).

This choice is in the resolution rule. One clause in the resolution is given as the last result, the other one is unspecified. For the second choice, you can just choose an arbitrary statement from the database. Prolog has a way of making choices for that, which results in it being not complete.

Example of SLD refutation: procedure Prolog with a linear trace. There is always an order to finish the process, i.e. in theory there is completeness. However, Prolog has to make a choice for the order of resolution steps; it might not finish.

Prolog selection rule for database items:

  • Left to right
  • Top to bottom.

Examples slide 14:

  1. A=21
  2. A=13+8
  3. A=2,B=1
  4. X=chas,Liz=chas (N.B. that Liz is a predicate, otherwise it would be "liz")
  5. false
  6. X=g(h(c)) (We do not care about the wildcards)

Selection rule example slide.

Remarks

[a,b] = [a | [b]] = [a,b|[]] = [a | [b | []]]

Get information about datatypes: apropos(list)

Slide 45: The cut operator really introduces order effects; different orders correspond to different declarative meanings (if red cut)

Red cut: changes program logical meaning. Green cut: doesn't do it.

not operator is not the same as the negation in logic; only that Prolog cannot prove the opposite.

Order matters, see slide 49! If reasonable matches first, the cut operator will prevent matching with the second term in the and statement.

Cut

!. Cut is always a success when the interpreter finds it the first time. When the cut is encountered a second time in the case of backtracking, then it prevents further backtracking within the clause of the cut. Also the interpreter will not try to match any other clause with the same name.

Reasons for using cut concern efficiency and sometimes correctness.

1) Efficiency * Prevent unnecessary backtracking 2) Correctness * E.g. indicating mutually exclusive clauses: that the selected clause (with the cut) is the only one that should be applied for a given (sub)problem

Example 1 for efficiency: cut following critical condition

Imagine the clause a :- b,c. It is given that this is the only clause that can produce a. Now imagine b has been confirmed as true, but that the interpreter cannot find a match for c. Since b is the critical condition for a, it does not make sense to try and match any other clause to produce a. This can be achieved by including a cut after the critical condition.

Why after the critical condition? Otherwise the interpreter will also search for alternatives for b; but this is irrelevant in this case.

Example 2 for efficiency: exceptions to general rule

if b fulfilled, never success... So b is here an exception.

a :- b,!,fail.

Watch out with cuts: why does the following program return yes to the query ?- number_of_parents(eve,2) instead of no?:

number_of_parents(adam,0) :- !.
number_of_parents(eve,0) :- !.
number_of_parents(X,2).

Manipulation of terms

Select specific argument of a functor: arg(I,T,A). I must be an integer, T must be a term. A will be instantiated to the I-th argument of the term T.

arg(2,employee(john,mccarthy),A): A = mccarthy.

Select left-most functor in a term: functor(T,F,N).

For term T, variable F will be instantiated to left-most functor of the term, and N to number of arguments of the functor.

functor(employee(john,mccarthy),F,N). F = employee, N=2.

N.B. T can also be the unknown in the query, so that a functor is constructed in "reverse" mode.

X =.. L.: Given a term X, then L will be a list with functor of X as first element, and arguments as following elements. In reverse mode, if you provide the list with a functor and arguments, then instead term X will be constructed as such: X =.. [employee,john,mccarthy,[salary=10000]]., then X=employee(john,mccarthy,[salary=10000]).

Inspect contents of database: clause(Head,Body).

Lecture 4: Model-based reasoning and non-monotonic reasoning

Model-based reasoning

In this course: model based diagnosis:

  • Consistency-based diagnosis
    • Basic idea: formalize a normal structure and functional behavior, and then describe a diagnosis of abnormal behavior by specifying broken components that account for a difference in predicted and actual behavior.
  • Abductive diagnosis
    • Instead depart from abnormal behavior, in terms of cause-effect relationships.

E.g. given some logical circuit. Goal: explain why the shown behavior is different from predicted behavior?

Consistency-based diagnosis with definitions

Based on the work of De Kleer.

System:

  • Some system SYS=(SD,COMP), where SD is the system description and COMP is the finite set of components.
  • A system description SD is originally intended to describe normal behavior, set of FOL propositions relating input to output.
    • Boolean extension to FOL needed, see lecture notes p. 74.

Hypothesis:

We have a set of positive literals defined on components Ab(c), and a set of negative literals $\negAb(c)$ .

A hypothesis is defined as $H={Ab(c)|c \in D} \cup {\negAb(c)|COMPS/D}$. That is... a hypothesis states that for components part of the diagnosis some literal holds, whereas for the remaining components that literal does not hold. Think I finally figured out that Ab(c) stands for: component c functions abnormally... That makes a lot clear.

This hypothesis/diagnosis is of course consistent only if it does not lead to a contradiction in combination with the system description (SD) and the observations.

When it is not consistent, we can adjust the hypothesis H into H' so that consistency holds. If you want $\negAb(c)$ to hold, then the component in D for which Ab(c) holds is a possible faulty one. (Ab(c) means component c is abnormal). E.g. if Ab(X1) then D'=X1.

Finding diagnoses efficiently with hitting-set algorithm

Nice that we can find diagnoses, but since there are exponentially many subsets of all components, we need an efficient algorithm.

In order to find a diagnosis (i.e. a set of components that might cause the failure), we can use conflict sets.

A conflict set "is a set of components that, if we assume that they are all normal, the observations imply an inconsistency. This implies that not all of the components in the conflict set can be normal, so at least one of them must occur in the diagnosis".

The assumption of normality is expressed a such: $SD \cup OBS \cup {\neg Ab(c) | c \in CS}$. CS is a conflict set if that assumption leads to a contradiction $\bot$. In that case for at least one component c in the conflict set CS, Ab(c) is observed.

Okay... so let's assume we can compute all conflict sets. We know that for each conflict set, at least one element must cause the contradiction and is part of a diagnosis.

Formally: $D \cap CS \neq \empty$. The intersection of diagnosis D and conflict set CS is not empty, i.e. they have at least one common element.

Then diagnoses are minimal hitting sets of the conflict sets. A minimal hitting set is defined on a superset of sets (e.g. of conflict sets) such that it contains minimally one element from each of the subsets.

E.g. for set { {1,2}, {3,4} } two possible MHS's are H1={1,3} and H2={1,4}.

Theorem: D is diagnosis for a diagnostic problem iff D is a minimal hitting set for all conflict sets of diagnostic problem DP.

A diagnosis has minimally one element in common with each element of the superset of all conflict sets, i.e. D is a hitting set.

Furthermore, D is also a minimal hitting set.

1) COMPS/D is no conflict set, because the conflicting element must be part of the diagnosis D and now is taken out. 2) But if we add any $c \in D$ to that we have a conflict set.

N.B. p.82 : we do not need all conflict sets. If there is no intersection between S and H, then there is also no intersection between any subset S' of S and H. Conclusion: minimal hitting sets can be computed from the minimal conflict sets. WHY?

Minimal hitting set algorithm

We have a node labeling function, and an edge labeling function. Nodes are labeled with F a set of sets, and OK. Edges are labeled with the union of all sets in F. (Correct?)

1) Generate root node (some conflict set; * cf. previous claim: here not the whole set of conflict sets is required). Given a conflict set, any superset is also a conflict set. (Relevant?). 2) DFS-like traversal; depth first. 1) H(n) is the set of edge labels on the path from the root to node n. 2) Node n labeled OK if for all sets S in F share minimally one element in H(n). Else, label n with a set that does not share an element with H(n). Nodes labeled with OK are thus a diagnosis. 3) If n is labeled with a subset of F instead of OK, then expand the tree downward for all elements s in S, so that this edge is connected to a new node H(m) = H(n) $\cup$ {s}. 3) Return HS tree.

  • Diagnostic problem DP=(SYS,OBS) with OBS a finite set of observed findings (known inputs and outputs).
  • Diagnosis: ... See slide 4: bit unclear.
    • A diagnosis gives a possible solution for which component is not working properly.
  • Conflict set: set of components for which the system description together with the observations and ... ALSO UNCLEAR THIS FUCKING LECTURE.

Proposition: Each diagnosis intersects with a conflict set.

History Β· 10 changes since 2019-02-05

Full changelog