Presentation is loading. Please wait.

Presentation is loading. Please wait.

Answer Set Programming

Similar presentations


Presentation on theme: "Answer Set Programming"— Presentation transcript:

1 Answer Set Programming
Cleyton Rodrigues, M. Sc.

2 So Far… Monotonic Logic Programming

3 Monotonic Logic “[…] Learning a new piece of knowledge cannot reduce the set of what is known.” A logic is monotonic if every thing that is entailed by a KB (Knowledge Base) is entailed by a superset of the KB: KB╞ a  KB  b╞ a

4 The “Problem”! A Monotonic Logic cannot handle various reasoning tasks; Default Reasoning Typical birds can fly. x bird(X)  flies(X). sparrow? bird(sparrow). flies(sparrow). DR:  (consequences may be derived only because of lack of evidence of the contrary

5 The “Problem”! A Monotonic Logic cannot handle various reasoning tasks; Default Reasoning Typical birds can fly. x bird(X)  flies(X). sparrow? bird(sparrow). flies(sparrow). peguin? bird(peguin), flies(peguin). (taken by the rule).  flies (peguin). Unsatisfiable! The default assumption must be retracted.

6 NAF – Negation as Failure
Negation-As-Failure enables defaults flies(X) :- bird(X), not penguin(X). bird(tweety). bird(opus). penguin(opus). tweety flies because he isn’t declared a penguin if we also asserted penguin(tweety)... Non-Monotonic Reasoning! Closed-world assumption (CWA) everything that is true is asserted; everything unsaid is assumed to be false Minimal Models – only believe what you have to smallest set of tuples that satisfies KB

7 Answer Set Programming

8 Answer Set Programming (ASP)
Declarative Programming; Search problems reduced to compute stable models; Non Monotonic Reasoning; “Unlike SLDNF resolution employed in Prolog, such algorithms, in principle, always terminate.”

9 ASP General Idea Problem Instance I P is a nonmonotonic logic program.
Solver Encoding: Program P P is a nonmonotonic logic program. Model (s) Solution (s)

10 Stable Models Model: Set of Atoms that satisfies every rule in the program. “Informally, a model is stable if every atom in its has a reason to be there: for each atom in the model there has to be some rule that has the atom as a head such that the rule body is true in the model”. Example (Prolog-style Program): PC Configuration System ide_drive :- hard_drive, not scsi_drive. scsi_drive :- hard_drive, not ide_drive. scsi_controller:- scsi_drive. hard_drive.

11 Stable Models? ide_drive :- hard_drive, not scsi_drive.
scsi_drive :- hard_drive, not ide_drive. scsi_controller: scsi_drive. hard_drive.

12 Stable Models? M1={hard_drive, ide_drive}.
ide_drive :- hard_drive, not scsi_drive. scsi_drive :- hard_drive, not ide_drive. scsi_controller: scsi_drive. hard_drive.

13 Stable Models? M1={hard_drive, ide_drive}.
M2={hard_drive, scsi_drive, scsi_controller}. ide_drive :- hard_drive, not scsi_drive. scsi_drive :- hard_drive, not ide_drive. scsi_controller: scsi_drive. hard_drive.

14 How to Find the Stable Model?

15 Without negative literals
Unique minimal Model. a. b. c :- a. d :- c,b. e :- f. Knaster-Tarski operator TP, where: Tp(M) = {h | h  l1, ..., ln is a rule in the program and l1, ..., ln  M}.

16 Without negative literals
Unique minimal Model. a. b. c :- a. d :- c,b. e :- f. Knaster-Tarski operator TP, where: Tp(M) = {h | h  l1, ..., ln is a rule in the program and l1, ..., ln  M}. SM = {a, b, c, d}.

17 With Negative Literals.
Let SM be a (potentially) stable Model for a Program P. Removing negations from P PSM: Each rule that has a negative literal “not a” in its body when a belongs to M; and All negative literals in the bodies of remaining rules. If SM is a stable model por PSM então SM is a stable model for the program P.

18 Find the Stable Models... a :- not b. b :- not a.

19 Formalizing ASP Programs

20 ASP Programs (Prolog Style Rules)
A Program P consists of a set of rules: General Rule <head> :- <body>. Fact <head>.

21 ASP Programs Example1: A P prolog-style Program consists of the following rules: p :- q. q :- not r. Stable Model SM

22 ASP Programs Example1: A P prolog-style Program consists of the following rules: p :- q. q :- not r. Stable Model SM SM = {p, q}.

23 ASP Programs (Extending Prolog)
P is a (potentially disjunctive) finite set of rules of the form: a1  ...  ak  b1, ...,bm, not c1,...,not cn. All ax, bi, cj are FOL literals; Arbitrarily Choice {p,q,r} :- t. “If ‘t’ is included in the stable model then chose arbitrarily which of the atoms to include.” None Just One A subset of the individuals;

24 ASP Programs Example2: A P ASP Program consists of the following rules: p :- q. q :- not r. {s,t}:- p. Stable Model SM

25 ASP Programs Example2: A P ASP Program consists of the following rules: p :- q. q :- not r. {s,t}:- p. Stable Model SM SM1:{p, q}. SM2:{p, q, s}. SM3:{p, q, t}. SM4:{p, q, t , s}.

26 ASP Program Arbritrarily Choice Variation Numerical Bounds
N {s,t} :- p. N: integer The bound means how many indivuals, at least, must be elected by Stable Models.

27 ASP Program Example 3: A P ASP Program consists of the following rules: p :- q. q :- not r. 1 {s,t} :- p Stable Models SM1: p q s SM2: p q t SM3: p q t s SM4: p q (error: not allowed due the numerical restriction)

28 ASP Program Constraint Rule (No Head) :- s, not t.
“Prohibits generating ‘s’ if ‘t’ is not generated.”

29 ASP Program Example 2: A P prolog Program consists of the following rules: p :- q. q :- not r. 1 {s,t} :- p :- s, not t. Stable Models SM1: p q s (error: not allowed due the constraint Rule) SM2: p q t SM3: p q t s

30 Non-Ground Programs

31 Non-ground Programs Example:
d(a). d(b). foo(X) :- not bar(X). bar(X) :- not foo(X). The set of stable Models for a non-ground logic program is defined to be the set of stable models o the Herbrand Instation of the Program.

32 Herbrand Instatiation
Herbrand Universe (HU): set of all ground terms using fuctions symbols and constants. HU = {a,b}; Herbrand Base (HB): set of ground atoms that can be constructed using the predicates in the program and the HU. HB = {foo(a), foo(b), bar(a), bar(b)}; Herbrand Instantiation (HI): set of ground instances of the rule using HB;

33 Herbrand Instantiation
Example: d(a). d(b). foo(X) :- not bar(X). bar(X) :- not foo(X). Herbrand Instantiantion: foo(a) :- not bar(a). bar(a) :- not foo(a). foo(b) :- not bar(b). bar(b) :- not foo(b).

34 Herbrand Instation SM? Herbrand Instantiantion: d(a). d(b).
foo(a) :- not bar(a). bar(a) :- not foo(a). foo(b) :- not bar(b). bar(b) :- not foo(b).

35 Herbrand Instantiation
Usually, most of the rules in the herbrand Instantiation have unsatisfiable bodies and they may be discarded without affecting the set of stable models. Example: d(a). e(b). e(c). foo(X) :- d(X), not bar(X). bar(X) :- d(X), not foo(X).

36 Example d(a). e(b). e(c). foo(a) :- d(a), not bar(a).
bar(a) :- d(a), not foo(a). foo(b) :- d(b), not bar(b). bar(b) :- d(b), not foo(b). foo(c) :- d(c), not bar(c). bar(c) :- d(c), not foo(c).

37 Example d(a). e(b). e(c). foo(a) :- d(a), not bar(a).
bar(a) :- d(a), not foo(a). foo(b) :- d(b), not bar(b). bar(b) :- d(b), not foo(b). foo(c) :- d(c), not bar(c). bar(c) :- d(c), not foo(c).

38 How we know which rules can be droped out?
Example How we know which rules can be droped out? d(a). e(b). e(c). foo(a) :- d(a), not bar(a). bar(a) :- d(a), not foo(a). foo(b) :- d(b), not bar(b). bar(b) :- d(b), not foo(b). foo(c) :- d(c), not bar(c). bar(c) :- d(c), not foo(c).

39 Lparse/ SModels

40 Lparse/ SModels

41 Exercise p :- not q. q :- not p. r :- p. r :- q. p :- not q.
Program 1 Program 2 p :- not q. q :- not p. r :- p. r :- q. p :- not q. q :- not p. r :- not r. r :- p.

42 Exercise Program 3 Program 4 person(joey).
1{male(X), female(X)} :- person(X). bachleor(X):- male(X), not married(X). :- male(X), female(X).


Download ppt "Answer Set Programming"

Similar presentations


Ads by Google