Page 86 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 86
Introduction to Artificial Intelligence & Expert Systems
Notes
Example: Here is a program to append comma sequences ...
sequence_append((X,R),S,(X,T)):-
!,
sequence_append(R,S,T).
sequence_append((X),S,(X,S)).
Note the use of cut (!) to make sure that the second clause is not available as a alternate choice for
multi-element sequences.
?- sequence_append((1,2,3),(a,b,c,d),S).
S = 1, 2, 3, a, b, c, d
5.6.3 Prolog as a Relational Language
A Probabilistic Relational Programming Language (PRPL) is a programming language specially
designed to describe and infer with Probabilistic Relational Models (PRMs). A PRM is usually
developed with a set of algorithms for reducing, inference about and discovery of concerned
distributions, which are embedded into the corresponding PRPL. PRPLs often extend from a
basic language. The inventors’ choices of underlying basic language depend on the similarity of
their relational models to the basic language’s relational model, as well as commercial
considerations and personal preference. For instance, Infer.NET is based on .NET framework,
while PRISM extends from Prolog. Currently there are several PRPLs in active development;
some of them have advanced to the beta stage. However because PRMs are new, up to year 2010
there have been no well-known software projects utilizing those languages.
We have introduced Lisp as the main representative functional programming language (especially
the widely used dialect Common Lisp), because it is still a widely used programming language
for a number of Artificial Intelligence problems, like Natural Language Understanding,
Information Extraction, Machine Learning, AI planning, or Genetic Programming. Beside Lisp a
number of alternative functional programming languages have been developed. We will briefly
mention two well-known members, viz. ML and Haskell. ML which stands for Meta-Language
is a static-scoped functional programming language.
The main differences to Lisp is its syntax (which is more similar to that of Pascal), and a strict
polymorphic type system (i.e., using strong types and type inference, which means that variables
need not be declared). The type of each declared variable and expression can be determined at
compile time. ML supports the definition of abstract data types, as demonstrated by the following
Example:
datatype tree = L of int
| int * tree * tree; which can be read as “every binary tree is either a leaf containing an integer or
it is a node containing an integer and two trees (the subtrees)”. An example of a recursive
function definition applied on a tree data structure is shown in the next example:
fun depth(L) = 1
| depth(N(i,l,r)) =
1 + max(depth l, depth r);
The function depth maps trees to integers. The depth of a leaf is 1 and the depth of any other tree
is 1 plus the maximum of the depths of the left and right sub trees.
Haskell is similar to ML: it uses a similar syntax, it is also static scoped, and makes use of the
same type inference method. It differs from ML in that it is purely functional. This means that it
80 LOVELY PROFESSIONAL UNIVERSITY