Answer Set Solving in Practice Torsten Schaub University of Potsdam - - PowerPoint PPT Presentation

answer set solving in practice
SMART_READER_LITE
LIVE PREVIEW

Answer Set Solving in Practice Torsten Schaub University of Potsdam - - PowerPoint PPT Presentation

Answer Set Solving in Practice Torsten Schaub University of Potsdam Torsten Schaub (KRR@UP) ASP in Practice 1 / 69 Outline 1 Motivation 2 Introduction 3 Modeling by Example Graph Coloring Queens Traveling Salesperson 4 Meta Programming 5


slide-1
SLIDE 1

Answer Set Solving in Practice

Torsten Schaub

University of Potsdam

Torsten Schaub (KRR@UP) ASP in Practice 1 / 69

slide-2
SLIDE 2

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 2 / 69

slide-3
SLIDE 3

Motivation

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 3 / 69

slide-4
SLIDE 4

Motivation

Goal: Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 4 / 69

slide-5
SLIDE 5

Motivation

Goal: Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 4 / 69

slide-6
SLIDE 6

Motivation

Goal: Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 4 / 69

slide-7
SLIDE 7

Motivation

Answer Set Programming (ASP) in a Nutshell

ASP is an approach to declarative problem solving, combining

a rich yet simple modeling language with high-performance solving capacities

tailored to Knowledge Representation and Reasoning ASP allows for solving all search problems in NP (and NPNP) in a uniform way (being more compact than SAT) The versatility of ASP is reflected by the ASP solver clasp, winning first places at ASP, CASC, MISC, PB, and SAT

http://potassco.sourceforge.net

ASP embraces many emerging application areas, eg.

RoboCup@Home at USTC, Beijing Configuration at SIEMENS, Vienna

Torsten Schaub (KRR@UP) ASP in Practice 5 / 69

slide-8
SLIDE 8

Motivation

Answer Set Programming (ASP) in a Nutshell

ASP is an approach to declarative problem solving, combining

a rich yet simple modeling language with high-performance solving capacities

tailored to Knowledge Representation and Reasoning ASP allows for solving all search problems in NP (and NPNP) in a uniform way (being more compact than SAT) The versatility of ASP is reflected by the ASP solver clasp, winning first places at ASP, CASC, MISC, PB, and SAT

http://potassco.sourceforge.net

ASP embraces many emerging application areas, eg.

RoboCup@Home at USTC, Beijing Configuration at SIEMENS, Vienna

Torsten Schaub (KRR@UP) ASP in Practice 5 / 69

slide-9
SLIDE 9

Motivation

Answer Set Programming (ASP) in a Nutshell

ASP is an approach to declarative problem solving, combining

a rich yet simple modeling language with high-performance solving capacities

tailored to Knowledge Representation and Reasoning ASP allows for solving all search problems in NP (and NPNP) in a uniform way (being more compact than SAT) The versatility of ASP is reflected by the ASP solver clasp, winning first places at ASP, CASC, MISC, PB, and SAT

http://potassco.sourceforge.net

ASP embraces many emerging application areas, eg.

RoboCup@Home at USTC, Beijing Configuration at SIEMENS, Vienna

Torsten Schaub (KRR@UP) ASP in Practice 5 / 69

slide-10
SLIDE 10

Motivation

Answer Set Programming (ASP) in a Nutshell

ASP is an approach to declarative problem solving, combining

a rich yet simple modeling language with high-performance solving capacities

tailored to Knowledge Representation and Reasoning ASP allows for solving all search problems in NP (and NPNP) in a uniform way (being more compact than SAT) The versatility of ASP is reflected by the ASP solver clasp, winning first places at ASP, CASC, MISC, PB, and SAT

http://potassco.sourceforge.net

ASP embraces many emerging application areas, eg.

RoboCup@Home at USTC, Beijing Configuration at SIEMENS, Vienna

Torsten Schaub (KRR@UP) ASP in Practice 5 / 69

slide-11
SLIDE 11

Motivation

Answer Set Programming (ASP) in a Nutshell

ASP is an approach to declarative problem solving, combining

a rich yet simple modeling language with high-performance solving capacities

tailored to Knowledge Representation and Reasoning ASP allows for solving all search problems in NP (and NPNP) in a uniform way (being more compact than SAT) The versatility of ASP is reflected by the ASP solver clasp, winning first places at ASP, CASC, MISC, PB, and SAT

http://potassco.sourceforge.net

ASP embraces many emerging application areas, eg.

RoboCup@Home at USTC, Beijing Configuration at SIEMENS, Vienna

Torsten Schaub (KRR@UP) ASP in Practice 5 / 69

slide-12
SLIDE 12

Introduction

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 6 / 69

slide-13
SLIDE 13

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 7 / 69

slide-14
SLIDE 14

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 7 / 69

slide-15
SLIDE 15

Introduction

Declarative model-based problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Model

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 7 / 69

slide-16
SLIDE 16

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-17
SLIDE 17

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-18
SLIDE 18

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models:

❍❍❍❍❍❍ ❍ ❥

