newRPL - build 1255 released! [updated to 1299]
07-31-2019, 02:15 PM (This post was last modified: 07-31-2019 02:34 PM by Claudio L..)
Post: #549
 Claudio L. Senior Member Posts: 1,883 Joined: Dec 2013
RE: newRPL - build 1255 released! [updated to 1282]
(07-31-2019 10:45 AM)JoJo1973 Wrote:  Would it make sense to enforce assumptions at EVALuation?

Suppose I have this expression on the stack:

'X+1' whereas X:Z∞

Now I store 0.5 in X and EVAL the expression above. Should it error out with "Wrong Assumptions" or similar, or not?

I think that would count as "nagging" :-). If I want to store 0.5 in X without rewriting my expression the last thing I want is the calc complaining that I have to do more work...
On the other hand, those "hints" are more for the symbolic manipulation of the expression than for evaluation, I see them as 2 completely different things.

What you want is more in line with the "given that" operator |.
We could use the same operator and have 2 different uses:
'X+1 | X:→4' would enforce X=4. This fixed substitution would take place before any of EVAL, RULEAPPLY, or AUTOSIMPLIFY (notice that X:→4 is nothing but a rule being applied prior to any other manipulation) so X would automatically be treated as an even positive integer number and would match all the rules for numbers.
After EVAL, RULEAPPLY or AUTOSIMPLIFY, the rule X:→4 and the operator | will be removed from the expression, since the substitution will have been done.
'X+1 | X:Z∞' would simply add hints to variable X without providing a specific value. Hints work only during symbolic manipulation, if a global variable X exists during evaluation, it will be replaced and there's no reason to enforce the hints.
After EVAL, RULEAPPLY or AUTOSIMPLIFY, the hints will still be there, rules will be gone (already applied).

EDIT: Actually, the operator | should have 3 different uses: enforcing rules, applying hints and providing constraints (equalities, inequalities, etc.), like 'X+Y+1 | X+Y>4'
I think inequalities can be handled with variable substitution:
A>B means A-B>0 (here A and B are arbitrary expressions, not variables), so we can substitute a=A-B (here 'a' is a variable) and therefore apply a rule A:→a+B
Then we can hint a:R>0 so the rules engine knows all the information the inequality provided.
Finally, after all is done (RULEAPPLY, AUTOSIMPLIFY, whatever), apply the inverse substitution: a:→A-B
 « Next Oldest | Next Newest »