<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki1463/index.php?action=history&amp;feed=atom&amp;title=Declarative_programming</id>
	<title>Declarative programming - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki1463/index.php?action=history&amp;feed=atom&amp;title=Declarative_programming"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki1463/index.php?title=Declarative_programming&amp;action=history"/>
	<updated>2026-12-01T07:35:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki1463/index.php?title=Declarative_programming&amp;diff=146424&amp;oldid=prev</id>
		<title>~2026-41888-44: split overly long paragraph</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki1463/index.php?title=Declarative_programming&amp;diff=146424&amp;oldid=prev"/>
		<updated>2026-08-02T19:36:47Z</updated>

		<summary type="html">&lt;p&gt;split overly long paragraph&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Programming paradigm based on modeling the logic of a computation}}&lt;br /&gt;
{{Multiple issues|&lt;br /&gt;
{{More footnotes needed|date=April 2010}}&lt;br /&gt;
{{More citations needed|date=February 2015}}&lt;br /&gt;
{{Rewrite|date=December 2025}}&lt;br /&gt;
}}&lt;br /&gt;
In [[computer science]], &amp;#039;&amp;#039;&amp;#039;declarative programming&amp;#039;&amp;#039;&amp;#039; is a [[programming paradigm]] that expresses the [[logic]] of a [[computation]] without fully describing its [[control flow]].&amp;lt;ref&amp;gt;{{cite conference |last1=Lloyd |first1=J.W. |title=Practical Advantages of Declarative Programming |book-title=GULP-PRODE&amp;#039;94 1994 Joint Conference on Declarative Programming |volume=I |pages=3-17 |editor-first1=María |editor-last1=Alpuente |editor-first2=Roberto |editor-last2=Barbuti |editor-first3=Isidro |editor-last3=Ramos |location=[[Peñíscola]], Spain |date=September 19–22, 1994 |url=https://www.programmazionelogica.it/wp-content/uploads/2015/12/GP1994-I-000-031.pdf}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The paradigm focuses on abstracting a program beyond the order of execution. This implies usage of a [[high-level programming language]]. &lt;br /&gt;
&lt;br /&gt;
Languages that permit this style allow a developer to minimize or eliminate [[Side effect (computer science)|side effects]] by describing &amp;#039;&amp;#039;what&amp;#039;&amp;#039; the program must accomplish in terms of the [[Domain knowledge|problem domain]], rather than fully describing &amp;#039;&amp;#039;how&amp;#039;&amp;#039; to accomplish it as a sequence of the programming [[language primitive]]s (the &amp;#039;&amp;#039;how&amp;#039;&amp;#039; being left up to the language&amp;#039;s [[programming language implementation|implementation]]). Declarative programming is in contrast with [[imperative programming]], which implements [[algorithm]]s in explicit steps.&amp;lt;ref name=&amp;quot;Sebesta 2016&amp;quot;&amp;gt;{{cite book |last1=Sebesta |first1=Robert |title=Concepts of programming languages |publisher=Pearson |publication-place=Boston |year=2016 |isbn=978-0-13-394302-3 |oclc=896687896}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |date=2021-05-21 |title=Imperative programming: Overview of the oldest programming paradigm |url=https://www.ionos.com/digitalguide/websites/web-development/imperative-programming/ |access-date=2023-05-23 |website=IONOS Digital Guide |language=en-US |archive-date=2022-05-03 |archive-url=https://web.archive.org/web/20220503083342/https://www.ionos.com/digitalguide/websites/web-development/imperative-programming/ |url-status=live}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Just like in the [[functional programming]] paradigm, [[Immutable object|mutating variables]] does not conform to the declarative paradigm because it implies an execution order which is [[Imperative programming|imperative]].&lt;br /&gt;
&lt;br /&gt;
Declarative programming may consider [[program (machine)|programs]] as [[Theory (mathematical logic)|theories]] of a [[Mathematical logic#Formal logical systems|formal logic]], and computations as deductions in that logical theory. Declarative programming at times simplifies the writing of [[Parallel computing|parallel programs]].&amp;lt;ref&amp;gt;{{cite web |url=http://www.cse.unsw.edu.au/~pls/damp09/ |title=DAMP 2009: Workshop on Declarative Aspects of Multicore Programming |publisher=Cse.unsw.edu.au |date=20 January 2009 |access-date=15 August 2013 |archive-url=https://web.archive.org/web/20130913162703/http://www.cse.unsw.edu.au/~pls/damp09/ |archive-date=13 September 2013 |url-status=dead}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Common declarative language paradigms include [[logic programming]] (e.g., [[Prolog]], [[Datalog]], [[answer set programming]]), and [[Algebraic modeling language|algebraic modeling]] systems.&lt;br /&gt;
&lt;br /&gt;
Some logic programming languages, such as [[Prolog]], and [[Query language|database query languages]], such as [[SQL]], while declarative in principle, also support a procedural style of programming.&amp;lt;ref&amp;gt;{{Cite web |title=SQL Stored Procedures |url=https://www.w3schools.com/SQL/sql_stored_procedures.asp |access-date=2026-08-02 |website=www.w3schools.com |language=en-US}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other definitions:&lt;br /&gt;
* Any programming language that lacks [[Side effect (computer science)|side effects]], or more specifically, has [[referential transparency]].&lt;br /&gt;
* A language with a clear correspondence to [[mathematical logic]].&amp;lt;ref&amp;gt;{{cite thesis |first1=Manuel M. T. |last1=Chakravarty |date=14 February 1997 |url=http://www.cse.unsw.edu.au/~chak/papers/diss.ps.gz |title=On the Massively Parallel Execution of Declarative Programs |type=Doctoral dissertation |publisher=[[Technische Universität Berlin]] |access-date=26 February 2015 |quote=In this context, the criterion for calling a programming language declarative is the existence of a clear, mathematically established correspondence between the language and mathematical logic such that a declarative semantics for the language can be based on the model or the proof theory (or both) of the logic. |archive-date=23 September 2015 |archive-url=https://web.archive.org/web/20150923211531/http://www.cse.unsw.edu.au/~chak/papers/diss.ps.gz |url-status=live}}&amp;lt;/ref&amp;gt;&amp;lt;!-- this citation is for this bullet point only --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subparadigms==&lt;br /&gt;
Declarative programming is an [[umbrella term]] that includes a number of better-known [[programming paradigm]]s.&lt;br /&gt;
&lt;br /&gt;
===Functional Programming===&lt;br /&gt;
{{Further|Functional programming}}In a [[pure functional language]], such as [[Haskell]], all functions are [[pure function|without side effects]], and state changes are only represented as functions that transform the state, which is explicitly represented as a [[First-class citizen|first-class]] object in the program. Although pure functional languages are non-imperative, they often provide a facility for describing the effect of a function as a series of steps. &lt;br /&gt;
&lt;br /&gt;
===Constraint programming===&lt;br /&gt;
{{Further|Constraint programming}}&lt;br /&gt;
Constraint programming states relations between [[Variable (high-level programming language)|variables]] in the form of constraints that specify the properties of the target solution. The set of constraints is [[solver (computer science)|solved]] by giving a [[Value (computer science)|value]] to each variable so that the solution is consistent with the maximum number of constraints. Constraint programming often complements other paradigms: functional, logical, or even imperative programming.&lt;br /&gt;
&lt;br /&gt;
===Hybrid languages===&lt;br /&gt;
{{see also|Multi-paradigm programming language}}&lt;br /&gt;
Makefiles, for example, specify dependencies in a declarative fashion,&amp;lt;ref&amp;gt;{{cite web |url=http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls |title=An overview on dsls |archive-url=https://web.archive.org/web/20071023021126/http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls |archive-date=October 23, 2007 |url-status=dead}}&amp;lt;/ref&amp;gt; but include an imperative list of actions to take as well. Similarly, yacc specifies a context free grammar declaratively, but includes code snippets from a host language, which is usually imperative (such as [[C (programming language)|C]]).&lt;br /&gt;
&lt;br /&gt;
===Logic programming===&lt;br /&gt;
{{Further|Logic programming}}&lt;br /&gt;
Logic programming languages are characterized by a mostly declarative programming style. In logic programming, programs consist of sentences expressed in [[logical form]], and computation uses those sentences to solve problems, which are also expressed in logical form.&lt;br /&gt;
&lt;br /&gt;
Logic programming languages, such as [[Prolog]], [[Datalog]] and [[answer set programming]], compute by proving that a goal is a logical consequence of the program, or by showing that the goal is true in a model defined by the program. Prolog computes by reducing goals to subgoals, top-down using [[backward chaining |backward reasoning]], whereas most Datalog systems compute bottom-up using [[forward chaining |forward reasoning]]. Answer set programs typically use [[Boolean SAT solver|SAT solvers]] to generate a model of the program.&lt;br /&gt;
&lt;br /&gt;
===Modeling===&lt;br /&gt;
{{Further|Mathematical model}}&lt;br /&gt;
Models, or mathematical representations, of physical systems may be implemented in computer code that is declarative. The code contains a number of equations, not imperative assignments, that describe (&amp;quot;declare&amp;quot;) the behavioral relationships. When a model is expressed in this formalism, a computer is able to perform algebraic manipulations to best formulate the solution algorithm. The mathematical causality is typically imposed at the boundaries of the physical system, while the behavioral description of the system itself is declarative or acausal. Declarative [[modeling language]]s and environments include [[Analytica (software)|Analytica]], [[Modelica]] and [[Simile (computing)|Simile]].&amp;lt;ref&amp;gt;{{cite web |url=http://www.simulistics.com/tour/declarative.htm |title=Declarative modelling |publisher=Simulistics |access-date=15 August 2013 |archive-date=11 August 2003 |archive-url=https://web.archive.org/web/20030811073949/http://www.simulistics.com/tour/declarative.htm |url-status=live}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Prolog===&lt;br /&gt;
[[Prolog]] (1972) stands for &amp;quot;PROgramming in LOGic.&amp;quot; It was developed for natural language [[question answering]],&amp;lt;ref name=&amp;quot;PrologHistory&amp;quot;&amp;gt;{{cite web&lt;br /&gt;
 |url=http://alain.colmerauer.free.fr/alcol/ArchivesPublications/PrologHistory/19november92.pdf&lt;br /&gt;
 |title=Birth of Prolog&lt;br /&gt;
 |date=November 1992&lt;br /&gt;
 |access-date=2022-05-25&lt;br /&gt;
 |archive-date=2015-04-02&lt;br /&gt;
 |archive-url=https://web.archive.org/web/20150402111123/http://alain.colmerauer.free.fr/alcol/ArchivesPublications/PrologHistory/19november92.pdf&lt;br /&gt;
 |url-status=live&lt;br /&gt;
 }}&amp;lt;/ref&amp;gt; using SL resolution&amp;lt;ref&amp;gt;{{cite journal |author1=Robert Kowalski |author2=Donald Kuehner |url=http://www.doc.ic.ac.uk/~rak/papers/sl.pdf |title=Linear Resolution with Selection Function |journal=Artificial Intelligence |issn=0004-3702 |volume=2 |issue=3–4 |date=Winter 1971 |pages=227–260 |doi=10.1016/0004-3702(71)90012-9 |access-date=2023-08-13 |archive-date=2015-09-23 |archive-url=https://web.archive.org/web/20150923215814/http://www.doc.ic.ac.uk/~rak/papers/sl.pdf |url-status=live}}&amp;lt;/ref&amp;gt; both to deduce answers to queries and to parse and generate natural language sentences.&lt;br /&gt;
&lt;br /&gt;
The building blocks of a Prolog program are &amp;#039;&amp;#039;facts&amp;#039;&amp;#039; and &amp;#039;&amp;#039;rules&amp;#039;&amp;#039;. Here is a simple example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=prolog&amp;gt;&lt;br /&gt;
cat(tom).                        % tom is a cat&lt;br /&gt;
mouse(jerry).                    % jerry is a mouse&lt;br /&gt;
&lt;br /&gt;
animal(X) :- cat(X).             % each cat is an animal&lt;br /&gt;
animal(X) :- mouse(X).           % each mouse is an animal&lt;br /&gt;
&lt;br /&gt;
big(X)   :- cat(X).              % each cat is big&lt;br /&gt;
small(X) :- mouse(X).            % each mouse is small&lt;br /&gt;
&lt;br /&gt;
eat(X,Y) :- mouse(X), cheese(Y). % each mouse eats each cheese&lt;br /&gt;
eat(X,Y) :- big(X),   small(Y).  % each big being eats each small being&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given this program, the query &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;eat(tom,jerry)&amp;lt;/syntaxhighlight&amp;gt; succeeds, while &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;eat(jerry,tom)&amp;lt;/syntaxhighlight&amp;gt; fails. Moreover, the query &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;eat(X,jerry)&amp;lt;/syntaxhighlight&amp;gt; succeeds with the answer substitution &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;X=tom&amp;lt;/syntaxhighlight&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Prolog executes programs top-down, using [[SLD resolution]] to [[backward chaining|reason backwards]], reducing goals to subgoals. In this example, it uses the last rule of the program to reduce the goal of answering the query &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;eat(X,jerry)&amp;lt;/syntaxhighlight&amp;gt; to the subgoals of first finding an X such that &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;big(X)&amp;lt;/syntaxhighlight&amp;gt; holds and then of showing that &amp;lt;syntaxhighlight inline lang=prolog&amp;gt;small(jerry)&amp;lt;/syntaxhighlight&amp;gt; holds. It repeatedly uses rules to further reduce subgoals to other subgoals, until it eventually succeeds in [[Unification (computer science)#Application: unification in logic programming|unifying]] all subgoals with facts in the program. This backward reasoning, goal-reduction strategy treats rules in logic programs as procedures, and makes Prolog both a declarative and [[Procedural programming#Logic programming|procedural programming]] language.&amp;lt;ref&amp;gt;Robert Kowalski [http://www.doc.ic.ac.uk/~rak/papers/IFIP%2074.pdf Predicate Logic as a Programming Language] {{Webarchive|url=https://web.archive.org/web/20160207012437/http://www.doc.ic.ac.uk/~rak/papers/IFIP%2074.pdf |date=2016-02-07}} Memo 70, Department of Artificial Intelligence, University of Edinburgh. 1973. Also in Proceedings IFIP Congress, Stockholm, North Holland Publishing Co., 1974, pp. 569-574.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The broad range of Prolog applications is highlighted in the Year of Prolog Book,&amp;lt;ref name=&amp;quot;Prolog Book&amp;quot;&amp;gt;{{cite book |last1=Warren |first1=D.S. |editor1-last=Warren |editor1-first=D.S. |editor2-last=Dahl |editor2-first=V. |editor3-last=Eiter |editor3-first=T. |editor4-last=Hermenegildo |editor4-first=M.V. |editor5-last=Kowalski |editor5-first=R. |editor6-last=Rossi |editor6-first=F. |date=2023 |chapter=Introduction to Prolog |title=Prolog: The Next 50 Years |series=Lecture Notes in Computer Science (LNCS) |volume=13900 |publisher=Springer, Cham. |doi=10.1007/978-3-031-35254-6_1 |pages=3–19 |isbn=978-3-031-35253-9}}&amp;lt;/ref&amp;gt; celebrating the 50 year anniversary of Prolog.&lt;br /&gt;
&lt;br /&gt;
===Datalog===&lt;br /&gt;
The [[Datalog#History|origins of Datalog]] date back to the beginning of logic programming, but it was identified as a separate area around 1977. [[Syntax and semantics of logic programming|Syntactically and semantically]], it is a subset of Prolog. But because it lacks [[Prolog#Data types |compound terms]], it is not [[Turing completeness|Turing-complete]].{{Citation needed|date=December 2025}}&lt;br /&gt;
&lt;br /&gt;
Most Datalog systems execute programs bottom-up, using rules to [[forward chaining |reason forwards]], deriving new facts from existing facts, and terminating when there are no new facts that can be derived, or when the derived facts unify with the query.{{cn|date=December 2025}} &lt;br /&gt;
&lt;br /&gt;
Datalog has been applied to such problems as [[data integration]], [[information extraction]], [[Computer network|networking]], [[security]], [[cloud computing]] and [[machine learning]].&amp;lt;ref&amp;gt;{{cite conference |last1=Huang |first1=Shan Shan |last2=Green |first2=Todd J. |last3=Loo |first3=Boon Thau |date=June 12–16, 2011 |url=https://www.cs.ucdavis.edu/~green/papers/sigmod906t-huang.pdf |conference=SIGMOD 2011 |title=Datalog and Emerging applications |publisher=Association for Computing Machinery |location=Athens, Greece |isbn=978-1-4503-0661-4 |access-date=2023-08-13 |archive-date=2020-10-22 |archive-url=https://web.archive.org/web/20201022234145/https://www.cs.ucdavis.edu/~green/papers/sigmod906t-huang.pdf |url-status=live}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite conference |last1=Mei |first1=Hongyuan |last2=Qin |first2=Guanghui |last3=Xu |first3=Minjie |last4=Eisner |first4=Jason |year=2020 |title=Neural Datalog Through Time: Informed Temporal Modeling via Logical Specification |book-title=Proceedings of ICML 2020 |arxiv=2006.16723}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Answer set programming===&lt;br /&gt;
[[Answer set programming]] (ASP) evolved in the late 1990s, based on the [[stable model semantics|stable model]] (answer set) semantics of logic programming. Like Datalog, it is a subset of Prolog; and, because it lacks compound terms, it is not Turing-complete.&lt;br /&gt;
&lt;br /&gt;
Most implementations of ASP execute a program by first &amp;#039;&amp;#039;grounding&amp;#039;&amp;#039; the program, replacing all variables in rules by constants in all possible ways, and then using a propositional SAT solver, such as the [[DPLL algorithm]] to generate one or more models of the program.&lt;br /&gt;
&lt;br /&gt;
Its applications are oriented towards solving difficult [[search algorithm|search problems]] and [[knowledge representation]].&amp;lt;ref&amp;gt;{{cite book |first1=Chitta |last1=Baral |title=Knowledge Representation, Reasoning and Declarative Problem Solving |url=https://archive.org/details/knowledgereprese00bara |url-access=registration |year=2003 |publisher=Cambridge University Press |isbn=978-0-521-81802-5}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite book |first1=Michael |last1=Gelfond |chapter=Answer sets |editor1-first=Frank |editor1-last=van Harmelen |editor2-first=Vladimir |editor2-last=Lifschitz |editor3-first=Bruce |editor3-last=Porter |year=2008 |title=Handbook of Knowledge Representation |chapter-url=https://books.google.com/books?id=xwBDylHhJhYC&amp;amp;pg=PA285 |publisher=Elsevier |pages=285–316 |isbn=978-0-08-055702-1}} [http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf as PDF] {{Webarchive|url=https://web.archive.org/web/20160303231241/http://www.depts.ttu.edu/cs/research/krlab/pdfs/papers/gel07b.pdf |date=2016-03-03}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Inductive programming]]&lt;br /&gt;
* [[List of programming languages by type#Declarative_languages|List of declarative programming languages]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* Frans Coenen. [https://web.archive.org/web/20060424045449/http://www.csc.liv.ac.uk/~frans/OldLectures/2CS24/declarative.html#detail Characteristics of declarative programming languages]. 1999.&lt;br /&gt;
*[[Robert Harper (computer scientist)|Robert Harper]].&lt;br /&gt;
**[https://existentialtype.wordpress.com/2013/07/18/what-if-anything-is-a-declarative-language/ What, If Anything, Is A Declarative Language?]. 2013.&lt;br /&gt;
**&amp;quot;[https://existentialtype.wordpress.com/2013/07/22/there-is-such-a-thing-as-a-declarative-language/ There Is Such A Thing As A Declarative Language, and It&amp;#039;s The World&amp;#039;s Best DSL]&amp;quot;. 2013.&lt;br /&gt;
* Olof Torgersson. [https://web.archive.org/web/20060330033506/http://www.cs.chalmers.se/~oloft/Papers/wm96/wm96.html A Note on Declarative Programming Paradigms and the Future of Definitional Programming]. 1996.&lt;br /&gt;
&lt;br /&gt;
{{Programming paradigms navbox}}&lt;br /&gt;
{{Types of programming languages}}&lt;br /&gt;
{{Authority control}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Declarative programming| ]]&lt;br /&gt;
[[Category:Programming paradigms]]&lt;br /&gt;
&amp;lt;!-- Hidden categories below --&amp;gt;&lt;br /&gt;
[[Category:Articles with example Lisp (programming language) code]]&lt;/div&gt;</summary>
		<author><name>~2026-41888-44</name></author>
	</entry>
</feed>