Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mathematica and GAP: Is there an interface?

Although the Abstract Algebra Add-on is a beautiful package for Mathematica, imo there is nothing that beats GAP, at least not for Group Theory. When I looked at Sage a few years ago, I found that said to have an interface with Mma but when I looked at it closer it turned out to be somewhat primitive ( but operational ). I know that work has been done at the Technical University of Eindhoven (OpenMath) on a platform for integrating / interfacing the major math tools, I even started to work on it. But that work got lost. Now to my question:

Is there, does anyone have, and are you willing to share, an interface between GAP and Mathematica?

like image 283
nilo de roock Avatar asked Dec 17 '11 13:12

nilo de roock


2 Answers

The GAP FAQ seems to be rather pessimistic about this:

8.1: Can I call GAP functions from another programme?

The short answer is no. To explain a little more fully, essentially all the algebraic functionality of the GAP system is written in the GAP language, and so needs the GAP interpreter to run. The interpreter is written in C, but does not coexist happily with other code in the same process for a number of reasons, so there is no sensible way to link GAP into a C, Java or other program as a subroutine library.

There is some hope, though:

What you can do is to run GAP in a child process and communicate with it using pipes, pseudo-ttys, UNIX FIFOs or some similar device. We have done this successfully in a number of projects, and you can contact the support list for more detailed advice if you want to go down this route.

Update

The FAQ now also reads:

Relatively recently, some of the SAGE developers have produced libGAP, which allows the entire GAP system to be embedded as a C library. One still can't embed individual functions by themselves though and the first call to libGAP still has to invoke the full GAP start-up sequence.

Alternatively, there are a number of ways of running GAP as a server process and calling it from C of C++ programs. See the SCSCP package for the GAP side. There are several C and C++ libraries that implement the client side.

like image 144
Sjoerd C. de Vries Avatar answered Oct 10 '22 12:10

Sjoerd C. de Vries


One options is to use Sage as an intermediate. Sage can interface both with Mathematica and GAP.
I believe that Sage interfaces with both programs by:
a) running their console interfaces in the background using pexpect
b) knowing how to translate most of the GAP and Mathematica syntax into its native syntax.

Note that I've done this a couple of times before and it works ok - but it means you don't get to use the Mathematica notebook interface....

A really useful tool would be to hook Mathematica up to expect (or pexpect) so that similar interfaces to console programs can be written for Mathematica. This is basically what the second quote in Sjoerd's answer is suggesting.

like image 25
Simon Avatar answered Oct 10 '22 13:10

Simon