@nahisaho/musubix-lean 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/converters/EarsToLeanConverter.d.ts +61 -0
- package/dist/converters/EarsToLeanConverter.d.ts.map +1 -0
- package/dist/converters/EarsToLeanConverter.js +300 -0
- package/dist/converters/EarsToLeanConverter.js.map +1 -0
- package/dist/converters/TypeScriptSpecifier.d.ts +63 -0
- package/dist/converters/TypeScriptSpecifier.d.ts.map +1 -0
- package/dist/converters/TypeScriptSpecifier.js +307 -0
- package/dist/converters/TypeScriptSpecifier.js.map +1 -0
- package/dist/converters/index.d.ts +7 -0
- package/dist/converters/index.d.ts.map +1 -0
- package/dist/converters/index.js +7 -0
- package/dist/converters/index.js.map +1 -0
- package/dist/environment/LeanEnvironmentDetector.d.ts +57 -0
- package/dist/environment/LeanEnvironmentDetector.d.ts.map +1 -0
- package/dist/environment/LeanEnvironmentDetector.js +221 -0
- package/dist/environment/LeanEnvironmentDetector.js.map +1 -0
- package/dist/environment/LeanProjectInitializer.d.ts +49 -0
- package/dist/environment/LeanProjectInitializer.d.ts.map +1 -0
- package/dist/environment/LeanProjectInitializer.js +232 -0
- package/dist/environment/LeanProjectInitializer.js.map +1 -0
- package/dist/environment/index.d.ts +7 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +7 -0
- package/dist/environment/index.js.map +1 -0
- package/dist/errors.d.ts +141 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +254 -0
- package/dist/errors.js.map +1 -0
- package/dist/hybrid/HybridVerifier.d.ts +113 -0
- package/dist/hybrid/HybridVerifier.d.ts.map +1 -0
- package/dist/hybrid/HybridVerifier.js +247 -0
- package/dist/hybrid/HybridVerifier.js.map +1 -0
- package/dist/hybrid/index.d.ts +6 -0
- package/dist/hybrid/index.d.ts.map +1 -0
- package/dist/hybrid/index.js +6 -0
- package/dist/hybrid/index.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/LeanFileGenerator.d.ts +70 -0
- package/dist/infrastructure/LeanFileGenerator.d.ts.map +1 -0
- package/dist/infrastructure/LeanFileGenerator.js +253 -0
- package/dist/infrastructure/LeanFileGenerator.js.map +1 -0
- package/dist/infrastructure/LeanRunner.d.ts +93 -0
- package/dist/infrastructure/LeanRunner.d.ts.map +1 -0
- package/dist/infrastructure/LeanRunner.js +296 -0
- package/dist/infrastructure/LeanRunner.js.map +1 -0
- package/dist/infrastructure/index.d.ts +7 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +7 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/integration/LeanIntegration.d.ts +138 -0
- package/dist/integration/LeanIntegration.d.ts.map +1 -0
- package/dist/integration/LeanIntegration.js +352 -0
- package/dist/integration/LeanIntegration.js.map +1 -0
- package/dist/proof/ProofGenerator.d.ts +53 -0
- package/dist/proof/ProofGenerator.d.ts.map +1 -0
- package/dist/proof/ProofGenerator.js +324 -0
- package/dist/proof/ProofGenerator.js.map +1 -0
- package/dist/proof/ReProverClient.d.ts +58 -0
- package/dist/proof/ReProverClient.d.ts.map +1 -0
- package/dist/proof/ReProverClient.js +260 -0
- package/dist/proof/ReProverClient.js.map +1 -0
- package/dist/proof/index.d.ts +7 -0
- package/dist/proof/index.d.ts.map +1 -0
- package/dist/proof/index.js +7 -0
- package/dist/proof/index.js.map +1 -0
- package/dist/reporting/VerificationReporter.d.ts +89 -0
- package/dist/reporting/VerificationReporter.d.ts.map +1 -0
- package/dist/reporting/VerificationReporter.js +296 -0
- package/dist/reporting/VerificationReporter.js.map +1 -0
- package/dist/reporting/index.d.ts +6 -0
- package/dist/reporting/index.d.ts.map +1 -0
- package/dist/reporting/index.js +6 -0
- package/dist/reporting/index.js.map +1 -0
- package/dist/traceability/TraceabilityManager.d.ts +104 -0
- package/dist/traceability/TraceabilityManager.d.ts.map +1 -0
- package/dist/traceability/TraceabilityManager.js +299 -0
- package/dist/traceability/TraceabilityManager.js.map +1 -0
- package/dist/traceability/index.d.ts +6 -0
- package/dist/traceability/index.d.ts.map +1 -0
- package/dist/traceability/index.js +6 -0
- package/dist/traceability/index.js.map +1 -0
- package/dist/types.d.ts +466 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Custom error classes for musubix-lean package
|
|
3
|
+
* @module @nahisaho/musubix-lean/errors
|
|
4
|
+
* @traceability REQ-LEAN-ERR-001, REQ-LEAN-ERR-002
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base error class for Lean-related errors
|
|
8
|
+
*/
|
|
9
|
+
export class LeanError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
cause;
|
|
12
|
+
constructor(message, code, cause) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.cause = cause;
|
|
16
|
+
this.name = 'LeanError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown when Lean 4 is not installed
|
|
21
|
+
* @traceability REQ-LEAN-ERR-001
|
|
22
|
+
*/
|
|
23
|
+
export class LeanNotFoundError extends LeanError {
|
|
24
|
+
constructor(os) {
|
|
25
|
+
const instructions = getInstallInstructions(os);
|
|
26
|
+
super(`Lean 4 is not installed on this system.\n\n${instructions}`, 'LEAN_NOT_FOUND');
|
|
27
|
+
this.name = 'LeanNotFoundError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error thrown when Lean version is below minimum required
|
|
32
|
+
* @traceability REQ-LEAN-ERR-001
|
|
33
|
+
*/
|
|
34
|
+
export class LeanVersionError extends LeanError {
|
|
35
|
+
required;
|
|
36
|
+
actual;
|
|
37
|
+
constructor(required, actual) {
|
|
38
|
+
super(`Lean version ${actual} is below minimum required version ${required}. Please upgrade Lean 4.`, 'LEAN_VERSION_MISMATCH');
|
|
39
|
+
this.required = required;
|
|
40
|
+
this.actual = actual;
|
|
41
|
+
this.name = 'LeanVersionError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when EARS-to-Lean conversion fails
|
|
46
|
+
* @traceability REQ-LEAN-ERR-002
|
|
47
|
+
*/
|
|
48
|
+
export class EarsConversionError extends LeanError {
|
|
49
|
+
requirementId;
|
|
50
|
+
reason;
|
|
51
|
+
constructor(requirementId, reason) {
|
|
52
|
+
super(`Failed to convert requirement ${requirementId} to Lean: ${reason}`, 'EARS_CONVERSION_FAILED');
|
|
53
|
+
this.requirementId = requirementId;
|
|
54
|
+
this.reason = reason;
|
|
55
|
+
this.name = 'EarsConversionError';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error thrown when EARS parsing fails
|
|
60
|
+
*/
|
|
61
|
+
export class EarsParseError extends LeanError {
|
|
62
|
+
text;
|
|
63
|
+
reason;
|
|
64
|
+
constructor(text, reason) {
|
|
65
|
+
super(`Failed to parse EARS requirement: ${reason}`, 'EARS_PARSE_FAILED');
|
|
66
|
+
this.text = text;
|
|
67
|
+
this.reason = reason;
|
|
68
|
+
this.name = 'EarsParseError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Error thrown when TypeScript specification fails
|
|
73
|
+
*/
|
|
74
|
+
export class TypeScriptSpecificationError extends LeanError {
|
|
75
|
+
functionName;
|
|
76
|
+
reason;
|
|
77
|
+
constructor(functionName, reason) {
|
|
78
|
+
super(`Failed to specify TypeScript function ${functionName}: ${reason}`, 'TS_SPECIFICATION_FAILED');
|
|
79
|
+
this.functionName = functionName;
|
|
80
|
+
this.reason = reason;
|
|
81
|
+
this.name = 'TypeScriptSpecificationError';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error thrown when proof generation times out
|
|
86
|
+
* @traceability REQ-LEAN-PERF-002
|
|
87
|
+
*/
|
|
88
|
+
export class ProofTimeoutError extends LeanError {
|
|
89
|
+
theoremName;
|
|
90
|
+
timeout;
|
|
91
|
+
constructor(theoremName, timeout) {
|
|
92
|
+
super(`Proof search for theorem '${theoremName}' timed out after ${timeout}ms`, 'PROOF_TIMEOUT');
|
|
93
|
+
this.theoremName = theoremName;
|
|
94
|
+
this.timeout = timeout;
|
|
95
|
+
this.name = 'ProofTimeoutError';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Error thrown when proof generation fails
|
|
100
|
+
*/
|
|
101
|
+
export class ProofGenerationError extends LeanError {
|
|
102
|
+
theoremName;
|
|
103
|
+
reason;
|
|
104
|
+
constructor(theoremName, reason) {
|
|
105
|
+
super(`Failed to generate proof for theorem '${theoremName}': ${reason}`, 'PROOF_GENERATION_FAILED');
|
|
106
|
+
this.theoremName = theoremName;
|
|
107
|
+
this.reason = reason;
|
|
108
|
+
this.name = 'ProofGenerationError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Error thrown when ReProver connection fails
|
|
113
|
+
* @traceability REQ-LEAN-REPROVER-001
|
|
114
|
+
*/
|
|
115
|
+
export class ReProverConnectionError extends LeanError {
|
|
116
|
+
endpoint;
|
|
117
|
+
reason;
|
|
118
|
+
constructor(endpoint, reason) {
|
|
119
|
+
super(`Failed to connect to ReProver at ${endpoint}: ${reason}`, 'REPROVER_CONNECTION_FAILED');
|
|
120
|
+
this.endpoint = endpoint;
|
|
121
|
+
this.reason = reason;
|
|
122
|
+
this.name = 'ReProverConnectionError';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Error thrown when Lean file generation fails
|
|
127
|
+
*/
|
|
128
|
+
export class LeanFileGenerationError extends LeanError {
|
|
129
|
+
filePath;
|
|
130
|
+
reason;
|
|
131
|
+
constructor(filePath, reason) {
|
|
132
|
+
super(`Failed to generate Lean file at ${filePath}: ${reason}`, 'LEAN_FILE_GENERATION_FAILED');
|
|
133
|
+
this.filePath = filePath;
|
|
134
|
+
this.reason = reason;
|
|
135
|
+
this.name = 'LeanFileGenerationError';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Error thrown when Lean execution fails
|
|
140
|
+
*/
|
|
141
|
+
export class LeanExecutionError extends LeanError {
|
|
142
|
+
command;
|
|
143
|
+
exitCodeOrMessage;
|
|
144
|
+
stderr;
|
|
145
|
+
constructor(command, exitCodeOrMessage, stderr) {
|
|
146
|
+
const message = typeof exitCodeOrMessage === 'number'
|
|
147
|
+
? `Lean command '${command}' failed with exit code ${exitCodeOrMessage}: ${stderr}`
|
|
148
|
+
: `Lean command '${command}' failed: ${exitCodeOrMessage}. ${stderr}`;
|
|
149
|
+
super(message, 'LEAN_EXECUTION_FAILED');
|
|
150
|
+
this.command = command;
|
|
151
|
+
this.exitCodeOrMessage = exitCodeOrMessage;
|
|
152
|
+
this.stderr = stderr;
|
|
153
|
+
this.name = 'LeanExecutionError';
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get installation instructions for the given OS
|
|
158
|
+
* @traceability REQ-LEAN-ERR-001
|
|
159
|
+
*/
|
|
160
|
+
function getInstallInstructions(os) {
|
|
161
|
+
const elanUrl = 'https://github.com/leanprover/elan';
|
|
162
|
+
switch (os.toLowerCase()) {
|
|
163
|
+
case 'linux':
|
|
164
|
+
return `To install Lean 4 on Linux:
|
|
165
|
+
1. Install elan (Lean version manager):
|
|
166
|
+
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh
|
|
167
|
+
2. Restart your terminal or run: source ~/.profile
|
|
168
|
+
3. Install Lean 4: elan default leanprover/lean4:stable
|
|
169
|
+
|
|
170
|
+
For more information, visit: ${elanUrl}`;
|
|
171
|
+
case 'darwin':
|
|
172
|
+
case 'macos':
|
|
173
|
+
return `To install Lean 4 on macOS:
|
|
174
|
+
1. Install elan (Lean version manager):
|
|
175
|
+
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh
|
|
176
|
+
Or via Homebrew: brew install elan-init
|
|
177
|
+
2. Restart your terminal
|
|
178
|
+
3. Install Lean 4: elan default leanprover/lean4:stable
|
|
179
|
+
|
|
180
|
+
For more information, visit: ${elanUrl}`;
|
|
181
|
+
case 'win32':
|
|
182
|
+
case 'windows':
|
|
183
|
+
return `To install Lean 4 on Windows:
|
|
184
|
+
1. Download the elan installer from: ${elanUrl}/releases
|
|
185
|
+
2. Run the installer and follow the prompts
|
|
186
|
+
3. Restart your terminal
|
|
187
|
+
4. Install Lean 4: elan default leanprover/lean4:stable
|
|
188
|
+
|
|
189
|
+
For more information, visit: ${elanUrl}`;
|
|
190
|
+
default:
|
|
191
|
+
return `To install Lean 4:
|
|
192
|
+
1. Visit ${elanUrl} for installation instructions
|
|
193
|
+
2. Install elan (Lean version manager)
|
|
194
|
+
3. Run: elan default leanprover/lean4:stable`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export { getInstallInstructions };
|
|
198
|
+
/**
|
|
199
|
+
* Error thrown when Lean environment detection fails
|
|
200
|
+
*/
|
|
201
|
+
export class LeanEnvironmentError extends LeanError {
|
|
202
|
+
constructor(message) {
|
|
203
|
+
super(message, 'LEAN_ENVIRONMENT_ERROR');
|
|
204
|
+
this.name = 'LeanEnvironmentError';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Error thrown when Lean conversion fails
|
|
209
|
+
*/
|
|
210
|
+
export class LeanConversionError extends LeanError {
|
|
211
|
+
constructor(message) {
|
|
212
|
+
super(message, 'LEAN_CONVERSION_ERROR');
|
|
213
|
+
this.name = 'LeanConversionError';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Error thrown when Lean verification fails
|
|
218
|
+
*/
|
|
219
|
+
export class LeanVerificationError extends LeanError {
|
|
220
|
+
errors;
|
|
221
|
+
constructor(message, errors = []) {
|
|
222
|
+
super(message, 'LEAN_VERIFICATION_ERROR');
|
|
223
|
+
this.name = 'LeanVerificationError';
|
|
224
|
+
this.errors = errors;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Error thrown when Lean proof generation fails
|
|
229
|
+
*/
|
|
230
|
+
export class LeanProofError extends LeanError {
|
|
231
|
+
constructor(message) {
|
|
232
|
+
super(message, 'LEAN_PROOF_ERROR');
|
|
233
|
+
this.name = 'LeanProofError';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Error thrown when Lean integration fails
|
|
238
|
+
*/
|
|
239
|
+
export class LeanIntegrationError extends LeanError {
|
|
240
|
+
constructor(message) {
|
|
241
|
+
super(message, 'LEAN_INTEGRATION_ERROR');
|
|
242
|
+
this.name = 'LeanIntegrationError';
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Error thrown when ReProver fails
|
|
247
|
+
*/
|
|
248
|
+
export class ReProverError extends LeanError {
|
|
249
|
+
constructor(message) {
|
|
250
|
+
super(message, 'REPROVER_ERROR');
|
|
251
|
+
this.name = 'ReProverError';
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGhB;IACA;IAHlB,YACE,OAAe,EACC,IAAY,EACZ,KAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,UA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
/**
|
|
2
|
+
* @fileoverview Hybrid verifier combining runtime tests and formal verification
|
|
3
|
+
* @module @nahisaho/musubix-lean/hybrid
|
|
4
|
+
* @traceability REQ-LEAN-HYBRID-001 to REQ-LEAN-HYBRID-003
|
|
5
|
+
*/
|
|
6
|
+
import { Result } from 'neverthrow';
|
|
7
|
+
import type { HybridVerificationResult, LeanTheorem, LeanConfig } from '../types.js';
|
|
8
|
+
import type { VerificationReporter } from '../reporting/VerificationReporter.js';
|
|
9
|
+
import type { TraceabilityManager } from '../traceability/TraceabilityManager.js';
|
|
10
|
+
import { LeanVerificationError } from '../errors.js';
|
|
11
|
+
/**
|
|
12
|
+
* Runtime test result
|
|
13
|
+
*/
|
|
14
|
+
export interface RuntimeTestResult {
|
|
15
|
+
functionId: string;
|
|
16
|
+
passed: boolean;
|
|
17
|
+
testCount: number;
|
|
18
|
+
failedTests: string[];
|
|
19
|
+
coverage: number;
|
|
20
|
+
duration: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Formal verification result
|
|
24
|
+
*/
|
|
25
|
+
export interface FormalVerificationResult {
|
|
26
|
+
theoremId: string;
|
|
27
|
+
proved: boolean;
|
|
28
|
+
proof?: string;
|
|
29
|
+
errors: string[];
|
|
30
|
+
duration: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Coverage metrics for hybrid verification
|
|
34
|
+
*/
|
|
35
|
+
export interface HybridCoverage {
|
|
36
|
+
runtimeCoverage: number;
|
|
37
|
+
formalCoverage: number;
|
|
38
|
+
combinedCoverage: number;
|
|
39
|
+
uncoveredPaths: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hybrid verification strategy
|
|
43
|
+
*/
|
|
44
|
+
export type VerificationStrategy = 'runtime-first' | 'formal-first' | 'parallel' | 'adaptive';
|
|
45
|
+
/**
|
|
46
|
+
* Combines runtime testing with formal proof verification
|
|
47
|
+
* @traceability REQ-LEAN-HYBRID-001
|
|
48
|
+
*/
|
|
49
|
+
export declare class HybridVerifier {
|
|
50
|
+
private runner;
|
|
51
|
+
private generator;
|
|
52
|
+
private _reporter?;
|
|
53
|
+
private traceability?;
|
|
54
|
+
private strategy;
|
|
55
|
+
constructor(config?: Partial<LeanConfig>);
|
|
56
|
+
/**
|
|
57
|
+
* Set verification reporter
|
|
58
|
+
*/
|
|
59
|
+
setReporter(reporter: VerificationReporter): void;
|
|
60
|
+
/**
|
|
61
|
+
* Set traceability manager
|
|
62
|
+
*/
|
|
63
|
+
setTraceabilityManager(manager: TraceabilityManager): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set verification strategy
|
|
66
|
+
*/
|
|
67
|
+
setStrategy(strategy: VerificationStrategy): void;
|
|
68
|
+
/**
|
|
69
|
+
* Verify a function with hybrid approach
|
|
70
|
+
* @traceability REQ-LEAN-HYBRID-002
|
|
71
|
+
*/
|
|
72
|
+
verify(functionId: string, runtimeTests: () => RuntimeTestResult, theorem: LeanTheorem): Promise<Result<HybridVerificationResult, LeanVerificationError>>;
|
|
73
|
+
/**
|
|
74
|
+
* Run formal verification for a theorem
|
|
75
|
+
*/
|
|
76
|
+
private runFormalVerification;
|
|
77
|
+
/**
|
|
78
|
+
* Build hybrid verification result
|
|
79
|
+
*/
|
|
80
|
+
private buildResult;
|
|
81
|
+
/**
|
|
82
|
+
* Calculate combined coverage metrics
|
|
83
|
+
* @traceability REQ-LEAN-HYBRID-003
|
|
84
|
+
*/
|
|
85
|
+
private calculateCoverage;
|
|
86
|
+
/**
|
|
87
|
+
* Determine combined verification status
|
|
88
|
+
*/
|
|
89
|
+
private determineCombinedStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Check if theorem is complex (heuristic)
|
|
92
|
+
*/
|
|
93
|
+
private isComplexTheorem;
|
|
94
|
+
/**
|
|
95
|
+
* Batch verify multiple functions
|
|
96
|
+
*/
|
|
97
|
+
verifyBatch(items: Array<{
|
|
98
|
+
functionId: string;
|
|
99
|
+
runtimeTests: () => RuntimeTestResult;
|
|
100
|
+
theorem: LeanTheorem;
|
|
101
|
+
}>): Promise<Map<string, HybridVerificationResult>>;
|
|
102
|
+
/**
|
|
103
|
+
* Get verification statistics
|
|
104
|
+
*/
|
|
105
|
+
getStatistics(results: Map<string, HybridVerificationResult>): {
|
|
106
|
+
total: number;
|
|
107
|
+
verified: number;
|
|
108
|
+
partial: number;
|
|
109
|
+
failed: number;
|
|
110
|
+
averageCoverage: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=HybridVerifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HybridVerifier.d.ts","sourceRoot":"","sources":["../../src/hybrid/HybridVerifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,wBAAwB,EACxB,WAAW,EACX,UAAU,EACX,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,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G,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAajD;;OAEG;IACH,aAAa,CACX,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,GAC7C;QACD,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,eAAe,EAAE,MAAM,CAAC;KACzB;CAqBF"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Hybrid verifier combining runtime tests and formal verification
|
|
3
|
+
* @module @nahisaho/musubix-lean/hybrid
|
|
4
|
+
* @traceability REQ-LEAN-HYBRID-001 to REQ-LEAN-HYBRID-003
|
|
5
|
+
*/
|
|
6
|
+
import { ok, err } from 'neverthrow';
|
|
7
|
+
import { LeanRunner } from '../infrastructure/LeanRunner.js';
|
|
8
|
+
import { LeanFileGenerator } from '../infrastructure/LeanFileGenerator.js';
|
|
9
|
+
import { LeanVerificationError } from '../errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* Combines runtime testing with formal proof verification
|
|
12
|
+
* @traceability REQ-LEAN-HYBRID-001
|
|
13
|
+
*/
|
|
14
|
+
export class HybridVerifier {
|
|
15
|
+
runner;
|
|
16
|
+
generator;
|
|
17
|
+
_reporter;
|
|
18
|
+
traceability;
|
|
19
|
+
strategy = 'runtime-first';
|
|
20
|
+
constructor(config = {}) {
|
|
21
|
+
this.runner = new LeanRunner(config);
|
|
22
|
+
this.generator = new LeanFileGenerator(config);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set verification reporter
|
|
26
|
+
*/
|
|
27
|
+
setReporter(reporter) {
|
|
28
|
+
this._reporter = reporter;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set traceability manager
|
|
32
|
+
*/
|
|
33
|
+
setTraceabilityManager(manager) {
|
|
34
|
+
this.traceability = manager;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Set verification strategy
|
|
38
|
+
*/
|
|
39
|
+
setStrategy(strategy) {
|
|
40
|
+
this.strategy = strategy;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Verify a function with hybrid approach
|
|
44
|
+
* @traceability REQ-LEAN-HYBRID-002
|
|
45
|
+
*/
|
|
46
|
+
async verify(functionId, runtimeTests, theorem) {
|
|
47
|
+
try {
|
|
48
|
+
let runtimeResult;
|
|
49
|
+
let formalResult;
|
|
50
|
+
switch (this.strategy) {
|
|
51
|
+
case 'runtime-first':
|
|
52
|
+
runtimeResult = runtimeTests();
|
|
53
|
+
if (!runtimeResult.passed) {
|
|
54
|
+
// Skip formal if runtime fails
|
|
55
|
+
return ok(this.buildResult(functionId, runtimeResult, undefined));
|
|
56
|
+
}
|
|
57
|
+
formalResult = await this.runFormalVerification(theorem);
|
|
58
|
+
break;
|
|
59
|
+
case 'formal-first':
|
|
60
|
+
formalResult = await this.runFormalVerification(theorem);
|
|
61
|
+
if (!formalResult.proved) {
|
|
62
|
+
// Skip runtime if formal fails
|
|
63
|
+
return ok(this.buildResult(functionId, undefined, formalResult));
|
|
64
|
+
}
|
|
65
|
+
runtimeResult = runtimeTests();
|
|
66
|
+
break;
|
|
67
|
+
case 'parallel':
|
|
68
|
+
// Run both in parallel
|
|
69
|
+
const [runtime, formal] = await Promise.all([
|
|
70
|
+
Promise.resolve(runtimeTests()),
|
|
71
|
+
this.runFormalVerification(theorem),
|
|
72
|
+
]);
|
|
73
|
+
runtimeResult = runtime;
|
|
74
|
+
formalResult = formal;
|
|
75
|
+
break;
|
|
76
|
+
case 'adaptive':
|
|
77
|
+
// Choose strategy based on theorem complexity
|
|
78
|
+
if (this.isComplexTheorem(theorem)) {
|
|
79
|
+
runtimeResult = runtimeTests();
|
|
80
|
+
if (runtimeResult.passed) {
|
|
81
|
+
formalResult = await this.runFormalVerification(theorem);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
formalResult = await this.runFormalVerification(theorem);
|
|
86
|
+
runtimeResult = runtimeTests();
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
const result = this.buildResult(functionId, runtimeResult, formalResult);
|
|
91
|
+
// Record in traceability
|
|
92
|
+
if (this.traceability) {
|
|
93
|
+
this.traceability.createLink(functionId, theorem.id, 'theorem_to_code', result.coverage.combinedCoverage / 100);
|
|
94
|
+
}
|
|
95
|
+
return ok(result);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return err(new LeanVerificationError(`Hybrid verification failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Run formal verification for a theorem
|
|
103
|
+
*/
|
|
104
|
+
async runFormalVerification(theorem) {
|
|
105
|
+
const startTime = Date.now();
|
|
106
|
+
try {
|
|
107
|
+
// Generate Lean file
|
|
108
|
+
const outputDir = process.cwd();
|
|
109
|
+
const genResult = await this.generator.generate([theorem], {
|
|
110
|
+
outputDir,
|
|
111
|
+
includeImports: true,
|
|
112
|
+
includeProofs: true,
|
|
113
|
+
});
|
|
114
|
+
// Type check with Lean
|
|
115
|
+
const checkResult = await this.runner.typeCheck(genResult.path);
|
|
116
|
+
return {
|
|
117
|
+
theoremId: theorem.id,
|
|
118
|
+
proved: checkResult.valid,
|
|
119
|
+
proof: theorem.proof?.leanCode,
|
|
120
|
+
errors: checkResult.errors,
|
|
121
|
+
duration: Date.now() - startTime,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return {
|
|
126
|
+
theoremId: theorem.id,
|
|
127
|
+
proved: false,
|
|
128
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
129
|
+
duration: Date.now() - startTime,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Build hybrid verification result
|
|
135
|
+
*/
|
|
136
|
+
buildResult(functionId, runtimeResult, formalResult) {
|
|
137
|
+
const coverage = this.calculateCoverage(runtimeResult, formalResult);
|
|
138
|
+
const combinedStatus = this.determineCombinedStatus(runtimeResult, formalResult);
|
|
139
|
+
return {
|
|
140
|
+
functionId,
|
|
141
|
+
runtimeResult: runtimeResult
|
|
142
|
+
? {
|
|
143
|
+
passed: runtimeResult.passed,
|
|
144
|
+
testCount: runtimeResult.testCount,
|
|
145
|
+
failedTests: runtimeResult.failedTests,
|
|
146
|
+
coverage: runtimeResult.coverage,
|
|
147
|
+
duration: runtimeResult.duration,
|
|
148
|
+
}
|
|
149
|
+
: undefined,
|
|
150
|
+
formalResult: formalResult
|
|
151
|
+
? {
|
|
152
|
+
proved: formalResult.proved,
|
|
153
|
+
proof: formalResult.proof,
|
|
154
|
+
errors: formalResult.errors,
|
|
155
|
+
duration: formalResult.duration,
|
|
156
|
+
}
|
|
157
|
+
: undefined,
|
|
158
|
+
combinedStatus,
|
|
159
|
+
coverage,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Calculate combined coverage metrics
|
|
164
|
+
* @traceability REQ-LEAN-HYBRID-003
|
|
165
|
+
*/
|
|
166
|
+
calculateCoverage(runtimeResult, formalResult) {
|
|
167
|
+
const runtimeCoverage = runtimeResult?.coverage ?? 0;
|
|
168
|
+
const formalCoverage = formalResult?.proved ? 100 : 0;
|
|
169
|
+
// Combined coverage weights: formal proof is weighted higher
|
|
170
|
+
const combinedCoverage = formalCoverage > 0
|
|
171
|
+
? Math.min(100, runtimeCoverage * 0.3 + formalCoverage * 0.7)
|
|
172
|
+
: runtimeCoverage * 0.5;
|
|
173
|
+
return {
|
|
174
|
+
runtimeCoverage,
|
|
175
|
+
formalCoverage,
|
|
176
|
+
combinedCoverage,
|
|
177
|
+
uncoveredPaths: [], // Would need path analysis to populate
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Determine combined verification status
|
|
182
|
+
*/
|
|
183
|
+
determineCombinedStatus(runtimeResult, formalResult) {
|
|
184
|
+
if (!runtimeResult && !formalResult) {
|
|
185
|
+
return 'unknown';
|
|
186
|
+
}
|
|
187
|
+
// Both passed
|
|
188
|
+
if (runtimeResult?.passed && formalResult?.proved) {
|
|
189
|
+
return 'verified';
|
|
190
|
+
}
|
|
191
|
+
// At least one passed
|
|
192
|
+
if (runtimeResult?.passed || formalResult?.proved) {
|
|
193
|
+
return 'partial';
|
|
194
|
+
}
|
|
195
|
+
// Both ran but failed
|
|
196
|
+
if (runtimeResult && formalResult) {
|
|
197
|
+
return 'failed';
|
|
198
|
+
}
|
|
199
|
+
// Only one ran
|
|
200
|
+
return 'partial';
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Check if theorem is complex (heuristic)
|
|
204
|
+
*/
|
|
205
|
+
isComplexTheorem(theorem) {
|
|
206
|
+
const statement = theorem.statement;
|
|
207
|
+
// Heuristics for complexity
|
|
208
|
+
const hasQuantifiers = /forall|exists|∀|∃/.test(statement);
|
|
209
|
+
const hasInduction = /induction|recursion/.test(statement);
|
|
210
|
+
const nestedDepth = (statement.match(/\(/g) || []).length;
|
|
211
|
+
return hasQuantifiers || hasInduction || nestedDepth > 5;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Batch verify multiple functions
|
|
215
|
+
*/
|
|
216
|
+
async verifyBatch(items) {
|
|
217
|
+
const results = new Map();
|
|
218
|
+
for (const item of items) {
|
|
219
|
+
const result = await this.verify(item.functionId, item.runtimeTests, item.theorem);
|
|
220
|
+
if (result.isOk()) {
|
|
221
|
+
results.set(item.functionId, result.value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return results;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get verification statistics
|
|
228
|
+
*/
|
|
229
|
+
getStatistics(results) {
|
|
230
|
+
const values = Array.from(results.values());
|
|
231
|
+
const total = values.length;
|
|
232
|
+
const verified = values.filter((r) => r.combinedStatus === 'verified').length;
|
|
233
|
+
const partial = values.filter((r) => r.combinedStatus === 'partial').length;
|
|
234
|
+
const failed = values.filter((r) => r.combinedStatus === 'failed').length;
|
|
235
|
+
const avgCoverage = total > 0
|
|
236
|
+
? values.reduce((sum, r) => sum + r.coverage.combinedCoverage, 0) / total
|
|
237
|
+
: 0;
|
|
238
|
+
return {
|
|
239
|
+
total,
|
|
240
|
+
verified,
|
|
241
|
+
partial,
|
|
242
|
+
failed,
|
|
243
|
+
averageCoverage: avgCoverage,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=HybridVerifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HybridVerifier.js","sourceRoot":"","sources":["../../src/hybrid/HybridVerifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAwCrD;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAa;IACnB,SAAS,CAAoB;IAC7B,SAAS,CAAwB;IACjC,YAAY,CAAuB;IACnC,QAAQ,GAAyB,eAAe,CAAC;IAEzD,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,QAA8B;QACxC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,OAA4B;QACj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,EAAE,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;QAE5B,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC;QAC9E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;QAC5E,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;QAE1E,MAAM,WAAW,GACf,KAAK,GAAG,CAAC;YACP,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAAG,KAAK;YACzE,CAAC,CAAC,CAAC,CAAC;QAER,OAAO;YACL,KAAK;YACL,QAAQ;YACR,OAAO;YACP,MAAM;YACN,eAAe,EAAE,WAAW;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Hybrid module exports
|
|
3
|
+
* @module @nahisaho/musubix-lean/hybrid
|
|
4
|
+
*/
|
|
5
|
+
export { HybridVerifier, type RuntimeTestResult, type FormalVerificationResult, type HybridCoverage, type VerificationStrategy, } from './HybridVerifier.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hybrid/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hybrid/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,GAKf,MAAM,qBAAqB,CAAC"}
|