CC-BY
Fabian M. Suchanek
Rule Mining
140
©
TV week
©
Dailymail
©
Public Domain
CC by
Jean-Marc Ayrault
CC by
Matthieu Riegler
©
Voici
Rules
hasChild
citizenOf
hasChild
marriedTo
marriedTo
citizenOf
hasChild
hasChild
hasChild
2
presidentOf
hasChild
©
TV week
©
Dailymail
©
Public Domain
CC by
Jean-Marc Ayrault
CC by
Matthieu Riegler
©
Voici
Rules
3
“Whenever someone has a child,
this is also the child of the spouse”
y
z
x
marriedTo
hasChild
hasChild
hasChild
citizenOf
hasChild
marriedTo
marriedTo
citizenOf
hasChild
hasChild
hasChild
presidentOf
hasChild
©
TV week
©
Dailymail
©
Public Domain
hasChild(x,y) ∧ marriedTo(x,z)
⇒ hasChild(z,y)
(rules don’t have to be always correct)
Rule Mining
4
hasChild
citizenOf
hasChild
marriedTo
marriedTo
citizenOf
hasChild
presidentOf
hasChild
presidentOf(x,z) ∧ hasChild(y,Mali)
⇒ marriedTo(x,y)
Rule Mining
5
?
>uses
©
TV week
©
Dailymail
©
Public Domain
hasChild
citizenOf
hasChild
marriedTo
marriedTo
citizenOf
hasChild
presidentOf
hasChild
hasChild(x,y) ∧ marriedTo(x,z)
⇒ hasChild(z,y)
Rule Mining for Completion
6
>uses
marriedTo
hasChild
Rule Mining for Completion
7
hasChild
>uses
hasChild(x,y) ∧ marriedTo(x,z)
⇒ hasChild(z,y)
marriedTo
hasChild
Rule Mining for Correction
8
marriedTo
hasChild
hasChild
>uses
hasChild(x,y) ∧ marriedTo(x,z)
⇒ hasChild(z,y)
Rule Mining for Correction
9
marriedTo
hasChild
hasChild
>uses
hasChild(x,y) ∧ marriedTo(x,z)
⇒ hasChild(z,y)
x
hasChild(x,y) ∧ marriedTo(x,z) ⇒ hasChild(z,y)
in(x, Europe) ∧ president(x, y) ⇒ male(x)
married(x, y) ⇒ married(y, x)
... obvious for us, but non-trivial for a computer.
Applications in
• artificial intelligence / question answering
• information extraction (see
lecture
)
• science
• engineering (fault finding)
• medicine
• social network mining
Rule Mining for Insights
10
... in n % of the cases
... in n % of the cases
type(x, sorceress) ∧ dumb(y) ⇒ likes(x, y) ?
Running example
11
likes
likes
is
dumb
childish
is
smart
is
is
male
gender
gender
sorceress
type
>atoms
->bindings
12
likes
envies
likes
Refresh: Atoms and KBs
An
atom
A is a propositional statement. A is a
positive literal
, and ¬ A is a
negative literal
.
The
polarity
is positive for A , and negative for ¬ A . A positive literal
holds
(“is true”) in a KB,
if it appears in the KB. A negative literal ¬ A
holds
in a KB if A does not hold.
likes(Hermione, Ron) ?
¬ envies(Ron, Harry) ?
We work here under the
closed world assumption
:
what is not in the KB is assumed to be false
13
Refresh: Atoms and KBs
An positive literal
holds
(“is true”) in a KB, if it appears in the KB.
A negative literal ¬ A
holds
in a KB if A does not hold.
A conjunction A ∧ B ∧... ∧ Z
holds
in a KB, if all of its elements hold.
likes(Hermione, Ron) ?
¬ envies(Ron, Harry) ?
¬ envies(Ron, Harry) ∧ likes(Harry, Hermione)
envies(Harry, Ron) ∧ likes(Hermione, Ron) ∧ likes(Harry, Elvis)
likes
envies
likes
likes(Hermione, Ron) ⇒ likes(Harry,Ron)
likes(Harry, Ron) ⇒ hasSpouse(Harry,Hermione)
¬ likes(Hermione, Harry) ⇒ envies(Harry,Ron)
¬ likes(Hermione, Harry) ⇒ hasSpouse(Harry,Ron)
likes(Herm., Ron)∧ ¬ envies(Harry,Ron)⇒ ffe(Harry,Ron)
14
Refresh: Implications
If
is a conjunction (called the
body
), and H is an atom (called the
head
),
then an implication
holds
in a KB if
does not hold or H holds.
likes
envies
likes
likes(Hermione, Ron)
15
Refresh: Implications
If
is a conjunction (called the
body
), and H is an atom (called the
head
),
then an implication
holds
in a KB if
does not hold or H holds.
The body can also be empty.
is a body‐less rule, i.e., equivalent to:
⇒ likes(Hermione, Ron)
likes
envies
likes
16
Def: Rules, Disjunctions, Clauses
An
implication
(also:
rule
)
is equivalent to a
disjunction
which we also write as a
clause
.
likes(Hermione, Ron) ⇒ likes(Harry,Ron)
¬ likes(Hermione, Ron) ∨ likes(Harry,Ron)
{¬ likes(Hermione, Ron), likes(Harry,Ron) }
“at least one of
these has to hold”
is equivalent to
is equivalent to
likes
envies
likes
A
substitution
is a function from variables to constants or variables.
Def: Substitution
17
(This is done only once, not iterated)
For a formula φ and a substitution θ , we write θ(φ) to mean the
formula obtained by replacing all variables as given by the substitution.
We now allow variables to appear in atoms and formulas, as in:
Intuitively, a formula with variables holds if it holds for all values of the variable
(the variables are
universally quantified
). We will now make this intuition more formal.
loves(Hermione, x) ⇒ hates(Harry, x)
θ = { x → y, y → z, z → Ron }
θ(φ) = loves(Hermione, y) ⇒ hates(Harry, y)
y is not replaced!
Def: Substitution
18
We now allow variables to appear in atoms and formulas, as in:
loves(Hermione, x) ⇒ hates(Harry, x)
>subst
A
substitution
is a function from variables to constants or variables.
For a formula φ and a substitution θ , we write θ(φ) to mean the
formula obtained by replacing all variables as given by the substitution.
θ = { x → y, y → z, z → Ron }
Intuitively, a formula with variables holds if it holds for all values of the variable
(the variables are
universally quantified
). We will now make this intuition more formal.
(This is done only once, not iterated)
θ = { x → Ron, y → Elvis }
An
instantiation
(ground instance) of a rule by a binding is the rule obtained by substituting
all variables by the constants given by the binding.
θ(φ)= loves(Hermione, Ron) ⇒ hates(Harry, Ron)
Def: Bindings
19
A
binding
is a substitution that maps variables to constants (not to other variables):
We now allow variables to appear in atoms and formulas, as in:
φ= loves(Hermione, x) ⇒ hates(Harry, x)
A rule with variables
holds
if all of its instantiations hold.
An atom p is the
prediction of a rule
r on a KB, if there is a binding so that all body atoms
are in the KB and p is the head atom. We write KB ∧ r ⊧ p .
marriedTo(x, y) ∧ hasChild(x, z) ⇒ hasChild(y, z)
Predictions of a Rule
20
hasChild
marriedTo
hasChild
marriedTo(x, y) ∧ hasChild(x, z) ⇒ hasChild(y, z)
Predictions:
•
x=Barack, y=Michelle, z=Malia: hasChild(Michelle, Malia)
•
x=Barack, y=Michelle, z=Sasha: hasChild(Michelle, Sasha)
Predictions of a Rule
hasChild
marriedTo
hasChild
21
>spec&queries
An atom p is the
prediction of a rule
r on a KB, if there is a binding so that all body atoms
are in the KB and p is the head atom. We write KB ∧ r ⊧ p .
Intuitively, some rules are more general than others:
dumb(x) ∧ gender(x, y) ⇒ loves(Hermione, x)
General and specific rules 1/2
22
Intuitively, some rules are more general than others:
dumb(x) ∧ gender(x, y) ⇒ loves(Hermione, x)
General and specific rules 1/2
23
General rule
The more specific rule adds more conditions, and applies to less people.
dumb(x) ∧ gender(x, male) ⇒ loves(Hermione, x)
Applies only to male x
More specific rule
Intuitively, some rules are more general than others:
dumb(x) ∧ gender(x, y) ⇒ loves(Hermione, x)
General and specific rules 2/2
24
The more specific rule adds more conditions, and applies to less people.
dumb(x) ∧ gender(x, y) ∧ poor(x) ⇒ loves(Hermione, x)
Applies only to x that are also poor
>subsume&queries
General rule
More specific rule
A clause φ
subsumes
another clause φ' if there is a substitution θ ,
such that θ(φ) ⊆ φ' . The first clause is
more general
than the second.
Def: Subsumption
25
dumb(x) ∧ gender(x, y) ⇒ loves(Hermione, x)
dumb(x) ∧ gender(x, male) ⇒ loves(Hermione, x)
{¬ dumb(x), ¬ gender(x, y), loves(Hermione, x) }
{¬ dumb(x), ¬ gender(x, male), loves(Hermione, x) }
θ={y→ male}
⊆
A clause φ
subsumes
another clause φ' if there is a substitution θ ,
such that θ(φ) ⊆ φ' . The first clause is
more general
than the second.
Def: Subsumption
26
dumb(x) ∧ gender(x, y) ⇒ loves(Hermione, x)
dumb(x) ∧ gender(x, y) ∧ poor(x) ⇒ loves(Hermione, x)
{¬ dumb(x), ¬ gender(x, y), loves(Hermione, x) }
{¬ dumb(x), ¬ gender(x, y), ¬ poor(x), loves(Hermione, x) }
θ={}
⊆
omit
atom
type(x, sorceress) ∧ dumb(Ron)
type(Hermione, sorceress) ∧ childish(Ron)
⇒ likes(Hermione, Ron)
type(Hermione, sorceress) ∧ dumb(Ron)
∧ childish(Ron) ⇒ likes(Hermione, Ron)
∧ childish(Ron) ⇒ likes(x, Ron)
introduce
variable
likes(x, y)
Generalization lattice
27
add
atom
∧ childish(Ron) ⇒ likes(Herm., Ron)
Specialization lattice
28
>queries
⇒ likes(Herm., Ron)
type(x, sorceress) ∧ dumb(Ron)
type(Hermione, sorceress) ∧ childish(Ron)
∧ childish(Ron) ⇒ likes(x, Ron)
remove
variable
likes(x, y)
type(Hermione, sorceress) ∧ dumb(Ron)
A
(conjunctive) query
is a conjunction of literals
An
answer
to a query for a given KB is a binding that makes the query true in the KB.
loves(Hermione, x) ∧ dumb(x) ∧ smart(y) ?
{ x → Ron, y → Harry }
Query
29
>queries
• More general, subsuming query Q1:
• More specific, subsumed queries Q2, Q2':
is(x,smart) ∧ likes(x,y) ⇒ answer(x)
is(x,smart) ∧ likes(x, Ron) ⇒ answer(x)
is(x,smart) ∧ likes(x,y) ∧ gender(x,male) ⇒ answer(x)
Query subsumption
30
is
gender
is
likes
male
likes
gender
smart
likes
>queries
is(x,smart) ∧ likes(x, Ron) ⇒ answer(x)
All answers to a more specific query
are also answers to the more general query
(with the same head).
Query subsumption
31
is(x,smart) ∧ likes(x,y) ⇒ answer(x)
is(x,smart) ∧ likes(x,y) ∧ gender(x,male) ⇒ answer(x)
>queries
• More general, subsuming query Q1:
• More specific, subsumed queries Q2, Q2':
likes(x, y) ∧ gender(x, male) ?
gender(x, male) ?
likes(x, y) ∧ is(y, smart) ∧ gender(y, male) ?
Example
32
likes
likes
is
dumb
childish
is
smart
is
is
male
gender
gender
sorceress
type
likes
>queries
A query can be written as a rule.
The body of a rule is basically a query.
likes(x, y) ∧ gender(x, male) ⇒ answer(x, y)
gender(x, male) ∧ is(x, dumb) ⇒ likes(Hermione, x)
Queries and Rules
33
likes
likes
is
dumb
childish
is
smart
is
is
male
gender
gender
sorceress
type
likes
query
Overview
Introduction to Rules
Rule Mining
•
Inductive Logic Programming
•
Confidence in a KB
•
Top-Down Rule Mining
•
Bottom-Up Rule Mining
34
35
smart
is
is
gender
male
dumb
likes
Summary: Rule Mining
Inductive Logic Programming
(ILP) is the task of finding hypotheses that cover examples
• ILP can be performed top-down by specialization (AMIE, Rudik)
• ... or bottom-up by generalization (GOLEM, AnyBURL)
Something similar can be achieved by embeddings.
Summary: Rule Mining
36
dumb
gender
male
is
is
likes
smart
likes
Open World Assumption!
Inductive Logic Programming
(ILP) is the task of finding hypotheses that cover examples
• ILP can be performed top-down by specialization (AMIE, Rudik)
• ... or bottom-up by generalization (GOLEM, AnyBURL)
Something similar can be achieved by embeddings.
->Embeddings
->Deep-learning
Luis Galárraga, Christina Teflioudi, Katja Hose, Fabian M. Suchanek:
“
AMIE: Association rule mining under incomplete evidence
”
Full paper at the International World Wide Web Conference (WWW) , 2013
N. Lavrač, S. Džeroski:
Inductive Logic Programming — techniques and applications
References
F. Suchanek, J. Lajus, A. Boschin, G. Weikum:
“
Knowledge Representation and Rule Mining in Entity-Centric KBs
”
Invited paper at the Reasoning Web Summer School (RW) , 2019
37
Armand Boschin, Nitisha Jain, Gurami Keretchashvili, Fabian M. Suchanek:
“Combining Embeddings and Rules for Fact Prediction”
Summer School on Artificial Intelligence in Bergen (AIB) 2022