Presentation is loading. Please wait.

Presentation is loading. Please wait.

Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara

Similar presentations


Presentation on theme: "Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara"— Presentation transcript:

1 Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara rdav90@gmail.com

2 AnsProlog, an overview An AnsProlog program consists in a collection of rules of the form: L 0 or … or L k  L k+1, …, L m, not L m+1, …, not L n. Where: -the L i s are literals in the sense of classical logic. The rule can be read as: -If L k+1, …, L m are to be true, and if not L m+1, …, not L n can be safely assumed to be false then at least one of L 0 or … or L k must be true. Unlike other nonmonotonic logics, AnsProlog now has efficient implementations which have been used in large applications.

3 Prolog vs. AnsProlog - Prolog contains several nondeclarative features such as: ! (the cut operator) and negation as a failure. AnsProlog is a declarative alternative to Prolog. - Prolog is restricted to the Horn clauses subset of logic. AnsProlog allows disjunction in the head of rules and negative literals in the body. - The ordering of literals in the body of the rule matters in Prolog as it processes them from left-to-right. The order in the rules is also important as it processes them from start to end. - In AnsProlog a program consists in a set of AnsProlog rules, and in each AnsProlog rule, the body is a set of literals and literals preceded by not. The order of literals and rules does not matter in AnsProlog. - In AnsProlog query-processing methodology is not part of the semantics. - AnsProlog uses answer set semantics to characterize negation as a failure.

4 Prolog vs. Logic Programming - AnsProlog is a particular kind of logic programming. - The semantics of AnsProlog is fix to the answer set semantics. - There are several proposals for semantics of programs with AnsProlog syntax. Two of the most popular ones are the stable model semantics and the well-founded semantics. - The stable models are same as the answer sets of AnsProlog programs. - The well-founded semantics differs from the stable models semantics in that: - -Well-founded models are three-valued, while stable models are two valued. - -Each AnsProlog program has a unique well-founded model, while some AnsProlog programs have multiple stable models and some do not have any. Example: {p  not p.} has no stable models while it has unique well-founded model where p is assigned the truth value unknown. - -Computing the well-founded model or entailment with respect to it is more tractable than computing the entailment with respect to stable models.

5 AnsProlog programs syntax An answer set framework consists of: (i) (i) Two alphabets (an axiom alphabet and a query alphabet). (ii) (ii) Two languages (an axiom language and a query language) defined over the two alphabets. (iii) (iii) A set of axioms. (iv) (iv) An entailment relation between sets of axioms and queries. The query alphabet will be closely associated with the axiom alphabet and the query language will be fairly simple.

6 AnsProlog programs syntax Def. The axiom alphabet (or simply the alphabet) consists of: (1) (1) Variables. (2) (2) Object constants (also referred as constants). (3) (3) Function symbols: f, g, … (4) (4) Predicate symbols: p, q, r, … (5) (5) Connectives: {¬, or, , not, “,”}. (6) (6) Punctuation symbols: {“(”, “)”, “.”}. (7) (7) The special symbol . Def. A term is inductively defined as follows: (i) (i) A constant is a term. (ii) (ii) A variable is a term. (iii) (iii) If f is an n-ary function symbol and t 1, …, t n are terms, then f(t 1, …, t n ) is a term. (iv) (iv) Nothing else is a term. Def. A term is said to be ground, if no variable occurs in it.

7 Herbrand Universe and Herbrand Base Def. An atom is of the form p(t 1, …, t n ), where p is a predicate symbol and each t i is a term. If each of the t i s is ground then the atom is said to be ground. Def. A literal is either an atom or an atom preceded by the symbol “¬”. The former is referred to as a positive literal, while the latter is referred to as a negative literal. Def. The Herbrand Universe of a language L, denoted by HU L, is the set of all ground terms which can be formed with the functions and constants in L. Def. The Herbrand Base of the language L, denoted by HB L, is the set of all ground atoms that can be formed with predicates from L and terms from HU L.