p → 1 q → 1 r → {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-19
SLIDE 19

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-20
SLIDE 20

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-21
SLIDE 21

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-22
SLIDE 22

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-23
SLIDE 23

Introduction

Basic idea

Consider the logical formula Φ and its three (classical) models: {p, q}, {q, r}, and {p, q, r} Φ q ∧ (q ∧ ¬r → p) Formula Φ has one stable model,

  • ften called answer set:

{p, q} PΦ q ← p ← q, ∼r Informally, a set X of atoms is an stable model of a logic program P if X is a (classical) model of P and if all atoms in X are justified by some rule in P

(rooted in intuitionistic logics HT (Heyting, 1930) and G3 (G¨

  • del, 1932))

Torsten Schaub (KRR@UP) ASP in Practice 8 / 69

slide-24
SLIDE 24

Introduction

ASP versus SAT

ASP SAT Model generation Bottom-up Constructive Logic Classical Logic Closed (and open) Open world reasoning world reasoning Modeling language — Complex reasoning modes Satisfiability testing Satisfiability Satisfiability Enumeration/Projection — Optimization — Intersection/Union —

(Turing +) NP(NP)

NP

Torsten Schaub (KRR@UP) ASP in Practice 9 / 69

slide-25
SLIDE 25

Introduction

ASP versus SAT

ASP SAT Model generation Bottom-up Constructive Logic Classical Logic Closed (and open) Open world reasoning world reasoning Modeling language — Complex reasoning modes Satisfiability testing Satisfiability Satisfiability Enumeration/Projection — Optimization — Intersection/Union —

(Turing +) NP(NP)

NP

Torsten Schaub (KRR@UP) ASP in Practice 9 / 69

slide-26
SLIDE 26

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-27
SLIDE 27

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-28
SLIDE 28

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-29
SLIDE 29

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-30
SLIDE 30

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-31
SLIDE 31

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-32
SLIDE 32

Introduction

Formal Definition

Syntax

A rule, r, is an expression of the form a ← b1, . . . , bm, ∼c1, . . . , ∼cn, where 0 ≤ m, n and each a, bi, cj is an atom A logic program is a finite set of rules

Semantics

The reduct, PX, of a program P relative to a set X of atoms is defined by PX = { a ← b1, . . . , bm | r ∈ P and {c1, . . . , cn} ∩ X = ∅} The ⊆–smallest model of PX is denoted by Cn(PX) A set X of atoms is an stable model of a program P, if X = Cn(PX)

Torsten Schaub (KRR@UP) ASP in Practice 10 / 69

slide-33
SLIDE 33

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 11 / 69

slide-34
SLIDE 34

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 11 / 69

slide-35
SLIDE 35

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-36
SLIDE 36

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-37
SLIDE 37

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-38
SLIDE 38

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-39
SLIDE 39

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-40
SLIDE 40

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-41
SLIDE 41

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-42
SLIDE 42

Introduction

Language Constructs

Variables (over the Herbrand Universe)

p(X) :- q(X) over constants {a, b, c} stands for p(a) :- q(a), p(b) :- q(b), p(c) :- q(c)

Conditional Literals

p :- q(X) : r(X) given r(a), r(b), r(c) stands for p :- q(a), q(b), q(c)

Disjunction

p(X) ; q(X) :- r(X)

Integrity Constraints

:- q(X), p(X)

Choice

2 { p(X,Y) : q(X) } 7 :- r(Y)

Aggregates

s(Y) :- r(Y), 2 #count { p(X,Y) : q(X) } 7 also: #sum, #times, #avg, #min, #max, #even, #odd

Torsten Schaub (KRR@UP) ASP in Practice 12 / 69

slide-43
SLIDE 43

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 13 / 69

slide-44
SLIDE 44

Introduction

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 13 / 69

slide-45
SLIDE 45

Introduction

Reasoning Modes

Satisfiability Enumeration† Projection† Intersection‡ Union‡ Optimization

† without solution recording ‡ without solution enumeration Torsten Schaub (KRR@UP) ASP in Practice 14 / 69

slide-46
SLIDE 46

Modeling by Example

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 15 / 69

slide-47
SLIDE 47

Modeling by Example

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 16 / 69

slide-48
SLIDE 48

Modeling by Example

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 16 / 69

slide-49
SLIDE 49

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-50
SLIDE 50

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-51
SLIDE 51

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-52
SLIDE 52

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-53
SLIDE 53

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-54
SLIDE 54

Modeling by Example

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲ ✻

Torsten Schaub (KRR@UP) ASP in Practice 17 / 69

slide-55
SLIDE 55

Modeling by Example Graph Coloring

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 18 / 69

slide-56
SLIDE 56

Modeling by Example Graph Coloring

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 19 / 69

slide-57
SLIDE 57

Modeling by Example Graph Coloring

Graph Coloring

node(1..6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 { color(X,C) : col(C) } 1 :- node(X). :- edge(X,Y), color(X,C), color(Y,C).

Torsten Schaub (KRR@UP) ASP in Practice 20 / 69

slide-58
SLIDE 58

Modeling by Example Graph Coloring

Graph Coloring

node(1..6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 { color(X,C) : col(C) } 1 :- node(X). :- edge(X,Y), color(X,C), color(Y,C).

Torsten Schaub (KRR@UP) ASP in Practice 20 / 69

slide-59
SLIDE 59

Modeling by Example Graph Coloring

Graph Coloring

node(1..6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 { color(X,C) : col(C) } 1 :- node(X). :- edge(X,Y), color(X,C), color(Y,C).

Torsten Schaub (KRR@UP) ASP in Practice 20 / 69

slide-60
SLIDE 60

Modeling by Example Graph Coloring

Graph Coloring

node(1..6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 { color(X,C) : col(C) } 1 :- node(X). :- edge(X,Y), color(X,C), color(Y,C).

Torsten Schaub (KRR@UP) ASP in Practice 20 / 69

slide-61
SLIDE 61

Modeling by Example Graph Coloring

Graph Coloring

node(1..6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 { color(X,C) : col(C) } 1 :- node(X). :- edge(X,Y), color(X,C), color(Y,C).

Torsten Schaub (KRR@UP) ASP in Practice 20 / 69

slide-62
SLIDE 62

Modeling by Example Graph Coloring

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 21 / 69

slide-63
SLIDE 63

Modeling by Example Graph Coloring

Graph Coloring: Grounding

$ gringo -t color.lp

node(1). node(2). node(3). node(4). node(5). node(6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 {color(1,r), color(1,b), color(1,g)} 1. 1 {color(2,r), color(2,b), color(2,g)} 1. 1 {color(3,r), color(3,b), color(3,g)} 1. 1 {color(4,r), color(4,b), color(4,g)} 1. 1 {color(5,r), color(5,b), color(5,g)} 1. 1 {color(6,r), color(6,b), color(6,g)} 1. :- color(1,r), color(2,r). :- color(2,g), color(5,g). ... :- color(6,r), color(2,r). :- color(1,b), color(2,b). :- color(2,r), color(6,r). :- color(6,b), color(2,b). :- color(1,g), color(2,g). :- color(2,b), color(6,b). :- color(6,g), color(2,g). :- color(1,r), color(3,r). :- color(2,g), color(6,g). :- color(6,r), color(3,r). :- color(1,b), color(3,b). :- color(3,r), color(1,r). :- color(6,b), color(3,b). :- color(1,g), color(3,g). :- color(3,b), color(1,b). :- color(6,g), color(3,g). :- color(1,r), color(4,r). :- color(3,g), color(1,g). :- color(6,r), color(5,r). :- color(1,b), color(4,b). :- color(3,r), color(4,r). :- color(6,b), color(5,b). :- color(1,g), color(4,g). :- color(3,b), color(4,b). :- color(6,g), color(5,g). :- color(2,r), color(4,r). :- color(3,g), color(4,g). :- color(2,b), color(4,b). :- color(3,r), color(5,r). :- color(2,g), color(4,g). :- color(3,b), color(5,b). :- color(2,r), color(5,r). :- color(3,g), color(5,g). :- color(2,b), color(5,b). :- color(4,r), color(1,r). Torsten Schaub (KRR@UP) ASP in Practice 22 / 69

slide-64
SLIDE 64

Modeling by Example Graph Coloring

Graph Coloring: Grounding

$ gringo -t color.lp

node(1). node(2). node(3). node(4). node(5). node(6). edge(1,2). edge(1,3). edge(1,4). edge(2,4). edge(2,5). edge(2,6). edge(3,1). edge(3,4). edge(3,5). edge(4,1). edge(4,2). edge(5,3). edge(5,4). edge(5,6). edge(6,2). edge(6,3). edge(6,5). col(r). col(b). col(g). 1 {color(1,r), color(1,b), color(1,g)} 1. 1 {color(2,r), color(2,b), color(2,g)} 1. 1 {color(3,r), color(3,b), color(3,g)} 1. 1 {color(4,r), color(4,b), color(4,g)} 1. 1 {color(5,r), color(5,b), color(5,g)} 1. 1 {color(6,r), color(6,b), color(6,g)} 1. :- color(1,r), color(2,r). :- color(2,g), color(5,g). ... :- color(6,r), color(2,r). :- color(1,b), color(2,b). :- color(2,r), color(6,r). :- color(6,b), color(2,b). :- color(1,g), color(2,g). :- color(2,b), color(6,b). :- color(6,g), color(2,g). :- color(1,r), color(3,r). :- color(2,g), color(6,g). :- color(6,r), color(3,r). :- color(1,b), color(3,b). :- color(3,r), color(1,r). :- color(6,b), color(3,b). :- color(1,g), color(3,g). :- color(3,b), color(1,b). :- color(6,g), color(3,g). :- color(1,r), color(4,r). :- color(3,g), color(1,g). :- color(6,r), color(5,r). :- color(1,b), color(4,b). :- color(3,r), color(4,r). :- color(6,b), color(5,b). :- color(1,g), color(4,g). :- color(3,b), color(4,b). :- color(6,g), color(5,g). :- color(2,r), color(4,r). :- color(3,g), color(4,g). :- color(2,b), color(4,b). :- color(3,r), color(5,r). :- color(2,g), color(4,g). :- color(3,b), color(5,b). :- color(2,r), color(5,r). :- color(3,g), color(5,g). :- color(2,b), color(5,b). :- color(4,r), color(1,r). Torsten Schaub (KRR@UP) ASP in Practice 22 / 69

slide-65
SLIDE 65

Modeling by Example Graph Coloring

ASP Solving Process

Program Grounder Solver Models

✲ ✲ ✲

Torsten Schaub (KRR@UP) ASP in Practice 23 / 69

slide-66
SLIDE 66

Modeling by Example Graph Coloring

Graph Coloring: Solving

$ gringo color.lp | clasp 0

clasp version 2.1.0 Reading from stdin Solving... Answer: 1 edge(1,2) ... col(r) ... node(1) ... color(6,b) color(5,g) color(4,b) color(3,r) color(2,r) color(1,g) Answer: 2 edge(1,2) ... col(r) ... node(1) ... color(6,r) color(5,g) color(4,r) color(3,b) color(2,b) color(1,g) Answer: 3 edge(1,2) ... col(r) ... node(1) ... color(6,g) color(5,b) color(4,g) color(3,r) color(2,r) color(1,b) Answer: 4 edge(1,2) ... col(r) ... node(1) ... color(6,r) color(5,b) color(4,r) color(3,g) color(2,g) color(1,b) Answer: 5 edge(1,2) ... col(r) ... node(1) ... color(6,g) color(5,r) color(4,g) color(3,b) color(2,b) color(1,r) Answer: 6 edge(1,2) ... col(r) ... node(1) ... color(6,b) color(5,r) color(4,b) color(3,g) color(2,g) color(1,r) SATISFIABLE Models : 6 Time : 0.002s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) CPU Time : 0.000s Torsten Schaub (KRR@UP) ASP in Practice 24 / 69

slide-67
SLIDE 67

Modeling by Example Graph Coloring

Graph Coloring: Solving

$ gringo color.lp | clasp 0

clasp version 2.1.0 Reading from stdin Solving... Answer: 1 edge(1,2) ... col(r) ... node(1) ... color(6,b) color(5,g) color(4,b) color(3,r) color(2,r) color(1,g) Answer: 2 edge(1,2) ... col(r) ... node(1) ... color(6,r) color(5,g) color(4,r) color(3,b) color(2,b) color(1,g) Answer: 3 edge(1,2) ... col(r) ... node(1) ... color(6,g) color(5,b) color(4,g) color(3,r) color(2,r) color(1,b) Answer: 4 edge(1,2) ... col(r) ... node(1) ... color(6,r) color(5,b) color(4,r) color(3,g) color(2,g) color(1,b) Answer: 5 edge(1,2) ... col(r) ... node(1) ... color(6,g) color(5,r) color(4,g) color(3,b) color(2,b) color(1,r) Answer: 6 edge(1,2) ... col(r) ... node(1) ... color(6,b) color(5,r) color(4,b) color(3,g) color(2,g) color(1,r) SATISFIABLE Models : 6 Time : 0.002s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s) CPU Time : 0.000s Torsten Schaub (KRR@UP) ASP in Practice 24 / 69

slide-68
SLIDE 68

Modeling by Example Queens

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 25 / 69

slide-69
SLIDE 69

Modeling by Example Queens

The n-Queens Problem

5 Z0Z0Z 4 0Z0Z0 3 Z0Z0Z 2 0Z0Z0 1 Z0Z0Z 1 2 3 4 5

Place n queens on an n × n chess board Queens must not attack one another

Q Q Q Q Q

Torsten Schaub (KRR@UP) ASP in Practice 26 / 69

slide-70
SLIDE 70

Modeling by Example Queens

Defining the Field

queens.lp

row (1..n). col (1..n). Create file queens.lp Define the field

n rows n columns

Torsten Schaub (KRR@UP) ASP in Practice 27 / 69

slide-71
SLIDE 71

Modeling by Example Queens

Defining the Field

Running . . .

$ clingo queens.lp -c n=5 Answer: 1 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) SATISFIABLE Models : 1 Time : 0.000 Prepare : 0.000 Prepro. : 0.000 Solving : 0.000

Torsten Schaub (KRR@UP) ASP in Practice 28 / 69

slide-72
SLIDE 72

Modeling by Example Queens

Placing some Queens

queens.lp

row (1..n). col (1..n). { queen(I,J) : row(I) : col(J) }. Guess a solution candidate by placing some queens on the board

Torsten Schaub (KRR@UP) ASP in Practice 29 / 69

slide-73
SLIDE 73

Modeling by Example Queens

Placing some Queens

Running . . .

$ clingo queens.lp -c n=5 3 Answer: 1 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) Answer: 2 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) queen(1,1) Answer: 3 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) queen(2,1) SATISFIABLE Models : 3+ ...

Torsten Schaub (KRR@UP) ASP in Practice 30 / 69

slide-74
SLIDE 74

Modeling by Example Queens

Placing some Queens: Answer 1

Answer 1

5 Z0Z0Z 4 0Z0Z0 3 Z0Z0Z 2 0Z0Z0 1 Z0Z0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 31 / 69

slide-75
SLIDE 75

Modeling by Example Queens

Placing some Queens: Answer 2

Answer 2

5 Z0Z0Z 4 0Z0Z0 3 Z0Z0Z 2 0Z0Z0 1 L0Z0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 32 / 69

slide-76
SLIDE 76

Modeling by Example Queens

Placing some Queens: Answer 3

Answer 3

5 Z0Z0Z 4 0Z0Z0 3 Z0Z0Z 2 QZ0Z0 1 Z0Z0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 33 / 69

slide-77
SLIDE 77

Modeling by Example Queens

Placing n Queens

queens.lp

row (1..n). col (1..n). { queen(I,J) : row(I) : col(J) }. :- not n { queen(I,J) } n. Place exactly n queens on the board

Torsten Schaub (KRR@UP) ASP in Practice 34 / 69

slide-78
SLIDE 78

Modeling by Example Queens

Placing n Queens

Running . . .

$ clingo queens.lp -c n=5 2 Answer: 1 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) \ queen(5,1) queen(4,1) queen(3,1) \ queen(2,1) queen(1,1) Answer: 2 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) \ queen(1,2) queen(4,1) queen(3,1) \ queen(2,1) queen(1,1) ...

