expreduce icon indicating copy to clipboard operation
expreduce copied to clipboard

Order in which rules get applied

Open cekdahl opened this issue 7 years ago • 1 comments

The order in which rules get applied is different than in Wolfram Language in two notable cases. I think both of them should be fixed. Mathematica:

{a, b} /. {a -> b, b -> c, c -> d}
(* Out: {b, c} *)

Expreduce:

{a, b} /. {a -> b, b -> c, c -> d}
(* Out: {d, d} *)

When expreduce has applied the first replacement rule it continues to apply the subsequent replacement rules to the replaced parts. Replaced parts should preferably be impervious to subsequent replacement rules.

Then there is this, in Mathematica:

h[f, g] /. {f -> b, h[f, g] -> a}
(* Out: a *)

Note that it tries to replace the expression at the top level first before it moves on to lower levels. This is how I think expreduce should also proceed, level by level. Currently it proceeds rule by rule:

h[f, g] /. {f -> b, h[f, g] -> a}
(* Out: h[b, g] *)

h[f, g] /. {h[f, g] -> a, f -> b}
(* Out: a *)

cekdahl avatar Sep 10 '17 23:09 cekdahl

This issue is related to #37

cekdahl avatar Sep 11 '17 19:09 cekdahl