in reply to Perl and maths

I wanted to code something like this twenty years ago. It would have been cumbersome in C but I think a lot more do-able in a reasonable effort in Perl.

The task is really just a bunch of simple text (or tree) transforms, and a set of rules on how to apply them. It has very little to do with math itself.

There are several symbolic math engines out there, but they usually skip the step-by-step proof production. They simplify the expression as far as possible, and stop. If you have source code to these engines, it should be trivial to break it up into an iterative process, returning a set of proof production steps.

Each rule would have a pattern it looks for, and a replacement pattern. Rules should be simple and ordered. Rules should be scanned in the order they are asserted. (Hey, this is sounding more like Prolog now.) Each time you apply a rule successfully, you should start at the top again to see if it can be simplified further.

For maximum benefit, each production in the proof should also explain the mathematical rule it applied. For instance:

(a*(b+c)) (a*b + a*c) -- distribute a to terms b and c

(Sheepishly, I tried to look up an official name for that simple transform on Wolfram's site, but came up empty. Apparently, if it's not some tensor product of primoral eigenvalues, it's too simple for Wolfram to discuss.)

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^2: Perl and maths
by jimbojones (Friar) on Feb 15, 2005 at 15:10 UTC
    This is the distributive property of multiplication

    -j

Re^2: Perl and maths
by Jenda (Abbot) on Feb 15, 2005 at 22:52 UTC

    Yep, I once wrote something like this in Prolog as an assignment. I don't remember the details and the code is long lost though. Anyway if I were to do it again (and had to implement it myself) I'd definitely use Prolog again. It does take some time to get used to it since you really have to think differently than when using imperative languages, but once you get the twist it's great for this kind of tasks.

    Jenda
    We'd like to help you learn to help yourself
    Look around you, all you see are sympathetic eyes
    Stroll around the grounds until you feel at home
       -- P. Simon in Mrs. Robinson

Re^2: Perl and maths
by mrborisguy (Hermit) on Feb 15, 2005 at 17:33 UTC
    this almost looks like you are getting into sentential and predicate logic, although not quite, but it could be considered a basic proof to go from (5/3 + 7/13)/(5/2 - 3/7) to 1204/1131 (is that the right answer?). just a thought...