Torsten Schaub (KRR@UP) ASP in Practice 35 / 69

slide-79
SLIDE 79

Modeling by Example Queens

Placing n Queens: Answer 1

Answer 1

5 L0Z0Z 4 QZ0Z0 3 L0Z0Z 2 QZ0Z0 1 L0Z0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 36 / 69

slide-80
SLIDE 80

Modeling by Example Queens

Placing n Queens: Answer 2

Answer 2

5 Z0Z0Z 4 QZ0Z0 3 L0Z0Z 2 QZ0Z0 1 LQZ0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 37 / 69

slide-81
SLIDE 81

Modeling by Example Queens

Horizontal and vertical Attack

queens.lp

row (1..n). col (1..n). { queen(I,J) : row(I) : col(J) }. :- not n { queen(I,J) } n. :- queen(I,J), queen(I,JJ), J != JJ. :- queen(I,J), queen(II,J), I != II. Forbid horizontal attacks Forbid vertical attacks

Torsten Schaub (KRR@UP) ASP in Practice 38 / 69

slide-82
SLIDE 82

Modeling by Example Queens

Horizontal and vertical Attack

queens.lp

row (1..n). col (1..n). { queen(I,J) : row(I) : col(J) }. :- not n { queen(I,J) } n. :- queen(I,J), queen(I,JJ), J != JJ. :- queen(I,J), queen(II,J), I != II. Forbid horizontal attacks Forbid vertical attacks

