Skip to content

[QuantumInfo/StabilizerFormalism]: PauliGroups and CliffordGroups - #2008

Open
Sammybro11 wants to merge 9 commits into
leanprover-community:masterfrom
Sammybro11:cliffordgroup
Open

Sammybro11 wants to merge 9 commits into
leanprover-community:masterfrom
Sammybro11:cliffordgroup

Conversation

@Sammybro11

@Sammybro11 Sammybro11 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The module will define the Pauli group on n qubits, the Clifford group, and the stabilizer tableau formalism. The long-term
goal is the Gottesman-Knill theorem.

TODO:

  • Pauli Groups
  • Stabilizer Tableau // Sort of main construction is finished, can be sharpened when/where needed.

@github-actions github-actions Bot added the small label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for this pull-request (PR). If this is your first PR, welcome to the community!

While you wait for a review, note that you can review PRs too; reviewing is not restricted to maintainers. Our review guidelines explain what to look for.

Over time, contributions such as reviews, maintenance and documentation are recorded on contributions.physlib.io.

Three main points:

  • Comment -awaiting-author on its own line to remove that label from your PR.
  • Comment blocked-by-PR or -blocked-by-PR on its own line to add or remove that label, respectively.
  • The first review might take several days to arrive. If in doubt message on the Zulip.

For the author: Please read

Below is what will happen next. Please read carefully if you are not familiar with the process. You may open other PRs while this one is being reviewed, and can stack PRs on top of each other, so don't let these steps slow you down.

  1. Some automated checks will be run on your PR. You can see the results of these checks at the buttom of your PR page. If any of these checks fail, you will need to fix the issues before your PR can be merged. You can learn more about these here, including how to run them locally, which is sometimes quicker than relying on the GitHub Actions. If you have never had a PR merged before, you may have to wait for a reviewer to manually start these checks (this is for security).

  2. A reviewer will look at your PR and may ask you to make changes. This may happen a couple of days after you submit your PR, so you may need to be patient. But it should not be longer than that - if it is please bring it to the attention of the community on the Zulip. The level of review will depend on where your PR is submitted. If it is submitted to ./Physlib or ./QuantumInfo, the review will be more thorough than if it is submitted to ./PhyslibAlpha. You can find out more about what the review process is looking for in our review guidelines. If a reviewer adds an awaiting-author label to your PR, address the review comments, then please remove that label by adding a comment with -awaiting-author. This helps us keep track of reviews.

  3. The reviewer will either approve your PR, or request more changes (in which case we return to step 2). Once your PR is approved, it will be merged by a maintainer, this should happen shortly after approval, though you may get more comments at this stage.

Tip: The easiest way to get a fast review is to submit a PR that is small and self-contained, and has clear documentation explaining why things are the way they are in your changes.

If you have any problems or questions, please reach out to the community on the Zulip.

For reviewers: Summary of your PR

Found differences:
@@ Physlib.QuantumMechanics.Qubit.PauliGroups @@
+ module added Physlib.QuantumMechanics.Qubit.PauliGroups (+318 -0)
  namespaces PauliGroup
+ added def multi
+ added def pauliTensor
+ added def phaseSign
+ added def single
+ added def symplectic
+ added def symplecticSingle
+ added def tensorAll
+ added lemma commute_pauli_iff
+ added lemma commute_single_iff
+ added lemma multi_commute_iff
+ added lemma multi_eq_smul
+ added lemma not_commute_of_entry_ne
+ added lemma pauliFactor_isUnit
+ added lemma pauliTensor_comm_sign
+ added lemma phaseSign_add
+ added lemma phaseSign_eq_one_iff
+ added lemma phaseSign_prod
+ added lemma sigma_mul_sigma
+ added lemma single_commute_iff
+ added lemma tensorAll_mul
+ added lemma tensorAll_ne_zero
+ added lemma tensorAll_smul
@@ Physlib @@
! module modified Physlib (+1 -0)
24 differences

The declarations are found by reading the diff as text, without regard for namespaces, so a declaration whose keyword and name are on different lines is missed, and two declarations of the same name in different namespaces are listed as one. A change to a proof, or to the body of a definition, does not appear. See scripts/alpha/github/pr_summary.lean.

Summary of commit 1e3b5a5, remade whenever a commit is pushed.

@Sammybro11

Copy link
Copy Markdown
Contributor Author

Unsure of whether this definition of pauli should go to states/pure/qubit.lean since its for one qubit only, so I have just placed it in PauliGroups.lean since it's also explained in the same flow in wikipedia.


/-- Two single-qubit Pauli operators commute if and only if their symplectic product is
zero. -/
lemma pauliSingle_commute_iff (p q : ZMod 4) (x z x' z' : ZMod 2) :

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am struggling with how to do this efficiently. Open to suggestions :)

@jstoobysmith

Copy link
Copy Markdown
Member

I think it's better to try and integrate this with the quantum mechanics formalization in either the probabilistic theory or the main Physlib repo.

@Sammybro11

Copy link
Copy Markdown
Contributor Author

@jstoobysmith I think it's better to try and integrate this with the quantum mechanics formalization in either the probabilistic theory or the main Physlib repo.

