Mathematica and GAP: Is there an interface?
Asked Answered
G

2

7

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?

Gatt answered 17/12, 2011 at 13:4 Comment(3)
@Sjoerd nice edit I made a while back. <:-oDogoodism
@mr.wizard It was late tonight. Please forgive me if I appear slow. To which edit are you referring?Enyo
I created the grammatical error you corrected. See the edit history for the full story.Dogoodism
S
4

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.

Stomachache answered 17/12, 2011 at 22:17 Comment(6)
I found the work that has already been done on the issue at openmath.org/software/index.html , but I think it the project has died. Maybe I should pursue from there.Gatt
@nilo There is Pythonika for interfacing with Python. It might make it easier to use pexpect. I looked at how Pythonika works the other day, and it does not inspire trust (e.g. uses and removes Global` variables and looks messy in general), but it does function. Also, pexpect seems to be Unix-only.Timoshenko
Thanks. @Stomachache and ( Szabolics ). I'll investigate further, since I'll be doing another course in Group Theory next year, I might work on a the Mathematica / GAP Interface myself. With all your expert advice this should be doable.Gatt
@nilo: A solid GAP/Mathematica interface would be great. I can see myself using such a thing, so I'll be glad to try to help (if I have time!)Stomachache
@Simon, Noted, and thanks. I'll get back to you on this in the next two weeks.Gatt
@nilo: I'll be on holiday and not checking SO. Then I'll be crazy busy writing up a couple of papers. So take your time...Stomachache
E
7

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.

Enyo answered 17/12, 2011 at 20:18 Comment(3)
I came as far as that, a few years ago. I used a Java program as an intermediary. ( The code is on a PC which needs repair. ) From and to GAP you can only read and write strings. openmath.org/software/index.html did a lot of work on the issue but I think that project died.Gatt
Ideas of OpenMath found further use in the SCIEnce project. The linked page contains a list of systems supporting SCSCP protocol, and both GAP and Mathematica implementations are there.Lodgment
In the meantime, the GAP FAQ quoted in the answer has been updated a little: please see here.Lodgment
S
4

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.

Stomachache answered 17/12, 2011 at 22:17 Comment(6)
I found the work that has already been done on the issue at openmath.org/software/index.html , but I think it the project has died. Maybe I should pursue from there.Gatt
@nilo There is Pythonika for interfacing with Python. It might make it easier to use pexpect. I looked at how Pythonika works the other day, and it does not inspire trust (e.g. uses and removes Global` variables and looks messy in general), but it does function. Also, pexpect seems to be Unix-only.Timoshenko
Thanks. @Stomachache and ( Szabolics ). I'll investigate further, since I'll be doing another course in Group Theory next year, I might work on a the Mathematica / GAP Interface myself. With all your expert advice this should be doable.Gatt
@nilo: A solid GAP/Mathematica interface would be great. I can see myself using such a thing, so I'll be glad to try to help (if I have time!)Stomachache
@Simon, Noted, and thanks. I'll get back to you on this in the next two weeks.Gatt
@nilo: I'll be on holiday and not checking SO. Then I'll be crazy busy writing up a couple of papers. So take your time...Stomachache

© 2022 - 2024 — McMap. All rights reserved.