Content deleted Content added
→Definition: Added period to bullet for consistency |
Removed double spaces throughout article for consistency |
||
Line 49:
===Logic programming===
[[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 |
===Modeling===
{{Main|Mathematical model}}
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 ("declare") 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.
==Examples==
Line 59:
===Lisp===
{{copyedit|section|reason=checking relevance and factual accuracy|date=December 2023}}
[[Lisp (programming language) | Lisp]] is a family of programming languages loosely inspired by mathematical notation and [[Alonzo Church]]'s [[lambda calculus]]. While some dialects, such as [[Common Lisp]] are primarily imperative, these lisps support functional programming, and other lisps, such as [[Scheme (programming language) |
In scheme, one may define the [[factorial]] function as such:
Line 72:
This can be construed as defining the factorial function using its recursive mathematical definition, as opposed to simply defining a procedure, as one would typically do in an imperative language.
In lisps, as in lambda calculus, functions are generally [[first-class citizen |
This can greatly simplify the definition of certain functions.
For example, if one wants to create a function that returns the first n [[square numbers |
<syntaxhighlight lang=scheme>
Line 148:
Given this program, the query <syntaxhighlight inline lang=prolog>eat(tom,jerry)</syntaxhighlight> succeeds, while <syntaxhighlight inline lang=prolog>eat(jerry,tom)</syntaxhighlight> fails. Moreover, the query <syntaxhighlight inline lang=prolog>eat(X,jerry)</syntaxhighlight> succeeds with the answer substitution <syntaxhighlight inline lang=prolog>X=tom</syntaxhighlight>.
Prolog executes programs top-down, using [[SLD resolution]] to [[backward chaining |
The broad range of Prolog applications is highlighted in the Year of Prolog Book,<ref name="Prolog Book">{{cite book |last1=Warren |first1=D.S. |editor-last1=Warren |editor-first1=D.S. |editor-last2=Dahl |editor-first2=V. |editor-last3=Eiter |editor-first3=T. |editor-last4=Hermenegildo |editor-first4=M.V. |editor-last5=Kowalski |editor-first5=R. |editor-last6=Rossi |editor-first6=F. |chapter=Introduction to Prolog |title=Prolog: The Next 50 Years |series=Lecture Notes in Computer Science() |date=2023 |volume=13900 |publisher=Springer, Cham. |doi=10.1007/978-3-031-35254-6_1 |pages=3–19|isbn=978-3-031-35253-9 }}</ref> celebrating the 50 year anniversary of Prolog.
===Datalog===
The [[Datalog#History |
Most Datalog systems execute programs bottom-up, using rules to [[forward chaining |
<syntaxhighlight lang="prolog">
animal(tom).
|