Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there Mathematica packages for presenting proofs/derivations?

When I write out a proof or derivation on paper I frequently make sign errors or drop terms as I move from one step to the next. I'd like to use Mathematica to save myself from these silly mistakes. I don't want Mathematica to solve the expression, I just want to use it carry out and display a series of algebraic manipulations. For a (trivial) example

In[111]:= MultBothSides[Equal[a_, b_], c_] := Equal[c a, c b];

In[112]:= expression = 2 a == a b

Out[112]= 2 a == a b

In[113]:= MultBothSides[expression, 1/a]

Out[113]= 2 == b

Can anyone point me to a package that would support this kind of manipulation?

Edit

Thanks for the input, not quite what I'm looking for though. The symbol manipulation isn't really the problem. I'm really looking for something that will make explicit the algebraic or mathematical justification of each step of a derivation. My goal here is really pedagogical.

like image 600
Charles E. Grant Avatar asked Aug 28 '09 03:08

Charles E. Grant


People also ask

Do companies use Mathematica?

We have data on 758 companies that use Mathematica. The companies using Mathematica are most often found in United States and in the Higher Education industry. Mathematica is most often used by companies with 1000-5000 employees and 200M-1000M dollars in revenue.

How do you use packages in Mathematica?

To load a package into Mathematica the package needs to be placed into a directory on the Mathematica $Path. After this it can be loaded with either Get (often this entered with the '<<' syntax) or Needs. If the package cannot be loaded then Mathematica will print an error.

What is new in Mathematica?

Mathematica 13 | December 2021 Reference » Version 13.0 adds a total of 117 completely new functions, but also many hundreds of updated and upgraded functions, several thousand bug fixes and small enhancements, and a host of new ideas to make the system ever easier and smoother to use.


2 Answers

I don't think you need a package. What you want to do is to manipulate each formula according to an inference rule. In MMa, you can model inference rules on a formula using transformations. So, if you have a formula f, you can apply an inference rule I by executing (my MMa syntax is 15 years rusty)

f ./ I 

to produce the next formula in your sequence.

MMa will of course try to simplify your formulas if they contain standard algebraic operators and terms, such as constant numbers and arithmetic operators. You can prevent MMa from applying its own "inference" rules by enclosing your formula in a Hold[...] form.

like image 22
Ira Baxter Avatar answered Sep 29 '22 02:09

Ira Baxter


Mathematica also provides a number of high-level functions for manipulating algebraic. Among these are Expand, Apart and Together, and Cancel, though there are quite a few more.

Also, for your specific example of applying the same transformation to both sides of an equation (that is, and expression with the head Equal), you can use the Thread function, which works just like your MultBothSides function, but with a great deal more generality.

In[1]:=  expression = 2 a == a b
Out[1]:= 2 a == a b

In[2]:=  Thread[expression /a, Equal]
Out[2]:= 2 == b

In[3]:=  Thread[expression - c, Equal]
Out[3]:= 2 a - c == a b - c

In either of the presented solutions, it should be relatively easy to see what the step entailed. If you want something a little more explicit, you can write your own function like so:

In[4]:=  ApplyToBothSides[f_, eq_Equal] := Map[f, eq]

In[5]:=  ApplyToBothSides[4 * #&, expression]
Out[5]:= 8 a == 4 a b

It's a generalization of your MultBothSides function that takes advantage of the fact that Map works on expressions with any head, not just head List. If you're trying to communicate with an audience that is unfamiliar with Mathematica, using these sorts of names can help you communicate more clearly. In a related vein, if you want to use replacement rules as suggested by Ira Baxter, it may be helpful to write out Replace or ReplaceAll instead of using the /. syntactic sugar.

In[6]:=  ReplaceAll[expression, a -> (x + y)]
Out[6]:= 2 (x + y) == b (x + y)

If you think it would be clearer to have the actual equation, instead of the variable name expression, in your input, and you're using the notebook interface, highlight the word expression with your mouse, call up the contextual menu, and select "Evaluate in Place".

The notebook interface is also a very pleasant environment for doing "literate programming", so you can also explain any steps that are not immediately obvious in words. I believe this is a good practice when writing mathematical proofs regardless of the medium.

like image 162
Pillsy Avatar answered Sep 29 '22 02:09

Pillsy