From nzhou@acm.org Wed Mar 10 00:51:00 2010 From: nzhou@acm.org (Neng-Fa Zhou) Date: Tue, 9 Mar 2010 19:51:00 -0500 Subject: [bp-users]New features in B-Prolog version 7.4 Message-ID: <005501cabfeb$c0ac2f50$d4f9f592@toshibauser> This is a multi-part message in MIME format. ------=_NextPart_000_0052_01CABFC1.D7C0CA90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I am pleased to announce the release of B-Prolog version 7.4. You can find below a list of new features available in the new version. A detailed note on the updates can be found at=20 http://probp.com/updates.htm. Best regards, Neng-Fa =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D ***The Array Subscript Notation The array subscript notation X[I1,...,In] can be used to access elements of an array, a structure, or a list without introducing temporary variables. This common notation is, however, not part of the standard Prolog syntax. To accommodate this notation, the parser is modified to insert a token ^ between a variable token and [. So, the notation X[I1,...,In] is just a shorthand for X^[I1,...,In]. This notation is interpreted as an element access when it occurs in an arithmetic expression, an arithmetic constraint, or as an argument of a call to @=3D/2. In any other context, it is treated as the term itself.=20 *** The foreach Built-ins and List Comprehension The foreach and list comprehension are provided for iterating over collections (lists and integer intervals) and constructing lists. A foreach call takes the form=20 foreach(E1 in D1, ..., Ek in Dk,Accs,LocalVars,Goal) or=20 foreach(E1 in D1, ..., Ek in Dk,LocalVars,Accs,Goal) where LocalVars (optional) specifies a list of variables that are local to each iteration and Accs is one or more accumulators. For example,=20 foreach(A in [a,b], I in 1..2, write((A,I)))=20 outputs four tuples (a,1), (a,2), (b,1), and (b,2).=20 A list comprehension takes the form=20 [T : E1 in D1, ..., Ek in Dk, LocalVars,Goal]=20 where LocalVars and Goal are optional. Syntactically, a list comprehension is just a list whose first element has the functor ':'. A list of this form is interpreted as a list comprehension in calls to @=3D/2 and in arithmetic constraints. For example=20 X @=3D [(A,I) : A in [a,b], I in 1..2]=20 binds X to the list [(a,1),(a,2),(b,1),(b,2)].=20 The loop constructs considerably enhance the modeling power of B-Prolog as a CLP language. As can be seen in the examples available at=20 http://www.probp.com/examples/index.html#FOREACH many problems that require lengthy descriptions using recursion can be described elegantly using these loop constructs. *** Table Modes By default, all the arguments of a tabled call are used in variant checking and all answers are tabled for a tabled predicate. Table modes allow the system to use only input arguments in variant checking and table answers selectively. The table mode declaration :-table p(M1,...,Mn):C. instructs the system how to do tabling on p/n, where C, called a cardinality limit, is an integer which limits the number of answers to be tabled, and each Mi is a mode which can be min, max, + (input), or - (output).=20 Table modes are very useful for declarative description of dynamic programming problems. For example, the following program encodes the Dijkstra's algorithm for finding a path with the minimum weight between a pair of nodes. :-table sp(+,+,-,min). sp(X,Y,[(X,Y)],W) :- edge(X,Y,W). sp(X,Y,[(X,Z)|Path],W) :- edge(X,Z,W1), sp(Z,Y,Path,W2), W is W1+W2. *** Table or Extensional Constraints A table or extensional constraint is either positive or negative. A positive constraint takes the form 'X in R' and a negative constraint takes the form 'X notin R' where X is a tuple variables (X1,...,Xn) or a list of tuples of variables, and R is a table defined as a set of tuples of integers where each tuple takes the form (a1,...,an). Table constraints are well suited to problems where relations are more easily maintained in extension than in intension such as configuration problems involving datasets. ------=_NextPart_000_0052_01CABFC1.D7C0CA90 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I am pleased to announce the release of = B-Prolog=20 version 7.4.
You can find below a list of new features available in = the=20 new
version. A detailed note on the updates can be found at =
 
   http://probp.com/updates.htm.
 