Torsten Schaub (KRR@UP) ASP in Practice 38 / 69

slide-83
SLIDE 83

Modeling by Example Queens

Horizontal and vertical Attack

Running . . .

$ clingo queens.lp -c n=5 Answer: 1 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) \ queen(5,5) queen(4,4) queen(3,3) \ queen(2,2) queen(1,1) ...

Torsten Schaub (KRR@UP) ASP in Practice 39 / 69

slide-84
SLIDE 84

Modeling by Example Queens

Horizontal and vertical Attack: Answer 1

Answer 1

5 Z0Z0L 4 0Z0L0 3 Z0L0Z 2 0L0Z0 1 L0Z0Z 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 40 / 69

slide-85
SLIDE 85

Modeling by Example Queens

Diagonal Attack

queens.lp

row (1..n). col (1..n). { queen(I,J) : row(I) : col(J) }. :- not n { queen(I,J) } n. :- queen(I,J), queen(I,JJ), J != JJ. :- queen(I,J), queen(II ,J), I != II. :- queen(I,J), queen(II,JJ), (I,J) != (II,JJ), I-J == II-JJ. :- queen(I,J), queen(II,JJ), (I,J) != (II,JJ), I+J == II+JJ. Forbid diagonal attacks

Torsten Schaub (KRR@UP) ASP in Practice 41 / 69

slide-86
SLIDE 86

Modeling by Example Queens

Diagonal Attack

Running . . .

$ clingo queens.lp -c n=5 Answer: 1 row (1) row (2) row (3) row (4) row (5) \ col (1) col (2) col (3) col (4) col (5) \ queen(4,5) queen(1,4) queen(3,3) \ queen(5,2) queen(2,1) SATISFIABLE Models : 1+ Time : 0.000 Prepare : 0.000 Prepro. : 0.000 Solving : 0.000

Torsten Schaub (KRR@UP) ASP in Practice 42 / 69

slide-87
SLIDE 87

Modeling by Example Queens

Diagonal Attack: Answer 1

Answer 1

5 ZQZ0Z 4 0Z0ZQ 3 Z0L0Z 2 QZ0Z0 1 Z0ZQZ 1 2 3 4 5

Torsten Schaub (KRR@UP) ASP in Practice 43 / 69

slide-88
SLIDE 88

Modeling by Example Queens

Optimizing

queens-opt.lp

1 { queen(I ,1..n) } 1 :- I = 1..n. 1 { queen (1..n,J) } 1 :- J = 1..n. :- 2 { queen(D-J,J) }, D = 2..2*n. :- 2 { queen(D+J,J) }, D = 1-n..n-1. Encoding can be optimized Much faster to solve

Torsten Schaub (KRR@UP) ASP in Practice 44 / 69

slide-89
SLIDE 89

Modeling by Example Traveling Salesperson

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 45 / 69

slide-90
SLIDE 90

Modeling by Example Traveling Salesperson

Traveling Salesperson

node(1..6). edge(1,2;3;4). edge(2,4;5;6). edge(3,1;4;5). edge(4,1;2). edge(5,3;4;6). edge(6,2;3;5). cost(1,2,2). cost(1,3,3). cost(1,4,1). cost(2,4,2). cost(2,5,2). cost(2,6,4). cost(3,1,3). cost(3,4,2). cost(3,5,2). cost(4,1,1). cost(4,2,2). cost(5,3,2). cost(5,4,2). cost(5,6,1). cost(6,2,4). cost(6,3,3). cost(6,5,1).

Torsten Schaub (KRR@UP) ASP in Practice 46 / 69

slide-91
SLIDE 91

Modeling by Example Traveling Salesperson

Traveling Salesperson

node(1..6). edge(1,2;3;4). edge(2,4;5;6). edge(3,1;4;5). edge(4,1;2). edge(5,3;4;6). edge(6,2;3;5). cost(1,2,2). cost(1,3,3). cost(1,4,1). cost(2,4,2). cost(2,5,2). cost(2,6,4). cost(3,1,3). cost(3,4,2). cost(3,5,2). cost(4,1,1). cost(4,2,2). cost(5,3,2). cost(5,4,2). cost(5,6,1). cost(6,2,4). cost(6,3,3). cost(6,5,1).

