To change the assumptions dynamically, this can be used:
$Assumptions := b
b = {c > 0};
Refine[{c < 0, c == 0, c > 0}]
b = {c < 0};
Refine[{c < 0, c == 0, c > 0}]
If you need to evaluate the Print
every time, this can be used:
$Assumptions := Evaluate[b]
b = {c > 0, Unevaluated@Print[kount]};
kount = 1;
Refine[{c < 0, c == 0, c > 0}]
kount = 2;
Refine[{c < 0, c == 0, c > 0}]
b = {c < 0, Unevaluated@Print[kount]};
kount = 3;
Refine[{c < 0, c == 0, c > 0}]
kount = 4;
Refine[{c < 0, c == 0, c > 0}]
Beware, however, that using Print
in the assumptions could have unintended consequences. Print
returns Null
, so the effect will be that Null
will be assumed to be True
, as illustrated here:
$Assumptions = {Print["beware"]};
Refine[Null]
(* beware *)
(* True *)
$Assumptions
is special. The values you set are checked immediately. Try e.g.$Assumptions =.
and you'll see that after this it is still set toTrue
. Try$Assumptions = {False}
, and notice the warning message "Warning: one or more assumptions evaluated to False." $\endgroup$