Best regards,
Neng-Fa
 
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D
***The=20 Array Subscript Notation
 
The array subscript notation = X[I1,...,In] can be=20 used to access
elements of an array, a structure, or a list without=20 introducing
temporary variables. This common notation is, however, = not=20 part
of the standard Prolog syntax. To accommodate this = notation,
the=20 parser is modified to insert a token ^ between a variable
token and = [. So,=20 the notation X[I1,...,In] is just a shorthand
for X^[I1,...,In]. This = notation is interpreted as an element
access when it occurs in an = arithmetic=20 expression, an arithmetic
constraint, or as an argument of a call to = @=3D/2. In=20 any other
context, it is treated as the term itself.
 
*** The foreach Built-ins and List=20 Comprehension
 
The foreach and list comprehension are = provided for=20 iterating
over collections (lists and integer intervals) and=20 constructing
lists. A foreach call takes the form
 
   foreach(E1 in D1, ..., Ek = in=20 Dk,Accs,LocalVars,Goal) or
   foreach(E1 in D1, ..., Ek in = Dk,LocalVars,Accs,Goal)
 
where LocalVars (optional) specifies a = list of=20 variables that
are local to each iteration and Accs is one or more=20 accumulators.
For example,
 
   foreach(A in [a,b], I in = 1..2,=20 write((A,I)))
 
outputs four tuples (a,1), (a,2), = (b,1), and (b,2).=20
 
A list comprehension takes the form =
 
   [T : E1 in D1, ..., Ek in = Dk,=20 LocalVars,Goal]
 
where LocalVars and Goal are optional.=20 Syntactically, a list
comprehension is just a list whose first = element has=20 the functor
':'. A list of this form is interpreted as a list=20 comprehension
in calls to @=3D/2 and in arithmetic constraints. For = example=20
 

   X @=3D [(A,I) : A in [a,b], I in 1..2]
 
binds X to the list [(a,1),(a,2),(b,1),(b,2)].
 
The loop constructs considerably enhance the modeling power = of
B-Prolog=20 as a CLP language. As can be seen in the examples available
at
 
   http://www.prob= p.com/examples/index.html#FOREACH
 
many problems that require lengthy descriptions using = recursion
can be=20 described elegantly using these loop constructs.
 
*** Table Modes
 
By default, all the arguments of a tabled call are used in=20 variant
checking and all answers are tabled for a tabled predicate.=20 Table
modes allow the system to use only input arguments in=20 variant
checking and table answers selectively. The table mode=20 declaration
 
     :-table p(M1,...,Mn):C.
 
instructs the system how to do tabling on p/n, where C, called
a = cardinality limit, is an integer which limits the number of
answers = to be=20 tabled, and each Mi is a mode which can be min,
max, + (input), or -=20 (output).
 
Table modes are very useful for declarative description of=20 dynamic
programming problems. For example, the following program=20 encodes
the Dijkstra's algorithm for finding a path with the=20 minimum
weight between a pair of nodes.
 
   :-table sp(+,+,-,min).
   = sp(X,Y,[(X,Y)],W)=20 :-
       edge(X,Y,W).
  =20 sp(X,Y,[(X,Z)|Path],W) :-
      =20 edge(X,Z,W1),
      =20 sp(Z,Y,Path,W2),
       W is = W1+W2.
 

*** Table or Extensional Constraints
 
A table or extensional constraint is either positive or = negative.
A=20 positive constraint takes the form 'X in R' and a negative
constraint = takes=20 the form 'X notin R' where X is a tuple variables
(X1,...,Xn) or a = list of=20 tuples of variables, and R is a table
defined as a set of tuples of = integers=20 where each tuple takes
the form (a1,...,an). Table constraints are = well=20 suited to problems
where relations are more easily maintained in = extension=20 than
in intension such as configuration problems involving = datasets.
 
 
------=_NextPart_000_0052_01CABFC1.D7C0CA90--