How to make a function in terms of constants to inherit the attribute of being constant

I have defined two variables a and b:

SetAttributes[a, Constant];
SetAtributes[b, Constant];

I have defined a function c as follows:

c = a*b;

But this does not inherit the attribute of being constant:

In:Attributes[c]
Out: {}

How can I make Mathematica understands that c is a new constant and inherits the attributes of a and b ?

• I want to define a new constant. @infinitezero Nov 28 '21 at 13:29
• The question is, should attributes on symbols be combined/merged when one adds them or multiply or subtract them from each others? How about c=Exp[a]*b or infinity number of other combinations. It is not clear what happens. Help does not say that attributes get inherited or migrated after some operation. And which attributes should be inherited? All? some? This can get complicated very quickly. I think the semantics is not clear here. May be there is a way to force this by adding special code. Nov 28 '21 at 13:29
• I mean in your function you defined, you can add special code to obtain the Attributes of the symbols, check if both have Constant and then use the SetAttribute to force Constant attribute on the new symbol you want. I mean do it case by case basis. Something along these lines since it is not done automatically it looks like it. Notice that Constant in Mathematica does not mean you can't change the value of the variable. (as constant means in other languages), It just means the derivative w.r.t to anything is zero. I never use it myself. I never find a use for it. Nov 28 '21 at 13:42
• @Nasser Indeed, Constant is only meaningful for symbols that don't have numeric values. Nov 28 '21 at 14:28
• c evaluates to a*b, and c disappears from an expression. The attributes of c seem unimportant. Can you give a use-case in which the attributes are important to what you are doing? For instance Dt[Exp[c*x]] first becomes Dt[Exp[a*b*x]] and then Dt is evaluated (after c has disappeared from the expression). Nov 28 '21 at 18:29