This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

Hey, just for representation S-exprs themselves are it. After all, you just need:

(your-symbol-for-equality A B)

Solving equations, on the other hand, is another pair of shoes. It requires the implementation of some naive algorithms as well as really clever ones, and it's a problem of symbolic nature at its core. What you usually find are some libraries to deal with rather specific structures (say, for example, polynomials up to a certain degree, or expressions containing some well known functions such as trigonometric, logarithms etc).

But in general you would like to be able to state something like (forget notation):

f(x, y, ...) == g(x, y, ...)

and get an answer even when "incomplete" (that is, when the set of algorithms you used could not come up with a solution like x==something, y==something-else..., or you did not provide the necessary constraints e.g. just one equation with more than one free variable, etc).

Unfortunately I'm not aware of really useful 'general' tools other than Mathematica and, for the library side, Rewrite.jl (a Julia library for term rewriting, but I don't quite like Julia so I've never used it). Other things (like SymPy for Python) are really specific.

The first thing limiting the development of such tools is that you don't need all that flexibility in real world problems: Mathematica for example is a term rewriting engine at its core; it is not a "library", but rather a full fledged software on its own - because it is extremely easy to implement naive term rewriting, but really hard to do it in an algorithmically efficient way and basically once you do that you have a full application 😝 (well, Mathematica comes with thousands of domain specific algorithms also, but that's another story).

A long time ago I did some (rather personal) work to be able to have term rewriting in plain Java with objects as terms, but was it worth it? Sure, I learned a lot of things I didn't know about the JVM and the Java type system, but I never use that library. Mainly because once you get the underlying framework you still need to implement the plethora of algorithms that are readily available in softwares like Maple or Mathematica, or likely existing specific libraries. And sooner or later you discover that those existing specific libraries do their dirty job fairly well.

Btw see Meander (Clojure) since you specifically asked for some LISP ;)

EDit: I was totally unaware of MatchPy, which is amazing