zxcalc / quantomatic

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

Add gates / hyperedges #203

Open hmillerbakewell opened 6 years ago

hmillerbakewell commented 6 years ago

ZXFest feature request

hmillerbakewell commented 6 years ago

Proposal for introducing gates:

We could view a gate as an ordered collection of wire vertices. Four lists of wire vertices, starting in the top left and proceeding clockwise. Data would be "name" (string) then "reflection marker" (bool) then "reflection flags" (int) then arities (int, int, int, int). Should we allow user data? We may need to examine more use-cases before we include that as an option.

Reflection flags: 1st-bit: reflection top-to-bottom 2nd-bit: reflection left-to-right

Arities: Top, right, bottom, left

Some names can be reserved; creating a gate with this name will infer the (arity, style, reflection) data from the Theory.

Expected problems:

Storage

Design

"Creating gate" and "bundle as gate"

Choosing "create a gate" on a given graph selection of wire vertices should make an intelligent guess at arity and create a gate there. "Bundle into a gate" on a graph should make an intelligent guess at arity based on the boundaries, prompt for a name, and create a bundle-unbundle rule.

Bundling and unbundling

The user should be able convert a graph to a gate, given a prompt for the name of the new gate. This should automatically create a rule that goes from gate-expanded to gate-as-gate. There should be a seperate directory for gates; consider having these auto-included in the rule application window for derivations.

Milestones

  1. Gates can exist internally
  2. Gates can be drawn on the UI
  3. Gates can be created on the UI
  4. Gates can be bundled and unbundled
  5. Gates can be matched on like any other vertex