Torsten Schaub (KRR@UP) ASP in Practice 46 / 69

slide-92
SLIDE 92

Modeling by Example Traveling Salesperson

Traveling Salesperson

node(1..6). edge(1,2;3;4). edge(2,4;5;6). edge(3,1;4;5). edge(4,1;2). edge(5,3;4;6). edge(6,2;3;5). cost(1,2,2). cost(1,3,3). cost(1,4,1). cost(2,4,2). cost(2,5,2). cost(2,6,4). cost(3,1,3). cost(3,4,2). cost(3,5,2). cost(4,1,1). cost(4,2,2). cost(5,3,2). cost(5,4,2). cost(5,6,1). cost(6,2,4). cost(6,3,3). cost(6,5,1).

Torsten Schaub (KRR@UP) ASP in Practice 46 / 69

slide-93
SLIDE 93

Modeling by Example Traveling Salesperson

Traveling Salesperson

1 { cycle(X,Y) : edge(X,Y) } 1 :- node(X). 1 { cycle(X,Y) : edge(X,Y) } 1 :- node(Y). reached(Y) :- cycle(1,Y). reached(Y) :- cycle(X,Y), reached(X). :- node(Y), not reached(Y). #minimize { cycle(X,Y) : cost(X,Y,C) = C }.

Torsten Schaub (KRR@UP) ASP in Practice 47 / 69

slide-94
SLIDE 94

Modeling by Example Traveling Salesperson

Traveling Salesperson

1 { cycle(X,Y) : edge(X,Y) } 1 :- node(X). 1 { cycle(X,Y) : edge(X,Y) } 1 :- node(Y). reached(Y) :- cycle(1,Y). reached(Y) :- cycle(X,Y), reached(X). :- node(Y), not reached(Y). #minimize { cycle(X,Y) : cost(X,Y,C) = C }.

Torsten Schaub (KRR@UP) ASP in Practice 47 / 69

slide-95
SLIDE 95

Modeling by Example Traveling Salesperson

Traveling Salesperson

1 { cycle(X,Y) : edge(X,Y) } 1 :- node(X). 1 { cycle(X,Y) : edge(X,Y) } 1 :- node(Y). reached(Y) :- cycle(1,Y). reached(Y) :- cycle(X,Y), reached(X). :- node(Y), not reached(Y). #minimize { cycle(X,Y) : cost(X,Y,C) = C }.

Torsten Schaub (KRR@UP) ASP in Practice 47 / 69

slide-96
SLIDE 96

Modeling by Example Traveling Salesperson

Traveling Salesperson

1 { cycle(X,Y) : edge(X,Y) } 1 :- node(X). 1 { cycle(X,Y) : edge(X,Y) } 1 :- node(Y). reached(Y) :- cycle(1,Y). reached(Y) :- cycle(X,Y), reached(X). :- node(Y), not reached(Y). #minimize { cycle(X,Y) : cost(X,Y,C) = C }.

Torsten Schaub (KRR@UP) ASP in Practice 47 / 69

slide-97
SLIDE 97

Modeling by Example Traveling Salesperson

What is ASP good for?

Combinatorial search problems in the realm of P, NP, and NPNP (some with substantial amount of data), like

For instance, auctions, bio-informatics, computer-aided verification, configuration, constraint satisfaction, diagnosis, information integration, planning and scheduling, security analysis, semantic web, wire-routing, zoology and linguistics, and many more

My favorite: Using ASP as a basis for a decision support system for NASA’s space shuttle (Gelfond et al., Texas Tech) Our own applications:

Automatic synthesis of multiprocessor systems Inconsistency detection, diagnosis, repair, and prediction in large biological networks Home monitoring for risk prevention in ambient assisted living General game playing

Torsten Schaub (KRR@UP) ASP in Practice 48 / 69

slide-98
SLIDE 98

Modeling by Example Traveling Salesperson

What is ASP good for?

Combinatorial search problems in the realm of P, NP, and NPNP (some with substantial amount of data), like

For instance, auctions, bio-informatics, computer-aided verification, configuration, constraint satisfaction, diagnosis, information integration, planning and scheduling, security analysis, semantic web, wire-routing, zoology and linguistics, and many more

My favorite: Using ASP as a basis for a decision support system for NASA’s space shuttle (Gelfond et al., Texas Tech) Our own applications:

Automatic synthesis of multiprocessor systems Inconsistency detection, diagnosis, repair, and prediction in large biological networks Home monitoring for risk prevention in ambient assisted living General game playing

Torsten Schaub (KRR@UP) ASP in Practice 48 / 69

slide-99
SLIDE 99

Modeling by Example Traveling Salesperson

What is ASP good for?

Combinatorial search problems in the realm of P, NP, and NPNP (some with substantial amount of data), like

For instance, auctions, bio-informatics, computer-aided verification, configuration, constraint satisfaction, diagnosis, information integration, planning and scheduling, security analysis, semantic web, wire-routing, zoology and linguistics, and many more

My favorite: Using ASP as a basis for a decision support system for NASA’s space shuttle (Gelfond et al., Texas Tech) Our own applications:

Automatic synthesis of multiprocessor systems Inconsistency detection, diagnosis, repair, and prediction in large biological networks Home monitoring for risk prevention in ambient assisted living General game playing

Torsten Schaub (KRR@UP) ASP in Practice 48 / 69

slide-100
SLIDE 100

Modeling by Example Traveling Salesperson

What does ASP offer?

Integration of KR, DB, and SAT techniques Succinct, elaboration-tolerant problem representations

Rapid application development tool

Easy handling of dynamic, knowledge intensive applications

including: data, frame axioms, exceptions, defaults, closures, etc.

Torsten Schaub (KRR@UP) ASP in Practice 49 / 69

slide-101
SLIDE 101

Modeling by Example Traveling Salesperson

What does ASP offer?

Integration of KR, DB, and SAT techniques Succinct, elaboration-tolerant problem representations

Rapid application development tool

Easy handling of dynamic, knowledge intensive applications

including: data, frame axioms, exceptions, defaults, closures, etc.

ASP = DB+LP+KR+SAT

Torsten Schaub (KRR@UP) ASP in Practice 49 / 69

slide-102
SLIDE 102

Meta Programming

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 50 / 69

slide-103
SLIDE 103

Meta Programming

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 51 / 69

slide-104
SLIDE 104

Meta Programming

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 51 / 69

slide-105
SLIDE 105

Meta Programming

Grounding by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

Torsten Schaub (KRR@UP) ASP in Practice 52 / 69

slide-106
SLIDE 106

Meta Programming

Grounding by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

Torsten Schaub (KRR@UP) ASP in Practice 52 / 69

slide-107
SLIDE 107

Meta Programming

Solving by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo easy.lp | clasp 0

