Practical Notes on Computer Algebra Systems (CAS)

On and off, I am teaching Symbolic Computation. Here are some notes, for my current students, and for my future self, about installing and using some CAS (and related systems) that have a free license (I will not use un-free software in teaching).

FriCAS

A typed CAS. Descendant of Scratchpad (1971), via Axiom (see http://axiom-developer.org/)

Maxima

Descendant of Macsyma (1960s)

Geonext

Not CAS but for geometric constructions. Each drawing is in fact a straight-line program of Euclidean operations, and it will be re-executed after moving initial points. This is great for visualizing theorems about locations, and it motivates the study of polynomial ideals to prove them.

Home page http://geonext.uni-bayreuth.de/, but this currently (2021-04-05) gives a Typo3 error. Most recent working version https://web.archive.org/web/20200202230951/http://geonext.uni-bayreuth.de/index.php?id=2277.

Installation and usage:

wget https://web.archive.org/web/20200202230951/http://geonext.uni-bayreuth.de/data/download/1.74/geonext.1.74.zip
            unzip -d geonext.1.74 geonext.1.74.zip
            cd geonext.1.74
            unzip -d geonext geonext.jar
            /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-4.fc34.x86_64/jre/bin/java -cp geonext geonext.Geonext

Remarks:

  • the JAR format is java-7 (?) and cannot be read by more current JVMs (hence, we unpack it)
  • other files are not needed
  • license is GPL, so the sources should be around somewhere
  • unzip -d: see remarks at http://www.linfo.org/tarbomb.html
  • DB error: would not have happened with static HTML pages

General notes on building and installation

For building from source (that’s the point of free software), we sometimes need several languages (compilers). In particular, CAS are often built on LISP, the first language of symbolic computation. Maxima and Fricas can be built with http://www.sbcl.org/.

The work of bootstrapping can be reduced by installing binaries instead - and sometimes that’s the only way (e.g., we need a LISP compiler to build SBCL LISP, and a Haskell compiler to build GHC, see below). Look first for packages in your OS’s distribution. Check other providers extra carefully, and definitely don’t curl ... | sudo bash.

But it’s only in a container/VM you say? Well, then you’re wasting space (the VMs duplicates packages that you already have) and it’s an extra security risk: your distribution’s packages will get security updates but their copies won’t.

Haskell

One might say that Haskell is a typed LISP. Well, ML (that’s “meta language”, not some abbreviation-du-jour) is typed LISP, and Haskell is lazy ML.

Bootstrapping is interesting since GHC, cabal, stack are written in Haskell; and cabal and stack already need lots of packages for building.

If you’re reasonably paranoid, start from some binary GHC download, and then bootstrap from source: first ghc, then cabal, then stack.

These tools appear eager to phone home, and to drop binaries on you, so put this in your $HOME/.cabal/config:

remote-build-reporting: none

and this in your $HOME/.stack/config.yaml:

system-ghc: true
            install-ghc: false

If you’re fully paranoid, or have an interest in retro-computing: there is a Haskell compiler written in C (https://archive.org/details/haskell-b-compiler), and a Haskell interpreter written in C (https://www.haskell.org/hugs/). It might be possible to bootstrap a current GHC from that. For (dis)trusting a bootstrapping compiler, see Ken Thompson’s 1984 Turing Award lecture https://dl.acm.org/doi/10.1145/358198.358210. For proving the correctness of a C compiler: https://compcert.org/.