User:Johnpool
From Wikipedia, the free encyclopedia
[edit] C#Prolog -- A Prolog interpreter written in C#
C#Prolog is a Prolog interpreter which has been written entirely in C#, from scratch, although some of the basic mechanisms are inspired by XProlog developed (in Java) by Jean Vaucher, who at his turn enhanced the WProlog program developed by Michael Winikoff. In comparison to XProlog it has the following new features:
• The possibility of defining new operators using :-op(Precedence, Type, Name);
• Enhanced arithmetic (many of the standard C# builtin functions are available);
• Builtin types DateTime and TimeSpan;
• Predicates for manipulating XML (à la PLXML; cf. Google). These predicates use the C# capabilities for handling XML;
• (Simple) preprocessor directives #define, #undefine #if, #else, #ifnot, #endif;
• assert/retract not only for facts, but also for rules;
• Builtin DCG processing;
• :-discontiguous(…) directive, to indicate that predicate clauses may be scattered over the source file. Multi-file predicates are not allowed, however;
• :-persistent(…) directive, to indicate that the predicate clauses are to be retrieved from / inserted into a database table (or stored procedure). This only applies to fully instantiated fact (head-only) predicates. The use of such predicates is completely transparent: the only difference is that asserted values are still there at the next session. This is also the method that I used for storing huge fact databases. The RDBMS that was used is Firebird (for DotNet, freeware), which is very reliable, very fast, and has many features;
• First-argument indexing;
• A more user-friendly (but still quite basic) DOS-box toplevel user-interface, with the possibility of referring to and editing of commands given earlier (using !, !!, !<n>, and editing via !<n>/<oldstring>/<newstring>/ );
• An option to set a limit to the execution time of a query;
• Enhanced debugging and tracing options. Debugging output can be captured into an XML-file;
• Regular expressions (limited, but easily extendible using C#’s capabilities).
It is fairly complete as far as the basic predicates are concerned, but this does not mean to say that there is nothing left to do. Some known problem areas are:
• The read-predicate may needs some debugging. I have not tested this predicate extensively. The same goes for 'seeing' and 'telling'. The consult-predicate works fine;
• The setof-predicate is not implemented according to the official definition, in that the existential operator (^) does not work. setof simply returns all solutions (sorted) in a single list;
• A graphical user-interface would be nice;
• C#Prolog does not completely support Unicode. In principle, this should not be to difficult, given the C# Unicode facilities;
• Atom/1 is not implemented fully correctly. It works fine for 'regular' atoms, but e.g. in case of atom(++) it should return true, but if + is defined as a prefix operator ++ is regarded as a compound term +(+);
• Quite some of the standard ISO-predicates are lacking. Usually their implementation will not be difficult, but there was simply no time available yet to do this;
• It would be nice to have a compile facility (WAM?).
C#Prolog is free software that is available at SourceForge (http://sourceforge.net/projects/cs-prolog/). It can be redistributed and/or modified under the terms of the GNU General Public License as published by the Free Software Foundation.

