1use super::config::VerifierConfig;
4use scirs2_core::Complex64;
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7use std::time::{Duration, SystemTime};
8
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11pub enum VerificationStatus {
12 Verified,
14 Failed,
16 Incomplete,
18 Unknown,
20 InProgress,
22}
23
24#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub enum VerificationOutcome {
27 Satisfied,
29 Violated,
31 Unknown,
33 Timeout,
35 Error { message: String },
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41pub enum EvidenceType {
42 MatrixNorm,
44 Eigenvalue,
46 Fidelity,
48 Entanglement,
50 Purity,
52 TraceDistance,
54 Custom { name: String },
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct NumericalEvidence {
61 pub evidence_type: EvidenceType,
63 pub measured_value: f64,
65 pub expected_value: f64,
67 pub deviation: f64,
69 pub p_value: Option<f64>,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct ErrorBounds {
76 pub lower_bound: f64,
78 pub upper_bound: f64,
80 pub confidence_interval: f64,
82 pub standard_deviation: f64,
84}
85
86#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88pub enum ViolationSeverity {
89 Minor,
91 Moderate,
93 Major,
95 High,
97 Critical,
99}
100
101#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
103pub enum ProofStatus {
104 Proved,
106 Disproved,
108 Incomplete,
110 Timeout,
112 Error { message: String },
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct ProofStep {
119 pub description: String,
121 pub rule: String,
123 pub justification: String,
125 pub confidence: f64,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct FormalProof {
132 pub proof_tree: ProofTree,
134 pub steps: Vec<ProofStep>,
136 pub axioms_used: Vec<String>,
138 pub confidence: f64,
140 pub checksum: String,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize)]
146pub struct ProofTree {
147 pub root: ProofNode,
149 pub branches: Vec<Self>,
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize)]
155pub struct ProofNode {
156 pub goal: String,
158 pub rule: Option<String>,
160 pub subgoals: Vec<String>,
162 pub status: ProofStatus,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct Counterexample {
169 pub inputs: HashMap<String, f64>,
171 pub expected_output: String,
173 pub actual_output: String,
175 pub is_minimal: bool,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
181pub struct ProofComplexityMetrics {
182 pub step_count: usize,
184 pub proof_depth: usize,
186 pub axiom_count: usize,
188 pub memory_usage: usize,
190 pub verification_time: Duration,
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196pub struct ExecutionTrace {
197 pub states: Vec<QuantumState>,
199 pub transitions: Vec<StateTransition>,
201 pub length: usize,
203 pub properties: HashMap<String, f64>,
205}
206
207#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct QuantumState {
210 pub state_vector: Vec<Complex64>,
212 pub properties: HashMap<String, f64>,
214 pub timestamp: u64,
216 pub metadata: HashMap<String, String>,
218}
219
220#[derive(Debug, Clone, Serialize, Deserialize)]
222pub struct StateTransition {
223 pub source: usize,
225 pub target: usize,
227 pub operation: String,
229 pub probability: f64,
231 pub time: f64,
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
237pub struct StateSpaceStatistics {
238 pub total_states: usize,
240 pub total_transitions: usize,
242 pub max_path_length: usize,
244 pub avg_path_length: f64,
246 pub diameter: usize,
248 pub memory_usage: usize,
250}
251
252#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
254pub enum TestOutcome {
255 Pass,
257 Fail,
259 Skip,
261 Error { message: String },
263}
264
265#[derive(Debug, Clone, Serialize, Deserialize)]
267pub struct VerificationStatistics {
268 pub total_time: Duration,
270 pub properties_verified: usize,
272 pub invariants_checked: usize,
274 pub theorems_proved: usize,
276 pub success_rate: f64,
278 pub memory_usage: usize,
280 pub confidence_stats: ConfidenceStatistics,
282}
283
284#[derive(Debug, Clone, Serialize, Deserialize)]
286pub struct ConfidenceStatistics {
287 pub average_confidence: f64,
289 pub min_confidence: f64,
291 pub max_confidence: f64,
293 pub confidence_std_dev: f64,
295}
296
297#[derive(Debug, Clone, Serialize, Deserialize)]
299pub struct VerificationIssue {
300 pub issue_type: IssueType,
302 pub severity: IssueSeverity,
304 pub description: String,
306 pub location: Option<CircuitLocation>,
308 pub suggested_fix: Option<String>,
310 pub evidence: Vec<NumericalEvidence>,
312}
313
314#[derive(Debug, Clone, Serialize, Deserialize)]
316pub enum IssueType {
317 PropertyViolation,
319 InvariantViolation,
321 TheoremFailure,
323 ModelCheckFailure,
325 SymbolicExecutionError,
327 NumericalInstability,
329 PerformanceIssue,
331}
332
333#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
335pub enum IssueSeverity {
336 Low,
338 Medium,
340 High,
342 Critical,
344}
345
346#[derive(Debug, Clone, Serialize, Deserialize)]
348pub struct CircuitLocation {
349 pub gate_index: usize,
351 pub qubit_indices: Vec<usize>,
353 pub depth: usize,
355}
356
357#[derive(Debug, Clone, Serialize, Deserialize)]
359pub struct VerificationMetadata {
360 pub timestamp: SystemTime,
362 pub verifier_version: String,
364 pub scirs2_version: String,
366 pub config: VerifierConfig,
368 pub hardware_info: HashMap<String, String>,
370}
371
372#[derive(Debug, Clone, Serialize, Deserialize)]
374pub enum ProofStrategy {
375 Direct,
377 Contradiction,
379 Induction,
381 CaseAnalysis,
383 SymbolicComputation,
385 NumericalVerification,
387 StatisticalTesting,
389}
390
391#[derive(Debug, Clone, Serialize, Deserialize)]
393pub enum ErrorModel {
394 Depolarizing { probability: f64 },
396 BitFlip { probability: f64 },
398 PhaseFlip { probability: f64 },
400 AmplitudeDamping { gamma: f64 },
402 Custom {
404 description: String,
405 parameters: HashMap<String, f64>,
406 },
407}
408
409#[derive(Debug, Clone, Serialize, Deserialize)]
411pub enum ExpectedOutput {
412 ClassicalBits { bits: Vec<bool> },
414 QuantumState { state: Vec<Complex64> },
416 ProbabilityDistribution { probabilities: Vec<f64> },
418 MeasurementStats { mean: f64, variance: f64 },
420}
421
422#[derive(Debug, Clone, Serialize, Deserialize)]
424pub struct ProofObligation {
425 pub name: String,
427 pub preconditions: Vec<String>,
429 pub postconditions: Vec<String>,
431 pub proof_steps: Vec<ProofStep>,
433}
434
435#[derive(Debug, Clone, Serialize, Deserialize)]
437pub struct TestCase {
438 pub input: Vec<Complex64>,
440 pub expected_output: Vec<Complex64>,
442 pub description: String,
444 pub weight: f64,
446}
447
448#[derive(Debug, Clone, Serialize, Deserialize)]
450pub enum ComplexityClass {
451 Constant,
453 Logarithmic,
455 Linear,
457 Polynomial { degree: f64 },
459 Exponential,
461}