- Prolog (Programming in logic, 1972) is the most well known
- representative of the paradigm. Prolog is based on Horn clauses and SLD resolution.
- Mostly developed in ﬁfth generation computer systems project.
- Specially designed for theorem proof and artiﬁcial intelligence.
- but allows general purpose computation.
A form of logical sentences commonly found in logic programming, but not exclusively, is the Horn clause . An example is:
p(X, Y) if q(X) and r(Y)
Some logic programming languages accept other logical sentences, such as the “choice” sentence in answer set programming.
Logical sentences can be understood purely declaratively. They can also be understood procedurally as goal-reduction procedures : to solve p(X, Y), first solve q(X), then solve r(Y).
A ramming paradigm Progbased on logic (more accurately, the Predicate Calculus?). A program is represented by a set of facts (statements/relationships which are held to be true), and a set of axioms (i.e. if A is true, then B is true). The axioms and clauses may have arguments.
For example, one could define the relation child(A,B), meaning that A is a child of B. One then could establish a set of facts (stored in a database–see below):
Child (Pebbles, Fred)
Child (Pebbles, Wilma)
Child (Wilma, Freds-mother-in-law) (what’s her name?)
Child (Bam-bam, Barney)
Child (Bam-bam, Betty)
One can query the database:
Child ? (Pebbles, Fred) -> True
Child ? (Pebbles, Barney) -> False (at least Fred hopes not!)
One then can define define a descendent relationship, the transitive closure of the child relationship (this is pseudocode , obviously)
Descendent (A , B) := child(A,B)
Descendent (A, B) := exists(x : child(A, x) && descendent(x, B))
One can query these relationships as well.
Descendent ? (Pebbles , Fred) -> True
Descendent ? (Pebbles, Freds-mother-in-law)? True
Descendent ? (Pebbles, Barney) -> False.
A theorem proving system is used to search the database of facts and to determine what is true and what isn’t.