Abstract
In principle, the design and implementation of quantum programming languages are the same essential tasks as for conventional (classical) programming languages. High-level programming constructs and compilation tools are structurally similar in both cases. The difference is mainly in the hardware machine executing the final code, which in the case of quantum programming languages is a quantum processor, i.e. a physical object obeying the laws of quantum mechanics. Therefore, special technical solutions are required to comply with such laws. In this paper, we show how static analysis can guarantee the correct implementation of quantum programs by introducing two data-flow analyses for detecting some ‘wrong’ uses of quantum variables. A compiler including such analyses would allow for a higher level of abstraction in the quantum language, relieving the programmer of low-level tasks such as the safe removal of temporary variables.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The ket notation \(\left| {\psi }\right\rangle \) is due to Dirac and represents the vector \((\alpha ,\beta )^T\) in linear algebraic notation.
- 2.
The Toffoli gate corresponds to a double controlled not; in particular we negate the target if both controllers are 1.
- 3.
Given two sets A and B,
.
- 4.
Functions that contain only classical gates, such as the NOT and the CNOT gates.
References
Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques, and Tools, 2nd edn. Addison-Wesley Longman Publishing Co., Inc., USA (2006)
Amy, M.: Formal Methods in Quantum Circuit Design. Ph.D. thesis, University of Waterloo (2019)
Amy, M., Gheorghiu, V.: staq–A full-stack quantum processing toolkit. Quantum Sci. Technol. 5(3), 034016 (2020)
Amy, M., Maslov, D., Mosca, M.: Polynomial-time T-depth optimization of Clifford+ T circuits via matroid partitioning. IEEE Trans. Comput. Aided Des. Integr. Circuits Syst. 33(10), 1476–1489 (2014)
Amy, M., Roetteler, M., Svore, K.M.: Verified compilation of space-efficient reversible circuits. In: Majumdar, R., Kunčak, V. (eds.) Computer Aided Verification, pp. 3–21. Springer International Publishing, Cham (2017)
Bichsel, B., Baader, M., Gehr, T., Vechev, M.: Silq: a high-level quantum language with safe uncomputation and intuitive semantics. In: Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 286–300. PLDI 2020, Association for Computing Machinery, New York, NY, USA (2020)
Bruni, R., Giacobazzi, R., Gori, R., Ranzato, F.: A correctness and incorrectness program logic. J. ACM 70(2), 1–45 (2023)
Chen, Y., Stade, Y.: Quantum Constant Propagation. In: International Static Analysis Symposium, pp. 164–189. Springer (2023)
Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Proceedings of the 4th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pp. 238–252 (1977)
Cross, A., et al.: OpenQASM 3: a broader and deeper quantum assembly language. ACM Trans. Quantum Comput. 3(3), 1–50 (2022)
Ding, Y., et al.: SQUARE: strategic quantum ancilla reuse for modular quantum programs via cost-effective uncomputation. In: 2020 ACM/IEEE 47th Annual International Symposium on Computer Architecture (ISCA), pp. 570–583 (2020)
Feng, Y., Li, S.: Abstract interpretation, Hoare logic, and incorrectness logic for quantum programs. Inf. Comput. 294, 105077 (2023)
Fu, P., Kishida, K., Ross, N.J., Selinger, P.: A Tutorial Introduction to Quantum Circuit Programming in Dependently Typed Proto-Quipper. In: Lanese, I., Rawski, M. (eds.) RC 2020. LNCS, vol. 12227, pp. 153–168. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-52482-1_9
Green, A.S., Lumsdaine, P.L., Ross, N.J., Selinger, P., Valiron, B.: Quipper: a scalable quantum programming language. In: Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 333–342. PLDI ’13, Association for Computing Machinery, New York, NY, USA (2013)
Guo, J., et al.: ISQ: towards a practical software stack for quantum programming. arXiv preprint arXiv:2205.03866 (2022)
Guo, J., et al.: ISQ: an integrated software stack for quantum programming. IEEE Trans. Quantum Eng. (2023)
Honda, K.: Analysis of quantum entanglement in quantum programs using stabilizer formalism. arXiv preprint arXiv:1511.01572 (2015)
Ittah, D., Häner, T., Kliuchnikov, V., Hoefler, T.: Enabling dataflow optimization for quantum programs. arXiv preprint arXiv:2101.11030 (2021)
JavadiAbhari, A., et al.: ScaffCC: a framework for compilation and analysis of quantum computing programs. In: Proceedings of the 11th ACM Conference on Computing Frontiers, pp. 1–10 (2014)
Johnston, E., Harrigan, N., Gimeno-Segovia, M.: Programming Quantum Computers: Essential Algorithms and Code Samples. O’Reilly Media, Incorporated (2019)
Kaul, M., Küchler, A., Banse, C.: A uniform representation of classical and quantum source code for static code analysis. In: 2023 IEEE International Conference on Quantum Computing and Engineering (QCE), vol. 1, pp. 1013–1019. IEEE (2023)
Kitaev, A.Y., Shen, A.H., Vyalyi, M.N.: Classical and Quantum Computation. American Mathematical Society, USA (2002)
Koch, M., Lawrence, A., Singhal, K., Sivarajah, S., Duncan, R.: GUPPY: pythonic quantum-classical programming. https://popl24.sigplan.org/details/planqc-2024-papers/8/GUPPY-Pythonic-Quantum-Classical-Programming
Matsakis, N.D., Klock, F.S.: The rust language. ACM SIGAda Ada Lett. 34(3), 103–104 (2014)
Nielsen, M.A., Chuang, I.L.: Quantum Computation and Quantum Information. Cambridge University Press, Cambridge (2010)
Nielson, F., Nielson, H.R., Hankin, C.: Principles of program analysis. Springer (2015)
O’Hearn, P.W.: Incorrectness logic. Proc. ACM Program. Lang. 4(POPL), 1–32 (2019)
Paltenghi, M., Pradel, M.: LintQ: a static analysis framework for qiskit quantum programs. arXiv preprint arXiv:2310.00718 (2023)
Paradis, A., Bichsel, B., Steffen, S., Vechev, M.: Unqomp: synthesizing uncomputation in quantum circuits. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, pp. 222–236. Association for Computing Machinery (2021)
Paradis, A., Bichsel, B., Vechev, M.: Reqomp: space-constrained uncomputation for quantum circuits (2022)
Parent, A., Roetteler, M., Svore, K.M.: Reversible circuit compilation with space constraints. arXiv preprint arXiv:1510.00377 (2015)
Parent, A., Roetteler, M., Svore, K.M.: REVS: a tool for space-optimized reversible circuit synthesis. In: Phillips, I., Rahaman, H. (eds.) Reversible Computation, pp. 90–101. Springer International Publishing (2017)
Paykin, J., Rand, R., Zdancewic, S.: QWIRE: a core language for quantum circuits. ACM SIGPLAN Notices 52(1), 846–858 (2017)
Peduri, A., Bhat, S., Grosser, T.: QSSA: an SSA-based IR for quantum computing. In: Proceedings of the 31st ACM SIGPLAN International Conference on Compiler Construction, pp. 2–14 (2022)
Perdrix, S.: Quantum patterns and types for entanglement and separability. Electron. Notes Theor. Comput. Sci. 170, 125–138 (2007)
Perdrix, S.: Quantum entanglement analysis based on abstract interpretation. In: International Static Analysis Symposium, pp. 270–282. Springer (2008)
Quantinuum: guppylang (2024). https://github.com/CQCL/guppylang
Rand, R., Paykin, J., Lee, D.H., Zdancewic, S.: ReQWIRE: reasoning about reversible quantum circuits. Electron. Proc. Theor. Comput. Sci. 287, 299–312 (2019)
Seidel, R., Bock, S., Tcholtchev, N., Hauswirth, M.: Qrisp: a framework for compilable high-level programming of gate-based quantum computers. PlanQC-Programming Languages for Quantum Computing (2022)
Seidel, R., Tcholtchev, N., Bock, S., Hauswirth, M.: Uncomputation in the qrisp high-level quantum programming framework. In: International Conference on Reversible Computation, pp. 150–165. Springer (2023)
Seidl, H., Wilhelm, R., Hack, S.: Compiler Design: Analysis and Transformation. Springer (2012)
Svore, K., et al.: Q#: enabling scalable quantum computing and development with a high-level DSL. In: Proceedings of the Real World Domain Specific Languages Workshop 2018. RWDSL2018, Association for Computing Machinery, New York, NY, USA (2018)
Voichick, F., Li, L., Rand, R., Hicks, M.: Qunity: a unified language for quantum and classical computing. Proc. ACM Programm. Lang. 7(POPL), 921–951 (2023)
Winskel, G.: The Formal Semantics of Programming Languages: An Introduction. MIT Press, Cambridge (1993)
Yamaguchi, F., Golde, N., Arp, D., Rieck, K.: Modeling and discovering vulnerabilities with code property graphs. In: 2014 IEEE Symposium on Security and Privacy, pp. 590–604. IEEE (2014)
Yu, N., Palsberg, J.: Quantum abstract interpretation. In: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation, pp. 542–558 (2021)
Zhao, P., Wu, X., Li, Z., Zhao, J.: Qchecker: detecting bugs in quantum programs via static analysis. In: 2023 IEEE/ACM 4th International Workshop on Quantum Software Engineering (Q-SE), pp. 50–57. IEEE (2023)
Funding
This work was partially supported by “INdAM - GNCS Project”, code CUP_E53C22001930001, and partially supported by the project SERICS (PE00000014) under the MUR National Recovery and Resilience Plan funded by the European Union - NextGenerationEU, and by PRIN2022PNRR “RAP-ARA” (PE6) - codice MUR: P2022HXNSC.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Assolini, N., Di Pierro, A., Mastroeni, I. (2025). Static Analysis of Quantum Programs. In: Giacobazzi, R., Gorla, A. (eds) Static Analysis. SAS 2024. Lecture Notes in Computer Science, vol 14995. Springer, Cham. https://doi.org/10.1007/978-3-031-74776-2_1
Download citation
DOI: https://doi.org/10.1007/978-3-031-74776-2_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-74775-5
Online ISBN: 978-3-031-74776-2
eBook Packages: Computer ScienceComputer Science (R0)