Answer Set Programming (2019)
19 points by hwayne
19 points by hwayne
Anyone have a quick explanation of how it differs from prolog?
A naive explanation is that the semantics of ASP is more declarative (clause order is irrelevant), whereas Prolog is more imperative (order matters). ASP is model-oriented (what are all valid sets of truths) whereas Prolog is query-oriented (is this fact true?).
ASP is a very nice high-level language for SAT/SMT. I encourage everyone to take a look at e.g. https://potassco.org, including examples in https://github.com/potassco/clingo/tree/master/examples/clingo. You can get started in an afternoon.
From the piece:
To write or understand Prolog programs, one has to think not only about their meaning as specifications, but also about Prolog’s search strategy. In that sense, Prolog is not fully declarative; it has an “operational semantics.” Answer set programming (ASP)—the form of logic programming described in this book—is closer to the ideal of declarativism. ASP became possible after the invention of the concept of a stable model and the creation of software systems that generate stable models. These systems are called answer set solvers, and their operation is described in many articles, dissertations, and books.
it sounds like the fact that this style of programming aims to find "all" answers (and, I guess implicitly, not work on problems with infinite solution spaces) means that it can operate in a different way and not be concerned with operational semantics.
I find this a bit hard to imagine but, well, this PDF is clearly describing something
Thanks, that makes sense. Sounds like the point is that for prolog the comma denotes sequencing and cut operator has significant imperative meaning.
To me this sounds like sequel queries with prolog syntax
To me this sounds like sequel queries with prolog syntax
That'd be datalog :p
ASP is more for constraint solving, like "what is the smallest set of facts that make this conclusion true". Another big difference is that in ASP, "not p" means "p is false", while in prolog it means "if p is true, backtrack."
wow, they even have tree-sitter for their language! https://github.com/potassco/tree-sitter-clingo (MIT)
and of especial curiosity to me, GH detected Answer Set Programming as a source language presumably from https://github.com/potassco/tree-sitter-clingo/blob/main/test/highlight/test_highlights.lp since it also syntax highlighted the file correctly