clasp version 2.0.0 Reading from stdin Solving... Answer: 1 p(1) p(2) p(3) q(2) SATISFIABLE Models : 1 Time : 0.000s CPU Time : 0.000s

Torsten Schaub (KRR@UP) ASP in Practice 53 / 69

slide-108
SLIDE 108

Meta Programming

Solving by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo easy.lp | clasp 0

clasp version 2.0.0 Reading from stdin Solving... Answer: 1 p(1) p(2) p(3) q(2) SATISFIABLE Models : 1 Time : 0.000s CPU Time : 0.000s

Torsten Schaub (KRR@UP) ASP in Practice 53 / 69

slide-109
SLIDE 109

Meta Programming

Reifying by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 54 / 69

slide-110
SLIDE 110

Meta Programming

Reifying by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 54 / 69

slide-111
SLIDE 111

Meta Programming

Reifying by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 54 / 69

slide-112
SLIDE 112

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-113
SLIDE 113

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-114
SLIDE 114

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-115
SLIDE 115

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-116
SLIDE 116

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-117
SLIDE 117

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-118
SLIDE 118

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-119
SLIDE 119

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-120
SLIDE 120

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-121
SLIDE 121

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-122
SLIDE 122

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-123
SLIDE 123

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-124
SLIDE 124

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-125
SLIDE 125

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-126
SLIDE 126

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-127
SLIDE 127

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-128
SLIDE 128

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-129
SLIDE 129

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-130
SLIDE 130

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-131
SLIDE 131

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-132
SLIDE 132

Meta Programming

Reifying by example

gringo --text easy.lp

#count{ p(1), p(2), p(3) }. :- #count{ p(3), p(2), p(1) } 2. q(2) :- p(2), p(3).

gringo --reify easy.lp

wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))).

Torsten Schaub (KRR@UP) ASP in Practice 55 / 69

slide-133
SLIDE 133

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-134
SLIDE 134

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-135
SLIDE 135

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-136
SLIDE 136

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-137
SLIDE 137

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-138
SLIDE 138

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-139
SLIDE 139

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-140
SLIDE 140

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-141
SLIDE 141

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-142
SLIDE 142

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-143
SLIDE 143

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-144
SLIDE 144

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-145
SLIDE 145

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-146
SLIDE 146

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-147
SLIDE 147

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-148
SLIDE 148

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-149
SLIDE 149

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-150
SLIDE 150

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-151
SLIDE 151

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-152
SLIDE 152

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-153
SLIDE 153

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-154
SLIDE 154

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-155
SLIDE 155

Meta Programming

Basic meta-encoding meta.lp

litb(B) :- rule(_,B). litb(E) :- litb(pos(conjunction(S))), set(S,E). litb(E) :- eleb(sum(_,S,_)), wlist(S,_,E,_). eleb(P) :- litb(pos(P)). eleb(N) :- litb(neg(N)). elem(E) :- eleb(E). elem(E) :- rule(pos(E),_). elem(P) :- rule(pos(sum(_,S,_)),_), wlist(S,_,pos(P),_). elem(N) :- rule(pos(sum(_,S,_)),_), wlist(S,_,neg(N),_). hold(conjunction(S)) :- eleb(conjunction(S)), hold(P) : set(S,pos(P)), not hold(N) : set(S,neg(N)). hold(sum(L,S,U)) :- eleb(sum(L,S,U)), L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U. hold(atom(A)) :- rule(pos(atom(A)), pos(B)), hold(B). L #sum [ hold(P) = W : wlist(S,Q,pos(P),W), not hold(N) = W : wlist(S,Q,neg(N),W) ] U :- rule(pos(sum(L,S,U)),pos(B)), hold(B). :- rule(pos(false), pos(B)), hold(B). #hide. #show hold(atom(A)). Torsten Schaub (KRR@UP) ASP in Practice 56 / 69

slide-156
SLIDE 156

Meta Programming

Reified Grounding by example

gringo --reify easy.lp | gringo - meta.lp

eleb(atom(p(1))). litb(pos(atom(p(1)))). elem(atom(p(1))). elem(false). eleb(atom(p(2))). litb(pos(atom(p(2)))). elem(atom(p(2))). elem(sum(0,0,2)). eleb(atom(p(3))). litb(pos(atom(p(3)))). elem(atom(p(3))). elem(sum(0,0,3)). eleb(conjunction(0)). litb(pos(conjunction(0))). elem(atom(q(2))). eleb(conjunction(1)). litb(pos(conjunction(1))). elem(conjunction(0)). eleb(conjunction(2)). litb(pos(conjunction(2))). elem(conjunction(1)). eleb(sum(0,0,2)). litb(pos(sum(0,0,2))). elem(conjunction(2)). wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))). hold(conjunction(2)) :- hold(atom(p(3))),hold(atom(p(2))). hold(conjunction(1)) :- hold(sum(0,0,2)). hold(conjunction(0)). hold(sum(0,0,2)) :- 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 2. hold(atom(q(2))) :- hold(conjunction(2)). 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 3. :- hold(conjunction(1)). #hide. #show hold(atom(p(1))). #show hold(atom(p(2))). #show hold(atom(p(3))). #show hold(atom(q(2))). Torsten Schaub (KRR@UP) ASP in Practice 57 / 69

slide-157
SLIDE 157

Meta Programming

Reified Grounding by example

gringo --reify easy.lp | gringo - meta.lp

eleb(atom(p(1))). litb(pos(atom(p(1)))). elem(atom(p(1))). elem(false). eleb(atom(p(2))). litb(pos(atom(p(2)))). elem(atom(p(2))). elem(sum(0,0,2)). eleb(atom(p(3))). litb(pos(atom(p(3)))). elem(atom(p(3))). elem(sum(0,0,3)). eleb(conjunction(0)). litb(pos(conjunction(0))). elem(atom(q(2))). eleb(conjunction(1)). litb(pos(conjunction(1))). elem(conjunction(0)). eleb(conjunction(2)). litb(pos(conjunction(2))). elem(conjunction(1)). eleb(sum(0,0,2)). litb(pos(sum(0,0,2))). elem(conjunction(2)). wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))). hold(conjunction(2)) :- hold(atom(p(3))),hold(atom(p(2))). hold(conjunction(1)) :- hold(sum(0,0,2)). hold(conjunction(0)). hold(sum(0,0,2)) :- 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 2. hold(atom(q(2))) :- hold(conjunction(2)). 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 3. :- hold(conjunction(1)). #hide. #show hold(atom(p(1))). #show hold(atom(p(2))). #show hold(atom(p(3))). #show hold(atom(q(2))). Torsten Schaub (KRR@UP) ASP in Practice 57 / 69

slide-158
SLIDE 158

Meta Programming

Reified Grounding by example

gringo --reify easy.lp | gringo - meta.lp

