Subscript (using subscripted symbols)

I wrote a package that makes it very easy to do switch back an forth between treating subscripts as symbols and not. The package is largely based on code samples discussed here and the package can be downloaded from http://library.wolfram.com/database/MathSource/4268.

The next line is a slight variation of a tip David Bailey sent to the MathGroup. Using this code an 'a' with a non-negative integer subscript evaluates to a symbol where the character 'a' is concatenated with the symbol.

Now in the next line the first three in the list are symbols, and all the

rest are subscript expressions.

If this approach is used you must avoid using both and {a1, a2, a3} as symbols, since the former will evaluate to the latter. This is demonstrated in the next cell.

The next line shows that the rule above is stored in DownValues[Subscript].

Before continuing the above DownValue is cleared.

Colin Rose gave the following examples where Subscripts can be used in Mathematica Version 4 without using the notation palette.

In v4, you can generally use subscripted "variables" as if they were

symbols. The examples below work fine.

The most common problem occurs when people simultaneously try to use

(x) and In that case if one uses (x=7) then . This sort of problem is easily avoided by NOT simultaneously using x with

Carl Woll indicated we can give Subscript the attribute HoldFirst. As in the

example below.

Now we can have symbols t, without conflict.

Collin Rose also indicated use of Symbolize button in the notation palette

can result in problems as in the following example.

So far we don't have a problem.

We now have two sets of "identical" notation in use. We have as a Symbol in z1, and as subscript expression in z2. However, the elements in z1 and z2 look the same on screen. One must be careful to make sure this doesn't happen.

The steps used above to make symbols can be undone by using the RemoveSymbolize button in the FullNotation palette. It's under Symbolizations, StandardForm Symbolize.

Allan Hayes suggested the following to symbolize ALL subscript objects. Below we see that this will cause even to have the head Symbol. It's hard to imagine why one would use such a form, so this may be of little concern.

After using the code above to treat anything with any type of a subscript as a Symbol the use of Table below doesn't return the list .

Before we continue we might want to remove the rule that makes anything with

a subscript a symbol. The line after RemoveSymbolize demonstrates that the

rule was in fact removed.

A modification of code Jason Harris sent to the MathGroup is given below.

One variation of code Jason Harris sent to the MathGroup is shown below. The version below will treat (i) with a non-negative integer subscript as a symbol, but (i) with any other subscript is treated as a Subscript expression. This requires the use of some advanced features of the Notation palette. Documentation can be found at Notation:Definition:NotationPatternTag under Add-ons in the Help Browser.

Now (i) with a positive integer subscript is an symbol, while (i) with any

other subscript is a subscript expression.

Below is an expression rather than a Symbol, so the list is returned.

Short of manually entering the necessary cell expression there are two ways

to make the Symbolize expression above. Both are explained below.

• Use keyboard shortcuts:

Type [ESC]symb[ESC][TAB]i

Depress [CTRL]-

Type [ESC]pattwraper[ESC][TAB]_?IntegerTest

• Use the Notation palette:

You may need to patch a bug before this will work.

In some versions of the Notation package one of the needed buttons needs to be fixed before the code below will work.To fix the problem use an ASC text editor (MS-Word will work on a PC) to edit the file (FullNotationPalette.nb). The file is normally in the directory

WolframResearch\Mathematica\AddOns\ExtraPackages\Utilities.

Once you have the file open with a test editor delete the line shortly after the introductory comments containing the word CacheID. Then use the Find feature to locate "InsertPatternWrapper" which will bring you to the code segment below. Shortly after

StyleBox["InsertPatternWrapper", ...

Change the code

ButtonData:>TagBox["\[PlaceHolder]", NotationPatternTag, ...

to

ButtonData:>TagBox["\[SelectionPlaceHolder]", NotationPatternTag, ...

After making these minor edits save the file.

Enter the input cell below.

Select the entered expression, and depress the Symbolize[

■] button in the Notation palette.

Select the subscript

_?IntegerTest

Depress the button for "Full Notation Palette".

When the Full Notation Palette comes up select "InsertPatternWrapper" under

"Wrapper Boxes".

Unfortunately it's rather difficult to use the RemoveSymbolize button to

remove the definition above.

Another modification of code Jason Harris provided is given below.

Once the Notation package is loaded evaluating the next cell will define a

function (SubscriptSymbols) that takes a symbol as an argument, set up things

so that if one evaluates SubscriptSymbols[vari], then (vari) with a

non-negative integer subscript will be treated as a symbol.

The next cell causes (v) with non-negative integer subscript to be treated as

a Symbol.

In the next cell only has the Head Symbol.

Still another modification of code Jason Harris provided is given below.

After evaluating the cells above the first three symbols below have the head

Symbol while the others have the head Subscript.

Created by Mathematica (May 16, 2004)