WorksComputer Science
Executable Specifications as First-Class Independent Verification and Validation Artifacts for Quantum Information and Machine Learning
Abstract
Executable specifications make software assumptions explicit and checkable, yet their role in quantum information and machine learning (QIML) remains underexplored. We argue that executable specifications should be treated as first-class artifacts for independent verification and validation (IV&V) of QIML systems. Static analysis, testing, simulation, and runtime checking can provide evidence about QIML behavior, while Design by Contract shows that selected quantum-state, measurement, and statistical properties can be expressed as checkable conditions. However, adapting existing methods for specification inference and assessment from conventional and machine-learning software to QIML raises several challenges, notably limited evidence for deriving generalizable specifications, cross-stage and probabilistic behavior, repository-scale reasoning across hybrid workflows, and weak behavioral oracles. We characterize these challenges and identify research directions for QIML corpora, specification semantics, repository-level analysis, and specification assessment.
Introduction
Quantum Information and Machine Learning (QIML) applications combine classical data processing, parameterized quantum circuits, measurement, optimization, and model evaluation. Their correctness, therefore, depends on more than whether individual functions execute successfully. Assumptions about input dimensions, parameter domains, circuit construction, quantum states, measurement behavior, execution order, and classical-quantum interactions may all determine whether an execution is meaningful. When these assumptions remain implicit, a QIML program can execute without exposing the violation of an intended behavioral condition. Quantum software already provides several mechanisms for detecting problematic behavior. LintQ identifies quantum-specific programming problems through static analysis [14]; MorphQ uses metamorphic testing when conventional output oracles are unavailable [13]; and QuraTest incorporates quantum-specific properties into test generation (Ye et al. 2023). Quantum Design by Contract (DbC) further shows that properties of circuit states, measurements, and
statistical processing can be expressed as explicit assertions [18, 19]. Beyond runtime-oriented assertions, quantum Hoare logic provides a deductive foundation for specifying quantum preconditions and postconditions, and for reasoning about the partial and total correctness of quantum programs [21].
Figure 1 makes the underlying specification problem concrete. The classifier checks that the classical feature dimension matches the model input dimension, uses that input dimension to configure the parameterized quantum circuit, and maps measurement outcomes to a binary output. These relationships can be expressed as a precondition on the classical input, a cross-stage invariant relating the classical and quantum dimensions, and a postcondition on measurement interpretation. The example illustrates that relevant behavioral assumptions may be distributed across multiple stages of a QIML workflow rather than contained within a single function. Existing analysis and testing mechanisms address how such behavior can be checked, but a different question remains: what behavioral claim should those mechanisms evaluate? In deep-learning software, useful specifications already cover properties of data, model structure, and execution behavior [2, 1]. QIML adds cross-stage dependencies: data preparation may constrain circuit construction, parameterization may affect measurement behavior, and measurement results may guide downstream classical optimization. Thus, a behavioral obli-
Figure 1. Illustrative Qiskit Machine Learning classifier and its executable specifications. The example exposes a classical-input precondition, a cross-stage invariant relating classical and quantum dimensions, and a postcondition on the interpretation of measurements.
Copyright © 2026, Association for the Advancement of Artificial Intelligence (www.aaai.org). All rights reserved. gation may be established in one stage but become observable only in another, making function-local checks insufficient to capture it. IV&V therefore requires two separate things: a mechanism for checking the system and an explicit claim about the behavior that the mechanism is intended to check. Recent efforts such as DARPA’s Quantum Benchmarking Initiative underscore the growing importance of independent assessment for emerging quantum systems [7]. Static analysis, testing, simulation, and runtime checking can provide evidence about a system, but that evidence is informative only when the expected behavior is stated explicitly. A passing test, for example, shows that particular executions succeeded; it does not establish that all relevant assumptions or cross-stage obligations were satisfied. At the QIML software layer, IV&V therefore requires behavioral expectations that can be stated and inspected independently of the mechanism used to check them. Executable specifications provide a practical representation of such expectations.
Our position is that executable specifications should serve as first-class IV&V artifacts for QIML. We use the term to denote explicit behavioral requirements that can be assessed using suitable verification or validation mechanisms. Preconditions, postconditions, and invariants from Design by Contract (DbC) provide one practical vocabulary for expressing such requirements, but our position is not tied to a particular specification language or verifier. The central challenge is determining how to derive, represent, check, and validate these requirements in realistic QIML systems. Existing methods do not transfer directly because QIML provides limited evidence for deriving generalizable specifications, exhibits probabilistic and cross-stage behavior, spans hybrid repository-scale workflows, and often lacks strong behavioral oracles. These challenges motivate the specification-driven IV&V perspective developed in the remainder of the paper.
Executable Specifications as IV&V Artifacts
IV&V requires a behavioral reference against which an implementation can be assessed. Executable specifications can provide this reference for QIML by specifying verifiable conditions on inputs, measurement outcomes, and relationships across hybrid workflows. Quantum DbC frameworks demonstrate specifications over circuit states, measurements, and statistical post-processing [18, 19], while deep-learning contracts extend beyond function signatures to data, model, and execution properties [2, 1]. For QIML, such a scope is necessary because relevant behavior can span classical and quantum stages.
A specification states expected behavior, while verification provides evidence that it holds. Static analysis can reason about program structure [14], symbolic execution can search for counterexamples [3] (Shahriar, Ayon and Ahmed 2026), quantum-specific testing can exercise relevant behaviors (Ye et al. 2023), and metamorphic testing can help when direct output oracles are unavailable [13].
None of these mechanisms defines intended behavior by itself; IV&V therefore requires explicit behavioral claims assessed with evidence appropriate to each claim.
Quantum-state properties further complicate runtime checking. Measuring an intermediate state can collapse it, while the no-cloning principle prevents the retention of an arbitrary copy for independent inspection. Statistical assertions can assess expected properties over repeated measurements [8]. Projection-based assertions instead use projective measurements that preserve a satisfying state and can be transformed for execution on measurement-restricted quantum hardware (Li et al. 2020). Thus, for quantum-state properties, the checking mechanism and execution context form part of the evidence scope.
Executable Specifications in QIML
What should an executable specification express in a QIML application? Existing work suggests that relevant properties can occur at several points in a hybrid quantum–classical workflow. Rather than proposing a complete taxonomy, we use four representative classes to illustrate how such properties differ in scope and how they may be assessed.
Data and Parameter Preconditions. QIML components can impose relationships between classical inputs and parameterized quantum circuits. For example, quantum neural networks distinguish quantum parameters representing input data from trainable weights, and their execution depends on inputs and weights having dimensions compatible with the corresponding circuit parameters. These conditions can be expressed as preconditions on the data and parameter configuration. Similar concerns arise in deep-learning software, where contracts may involve data and model properties that are not captured by ordinary function signatures [2, 1].
Circuit and State Conditions. Some requirements concern the construction or state of the quantum computation itself. Circuit components such as feature maps and ansätze must be composed consistently, and relevant properties may depend on the circuit produced through a sequence of construction operations rather than on a single function call. Quantum DbC frameworks demonstrate that assertions can be written over the input and output states of quantum circuits and checked during simulator-based testing [18, 19]. This makes circuit- and state-level properties a distinct target for executable specification.
Measurement and Post-Processing Conditions. Other properties become observable only after quantum execution. Measurement results are consumed by classical post-processing and may therefore be subject to conditions that cannot be evaluated before the circuit is run. Yamaguchi et al. explicitly support assertions over the post-processing of measurement results [19], while QuraTest demonstrates that quantum-specific properties such as magnitude, phase, and entanglement can guide testing (Ye et al. 2023). These examples show that executable QIML specifications may need to describe properties of observed quantum behavior rather than only classical inputs and outputs.
| QIML Stage | Illustrative Behavioral Obligation | Specification Form | Possible Evidence |
| Data / parameters | Input data and parameter dimensions are compatible with the parameterized quantum circuit | Precondition | Classical runtime checking on simulator or hardware |
| Circuit / state | Circuit construction or quantum state satisfies an expected structural or state property | Precondition / postcondition | Simulator state inspection or hardware-feasible projection assertions |
| Measurement / post-processing | Measurement-derived results satisfy an expected property during classical post-processing | Postcondition | Finite-shot execution or testing on simulator or hardware |
| Cross-stage workflow | A condition established in one stage remains valid when consumed by a later classical or quantum stage | Precondition / postcondition / invariant | Integration testing or combined analysis, depending on evidence scope |
Table 1. Representative executable specification obligations in a QIML workflow. Different classes of properties may require different forms of evidence for assessment.
Cross-Stage Conditions. Finally, a relevant property may span more than one stage of a QIML workflow. Deep-learning contract research already shows that useful conditions can involve multiple APIs at different stages of an ML pipeline, as well as intermediate execution properties (Ahmed et al. [2]). QIML introduces an additional boundary between classical processing and quantum computation: data and parameters configure a circuit, quantum execution produces measurements, and those results are subsequently interpreted by classical software. Learning-specific obligations can also arise during variational optimization, where finite-shot noise affects gradient estimation under both parameter-shift and finite-difference methods ([11, 15]). An important question for QIML specification is, therefore, how to express and check properties whose assumptions are established in one stage but whose consequences become observable in another.
Open Research Challenges
Limited Evidence for Generalizable Specifications. Specification inference often depends on recurring evidence across large corpora. Nguyen et al. mined API preconditions from almost 120 million lines of Java by exploiting repeated guard conditions (Nguyen et al. [12]), while DLContract drew on documentation, prior studies, and buggy and correct deep-learning programs (Ahmed et al. [2]). In our preliminary search for repositories using qiskit-machine-learning and its major submodules, after applying repository deduplication, a 10-star threshold, and exclusions for forks and archived repositories, we obtained 44 candidate repositories. These repositories contain a median of 5.1 KLOC of Python code (IQR: 1.8–11.8 KLOC). This single-framework, restricted evidence base makes recurring behavioral patterns harder to identify and raises concerns about representativeness ([6, 5]).
QIML Properties Span Workflow Stages. QIML conditions may be established in one stage and observed in another. Data preparation can constrain circuit parameters, circuit construction can determine later behavior, and measurement results can affect downstream classical processing. Some properties may also require repeated observations rather than deterministic predicates. Existing quantum DbC work supports assertions over states, measurements, and post-processing ([18, 19]), but representing cross-stage QIML properties remains an open problem.
Repository-Scale Verification Remains Difficult. Executable specifications are useful only if they can be checked. SpecPyLot uses symbolic execution for Python contracts but does not model quantum operations or quantum-state semantics (Ayon and Ahmed [4]); SpecGen integrates formal verification (Ma et al. 2025), and Fun2Spec validates specifications through executable assertions and tests (Ugare et al. [17]). QIML adds circuit construction, quantum operations, measurements, and classical–quantum dependencies that general-purpose symbolic tools may not model directly. Future work must determine which properties admit conventional verification and which require quantum-specific analysis, simulation, or execution.
A Checkable Specification May Still Be Wrong. Executability does not guarantee that a specification captures intended behavior. Existing systems therefore use counterexamples, formal verification, tests, and manual assessment ([4, 17] (Ma et al. 2025)). Quantum testing similarly relies on alternative oracles when direct expected outputs are unavailable ([13] (Ye et al. 2023)). QIML IV&V, therefore, needs methods that validate both implementation conformance and the credibility of the specification itself.
Evidence Requirements for IV&V
Specification-driven IV&V should distinguish three dimensions: specification justification, implementation conformance, and evidence scope.
Specification Justification. A specification must be supported by a credible source of intent, such as an API requirement, mathematical constraint, framework semantics, or developer requirement. Executability alone is insufficient: a condition can be checkable but still encode the wrong be behavior. Existing specification-generation work therefore uses verification, counterexamples, tests, or manual assessment to evaluate generated specifications (Ma et al. 2025; Ayon and Ahmed 2026b; Ugare et al. 2026).
Implementation Conformance. The next question is whether the implementation satisfies the stated property. Different properties require different evidence: static analysis can check structural properties [14], symbolic execution can search for counterexamples [4], simulator-based assertions can check selected quantum-state and measurement properties [19], and quantum-specific or metamorphic testing can provide evidence when direct output oracles are unavailable (Ye et al. 2023; Paltenghi and Pradel 2023). A successful check supports conformance only within the scope explored.
Evidence Scope. Finally, IV&V must state where the evidence applies. Results obtained from symbolic exploration, simulation, finite-shot execution, or a particular backend do not automatically generalize beyond those conditions. Each result should therefore record the relevant assumptions, execution context, and coverage.
Taken together, specification justification, implementation conformance, and evidence scope should remain distinct. A successful check in one dimension should not be interpreted as establishing the others.
What Specification Driven QIML IV&V Requires
The challenges above point to four research directions. First, QIML needs representative corpora and benchmarks for specification inference and assessment. Second, specification representations must capture cross-stage classical–quantum properties and, where needed, statistical rather than purely Boolean conditions. Third, checking mechanisms should be matched to the property being assessed, since static analysis, symbolic reasoning, simulation, testing, and execution provide different forms of evidence (Paltenghi and Pradel 2024, 2023; Ye et al. 2023; Yamaguchi, Yoshioka, and Ishikawa 2025). Finally, QIML needs evaluation protocols that assess whether specifications are meaningful, checkable, and behaviorally discriminative. These capabilities should complement quantum benchmarking and hardware-level assessment by making behavioral claims, supporting evidence, and the scope of evidence explicit.
Evaluation Criteria
Future QIML specification methods should be evaluated on more than the number of conditions they generate or execute. We propose four criteria.
Semantic Support. A specification should be supported by identifiable evidence about intended behavior rather than by syntactic validity or plausibility alone. This is especially important when no reference specification is available.
Checkability. The evaluation should report which specifications can be assessed and how. Some properties may admit direct assertions or symbolic reasoning, whereas others may require simulation, repeated execution, or domain-specific analysis (Ma et al. 2025; Ayon and Ahmed 2026b; Yamaguchi, Yoshioka, and Ishikawa 2025).
Behavioral Discrimination. A useful specification should accept behavior consistent with its intended requirement while detecting relevant violations. Evaluation should therefore consider both overly restrictive specifications and specifications too weak to expose incorrect behavior. Mutation analysis can operationalize this distinction by introducing controlled behavioral faults and measuring whether the specification detects the resulting violations. Counterexample search, testing, metamorphic relations, and domain-specific test generation provide complementary ways to assess the same distinction (Ayon and Ahmed 2026b; Ma et al. 2025; Paltenghi and Pradel 2023; Ye et al. 2023).
Scope and Compositionality. Evaluation should report where a specification applies and whether locally checked properties can support claims across multiple workflow stages. This matters because QIML behavior may depend on relationships among data preparation, circuit construction, measurement, and downstream classical processing. Prior deep-learning contract work similarly shows that relevant conditions can span multiple APIs and stages of an ML pipeline [2]. Studies should therefore report both the covered execution contexts and whether assumptions and guarantees can be related across component boundaries.
Conclusion
QIML does not lack mechanisms for checking software behavior; it lacks a common layer of explicit behavioral claims around which those mechanisms can be interpreted. We argue that executable specifications can serve as first-class IV&V artifacts. Making this practical requires credible evidence for deriving specifications, representations that capture properties spanning classical and quantum stages, checking mechanisms matched to those properties, and validation methods that distinguish implementation conformance from the correctness of the specification itself. These requirements are particularly important when available evidence is limited, relevant behavior is cross-stage or probabilistic, and direct behavioral oracles are unavailable.
The goal is not a universal verifier for QIML. Rather, specification-driven IV&V should make each behavioral claim explicit, associate it with appropriate evidence, and state the conditions under which that evidence applies. Such an approach would allow static analysis, symbolic reasoning, simulation, testing, and execution-based evidence to contribute complementary assurance without treating any single mechanism as a complete correctness oracle. Executable specifications can therefore provide a practical foundation for making QIML behavioral claims independently assessable, comparable, and challengeable.
References
- [1]Ahmed, S.; Gao, H.; and Rajan, H. 2024. Inferring Data Preconditions from Deep Learning Models for Trustworthy Prediction in Deployment. In Proceedings of the IEEE/ACM 46th International Conference on Software Engineering, ICSE ’24, New York, NY, USA: Association for Computing Machinery. ISBN 9798400702174.arxiv.org/abs/2401.14628
- [2]Ahmed, S.; Imtiaz, S. M.; Khairunnesa, S. S.; Cruz, B. D.; and Rajan, H. 2023. Design by Contract for Deep Learning APIs. In Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering, ESEC/FSE 2023, 94–106. New York, NY, USA: Association for Computing Machinery. ISBN 9798400703270.DOI
- [3]Ayon, R. S.; and Ahmed, S. 2026a. AutoReSpec: A Framework for Generating Specification using Large Language Models. In Proceedings of the 2026 IEEE/ACM Third International Conference on AI Foundation Models and Software Engineering, FORGE ’26, 29–39. New York, NY, USA: Association for Computing Machinery. ISBN 9798400724770.
- [4]Ayon, R. S.; and Ahmed, S. 2026b. SpecPylot: Python Specification Generation with Large Language Models, 237–241. New York, NY, USA: Association for Computing Machinery. ISBN 9798400726361.DOI
- [5]Borges, H.; and Tulio Valente, M. 2018. What’s in a GitHub Star? Understanding Repository Starring Practices in a Social Coding Platform. Journal of Systems and Software, 146: 112–129.
- [6]Dabic, O.; Aghajani, E.; and Bavota, G. 2021. Sampling Projects in GitHub for MSR Studies. In 2021 IEEE/ACM 18th International Conference on Mining Software Repositories (MSR), 560–564.
- [7]Defense Advanced Research Projects Agency. 2026. QBI Topic Independent Verification and Validation (IV&V). DARPA-PA-26-02-01. Quantum Benchmarking Initiative, available via SAM.gov.
- [8]Huang, Y.; and Martonosi, M. 2019. Statistical assertions for validating patterns and finding bugs in quantum programs. In Proceedings of the 46th International Symposium on Computer Architecture, ISCA ’19, 541–553. New York, NY, USA: Association for Computing Machinery. ISBN 9781450366694.DOI
- [11]Mari, A.; Bromley, T. R.; and Killoran, N. 2021. Estimating the gradient and higher-order derivatives on quantum hardware. Phys. Rev. A, 103: 012405.DOI
- [12]Nguyen, H. A.; Dyer, J. R.; Nguyen, T. N.; and Rajan, H. 2014. Mining preconditions of APIs in large-scale code corpus. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, FSE 2014, 166–177. New York, NY, USA: Association for Computing Machinery. ISBN 978145030565.DOI
- [13]Paltenghi, M.; and Pradel, M. 2023. MorphQ: Metamorphic Testing of the Qiskit Quantum Computing Platform. In 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE), 2413–2424.DOI
- [14]Paltenghi, M.; and Pradel, M. 2024. Analyzing Quantum Programs with LintQ: A Static Analysis Framework for Qiskit. Proc. ACM Softw. Eng., 1(FSE).DOI
- [15]Piskor, T.; Reiner, J.-M.; Zanker, S.; Vogt, N.; Marthaler, M.; Wilhelm, F. K.; and Eich, F. G. 2022. Using gradient-based algorithms to determine ground-state energies on a quantum computer. Phys. Rev. A, 105: 062415.DOI
- [17]Ugare, S.; Suresh, T.; Misailovic, S.; and Vanegue, J. 2026. Fun2spec: Code Contract Synthesis At Scale. In Proceedings of the 34th ACM International Conference on the Foundations of Software Engineering, FSE Companion ’26, 914–925. New York, NY, USA: Association for Computing Machinery. ISBN 9798400726361.DOI
- [18]Yamaguchi, M.; and Yoshioka, N. 2023. Design by Contract Framework for Quantum Software. In 2023 IEEE/ACM 4th International Workshop on Quantum Software Engineering (Q-SE), 24–25.
- [19]Yamaguchi, M.; Yoshioka, N.; and Ishikawa, F. 2025. Practical Design by Contract Framework for Quantum Applications. In Proceedings of the 33rd ACM International Conference on the Foundations of Software Engineering, FSE Companion ’25, 1699–1709. New York, NY, USA: Association for Computing Machinery. ISBN 9798400712760.
- [21]Ying, M. 2012. Floyd–hoare logic for quantum programs. ACM Trans. Program. Lang. Syst., 33(6).DOI