8 Herbrand Universe and Herbrand Base Def. A naf-literal is either an atom or an atom preceded by the symbol not. Def. A gen-literal is either a literal or a literal preceded by the symbol not.

9 Herbrand Universe and Herbrand Base Example Consider an alphabet with variables X and Y, object constants a, b, function symbols f of arity 1, and predicate symbols p of arity 1. Let L 1 be the language defined by this alphabet. Then: f(X) and f(f(Y)) are terms f(a) is a ground term p(f(X)) and p(Y) are atoms p(a) and p(f(a)) are ground terms The Herbrand Universe of L 1 is the set: {a, b, f(a), f(b), f(f(a)), f(f(b)), f(f(f(a))), f(f(f(b))), …} The Herbrand Base of L 1 is the set: {p(a), p(b), p(f(a)), p(f(b)), p(f(f(a)), p(f(f(b)), …}

10 Herbrand Universe and Herbrand Base Def. A rule has the form: L 0 or … or L k  L k+1, …, L m, not L m+1, …, not L n. Where: - -The L i s are literals or when k=0, L 0 may be the symbol , and k≥0, m≥k, and n≥m. - -A rule is said to be ground if all the literals in the rule are ground. - -The left part is called the head of the rule, and the right one the body. - -A rule with an empty body and a single disjunct in the head (i.e. k=0) is called a fact, and then if L 0 is a ground literal we refer to it as a ground fact. - -A fact can be written L 0  or simply L 0. - -When k=0, and L 0 = , we refer to the rule as a constraint. - -The s in the head s of constraints are often eliminated and written:  L 1, …, L m, not L m+1, …, not L n.

11 Herbrand Universe and Herbrand Base Def. Let r be a rule in a language L. The grounding of r in L, denoted by ground(r, L ), is the set of all rules obtained from r by all possible substitutions of elements of HU L for the variables in r. Example: Consider the rule p(f(X))  p(X), and the language L 1 introduced before. Then ground(p(f(X))  p(X), L 1 ) will consist of the following rules: p(f(a))  p(a). p(f(b))  p(b). p(f(f(a)))  p(f(a)). …

12 Herbrand Universe and Herbrand Base Def. The answer set language given by an alphabet consists of the set of all ground rules constructed from the symbols of the alphabet. Def. The language given by an alphabet is uniquely determined by its constants O, its function symbols F, and predicate symbols P. This triple  =, is referred as signature of the answer set framework. Often a language is described just by giving its signature.

13 AnsProlog* Programs Def. An AnsProlog* program is a finite set of rules of the form: L 0 or … or L k  L k+1, …, L m, not L m+1, …, not L n. and is used to succinctly express a set of axioms of an answer set framework. AnsProlog is a short for Answer Set Programming in Logic, and the “*” denotes that there are not restrictions on the rules. With each AnsProlog* program , we associate the language L () that is defined by the predicates, functions, and constants occurring in . If no constants occur in , we add some constants for technical reasons.

14 AnsProlog* Programs Example p(a). p(b). p(c). p(f(X))  p(x).

15 AnsProlog* Programs Exists several distinct sub-classes of AnsProlog programs. The important ones are: - - AnsProlog program: A set of rules where L i s are atoms and k=0. This is the most popular sub-class. Such programs are syntactically referred to as general logic programs and normal logic programs. - - AnsProlog -not program: A set of rules where L i s are atoms, k=0, and m=n. Such programs are referred as definite programs and Horn logic programs. - - AnsProlog ¬ program: A set of rules where k=0. Such programs are called extended logic programs. - - AnsProlog or program: A set of rules where L i s are atoms. Such programs are referred as normal disjunctive logic programs.

16 Applications of AnsProlog - AnsProlog has a greater ability than Datalog in expressing database query features. It can be used for quering in the presence of different kinds of incomplete information, including null values. - AnsProlog has been used in planning


Download ppt "Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara"

Similar presentations


Ads by Google