-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Linearity checking for places (#290)
See #295 for context, the tests are at #293 The basic idea is that we implicitly "unfold" structs into tuples and then rely on the existing linearity checking logic. The example from #295 is checked as follows: ```python @guppy.struct class MyStruct: q1: qubit q2: qubit x: int def main(s: MyStruct): s_q1, s_q2, s_x = s q = h(s_q1) t = h(s_q2) y = s_x + s_x use((s_q1, s_q2, s_x)) # Error ... ``` This is implemented using the `leaf_places()` iterator that gives us the leaf projections of places with (nested) struct types.
- Loading branch information
Showing
3 changed files
with
167 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters