Declarative programming is a programming paradigm where the focus is on what must be accomplished, rather than how it is to be accomplished. Hence it is more about "declaring" than about implementing algorithms. Use this tag for questions about how declarative programming is used in AI systems.
Declarative programming is a computer programming paradigm where the focus is on declaring what should be accomplished, rather than explaining how it should be accomplished.
A good example of a declarative programming language is Prolog, which is based upon predicate logic. Here is a simple Prolog program:
dog(brutus).
dog(pluto).
dog(X):-barks(X).
This program states (declares) 3 things: (1) that brutus is dog, (2) that pluto is a dog, and (3) that if something is a dog, it barks.
(Note that the names of the dogs are in small letters; Prolog uses capital letters to identify variables).
We can now ask this program to tell us who barks:
barks(X)
and it will give us the solutions:
X = brutus ;
X = pluto ;
no more solutions
Note how we did not tell our program how to arrive at this result; this is done by the Prolog system itself.
Declarative programming, by focusing on the "what" rather than the "how", is useful for building knowledge bases.