eleb(atom(p(1))). litb(pos(atom(p(1)))). elem(atom(p(1))). elem(false). eleb(atom(p(2))). litb(pos(atom(p(2)))). elem(atom(p(2))). elem(sum(0,0,2)). eleb(atom(p(3))). litb(pos(atom(p(3)))). elem(atom(p(3))). elem(sum(0,0,3)). eleb(conjunction(0)). litb(pos(conjunction(0))). elem(atom(q(2))). eleb(conjunction(1)). litb(pos(conjunction(1))). elem(conjunction(0)). eleb(conjunction(2)). litb(pos(conjunction(2))). elem(conjunction(1)). eleb(sum(0,0,2)). litb(pos(sum(0,0,2))). elem(conjunction(2)). wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))). hold(conjunction(2)) :- hold(atom(p(3))),hold(atom(p(2))). hold(conjunction(1)) :- hold(sum(0,0,2)). hold(conjunction(0)). hold(sum(0,0,2)) :- 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 2. hold(atom(q(2))) :- hold(conjunction(2)). 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 3. :- hold(conjunction(1)). #hide. #show hold(atom(p(1))). #show hold(atom(p(2))). #show hold(atom(p(3))). #show hold(atom(q(2))). Torsten Schaub (KRR@UP) ASP in Practice 57 / 69

slide-159
SLIDE 159

Meta Programming

Reified Grounding by example

gringo --reify easy.lp | gringo - meta.lp

eleb(atom(p(1))). litb(pos(atom(p(1)))). elem(atom(p(1))). elem(false). eleb(atom(p(2))). litb(pos(atom(p(2)))). elem(atom(p(2))). elem(sum(0,0,2)). eleb(atom(p(3))). litb(pos(atom(p(3)))). elem(atom(p(3))). elem(sum(0,0,3)). eleb(conjunction(0)). litb(pos(conjunction(0))). elem(atom(q(2))). eleb(conjunction(1)). litb(pos(conjunction(1))). elem(conjunction(0)). eleb(conjunction(2)). litb(pos(conjunction(2))). elem(conjunction(1)). eleb(sum(0,0,2)). litb(pos(sum(0,0,2))). elem(conjunction(2)). wlist(0,0,pos(atom(p(1))),1). wlist(0,1,pos(atom(p(2))),1). wlist(0,2,pos(atom(p(3))),1). rule(pos(sum(0,0,3)),pos(conjunction(0))). set(1,pos(sum(0,0,2))). rule(pos(false),pos(conjunction(1))). set(2,pos(atom(p(2)))). set(2,pos(atom(p(3)))). rule(pos(atom(q(2))),pos(conjunction(2))). hold(conjunction(2)) :- hold(atom(p(3))),hold(atom(p(2))). hold(conjunction(1)) :- hold(sum(0,0,2)). hold(conjunction(0)). hold(sum(0,0,2)) :- 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 2. hold(atom(q(2))) :- hold(conjunction(2)). 0 #sum [ hold(atom(p(3)))=1, hold(atom(p(2)))=1, hold(atom(p(1)))=1 ] 3. :- hold(conjunction(1)). #hide. #show hold(atom(p(1))). #show hold(atom(p(2))). #show hold(atom(p(3))). #show hold(atom(q(2))). Torsten Schaub (KRR@UP) ASP in Practice 57 / 69

slide-160
SLIDE 160

Meta Programming

Solving by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --reify easy.lp | gringo - meta.lp | clasp 0

clasp version 2.0.0 Reading from stdin Solving... Answer: 1 hold(atom(p(3))) hold(atom(p(2))) hold(atom(p(1))) hold(atom(q(2))) SATISFIABLE Models : 1 Time : 0.000s CPU Time : 0.000s

Torsten Schaub (KRR@UP) ASP in Practice 58 / 69

slide-161
SLIDE 161

Meta Programming

Solving by example

easy.lp

{ p(1..3) }. :- { p(X) } 2. q(X) :- p(X), p(X+1), X>1.

gringo --reify easy.lp | gringo - meta.lp | clasp 0

clasp version 2.0.0 Reading from stdin Solving... Answer: 1 hold(atom(p(3))) hold(atom(p(2))) hold(atom(p(1))) hold(atom(q(2))) SATISFIABLE Models : 1 Time : 0.000s CPU Time : 0.000s

Torsten Schaub (KRR@UP) ASP in Practice 58 / 69

slide-162
SLIDE 162

Conflict-Driven Answer Set Solving

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 59 / 69

slide-163
SLIDE 163

Conflict-Driven Answer Set Solving

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 60 / 69

slide-164
SLIDE 164

Conflict-Driven Answer Set Solving

Declarative problem solving

“What is the problem?” instead of “How to solve the problem?” Problem Representation Solution Output

❄ ✲ ✻

Modeling Interpreting Solving

Torsten Schaub (KRR@UP) ASP in Practice 60 / 69

slide-165
SLIDE 165

Conflict-Driven Answer Set Solving

Towards conflict-driven search

Boolean constraint solving algorithms pioneered for SAT led to: Traditional DPLL-style approach

(DPLL stands for ‘Davis-Putnam-Logemann-Loveland’)

(Unit) propagation (Chronological) backtracking in ASP, eg smodels

Modern CDCL-style approach

(CDCL stands for ‘Conflict-Driven Constraint Learning’)

(Unit) propagation Conflict analysis (via resolution) Learning + Backjumping + Assertion in ASP, eg clasp

Torsten Schaub (KRR@UP) ASP in Practice 61 / 69

slide-166
SLIDE 166

Conflict-Driven Answer Set Solving

DPLL-style solving

loop propagate // deterministically assign literals if no conflict then

if all variables assigned then return solution else decide // non-deterministically assign some literal

else

if top-level conflict then return unsatisfiable else

backtrack // unassign literals made after last decision flip // assign complement of last decision literal

Torsten Schaub (KRR@UP) ASP in Practice 62 / 69

slide-167
SLIDE 167

Conflict-Driven Answer Set Solving

CDCL-style solving

loop propagate // deterministically assign literals if no conflict then

if all variables assigned then return solution else decide // non-deterministically assign some literal

else

if top-level conflict then return unsatisfiable else

analyze // analyze conflict and add conflict constraint backjump // unassign literals until conflict constraint is unit

Torsten Schaub (KRR@UP) ASP in Practice 63 / 69

slide-168
SLIDE 168

Conflict-Driven Answer Set Solving

Multi-threaded architecture of clasp

