Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Some of the big mysteries of Universe Mathematica for me is the application of UpValues. I know about this question and know the very poor Mathematica documentation on that. I'm very curious to know if someone that not Leonid uses this too.

Just to get some clue on how it works, I would like to know what's the difference between TagSet and UpSet. Can I say that UpSet is subset of TagSet?

For instance, I can say these examples are equivalent.

name[alien]^= "Alf"    
alien /: name[alien] = "Alf"

In what situations should I apply each case?

share|improve this question
In addition to the answer of @Mr.Wizard, I discussed exactly this issue in this answer (last subsection), where it is put in a wider context of UpValues in general. – Leonid Shifrin Jan 25 '13 at 10:11
Tks @LeonidShifrin, It was very helpfull. – Murta Jan 26 '13 at 0:52
Murta, I see that you did not Accept my answer. Is there something I can do to make it more satisfactory? – Mr.Wizard Feb 27 '13 at 8:31
No! Just forgot. Tks! – Murta Feb 27 '13 at 11:14
up vote 14 down vote accepted

UpSet and UpSetDelayed make multiple assignments:

UpSet associates an assignment with all the distinct symbols that occur either directly as arguments of lhs, or as the heads of arguments of lhs.

f[a[__], b[__], c[__]] ^:= "UpValue"

{HoldPattern[f[a[__], b[__], c[__]]] :> "UpValue"}

{HoldPattern[f[a[__], b[__], c[__]]] :> "UpValue"}

{HoldPattern[f[a[__], b[__], c[__]]] :> "UpValue"}

TagSet and TagSetDelayed make specific assignments:

k /: g[i[__], j[__], k[__]] := "UpValue"



{HoldPattern[g[i[__], j[__], k[__]]] :> "UpValue"}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.