Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one get a list of Mathematica's built-in global rewrite rules?

I understand that over a thousand built-in rewrite rules in Mathematica populate the global rules table by default. Is there any way to get Mathematica to give a full or even partial list of those rules?

like image 242
sblom Avatar asked Jul 26 '11 06:07

sblom


1 Answers

The best way is to get a job at Wolfram Research.

Failing that, I think that for things not completely compiled into the kernel you can recover most of the rules/definitions. Look at

Attributes[fn]

where fn is the command that you're interested in. If it returns

{Protected, ReadProtected}

then there's something you can get a look at (although often it's just a MakeBoxes (formatting) definition or a AutoLoad/Stub type definition). To see what's there run

Unprotect[fn];
ClearAttributes[fn, ReadProtected];
??fn

Quite often you'll have to run an example of the command to load it if it was a stub. You'll also have to dig down from the user-facing commands to the back-end implementations. Eventually you'll most likely reach a core command that is compiled into the kernel that you can not see the details of.

I previously mentioned this in tips for creating Graph diagrams and it got a mention in What is in your Mathematica tool bag?.

An good example, with a nice bite-sized and digestible bit of code is Experimental`AngularSlider[] mentioned in Circular/Angular slider. I'll leave it up to you to look at the code produced.

Another example is something like BoxWhiskerChart, where you need to call it once in order to load all of the code. Then you see that BoxWhiskerChart proceeds to call Charting`iBoxWhiskerChart which you'll have to unprotect to look at, etc...

like image 118
Simon Avatar answered Sep 17 '22 13:09

Simon