CS.VANSICKLE@R20.UTEXAS.EDU (09/19/86)
Two simple things you CANNOT do in Turbo Prolog: 1. Compute lists containing elements of different basic types. Turbo Prolog does not let you have goals such as append([a,b,c],[1,2,3],L). Turbo Prolog requires that the types of every predicate be declared, but the typing system does not allow you to declare types that mix basic types. Also lists like: [1,a] [2,[3,4]] [5,a(6)] cannot be created in Turbo Prolog. The syntax of types is: a) name = basictype where basictype is integer, char, real, string or symbol, b) name = type* where type is either a basic type or a user defined type, the asterisk indicates a list, c) name = f1(d11,...d1n1);f2(d21,...,d2n2);...fm(dm1,...d2nm) where fi are functors and dij are types, called "domains." The functors and their domains are alternative structures allowed in the type being defined. The important thing to notice is that you cannot define a type that has basic types as alternatives. You can only define alternatives for types that contain functors. So you cannot define types mytype = integer;symbol mylisttype = mytype* which is what you would need to append a list of integers to a list of symbols. What the Turbo Prolog manual recommends for this case is to define mytype = s(symbol);i(integer) mylisttype = mytype* and declare append as append(mylisttype,mylisttype,mylisttype) which would allow us to state the goal append([s(a),s(b),s(c)],[i(1),i(2),i(3)],L). This is clumsy, kludgy, and ugly. 2. Compute expressions that contain different basic types or mixtures of structures and basic types. Simplifying arithmetic expressions that contain constants and variables seems like it should be easy in a language designed to do symbolic computation. In C & M Prolog some rules for simplifying multiplication might be simplify(0 * X,0). simplify(X * 0,0). simplify(1 * X,X). simplify(X * 1,X). In C & M Prolog you can enter goals such as simplify(a - 1 * (b - c),X). Now in Turbo Prolog, because of the limited typing, you cannot have expressions that contain both symbols and integers. (You also cannot have infix expressions, but that is another issue). Instead, you would have to do something like this: exprtype = i(integer);s(symbol);times(exprtype,exprtype) and declare simplify as: simplify(exprtype,exprtype) and the clauses would be: simplify(times(i(0),X),i(0)). simplify(times(X,i(0)),i(0)). simplify(times(i(1),X),X). simplify(times(X,i(1)),X). The goal would be: simplify(minus(s(a),times(i(1),minus(s(b),s(c)))),X). This should speak for itself, but I'll spell it out: REAL Prolog can do symbolic computation involving mixtures of symbols, numeric constants, and expressions; the programs are simple and elegant; input and output are easy. In Turbo Prolog you can't even create most of the expressions that real Prolog can; the programs are long, opaque, and clumsy; you have to write your own predicates to read and write expressions in infix notation. It is a shame that this product comes from a company with a reputation for good software. If it came from an unknown company people would be a lot more cautious about buying it. Since it's from Borland, a lot of people will assume it's good. They are going to be disappointed. -- Larry Van Sickle cs.vansickle@r20.utexas.edu 512-471-9589 -------