Solver 1. . . n Decision Heuristic Decision Heuristic Conflict Resolution Conflict Resolution Assignment Atoms/Bodies Recorded Nogoods Propagation Unit Propagation Unit Propagation Post Propagation Post Propagation Post Propagation Post Propagation Coordination SharedContext Propositional Variables Atoms Bodies Static Nogoods Implication Graph ParallelContext Threads S1 S2 . . . Sn Counter T W . . . S Queue P1 P2 . . .Pn Shared Nogoods Enumerator Enumerator Nogood Distributor Nogood Distributor Logic Program Preprocessing Program Builder Program Builder Preprocessor Preprocessor Preprocessor Preprocessor

Torsten Schaub (KRR@UP) ASP in Practice 64 / 69

slide-169
SLIDE 169

Conflict-Driven Answer Set Solving

Multi-threaded architecture of clasp

Solver 1. . . n Decision Heuristic Decision Heuristic Conflict Resolution Conflict Resolution Assignment Atoms/Bodies Recorded Nogoods Propagation Unit Propagation Unit Propagation Post Propagation Post Propagation Post Propagation Post Propagation Coordination SharedContext Propositional Variables Atoms Bodies Static Nogoods Implication Graph ParallelContext Threads S1 S2 . . . Sn Counter T W . . . S Queue P1 P2 . . .Pn Shared Nogoods Enumerator Enumerator Nogood Distributor Nogood Distributor Logic Program Preprocessing Program Builder Program Builder Preprocessor Preprocessor Preprocessor Preprocessor

Torsten Schaub (KRR@UP) ASP in Practice 64 / 69

slide-170
SLIDE 170

Conflict-Driven Answer Set Solving

Multi-threaded architecture of clasp

Solver 1. . . n Decision Heuristic Decision Heuristic Conflict Resolution Conflict Resolution Assignment Atoms/Bodies Recorded Nogoods Propagation Unit Propagation Unit Propagation Post Propagation Post Propagation Post Propagation Post Propagation Coordination SharedContext Propositional Variables Atoms Bodies Static Nogoods Implication Graph ParallelContext Threads S1 S2 . . . Sn Counter T W . . . S Queue P1 P2 . . .Pn Shared Nogoods Enumerator Enumerator Nogood Distributor Nogood Distributor Logic Program Preprocessing Program Builder Program Builder Preprocessor Preprocessor Preprocessor Preprocessor

Torsten Schaub (KRR@UP) ASP in Practice 64 / 69

slide-171
SLIDE 171

Conflict-Driven Answer Set Solving

Multi-threaded architecture of clasp

Solver 1. . . n Decision Heuristic Decision Heuristic Conflict Resolution Conflict Resolution Assignment Atoms/Bodies Recorded Nogoods Propagation Unit Propagation Unit Propagation Post Propagation Post Propagation Post Propagation Post Propagation Coordination SharedContext Propositional Variables Atoms Bodies Static Nogoods Implication Graph ParallelContext Threads S1 S2 . . . Sn Counter T W . . . S Queue P1 P2 . . .Pn Shared Nogoods Enumerator Enumerator Nogood Distributor Nogood Distributor Logic Program Preprocessing Program Builder Program Builder Preprocessor Preprocessor Preprocessor Preprocessor

Torsten Schaub (KRR@UP) ASP in Practice 64 / 69

slide-172
SLIDE 172

Potassco

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 65 / 69

slide-173
SLIDE 173

Potassco

http://potassco.sourceforge.net

Potassco, the Potsdam Answer Set Solving Collection, bundles tools for ASP developed at the University of Potsdam, for instance: Grounder: gringo, pyngo Solver: clasp, {a,u,h}clasp, claspD, claspfolio, claspar, aspeed Grounder+Solver: Clingo, iClingo, oClingo, Clingcon Further Tools: as{un}cud, coala, fimo, metasp, plasp, etc. Benchmarking: http://asparagus.cs.uni-potsdam.de

Torsten Schaub (KRR@UP) ASP in Practice 66 / 69

slide-174
SLIDE 174

Potassco

http://potassco.sourceforge.net

Potassco, the Potsdam Answer Set Solving Collection, bundles tools for ASP developed at the University of Potsdam, for instance: Grounder: gringo, pyngo Solver: clasp, {a,u,h}clasp, claspD, claspfolio, claspar, aspeed Grounder+Solver: Clingo, iClingo, oClingo, Clingcon Further Tools: as{un}cud, coala, fimo, metasp, plasp, etc. Benchmarking: http://asparagus.cs.uni-potsdam.de

Torsten Schaub (KRR@UP) ASP in Practice 66 / 69

slide-175
SLIDE 175

Potassco

http://potassco.sourceforge.net

Potassco, the Potsdam Answer Set Solving Collection, bundles tools for ASP developed at the University of Potsdam, for instance: Grounder: gringo, pyngo Solver: clasp, {a,u,h}clasp, claspD, claspfolio, claspar, aspeed Grounder+Solver: Clingo, iClingo, oClingo, Clingcon Further Tools: as{un}cud, coala, fimo, metasp, plasp, etc. Benchmarking: http://asparagus.cs.uni-potsdam.de

Torsten Schaub (KRR@UP) ASP in Practice 66 / 69

slide-176
SLIDE 176

Summary

Outline

1 Motivation 2 Introduction 3 Modeling by Example

Graph Coloring Queens Traveling Salesperson

4 Meta Programming 5 Conflict-Driven Answer Set Solving 6 Potassco 7 Summary

Torsten Schaub (KRR@UP) ASP in Practice 67 / 69

slide-177
SLIDE 177

Summary

Summary

ASP is emerging as a viable tool for Knowledge Representation and Reasoning ASP offers efficient and versatile off-the-shelf solving technology

http://potassco.sourceforge.net ASP, CASC, MISC, PB, and SAT competitions

ASP offers an expanding functionality and ease of use

Rapid application development tool

ASP has a growing range of applications

Torsten Schaub (KRR@UP) ASP in Practice 68 / 69

slide-178
SLIDE 178

Summary

Summary

ASP is emerging as a viable tool for Knowledge Representation and Reasoning ASP offers efficient and versatile off-the-shelf solving technology

http://potassco.sourceforge.net ASP, CASC, MISC, PB, and SAT competitions

ASP offers an expanding functionality and ease of use

Rapid application development tool

ASP has a growing range of applications

ASP = DB+LP+KR+SAT

Torsten Schaub (KRR@UP) ASP in Practice 68 / 69

slide-179
SLIDE 179

Summary

The (forthcoming) Potassco Book

1. Motivation 2. Introduction 3. Basic modeling 4. Grounding 5. Characterizations 6. Solving 7. Systems 8. Advanced modeling 9. Conclusions

Answer Set Solving in Practice

Martin Gebser, Roland Kaminski, Benjamin Kaufmann, and Torsten Schaub University of Potsdam SYNTHESIS LECTURES ON SAMPLE SERIES #1

C M &

cLaypool Morgan publishers &

http://potassco.sourceforge.net/teaching.html

Torsten Schaub (KRR@UP) ASP in Practice 69 / 69