Answer Set Programming Overview Dr. Rogelio Dávila
16 Slides767.50 KB
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara [email protected]
AnsProlog, an overview An AnsProlog program consists in a collection of rules of the form: L0 or or Lk Lk 1, , Lm, not Lm 1, , not Ln. Where: - the Lis are literals in the sense of classical logic. The rule can be read as: - If Lk 1, , Lm are to be true, and if not Lm 1, , not Ln can be safely assumed to be false then at least one of L0 or or Lk must be true. Unlike other nonmonotonic logics, AnsProlog now has efficient implementations which have been used in large applications.
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.
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 wellfounded 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.
AnsProlog programs syntax An answer set framework consists of: Two alphabets (an axiom alphabet and a query alphabet). (ii) Two languages (an axiom language and a query language) defined over the two alphabets. (iii)A set of axioms. (iv) An entailment relation between sets of axioms and queries. (i) The query alphabet will be closely associated with the axiom alphabet and the query language will be fairly simple.
AnsProlog programs syntax Def. The axiom alphabet (or simply the alphabet) consists of: (1) Variables. (2) Object constants (also referred as constants). (3) Function symbols: f, g, (4) Predicate symbols: p, q, r, (5) Connectives: { , or, , not, “,”}. (6) Punctuation symbols: {“(”, “)”, “.”}. (7) The special symbol . Def. A term is inductively defined as follows: (1) A constant is a term. (2) A variable is a term. (3) If f is an n-ary function symbol and t1, , tn are terms, then f(t1, , tn) is a term. (4) Nothing else is a term. Def. A term is said to be ground, if no variable occurs in it.
Herbrand Universe and Herbrand Base Def. An atom is of the form p(t1, , tn), where p is a predicate symbol and each ti is a term. If each of the tis 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 HUL, 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 HBL , is the set of all ground atoms that can be formed with predicates from L and terms from HUL.
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.
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 L1 be the language defined by this alphabet. Then: f(X) and f(f(Y)) f(a) is a ground p(f(X)) and p(Y) p(a) and p(f(a)) are terms term are atoms are ground terms The Herbrand Universe of L1 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 L1 is the set: {p(a), p(b), p(f(a)), p(f(b)), p(f(f(a)), p(f(f(b)), }
Herbrand Universe and Herbrand Base Def. A rule has the form: L0 or or Lk Lk 1, , Lm, not Lm 1, , not Ln. Where: - The Lis are literals or when k 0, L0 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 L0 is a ground literal we refer to it as a ground fact. A fact can be written L0 or simply L0. When k 0, and L0 , we refer to the rule as a constraint. The s in the head s of constraints are often eliminated and written: L1, , Lm, not Lm 1, , not Ln.
Herbrand Universe and Herbrand Base L. The grounding ground(r, L), is the set of Def. Let r be a rule in a language of r in L, denoted by all rules obtained from r by all possible substitutions of elements of HUL for the variables in r. Example: Consider the rule p(f(X)) language p(X), p(f(a)) L1 introduced before. Then ground(p(f(X)) L1) will consist of the following rules: p(a). p(f(b)) p(b). p(f(f(a))) p(f(a)). p(X), and the
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 O, F, P , is referred as signature of the answer set framework. Often a language is described just by giving its signature.
AnsProlog* Programs Def. An AnsProlog* program is a finite set of rules of the form: L0 or or Lk Lk 1, , Lm, not Lm 1, , not Ln. 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.
AnsProlog* Programs Example p(a). p(b). p(c). p(f(X)) p(x).
AnsProlog* Programs Exists several distinct sub-classes of AnsProlog programs. The important ones are: - AnsProlog program: A set of rules where Lis 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 Lis 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. - AnsPrologor program: A set of rules where Lis are atoms. Such programs are referred as normal disjunctive logic programs.
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