zxcalc / quantomatic

Quantomatic is a tool for doing automated graph rewriting.
http://quantomatic.github.io
152 stars 22 forks source link

simproc API : rewrite targeted w traversal #191

Open rossduncan opened 6 years ago

rossduncan commented 6 years ago

Add a new simproc combinator,

REWRITE_W_TRAVERSAL(rule, v, t) takes a rule, the name of a vertex 'v' within the rule (as a string), and a "traversal" object 't' which is (effectively) a sequence of targeting functions as per REWRITE_TARGETED. If the desired rewrite cannot be performed at the desired location, then move on the next target in the traversal.

I'm imagining that the traversal will either be stateful with some method called multiple times , or be required to return a continuation which produces the next target. Either way it will probably do a lot of computation upfront.

(Also consider the possibility to update a traversal object after the rewrite has been performed to avoid recomputing things already known.)