zxcalc / quantomatic

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

Rules that introduce variables should prompt the user for values #237

Closed hmillerbakewell closed 5 years ago

hmillerbakewell commented 6 years ago

For example the inverse spider law can introduce spiders with values like +- \beta. The matcher should be able to not suggest names that are not already taken, and prompt the user for the option of assigning values instead of new names.

hmillerbakewell commented 6 years ago

The current implementation runs like this: If the rule introduces variables that are not already present in the graph then it prompts for values.

Values are treated the same way as specifying data on a node normally; except that these are singular PhaseExpressions, not CompositeExpressions (so anything after any commas will be ignored.)

rossduncan commented 6 years ago

This is slightly bugged. Choosing 0 at the prompt generates the warning :

[info] 12:17:59: Could not parse -1 0 for type angle_expr, regex error: `/' expected but `0' found

which is also printed in the status bar.

rossduncan commented 6 years ago

How should this work in simprocs? Firstly this should be an option to switch on or off. If switched on, I propose that a default constant -- 0 -- be used in place of a fresh variable. A more sophisticated alternative would be for the simproc to define a call back which will provide the value to be used.