Answer set programming (ASP) is a form of declarative programming oriented towards difficult (primarily NP-hard) search problems. It is based on the stable model (answer set) semantics of logic programming. In ASP, search problems are reduced to computing stable models, and answer set solvers—programs for generating stable models—are used to perform search. The computational process employed in the design of many answer set solvers is an enhancement of the DPLL algorithm and, in principle, it always terminates (unlike Prolog query evaluation, which may lead to an infinite loop).
In a more general sense, ASP includes all applications of answer sets to knowledge representation and reasoning[1][2] and the use of Prolog-style query evaluation for solving problems arising in these applications.
History
An early example of answer set programming was the planning method proposed in 1997 by Dimopoulos, Nebel and Köhler.[3][4] Their approach is based on the relationship between plans and stable models.[5]
In 1998 Soininen and Niemelä[6]
applied what is now known as answer set programming to the problem of product configuration.[4] In 1999, the term "answer set programming" appeared for the first time in a book The Logic Programming Paradigm as the title of a collection of two papers.[4] The first of these papers identified the use of answer set solvers for search as a new programming paradigm.[7] That same year Niemelä also proposed "logic programs with stable model semantics" as a new paradigm.[8]
Answer set programming language AnsProlog
Lparse is the name of the program that was originally created as a grounding tool (front-end) for the answer set solver smodels. The language that Lparse accepts is now commonly called AnsProlog,[9] short for Answer Set Programming in Logic.[10] It is now used in the same way in many other answer set solvers, including assat, clasp, cmodels, gNt, nomore++ and pbmodels. (dlv is an exception; the syntax of ASP programs written for dlv is somewhat different.)
An AnsProlog program consists of rules of the form
<head>:-<body>.
The symbol :- ("if") is dropped if <body> is empty; such rules are called facts. The simplest kind of Lparse rules are rules with constraints.
One other useful construct included in this language is choice. For instance, the choice rule
{p,q,r}.
says: choose arbitrarily which of the atoms to include in the stable model. The Lparse program that contains this choice rule and no other rules has 8 stable models—arbitrary subsets of . The definition of a stable model was generalized to programs with choice rules.[11] Choice rules can be treated also as abbreviations for propositional formulas under the stable model semantics.[12] For instance, the choice rule above can be viewed as shorthand for the conjunction of three "excluded middle" formulas:
The language of Lparse allows us also to write "constrained" choice rules, such as
1{p,q,r}2.
This rule says: choose at least 1 of the atoms , but not more than 2. The meaning of this rule under the stable model semantics is represented by the propositional formula
Cardinality bounds can be used in the body of a rule as well, for instance:
:-2{p,q,r}.
Adding this constraint to an Lparse program eliminates the stable models that contain at least 2 of the atoms . The meaning of this rule can be represented by the propositional formula
Variables (capitalized, as in Prolog) are used in Lparse to abbreviate collections of rules that follow the same pattern, and also to abbreviate collections of atoms within the same rule. For instance, the Lparse program
p(a).p(b).p(c).q(X):-p(X),X!=a.
has the same meaning as
p(a).p(b).p(c).q(b).q(c).
The program
p(a).p(b).p(c).{q(X):-p(X)}2.
is shorthand for
p(a).p(b).p(c).{q(a),q(b),q(c)}2.
A range is of the form:
(start..end)
where start and end are constant-valued arithmetic expressions. A range is a notational shortcut that is mainly used to define numerical domains in a compatible way. For example, the fact
a(1..3).
is a shortcut for
a(1).a(2).a(3).
Ranges can also be used in rule bodies with the same semantics.
A conditional literal is of the form:
p(X):q(X)
If the extension of q is {q(a1), q(a2), ..., q(aN)}, the above condition is semantically equivalent to writing {p(a1), p(a2), ..., p(aN)} in the place of the condition. For example,
q(1..2).a:-1{p(X):q(X)}.
is a shorthand for
q(1).q(2).a:-1{p(1),p(2)}.
Generating stable models
To find a stable model of the Lparse program stored in file ${filename} we use the command
% lparse${filename}|smodels
Option 0 instructs smodels to find all stable models of the program. For instance, if file test contains the rules
1{p,q,r}2.s:-notp.
then the command produces the output
% lparsetest|smodels0Answer: 1Stable Model: q p Answer: 2Stable Model: p Answer: 3Stable Model: r p Answer: 4Stable Model: q s Answer: 5Stable Model: r s Answer: 6Stable Model: r q s
Examples of ASP programs
Graph coloring
An -coloring of a graph is a function such that for every pair of adjacent vertices . We would like to use ASP to find an -coloring of a given graph (or determine that it does not exist).
This can be accomplished using the following Lparse program:
Line 1 defines the numbers to be colors. According to the choice rule in Line 2, a unique color should be assigned to each vertex . The constraint in Line 3 prohibits assigning the same color to vertices and if there is an edge connecting them.
If we combine this file with a definition of , such as
v(1..100).% 1,...,100 are verticese(1,55).% there is an edge from 1 to 55...
and run smodels on it, with the numeric value of specified on the command line, then the atoms of the form in the output of smodels will represent an -coloring of .
The program in this example illustrates the "generate-and-test" organization that is often found in simple ASP programs. The choice rule describes a set of "potential solutions"—a simple superset of the set of solutions to the given search problem. It is followed by a constraint, which eliminates all potential solutions that are not acceptable. However, the search process employed by smodels and other answer set solvers is not based on trial and error.
Large clique
A clique in a graph is a set of pairwise adjacent vertices. The following Lparse program finds a clique of size in a given directed graph, or determines that it does not exist:
n{in(X):v(X)}.:-in(X),in(Y),X!=Y,note(X,Y).
This is another example of the generate-and-test organization. The choice rule in Line 1 "generates" all sets consisting of vertices. The constraint in Line 2 "weeds out" the sets that are not cliques.
Hamiltonian cycle
A Hamiltonian cycle in a directed graph is a cycle that passes through each vertex of the graph exactly once. The following Lparse program can be used to find a Hamiltonian cycle in a given directed graph if it exists; we assume that 0 is one of the vertices.
The choice rule in Line 1 "generates" all subsets of the set of edges. The three constraints "weed out" the subsets that are not Hamiltonian cycles. The last of them uses the auxiliary predicate (" is reachable from 0") to prohibit the vertices that do not satisfy this condition. This predicate is defined recursively in Lines 6 and 7.
This program is an example of the more general "generate, define and test" organization: it includes the definition of an auxiliary predicate that helps us eliminate all "bad" potential solutions.
Dependency parsing
In natural language processing, dependency-based parsing can be formulated as an ASP problem.[13]
The following code parses the Latin sentence "Puella pulchra in villa linguam latinam discit", "the pretty girl is learning Latin in the villa".
The syntax tree is expressed by the arc predicates which represent the dependencies between the words of the sentence.
The computed structure is a linearly ordered rooted tree.
% ********** input sentence **********word(1,puella).word(2,pulchra).word(3,in).word(4,villa).word(5,linguam).word(6,latinam).word(7,discit).% ********** lexicon **********1{node(X,attr(pulcher,a,fem,nom,sg));node(X,attr(pulcher,a,fem,abl,sg))}1:-word(X,pulchra).node(X,attr(latinus,a,fem,acc,sg)):-word(X,latinam).1{node(X,attr(puella,n,fem,nom,sg));node(X,attr(puella,n,fem,abl,sg))}1:-word(X,puella).1{node(X,attr(villa,n,fem,nom,sg));node(X,attr(villa,n,fem,abl,sg))}1:-word(X,villa).node(X,attr(linguam,n,fem,acc,sg)):-word(X,linguam).node(X,attr(discere,v,pres,3,sg)):-word(X,discit).node(X,attr(in,p)):-word(X,in).% ********** syntactic rules **********0{arc(X,Y,subj)}1:-node(X,attr(_,v,_,3,sg)),node(Y,attr(_,n,_,nom,sg)).0{arc(X,Y,dobj)}1:-node(X,attr(_,v,_,3,sg)),node(Y,attr(_,n,_,acc,sg)).0{arc(X,Y,attr)}1:-node(X,attr(_,n,Gender,Case,Number)),node(Y,attr(_,a,Gender,Case,Number)).0{arc(X,Y,prep)}1:-node(X,attr(_,p)),node(Y,attr(_,n,_,abl,_)),X<Y.0{arc(X,Y,adv)}1:-node(X,attr(_,v,_,_,_)),node(Y,attr(_,p)),notleaf(Y).% ********** guaranteeing the treeness of the graph **********1{root(X):node(X,_)}1.:-arc(X,Z,_),arc(Y,Z,_),X!=Y.:-arc(X,Y,L1),arc(X,Y,L2),L1!=L2.path(X,Y):-arc(X,Y,_).path(X,Z):-arc(X,Y,_),path(Y,Z).:-path(X,X).:-root(X),node(Y,_),X!=Y,notpath(X,Y).leaf(X):-node(X,_),notarc(X,_,_).
Language standardization and ASP Competition
The ASP standardization working group produced a standard language specification, called ASP-Core-2,[14] towards which recent ASP systems are converging. ASP-Core-2 is the reference language for the Answer Set Programming Competition, in which ASP solvers are periodically benchmarked over a number of reference problems.
Comparison of implementations
Early systems, such as smodels, used backtracking to find solutions. As the theory and practice of Boolean SAT solvers evolved, a number of ASP solvers were built on top of SAT solvers, including ASSAT and Cmodels. These converted ASP formula into SAT propositions, applied the SAT solver, and then converted the solutions back to ASP form. More recent systems, such as Clasp, use a hybrid approach, using conflict-driven algorithms inspired by SAT, without fully converting into a Boolean-logic form. These approaches allow for significant improvements of performance, often by an order of magnitude, over earlier backtracking algorithms.
The Potassco project acts as an umbrella for many of the systems below, including clasp, grounding systems (gringo), incremental systems (iclingo), constraint solvers (clingcon), action language to ASP compilers (coala), distributed Message Passing Interface implementations (claspar), and many others.
Most systems support variables, but only indirectly, by forcing grounding, by using a grounding system such as Lparse or gringo as a front end. The need for grounding can cause a combinatorial explosion of clauses; thus, systems that perform on-the-fly grounding might have an advantage.[15]
Query-driven implementations of answer set programming, such as the Galliwasp system[16] and s(CASP)[17] avoid grounding altogether by using a combination of resolution and coinduction.
^ abcLifschitz, Vladimir (13 July 2008). "What is answer set programming?"(PDF). Proceedings of the 23rd National Conference on Artificial Intelligence. 3. AAAI Press: 1594–1597.
^Niemelä, I.; Simons, P.; Soinenen, T. (2000). "Stable model semantics of weight constraint rules". In Gelfond, Michael; Leone, Nicole; Pfeifer, Gerald (eds.). Logic Programming and Nonmonotonic Reasoning: 5th International Conference, LPNMR '99, El Paso, Texas, USA, December 2–4, 1999 Proceedings. Lecture Notes in Computer Science: Lecture Notes in Artificial Intelligence. Vol. 1730. Springer. pp. 317–331. ISBN978-3-540-66749-0. as Postscript
^
Marple, Kyle.; Gupta, Gopal. (2012). "Galliwasp: A Goal-Directed Answer Set Solver". In Albert, Elvira (ed.). Logic-Based Program Synthesis and Transformation, 22nd International Symposium, LOPSTR 2012, Leuven, Belgium, September 18-20, 2012, Revised Selected Papers. Springer. pp. 122–136.
Basilika Santo Yudas TadeusBasilika Minor Santo Yudas TadeusSpanyol: Basílica de San Judas Tadeocode: es is deprecated Basilika Santo Yudas TadeusLokasiEl SantuarioNegaraKolombiaDenominasiGereja Katolik RomaArsitekturStatusBasilika minorStatus fungsionalAktif Basilika Santo Yudas Tadeus (Spanyol: Basílica de San Judas Tadeocode: es is deprecated ) adalah sebuah gereja basilika minor Katolik yang terletak di El Santuario, Kolombia. Basilika ini ditetapkan statusnya pada tahun 2017 dan didedi...
Disambiguazione – Se stai cercando il dispositivo di illuminazione basato sull'arco voltaico, vedi Lampada ad arco. Arcoprodotto di disegno industrialeDati generaliAnno di progettazione1962 ProgettistaPier Giacomo Castiglioni e Achille Castiglioni Profilo prodottoTipo di oggettolampada Ideauna lampada da terra che permetta di avere il punto luce direttamente sopra il tavolo (o la testa) ovviando al sistema di sospensione Concettisemplicità, razionalità, praticità, versatilità Produttor...
Pierre-Augustin Caron de BeaumarchaisJean-Marc Nattier, Portrait de Beaumarchais (1755),London, koleksi spesifik[1]LahirPierre-Augustin Caron24 Januari 1732Paris, PrancisMeninggal18 Mei 1799Paris, PrancisKebangsaanPrancisPekerjaanpengarangdramawanagen intelijenKarya terkenal Le Barbier de Séville (1775) Le Mariage de Figaro (1784) La Mère coupable (1792) Tanda tangan Pierre-Augustin Caron de Beaumarchais (bahasa Prancis: [pjɛʁ bomaʁʃe]; 24 Januari 1732–18 Mei 1799; diken...
Dewan Perwakilan Rakyat DaerahKabupaten Boyolali ꦝꦺꦮꦤ꧀ꦥꦼꦂꦮꦏꦶꦭꦤ꧀ꦫꦏꦾꦠ꧀ꦝꦲꦺꦫꦃꦏꦧꦸꦥꦠꦺꦤ꧀ꦧꦺꦴꦪꦭꦭꦶDhéwan Perwakilan Rakyat Dhaérah Kabupatèn BoyalaliDewan Perwakilan RakyatKabupaten Boyolali2019-2024JenisJenisUnikameral Jangka waktu5 tahunSejarahSesi baru dimulai19 Agustus 2019PimpinanKetuaMarsono, S.H. (PDI-P) sejak 12 Agustus 2021 Wakil Ketua IH. Fuadi, S.H., M.H. (Golkar) sejak 24 September 2019 W...
PT Pertani (Persero)Kantor pusat PertaniJenisBadan usaha milik negaraIndustriPertanianNasibDigabung ke Sang Hyang SeriDidirikan14 Januari 1959; 65 tahun lalu (1959-01-14)Ditutup15 September 2021; 2 tahun lalu (2021-09-15)KantorpusatJakarta, IndonesiaWilayah operasiIndonesiaTokohkunciMaryono[1](Direktur Utama)Asep Sasa Purnama[1](Komisaris Utama)ProdukBerasBenih padiBenih jagung hibridaPupuk organikPembenah tanahMerekRatu MutiaraFirdausOnyxKharismaCelebesPadiKuProcalB...
1864 overture by Pyotr Ilyich Tchaikovsky Not to be confused with the symphonic fantasia The Tempest, Op. 18, written in 1873. The Stormby Pyotr Ilyich TchaikovskyTchaikovsky around the time of composition.KeyE minorComposed1864 The Storm, Op. 76 (TH 36) (Russian: Гроза, groza), is an overture (in the context of a symphonic poem) in E minor composed by Pyotr Ilyich Tchaikovsky around June and August 1864. The work is inspired by the play The Storm by the Russian playwright Alexander Ostr...
2020 Hawaii House of Representatives election ← 2018 November 3, 2020 2022 → All 51 seats in the Hawaii House of Representatives26 seats needed for a majority Majority party Minority party Leader Scott Saiki Gene Ward Party Democratic Republican Leader's seat 26th 17th Last election 46 5 Seats before 46 5 Seats won 47 4 Seat change 1 1 Popular vote 240,042 105,475 Percentage 65.8% 28.9% Results: De...
United States historic placePhilanthropic Hall, Davidson CollegeU.S. National Register of Historic Places Philanthropic Hall, 2005Show map of North CarolinaShow map of the United StatesLocationDavidson College campus, Davidson, North CarolinaCoordinates35°29′57″N 80°50′47″W / 35.49917°N 80.84639°W / 35.49917; -80.84639Area0.8 acres (0.32 ha)Built1849 (1849)-1850Architectural styleGreek RevivalNRHP reference No.72000975[1]Add...
Pertempuran NankingBagian dari Perang Tiongkok-Jepang KeduaPrajutir Jepang berdiri di atas reruntuhan Gerbang Zhongshan Nanking pada tanggal 13 Desember dengan latar Gunung ZijinshanTanggal13 Desember 1937LokasiNanking dan wilayah sekitarnyaHasil Kemenangan JepangKejatuhan NankingPembantaian NankingPihak terlibat Republik Tiongkok Kekaisaran JepangTokoh dan pemimpin Tang Shengzhi Iwane MatsuiPasukan Pasukan Garnisun Nanking Tentara Jepang Wilayah Tiongkok TengahKekuatan perkiraan bervar...
Neo-grotesque sans-serif typefaceFor the country referred to as the same name in Latin, see Switzerland.For other uses, see Helvetica (disambiguation).Not to be confused with Helvetia, the national personification of Switzerland.HelveticaCategorySans-serifClassificationNeo-grotesque[1]Designer(s)Max MiedingerEduard HoffmannFoundryHaas'sche Schriftgiesserei (Basel)Date released1957Re-issuing foundriesMergenthaler Linotype CompanyDesign based onAkzidenz-GroteskVariationsHelvetica Insera...
Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada Desember 2023. Dokter menggunakan metode bedah . Dari Bedah Kekaisaran Şerafeddin Sabuncuoğlu (1465). Berikut ini adalah daftar penemuan yang dibuat di dunia Islam abad pertengahan, terutama selama Zaman Keemasan Islam,[1][1] serta di negara-negara...
Berzano di San PietroKomuneComune di Berzano di San PietroNegaraItaliaWilayah PiedmontProvinsiProvinsi Asti (AT)FrazioniValle Gervaso, Valle OcheraPemerintahan • Wali kotaSergio TejaLuas • Total7,4 km2 (29 sq mi)Populasi (1 Januari 2009) • Total440 • Kepadatan5,9/km2 (15/sq mi)DemonimBerzanesiZona waktuUTC+1 (CET) • Musim panas (DST)UTC+2 (CEST)Kode pos14020Kode area telepon011 Berzano di San Pietro adal...
Former mansion in Pennsylvania, United States Whitemarsh HallExterior view of the mansionGeneral informationTypeGilded Age MansionArchitectural styleNeoclassical RevivalTown or cityWyndmoor, PennsylvaniaCountryUnited StatesCoordinates40°05′37″N 75°11′54″W / 40.0936°N 75.1982°W / 40.0936; -75.1982Construction started1916Completed1921Demolished1980Costest. US$10,000,000 (equivalent to $301,184,211 in 2023)[1]ClientEdward T. StotesburyTechnical det...
Worldwide youth movement This article is about the Scout Movement. For other uses, see Scout (disambiguation). ScoutingCountryWorldwideUnited Kingdom (origin)Founded1907, Brownsea IslandFounderRobert Baden-Powell, 1st Baron Baden-Powell Scouting portal Scouting, also known as the Scout Movement, is a worldwide youth social movement employing the Scout method, a program of informal education with an emphasis on practical outdoor activities, including camping, woodcraft, aquatics, hiking,...
Slave markets in North Africa The redemption (buying back) of Christian captives by Mercedarian friars in the Barbary states. Part of a series onForced labour and slavery Contemporary Child labour Child soldiers Conscription Debt Forced marriage Bride buying Child marriage Wife selling Forced prostitution Human trafficking Peonage Penal labour Contemporary Africa 21st-century jihadism Sexual slavery Wage slavery Historical Antiquity Egypt Babylonia Greece Rome Medieval Europe Ancillae Black S...
Railway station in East Sussex, England St Leonards Warrior SquareThe station in 2007General informationLocationSt Leonards-on-Sea, Hastings, East SussexEnglandGrid referenceTQ803093Managed bySoutheasternPlatforms2Other informationStation codeSLQClassificationDfT category DKey dates13 February 1851 (1851-02-13)Opened as St Leonards[1]5 December 1870Renamed St Leonards Warrior Square[1]1 January 1917Closed[1]1 January 1919Reopened[1]Passengers2018...
West-east street in Manhattan, New York 40°45′51″N 73°58′23″W / 40.7642908724°N 73.9730390°W / 40.7642908724; -73.9730390 59th StreetLooking west along Central Park SouthWest end NY 9A / West Side HighwayMajorjunctionsGrand Army Plaza, Columbus CircleEast endSutton Place 59th Street is a crosstown street in the New York City borough of Manhattan, running from York Avenue and Sutton Place on the East Side of Manhattan to the West Side Highway ...
التعليم في البلد الميزانية الوطنية للتعليم معلومات عامة التحصيل الالتحاق الوصول تعديل مصدري - تعديل الحياة في السعودية الثقافة الثقافة المطبخ السينما الأعياد الرياضة الدين التاريخ العَلم المجتمع السكان اللغات الصحة التعليم العالي الإعلام جرائم البدون الحكومة حقوق ...
Championnat de France féminin de hockey sur glace Généralités Sport Hockey sur glace Création 1986 Organisateur(s) FFHG Éditions 38 Catégorie Élite Périodicité annuelle Lieu(x) France Participants 11 Statut des participants Amateurs Site web officiel hockeyfrance.com Palmarès Tenant du titre Remparts de Tours Plus titré(s) HC Cergy-Pontoise (18 titres) Pour la dernière compétition voir : Championnat de France féminin de hockey sur glace 2023-2024 modifier Le Champion...