Weighted MAX SAT
CC-BY
Fabian M. Suchanek
2
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
3
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)
4
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)
5
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
6
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
Refresh:Universal quantification
7
hasSpouse
hasSpouse
hasSpouse
A universally quantified formula
holds
in a KB, if all of its instantiations hold.
hasSpouse(x, y)
hasSpouse(x, y) ⇒ hasSpouse(y, x)
hasSpouse(Elvis, y) ⇒ hasSpouse(y, Elvis)
hasSpouse(Hermione, y) ⇒ hasSpouse(y, Hermione)
hasSpouse(x, y) ⇒ hasSpouse(y, x)
8
hasSpouse
hasSpouse
In the following, we consider only instantiated rules. A universally quantified rule is a shorthand
notation for all
relevant
instantiations, i.e., those with known entities.
hasSpouse(Elvis, Priscilla) ⇒ hasSpouse(Priscilla, Elvis)
hasSpouse(Hermione, Ron) ⇒ hasSpouse(Ron, Hermione)
...
hasSpouse(dog, cat) ⇒ hasSpouse(cat, dog)
relevant
instantiations
irrelevant
hasSpouse(Elvis, Elvis) ⇒ hasSpouse(Elvis, Elvis)
Refresh:Universal quantification
hasSpouse
Def: Weighted Rule
hasSpouse(Elvis,Priscilla) ⇒ hasSpouse(Priscilla, Elvis)[3.14]
A
weighted rule
is a rule with an associated real-valued weight.
9
A weighted rule can also be seen as a
weighted disjunction
...
...or a
weighted clause
.
¬ hasSpouse(Elvis,Priscilla) ∨ hasSpouse(Priscilla, Elvis)[3.14]
{¬ hasSpouse(Elvis,Priscilla), hasSpouse(Priscilla, Elvis)} [3.14]
Def: Weight of a KB
Given a set of atoms (=
possible world
,
KB
) and a set of instantiated rules with weights,
the
weight of the KB
is the sum of the weights of all rules that hold in the KB.
hasSpouse(Elvis,Priscilla) ⇒ hasSpouse(Priscilla,Elvis)[3]
hasSpouse(cat,dog) ⇒ hasSpouse(dog,cat)[2]
10
hasSpouse
hasSpouse
hasSpouse
KB1
KB2
Def: Weight of a KB
Given a set of atoms (=
possible world
,
KB
) and a set of instantiated rules with weights,
the
weight of the KB
is the sum of the weights of all rules that hold in the KB.
hasSpouse(Elvis,Priscilla) ⇒ hasSpouse(Priscilla,Elvis)[3]
hasSpouse(cat,dog) ⇒ hasSpouse(dog,cat)[2]
11
hasSpouse
hasSpouse
hasSpouse
KB1
KB2
Weight: 2
Weight: 5
Def: Weighted MAX SAT
is(Ron,immature) [10]
type(Hermione, sorceress) [4]
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
12
Given a set of instantiated rules with weights,
weighted MAX SAT
is the problem of finding the KB
with the highest weight. If there are several, find the one with the least number of atoms.
Def: Weighted MAX SAT
is(Ron,immature) [10]
13
type(Hermione,sorceress)
is(Ron,immature)
likes(Hermione,Ron)
weight: 17
Best world:
Given a set of instantiated rules with weights,
weighted MAX SAT
is the problem of finding the KB
with the highest weight. If there are several, find the one with the least number of atoms.
type(Hermione, sorceress) [4]
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
Task: Weighted MAX SAT
Find the KB with the highest weight:
is(Hermione,smart)[1]
likes(Hermione,Ron) ⇒ ¬ likes(Hermione,Harry)[100]
likes(Hermione,Ron)[20]
is(Harry,smart)[10]
is(Herm.,smart) ∧ is(Harry,smart) ⇒ likes(Herm.,Harry)[3]
14
Def: Exhaustive search
Exhaustive search
is an algorithm for the Weighted MAX SAT problem that tries out all
possible worlds with the atoms that appear in the rules in order to find the possible world
with the maximal weight.
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
15
is(Ron,immature), type(Hermione, sorceress), likes(Hermione, Ron)
Atoms:
Def: Exhaustive search
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
16
Atoms:
Possible worlds:
{} : weight 3
{is(Ron,immature)} : weight 13,
{is(Ron,immature), type (Hermione, sorceress)} : weight 14, etc.
Exhaustive search
is an algorithm for the Weighted MAX SAT problem that tries out all
possible worlds with the atoms that appear in the rules in order to find the possible world
with the maximal weight.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
is(Ron,immature), type(Hermione, sorceress), likes(Hermione, Ron)
Def: Exhaustive search
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
17
Atoms:
Exhaustive search is a correct and complete algorithm for the Weighted Max Sat problem.
However, it has to analyze
possible worlds, where n is the number of atoms.
Exhaustive search
is an algorithm for the Weighted MAX SAT problem that tries out all
possible worlds with the atoms that appear in the rules in order to find the possible world
with the maximal weight.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
is(Ron,immature), type(Hermione, sorceress), likes(Hermione, Ron)
Intuition of unit propagation
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
18
>example&unitcl
Unit propagation
repeatedly (1) adds the head of a body-less rule to the KB,
(2) removes this atom from the bodies of the other rules, and (3) removes definitively satisfied rules.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
19
KB: {is(Ron,immature)}
Intuition of unit propagation
>example&unitcl
Unit propagation
repeatedly (1) adds the head of a body-less rule to the KB,
(2) removes this atom from the bodies of the other rules, and (3) removes definitively satisfied rules.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
20
KB: {is(Ron,immature)}
Intuition of unit propagation
>example&unitcl
Unit propagation
repeatedly (1) adds the head of a body-less rule to the KB,
(2) removes this atom from the bodies of the other rules, and (3) removes definitively satisfied rules.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
21
KB: {is(Ron,immature), type(Hermione,sorceress)}
Intuition of unit propagation
>example&unitcl
Unit propagation
repeatedly (1) adds the head of a body-less rule to the KB,
(2) removes this atom from the bodies of the other rules, and (3) removes definitively satisfied rules.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
22
>unitcl
Intuition of unit propagation
is(Ron,immature) [10]
type(Hermione,sorceress) [4]
KB: {is(Ron,immature), type(Hermione,sorceress), likes(Hermione, Ron}
Unit propagation
repeatedly (1) adds the head of a body-less rule to the KB,
(2) removes this atom from the bodies of the other rules, and (3) removes definitively satisfied rules.
is(Ron,immature) ∧ type(Hermione, sorceress) ⇒ likes(Hermione, Ron) [3]
Unit propagation for clauses
Unit propagation
repeatedly (1) adds the literal of a unit-clause to the KB,
(2) removes the
negation
of the literal from the other clauses, and
(3) removes all clauses that contain this literal.
{is(Ron,immature)} [10]
{ type(Hermione, sorceress)} [4]
{ ¬ is(Ron,immature), ¬ type(Hermione, sorceress), likes(Hermione, Ron)} [3]
23
{is(Ron,immature)} [10]
24
KB: {is(Ron, immature)}
Unit propagation for clauses
{ type(Hermione, sorceress)} [4]
{ ¬ is(Ron,immature), ¬ type(Hermione, sorceress), likes(Hermione, Ron)} [3]
Unit propagation
repeatedly (1) adds the literal of a unit-clause to the KB,
(2) removes the
negation
of the literal from the other clauses, and
(3) removes all clauses that contain this literal.
{is(Ron,immature)} [10]
25
KB: {is(Ron, immature)}
Unit propagation for clauses
{ type(Hermione, sorceress)} [4]
{ ¬ is(Ron,immature), ¬ type(Hermione, sorceress), likes(Hermione, Ron)} [3]
Unit propagation
repeatedly (1) adds the literal of a unit-clause to the KB,
(2) removes the
negation
of the literal from the other clauses, and
(3) removes all clauses that contain this literal.
{is(Ron,immature)} [10]
26
KB: {is(Ron, immature)}
etc.
Unit propagation for clauses
{ type(Hermione, sorceress)} [4]
{ ¬ is(Ron,immature), ¬ type(Hermione, sorceress), likes(Hermione, Ron)} [3]
Unit propagation
repeatedly (1) adds the literal of a unit-clause to the KB,
(2) removes the
negation
of the literal from the other clauses, and
(3) removes all clauses that contain this literal.
{is(Ron,immature)} [10]
27
Def: Unit propagation for clauses
Unit propagation is a
correct
(but not complete) algorithm for the Weighted Max Sat Problem
if a unit clause is propagated only when its weight is higher than the sum of the weights
of the rules where the literal appears with inverse polarity.
Wikipedia/Unit propagation with a partial model
{ type(Hermione, sorceress)} [4]
{ ¬ is(Ron,immature), ¬ type(Hermione, sorceress), likes(Hermione, Ron)} [3]
Unit propagation
repeatedly (1) adds the literal of a unit-clause to the KB,
(2) removes the
negation
of the literal from the other clauses, and
(3) removes all clauses that contain this literal.
Solving Weighted MAX SAT
28
To always find the optimal solution, one has to do an exhaustive search.
Since SAT is NP-complete, so is MAX SAT and Weighted MAX SAT.
To find an approximate solution, possible strategies are:
• do an exhaustive search if there are few atoms
• try out several random KBs
• apply unit propagation wherever possible
• give preference to rules/unit clauses with higher weights
• add atoms to the KB that appear only positive,
add the negation of all atoms that appear only negative
Summary: Weighted MAX SAT
A weighted formula is a logical formula with a real‐valued weight.
dumb(Ron) [10], dumb(x) ⇒ loves(Hermione, x) [3.2]
equivalently written as a clause:
instantiated:
{¬ dumb(x), loves(Hermione, x)} [3.2]
Given a set of instantiated clauses with weights,
weighted MAX SAT
is the problem of finding the KB
with the highest weight. If there are several, find the one with the least number of atoms.
{¬ dumb(Ron), loves(Hermione, Ron)} [3.2]
Given weighted clauses, the weight of a KB (= set of facts) is the sum of the weights of the
clauses that are satisfied in the KB.
is
dumb
weight: 10
is
dumb
weight: 13.2
loves
->Ie-by-reasoning
->Markov-logic