hugr
hugr copied to clipboard
Confluently persistent Hugr data structure
Create a PersistentHugr struct that allows for non-destructive modifications of Hugrs. In other words https://github.com/CQCL/tket2/pull/773 should be moved/generalised to Hugr.
This is blocked by
- Agree on hugr mutation naming scheme (https://github.com/CQCL/hugr/issues/588)
- Generic rewrite over subject type (https://github.com/CQCL/hugr/issues/2052)
HugrInternalscannot expose theHugr, or elseHugrViewmust be implementable withoutHugrInternals(https://github.com/CQCL/hugr/issues/1926)
Suggested naming scheme (pending #588)
PatchGraph: a whole bunch ofPatches that are the result of applying rewrites, possibly conflicting. It's main purpose is to keep Rcs to thePatches that we are interested in during optimisation.PatchHistory: a subgraph ofPatchGraphthat only contains non-conflicting rewrites that can be applied to obtain aHugr.PersistentHugr: the main object users will actually interact with. ImplementsHugrView, but is immutable and fully persistent. Is in fact a wrapper aroundPatchHistory.Patch: a mostly module-internal struct that are the nodes of thePatchGraphandPatchHistory. It stores the location of an edit within its parentPatches, along with the new subgraph that replaces them. In the first version, the Patch will be aSimpleReplacement.