To use P#, you require a C# compiler and the ability to run C# programs.
To install P# you should download the following files:
These files can also be obtained zipped together in the following zip file.
The source code (both Prolog and C#) is also available:
You should add Psharp.dll to the Global Assembly Cache (GAC). Having done this you can run P# by executing the Psharp.exe file. It is possible to run Psharp.exe without putting Psharp.dll in the GAC, simply by placing the two files in the same folder. However, putting Psharp.dll in the GAC makes it easier for C# programs generated by P# to find the DLL (alternatively you can add a reference to some copy of the DLL when you compile your C# files).
To translate a Prolog source file, called myfile.pl, say, run P# and enter the command
then press CTRL-Z to exit P#.
If the compilation was successful there will now be a number of C# files in the directory. Copy the file Loader.cs into the directory as well.
Assuming that your
csc (C# compile) command is reachable from the path, and that you
have put your P#.dll file in the folder C:\psharp, say, you
should then be able to compile these into a P# application with the following command:
csc /r:"C:\psharp\Psharp.dll" /out:MyProgram.exe *.cs
This generates an executable file which when run will load the P# dll and start executing
main/0 in the Prolog file you compiled. To run another predicate
of arity zero, say
my_pred you can use the command
Notice how Prolog predicate names are renamed (if in doubt just look at the class name in the generated C# file).
Using P# is very similar to using Prolog Cafe (P# 1.1 is based on Prolog Cafe version 0.44). We have added several extra predicates: loadAssembly/1, which is passed an assembly name (as a term). This assembly, and any predicates defined in it then become visible to P#. See the papers for details of the other new predicates. I am working on documentation for the many other new predicates added.
A screenshot of the Graphical User Interface for P#, this can be downloaded above. You can also download the source code, and the icon.
A screenshot of a Web Application which allows the user to play a game of noughts and crosses against a Prolog program. You can also download the Prolog and C# source code.
A screenshot of an object oriented assistant, which allows the user to query the C# namespaces
and Java library packages. Here is the C# code for the C# Assistant, the C# code for the Java Assistant and the Prolog searching code. Finally there is a C# icon and a
In order to try out this application you need an example database,
these tend to be quite large, so only System.Collections for C# and java.util.jar for Java are provided here. Put these in the same directory as the executable and run it from that directory. The Java assistant
requires as a command line argument the
api directory of the Java
documentation. The final slash is needed. For example on my computer the
assistant is invoked by:
"Java OO Assistant.exe" file:C:\j2sdk-1_4_0-doc\docs\api\
or you could give it a URL for the online version.
A screen shot of the agents example discussed in the concurrency paper, here is the server C# code, the server Prolog code, the first agent C# file, the second agent C# file, an example XML setup file for the server, and the agent icon. Pass the filename of the Xml file as a command line argument to the server.
IMPORTANT NOTE: In order to run some of the above demos, you will need the latest build of P# (184.108.40.206). To compile a demo, add the C# files to a Visual Studio Project, then compile the Prolog files to C# using either the Graphical or terminal interface to P#. Having done this add the generated C# files to the project. Add the Psharp DLL to the references and compile.