I think that would be difficult right now, because the fundamentals are all based on group theory. Even in later stages most of the work with stabilizer formalism is done using homology. Only things which connect it back are the pauli operators. Otherwise it's very unrelated, from my point of view.
I would love to know ways on how it could be done tho, just seems like it won't be possible right now.

@jstoobysmith

Copy link
Copy Markdown
Member

@Sammybro11 Is there a reason why it is more possible in the ./QuantumInfo library compared to these other parts of the library?

@Sammybro11

Copy link
Copy Markdown
Contributor Author

@jstoobysmith I need alot of the matrix proofs already in Unitary for the lemmas, I could obviously place the whole new module in a Physlib section but then I would still be calling lemmas from the QuantumInfo Section, if that's not an issue then I don't see why we can't create the whole module in Physlib. At the end it's mostly going to be group theory lemmas with some unitary matrix lemmas being used.

P.S. Haven't made more progress yet due to exams, will get back on this in a week and half.

@jstoobysmith

Copy link
Copy Markdown
Member

There isn't much issue with this move, and ideally it is the end goal. It might just take a bit of time to do it properly (some of the results in QuantumInfo don't pass all the required linters of Physlib). If you would be up to do this, it would be great.
I think it is best if ./Physlib does not depend on ./QuantumInfo, but the other way around is fine.

@Sammybro11

Copy link
Copy Markdown
Contributor Author

Okay, I'll have to think a little about how much can be done using only Physlib, I'll let you know soon if it's possible to write the module without QuantumInfo

Add structure for `n` qubit Pauli Operator using Tableau of X and Z bit
strings, and added sympletic product of Operators to show commutation
later.
Starting with single qubit and then building on that to multiqubit.
Solving each case is just extremely painful. I think there has to be a
better way to do this, currentlu just walking through all 4x4=16 cases.
@github-actions github-actions Bot added large and removed medium labels Nov 25, 2026
Move the single-qubit Pauli group from QuantumInfo to Physlib along with
lemma for commutation and sympletic product.
@Sammybro11

Copy link
Copy Markdown
Contributor Author

@jstoobysmith I have moved it the QuantumMechanics/Qubit module, also this ended up working out really well because switching from Qubit to Fin 2 probably was a better choice it made the proofs much smaller.

I'll add N Qubit Pauli Operator in the PR and then I think it should be fine to merge. Other Unitary stuff can come in other PRs

Added an N qubit `tensorAll` and it's private along with a `pauliTensor`
for easier notation of the same.

Finally a main `multi_commute_iff` showing the final commutation
relation using sympletic products defined in `symplectic`.
@Sammybro11
Sammybro11 marked this pull request as ready for review December 4, 2026 02:15
@jstoobysmith

Copy link
Copy Markdown
Member

Would it be possible to use the existing definitions of Pauli matrices as operators acting on the qubit Hilbert space? Then we probably need to define, at some point, the Hilbert space for multi-qubits and the operators on those. I think if we do that, all of this will tie together much more nicely.

@jstoobysmith

Copy link
Copy Markdown
Member

awaiting-author

@github-actions github-actions Bot added the awaiting-author A reviewer has asked the author a question or requested changes label Dec 4, 2026
@Sammybro11

Copy link
Copy Markdown
Contributor Author

@jstoobysmith

Would it be possible to use the existing definitions of Pauli matrices as operators acting on the qubit Hilbert space? Then we probably need to define, at some point, the Hilbert space for multi-qubits and the operators on those. I think if we do that, all of this will tie together much more nicely.

I am hoping to build in that direction, I mentioned in earlier todos (before I removed it 😅) that I wanted to add mapping to unitary operators, but it would be a much larger task, especially due the N qubit operators and probably more suitable for another PR. I will keep this in mind and add a mapping to the hilbert space as well in that same PR in the future since they are very similar.

@Sammybro11

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author A reviewer has asked the author a question or requested changes label Dec 4, 2026
@jstoobysmith

Copy link
Copy Markdown
Member

I think it might be better to focus on those pull requests first before merging this one, because then we can write these operators in the correct language rather than them just being matrices. They can be actual operators on the qubit space, or we can restrict this pull request to just defining it for the single-qubit case and making sure that everything's up to date with the operators.

awaiting-author

@github-actions github-actions Bot added the awaiting-author A reviewer has asked the author a question or requested changes label Dec 4, 2026
@Sammybro11

Sammybro11 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor Author

ok I think I am confusing the ideas, do you mean somehthing like converting
multi p x z : Matrix (Fin n → Fin 2) (Fin n → Fin 2) ℂ this into something like

multiOp p x z : 𝓗[Fin n → Fin 2] →ₗ[ℂ] 𝓗[Fin n → Fin 2]
multiOp_toMatrix : (multiOp p x z).toMatrix basis basis = multi p x z
multiOp_commute_iff : Commute (multiOp ...) (multiOp ...) ↔ symplectic ... = 0

This would be relatively simple to do

-awaiting-author

@Sammybro11

Copy link
Copy Markdown
Contributor Author

-awaiting-author

@github-actions github-actions Bot removed the awaiting-author A reviewer has asked the author a question or requested changes label Dec 4, 2026
@Sammybro11

Copy link
Copy Markdown
Contributor Author

I mean this makes more sense to me for use, but it won't be the same as like creating the whole N qubit group by doing tensor on multiple 1 qubit operators in the hilbert space, when I tried that last time it was really weird.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants