@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/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for @nahisaho/musubix-lean
|
|
3
|
+
* @module @nahisaho/musubix-lean
|
|
4
|
+
* @version 2.0.0-alpha.1
|
|
5
|
+
*/
|
|
6
|
+
export type { LeanConfig, LeanVersion, LeanTheorem, LeanProof, LeanHypothesis, LeanExpression, LeanEnvironmentInfo, VerificationResult, VerificationReport, ReportFormat, ReportStatistics, ProofFeedback, ProofGoal, ProofState, EarsRequirement, EarsPattern, EarsParsedComponents, TypeScriptSpec, TypeScriptFunction, TypeScriptParameter, Precondition, Postcondition, Invariant, TraceabilityLink, TraceabilityArtifact, ArtifactType, LinkType, HybridVerificationResult, } from './types.js';
|
|
7
|
+
export { LeanError, LeanNotFoundError, LeanVersionError, LeanEnvironmentError, LeanConversionError, LeanVerificationError, LeanProofError, LeanIntegrationError, ReProverError, EarsConversionError, EarsParseError, TypeScriptSpecificationError, ProofTimeoutError, ProofGenerationError, ReProverConnectionError, LeanFileGenerationError, LeanExecutionError, } from './errors.js';
|
|
8
|
+
export { LeanEnvironmentDetector, } from './environment/LeanEnvironmentDetector.js';
|
|
9
|
+
export { LeanProjectInitializer, } from './environment/LeanProjectInitializer.js';
|
|
10
|
+
export { EarsToLeanConverter, } from './converters/EarsToLeanConverter.js';
|
|
11
|
+
export { TypeScriptSpecifier, } from './converters/TypeScriptSpecifier.js';
|
|
12
|
+
export { ProofGenerator, } from './proof/ProofGenerator.js';
|
|
13
|
+
export { ReProverClient, } from './proof/ReProverClient.js';
|
|
14
|
+
export { LeanRunner, } from './infrastructure/LeanRunner.js';
|
|
15
|
+
export { LeanFileGenerator, } from './infrastructure/LeanFileGenerator.js';
|
|
16
|
+
export { VerificationReporter, type VerificationResultEntry, type VerificationStatus, } from './reporting/VerificationReporter.js';
|
|
17
|
+
export { TraceabilityManager, type TraceabilityCoverage, } from './traceability/TraceabilityManager.js';
|
|
18
|
+
export { HybridVerifier, type RuntimeTestResult, type FormalVerificationResult, type HybridCoverage, type VerificationStrategy, } from './hybrid/HybridVerifier.js';
|
|
19
|
+
export { LeanIntegration, createLeanIntegration, type IntegrationStatus, type VerificationOptions, } from './integration/LeanIntegration.js';
|
|
20
|
+
export { LeanIntegration as default } from './integration/LeanIntegration.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,YAAY,EAEV,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,cAAc,EACd,cAAc,EACd,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,UAAU,EAGV,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,SAAS,EAGT,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EAGR,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAKrB,OAAO,EACL,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACL,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AAKjD,OAAO,EACL,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EACL,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,cAAc,GACf,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EACL,UAAU,GACX,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAK/C,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,uCAAuC,CAAC;AAK/C,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for @nahisaho/musubix-lean
|
|
3
|
+
* @module @nahisaho/musubix-lean
|
|
4
|
+
* @version 2.0.0-alpha.1
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Errors
|
|
8
|
+
// ============================================================================
|
|
9
|
+
export { LeanError, LeanNotFoundError, LeanVersionError, LeanEnvironmentError, LeanConversionError, LeanVerificationError, LeanProofError, LeanIntegrationError, ReProverError, EarsConversionError, EarsParseError, TypeScriptSpecificationError, ProofTimeoutError, ProofGenerationError, ReProverConnectionError, LeanFileGenerationError, LeanExecutionError, } from './errors.js';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Environment
|
|
12
|
+
// ============================================================================
|
|
13
|
+
export { LeanEnvironmentDetector, } from './environment/LeanEnvironmentDetector.js';
|
|
14
|
+
export { LeanProjectInitializer, } from './environment/LeanProjectInitializer.js';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Converters
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export { EarsToLeanConverter, } from './converters/EarsToLeanConverter.js';
|
|
19
|
+
export { TypeScriptSpecifier, } from './converters/TypeScriptSpecifier.js';
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Proof Generation
|
|
22
|
+
// ============================================================================
|
|
23
|
+
export { ProofGenerator, } from './proof/ProofGenerator.js';
|
|
24
|
+
export { ReProverClient, } from './proof/ReProverClient.js';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Infrastructure
|
|
27
|
+
// ============================================================================
|
|
28
|
+
export { LeanRunner, } from './infrastructure/LeanRunner.js';
|
|
29
|
+
export { LeanFileGenerator, } from './infrastructure/LeanFileGenerator.js';
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Reporting
|
|
32
|
+
// ============================================================================
|
|
33
|
+
export { VerificationReporter, } from './reporting/VerificationReporter.js';
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Traceability
|
|
36
|
+
// ============================================================================
|
|
37
|
+
export { TraceabilityManager, } from './traceability/TraceabilityManager.js';
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Hybrid Verification
|
|
40
|
+
// ============================================================================
|
|
41
|
+
export { HybridVerifier, } from './hybrid/HybridVerifier.js';
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Main Integration
|
|
44
|
+
// ============================================================================
|
|
45
|
+
export { LeanIntegration, createLeanIntegration, } from './integration/LeanIntegration.js';
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Default Export
|
|
48
|
+
// ============================================================================
|
|
49
|
+
export { LeanIntegration as default } from './integration/LeanIntegration.js';
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA6CH,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAC/E,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,4BAA4B,EAC5B,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAC/E,OAAO,EACL,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EACL,sBAAsB,GACvB,MAAM,yCAAyC,CAAC;AAEjD,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAC/E,OAAO,EACL,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAE7C,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAC/E,OAAO,EACL,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAC/E,OAAO,EACL,UAAU,GACX,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAE/C,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAC/E,OAAO,EACL,oBAAoB,GAGrB,MAAM,qCAAqC,CAAC;AAE7C,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAC/E,OAAO,EACL,mBAAmB,GAEpB,MAAM,uCAAuC,CAAC;AAE/C,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAC/E,OAAO,EACL,cAAc,GAKf,MAAM,4BAA4B,CAAC;AAEpC,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAC/E,OAAO,EACL,eAAe,EACf,qBAAqB,GAGtB,MAAM,kCAAkC,CAAC;AAE1C,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAC/E,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Lean file generator for creating .lean source files
|
|
3
|
+
* @module @nahisaho/musubix-lean/infrastructure
|
|
4
|
+
* @traceability REQ-LEAN-CORE-003
|
|
5
|
+
*/
|
|
6
|
+
import type { LeanTheorem, LeanProof, LeanConfig } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generated file information
|
|
9
|
+
*/
|
|
10
|
+
export interface GeneratedFile {
|
|
11
|
+
path: string;
|
|
12
|
+
content: string;
|
|
13
|
+
theoremCount: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* File generation options
|
|
17
|
+
*/
|
|
18
|
+
export interface GenerationOptions {
|
|
19
|
+
outputDir: string;
|
|
20
|
+
fileName?: string;
|
|
21
|
+
includeImports?: boolean;
|
|
22
|
+
includeProofs?: boolean;
|
|
23
|
+
modulePrefix?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generates Lean source files from theorems
|
|
27
|
+
* @traceability REQ-LEAN-CORE-003
|
|
28
|
+
*/
|
|
29
|
+
export declare class LeanFileGenerator {
|
|
30
|
+
private projectPath;
|
|
31
|
+
private timeout;
|
|
32
|
+
constructor(config?: Partial<LeanConfig>);
|
|
33
|
+
/**
|
|
34
|
+
* Generate a Lean file from theorems
|
|
35
|
+
* @traceability REQ-LEAN-CORE-003
|
|
36
|
+
*/
|
|
37
|
+
generate(theorems: LeanTheorem[], options: GenerationOptions): Promise<GeneratedFile>;
|
|
38
|
+
/**
|
|
39
|
+
* Generate multiple Lean files (one per requirement category)
|
|
40
|
+
*/
|
|
41
|
+
generateMultiple(theorems: LeanTheorem[], outputDir: string): Promise<GeneratedFile[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Build Lean file content from theorems
|
|
44
|
+
*/
|
|
45
|
+
private buildFileContent;
|
|
46
|
+
/**
|
|
47
|
+
* Format a single theorem as Lean code
|
|
48
|
+
*/
|
|
49
|
+
private formatTheorem;
|
|
50
|
+
/**
|
|
51
|
+
* Generate a file name from theorems
|
|
52
|
+
*/
|
|
53
|
+
private generateFileName;
|
|
54
|
+
/**
|
|
55
|
+
* Combine a proof with a theorem
|
|
56
|
+
*/
|
|
57
|
+
combineTheoremWithProof(theorem: LeanTheorem, proof: LeanProof): LeanTheorem;
|
|
58
|
+
/**
|
|
59
|
+
* Validate generated Lean syntax (basic check)
|
|
60
|
+
*/
|
|
61
|
+
validateSyntax(content: string): {
|
|
62
|
+
valid: boolean;
|
|
63
|
+
errors: string[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get Lean file template
|
|
67
|
+
*/
|
|
68
|
+
getTemplate(templateType: 'basic' | 'mathlib' | 'custom'): string;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=LeanFileGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeanFileGenerator.d.ts","sourceRoot":"","sources":["../../src/infrastructure/LeanFileGenerator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGtE;;GAEG;AACH,MAAM,WAA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@module @nahisaho/musubix-lean/infrastructure
|
|
4
|
+
* @traceability REQ-LEAN-CORE-003
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { LeanFileGenerationError } from '../errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Standard Lean 4 imports
|
|
11
|
+
*/
|
|
12
|
+
const STANDARD_IMPORTS = `import Lean
|
|
13
|
+
import Mathlib.Tactic`;
|
|
14
|
+
/**
|
|
15
|
+
* MUSUBIX namespace header
|
|
16
|
+
*/
|
|
17
|
+
const MUSUBIX_HEADER = `/-!
|
|
18
|
+
# MUSUBIX Generated Theorems
|
|
19
|
+
|
|
20
|
+
This file was automatically generated by @nahisaho/musubix-lean.
|
|
21
|
+
Do not edit manually unless you know what you're doing.
|
|
22
|
+
|
|
23
|
+
## Requirements Traceability
|
|
24
|
+
Each theorem maps to a specific EARS requirement from the system specification.
|
|
25
|
+
-/`;
|
|
26
|
+
/**
|
|
27
|
+
* Generates Lean source files from theorems
|
|
28
|
+
* @traceability REQ-LEAN-CORE-003
|
|
29
|
+
*/
|
|
30
|
+
export class LeanFileGenerator {
|
|
31
|
+
projectPath;
|
|
32
|
+
timeout;
|
|
33
|
+
constructor(config = {}) {
|
|
34
|
+
this.projectPath = config.projectPath ?? process.cwd();
|
|
35
|
+
this.timeout = config.timeout ?? 30000;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate a Lean file from theorems
|
|
39
|
+
* @traceability REQ-LEAN-CORE-003
|
|
40
|
+
*/
|
|
41
|
+
async generate(theorems, options) {
|
|
42
|
+
const { outputDir, fileName, includeImports, includeProofs, modulePrefix } = options;
|
|
43
|
+
// Build file content
|
|
44
|
+
const content = this.buildFileContent(theorems, {
|
|
45
|
+
includeImports: includeImports ?? true,
|
|
46
|
+
includeProofs: includeProofs ?? true,
|
|
47
|
+
modulePrefix,
|
|
48
|
+
});
|
|
49
|
+
// Determine file name
|
|
50
|
+
const finalFileName = fileName ?? this.generateFileName(theorems);
|
|
51
|
+
const filePath = path.join(outputDir, finalFileName);
|
|
52
|
+
// Ensure output directory exists
|
|
53
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
54
|
+
// Write file
|
|
55
|
+
try {
|
|
56
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
throw new LeanFileGenerationError(filePath, error instanceof Error ? error.message : String(error));
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
path: filePath,
|
|
63
|
+
content,
|
|
64
|
+
theoremCount: theorems.length,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Generate multiple Lean files (one per requirement category)
|
|
69
|
+
*/
|
|
70
|
+
async generateMultiple(theorems, outputDir) {
|
|
71
|
+
// Group theorems by requirement prefix
|
|
72
|
+
const groups = new Map();
|
|
73
|
+
for (const theorem of theorems) {
|
|
74
|
+
// Extract category from requirement ID (e.g., REQ-LEAN-CORE-001 -> CORE)
|
|
75
|
+
const match = theorem.requirementId?.match(/REQ-\w+-(\w+)-/);
|
|
76
|
+
const category = match?.[1] ?? 'General';
|
|
77
|
+
if (!groups.has(category)) {
|
|
78
|
+
groups.set(category, []);
|
|
79
|
+
}
|
|
80
|
+
groups.get(category).push(theorem);
|
|
81
|
+
}
|
|
82
|
+
// Generate file for each group
|
|
83
|
+
const files = [];
|
|
84
|
+
for (const [category, categoryTheorems] of groups) {
|
|
85
|
+
const file = await this.generate(categoryTheorems, {
|
|
86
|
+
outputDir,
|
|
87
|
+
fileName: `${category}.lean`,
|
|
88
|
+
modulePrefix: `MUSUBIX.${category}`,
|
|
89
|
+
});
|
|
90
|
+
files.push(file);
|
|
91
|
+
}
|
|
92
|
+
return files;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Build Lean file content from theorems
|
|
96
|
+
*/
|
|
97
|
+
buildFileContent(theorems, options) {
|
|
98
|
+
const lines = [];
|
|
99
|
+
// Header
|
|
100
|
+
lines.push(MUSUBIX_HEADER);
|
|
101
|
+
lines.push('');
|
|
102
|
+
// Imports
|
|
103
|
+
if (options.includeImports !== false) {
|
|
104
|
+
lines.push(STANDARD_IMPORTS);
|
|
105
|
+
lines.push('');
|
|
106
|
+
}
|
|
107
|
+
// Namespace
|
|
108
|
+
const namespace = options.modulePrefix ?? 'MUSUBIX.Generated';
|
|
109
|
+
lines.push(`namespace ${namespace}`);
|
|
110
|
+
lines.push('');
|
|
111
|
+
// Theorems
|
|
112
|
+
for (const theorem of theorems) {
|
|
113
|
+
lines.push(this.formatTheorem(theorem, options.includeProofs ?? true));
|
|
114
|
+
lines.push('');
|
|
115
|
+
}
|
|
116
|
+
// Close namespace
|
|
117
|
+
lines.push(`end ${namespace}`);
|
|
118
|
+
lines.push('');
|
|
119
|
+
return lines.join('\n');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Format a single theorem as Lean code
|
|
123
|
+
*/
|
|
124
|
+
formatTheorem(theorem, includeProof) {
|
|
125
|
+
const lines = [];
|
|
126
|
+
// Doc comment
|
|
127
|
+
if (theorem.description) {
|
|
128
|
+
lines.push(`/-- ${theorem.description}`);
|
|
129
|
+
if (theorem.requirementId) {
|
|
130
|
+
lines.push(` @traceability ${theorem.requirementId}`);
|
|
131
|
+
}
|
|
132
|
+
lines.push('-/');
|
|
133
|
+
}
|
|
134
|
+
// Theorem declaration
|
|
135
|
+
const proofCode = includeProof && theorem.proof
|
|
136
|
+
? theorem.proof.leanCode
|
|
137
|
+
: 'sorry';
|
|
138
|
+
lines.push(`theorem ${theorem.name} : ${theorem.statement} := by`);
|
|
139
|
+
lines.push(` ${proofCode}`);
|
|
140
|
+
return lines.join('\n');
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generate a file name from theorems
|
|
144
|
+
*/
|
|
145
|
+
generateFileName(theorems) {
|
|
146
|
+
if (theorems.length === 0) {
|
|
147
|
+
return 'Empty.lean';
|
|
148
|
+
}
|
|
149
|
+
// Use first theorem's requirement ID if available
|
|
150
|
+
const first = theorems[0];
|
|
151
|
+
if (first.requirementId) {
|
|
152
|
+
const match = first.requirementId.match(/REQ-(\w+)/);
|
|
153
|
+
if (match) {
|
|
154
|
+
return `${match[1]}.lean`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Default
|
|
158
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').substring(0, 19);
|
|
159
|
+
return `Generated_${timestamp}.lean`;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Combine a proof with a theorem
|
|
163
|
+
*/
|
|
164
|
+
combineTheoremWithProof(theorem, proof) {
|
|
165
|
+
return {
|
|
166
|
+
...theorem,
|
|
167
|
+
proof,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Validate generated Lean syntax (basic check)
|
|
172
|
+
*/
|
|
173
|
+
validateSyntax(content) {
|
|
174
|
+
const errors = [];
|
|
175
|
+
// Check for balanced delimiters
|
|
176
|
+
const openParens = (content.match(/\(/g) || []).length;
|
|
177
|
+
const closeParens = (content.match(/\)/g) || []).length;
|
|
178
|
+
if (openParens !== closeParens) {
|
|
179
|
+
errors.push(`Unbalanced parentheses: ${openParens} open, ${closeParens} close`);
|
|
180
|
+
}
|
|
181
|
+
const openBraces = (content.match(/\{/g) || []).length;
|
|
182
|
+
const closeBraces = (content.match(/\}/g) || []).length;
|
|
183
|
+
if (openBraces !== closeBraces) {
|
|
184
|
+
errors.push(`Unbalanced braces: ${openBraces} open, ${closeBraces} close`);
|
|
185
|
+
}
|
|
186
|
+
const openBrackets = (content.match(/\[/g) || []).length;
|
|
187
|
+
const closeBrackets = (content.match(/\]/g) || []).length;
|
|
188
|
+
if (openBrackets !== closeBrackets) {
|
|
189
|
+
errors.push(`Unbalanced brackets: ${openBrackets} open, ${closeBrackets} close`);
|
|
190
|
+
}
|
|
191
|
+
// Check for common errors
|
|
192
|
+
if (content.includes(':= by\n\n')) {
|
|
193
|
+
errors.push('Empty proof block detected');
|
|
194
|
+
}
|
|
195
|
+
// Check for namespace balance
|
|
196
|
+
const namespaceCount = (content.match(/\bnamespace\s+\w+/g) || []).length;
|
|
197
|
+
const endCount = (content.match(/\bend\s+\w+/g) || []).length;
|
|
198
|
+
if (namespaceCount !== endCount) {
|
|
199
|
+
errors.push(`Unbalanced namespace: ${namespaceCount} namespace, ${endCount} end`);
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
valid: errors.length === 0,
|
|
203
|
+
errors,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get Lean file template
|
|
208
|
+
*/
|
|
209
|
+
getTemplate(templateType) {
|
|
210
|
+
switch (templateType) {
|
|
211
|
+
case 'basic':
|
|
212
|
+
return `import Lean
|
|
213
|
+
|
|
214
|
+
namespace MyProject
|
|
215
|
+
|
|
216
|
+
-- Your theorems here
|
|
217
|
+
|
|
218
|
+
end MyProject
|
|
219
|
+
`;
|
|
220
|
+
case 'mathlib':
|
|
221
|
+
return `import Mathlib.Tactic
|
|
222
|
+
import Mathlib.Data.Nat.Basic
|
|
223
|
+
import Mathlib.Data.List.Basic
|
|
224
|
+
|
|
225
|
+
namespace MyProject
|
|
226
|
+
|
|
227
|
+
open Nat List
|
|
228
|
+
|
|
229
|
+
-- Your theorems here
|
|
230
|
+
|
|
231
|
+
end MyProject
|
|
232
|
+
`;
|
|
233
|
+
case 'custom':
|
|
234
|
+
return `/-!
|
|
235
|
+
# Custom MUSUBIX Project
|
|
236
|
+
|
|
237
|
+
Add your imports and theorems below.
|
|
238
|
+
-/
|
|
239
|
+
|
|
240
|
+
import Lean
|
|
241
|
+
|
|
242
|
+
namespace MUSUBIX
|
|
243
|
+
|
|
244
|
+
-- Requirements-driven theorems
|
|
245
|
+
|
|
246
|
+
end MUSUBIX
|
|
247
|
+
`;
|
|
248
|
+
default:
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=LeanFileGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeanFileGenerator.js","sourceRoot":"","sources":["../../src/infrastructure/LeanFileGenerator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAsBvD;;GAEG;AACH,MAAM,gBAAgB,GAAG;sBACH,CAAC;AAEvB;;GAEG;AACH,MAAM,cAAc,GAAG;;;;;;;;GAQpB,CAAC;AAEJ;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACpB,WAAW,CAAS;IACpB,OAAO,CAAS;IAExB,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CACZ,QAAuB,EACvB,OAA0B;QAE1B,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAErF,qBAAqB;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE;YAC9C,cAAc,EAAE,cAAc,IAAI,IAAI;YACtC,aAAa,EAAE,aAAa,IAAI,IAAI;YACpC,YAAY;SACb,CAAC,CAAC;QAEH,sBAAsB;QACtB,MAAM,aAAa,GAAG,QAAQ,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,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N-CORE-004
|
|
5
|
+
*/
|
|
6
|
+
import type { LeanConfig, LeanVersion } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Lean execution result
|
|
9
|
+
*/
|
|
10
|
+
export interface LeanExecutionResult {
|
|
11
|
+
success: boolean;
|
|
12
|
+
stdout: string;
|
|
13
|
+
stderr: string;
|
|
14
|
+
exitCode: number;
|
|
15
|
+
duration: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Lean goal information
|
|
19
|
+
*/
|
|
20
|
+
export interface LeanGoalInfo {
|
|
21
|
+
goals: string[];
|
|
22
|
+
hypotheses: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs Lean commands and validates proofs
|
|
26
|
+
* @traceability REQ-LEAN-CORE-004
|
|
27
|
+
*/
|
|
28
|
+
export declare class LeanRunner {
|
|
29
|
+
private leanPath;
|
|
30
|
+
private projectPath;
|
|
31
|
+
private timeout;
|
|
32
|
+
private lakeEnabled;
|
|
33
|
+
private verbose;
|
|
34
|
+
private leanVersion;
|
|
35
|
+
constructor(config?: Partial<LeanConfig>);
|
|
36
|
+
/**
|
|
37
|
+
* Execute Lean code file
|
|
38
|
+
* @traceability REQ-LEAN-CORE-004
|
|
39
|
+
*/
|
|
40
|
+
execute(filePath: string, options?: {
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}): Promise<LeanExecutionResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Execute Lean code string (creates temp file)
|
|
45
|
+
*/
|
|
46
|
+
executeCode(code: string, options?: {
|
|
47
|
+
timeout?: number;
|
|
48
|
+
}): Promise<LeanExecutionResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Check if Lean can type-check a file
|
|
51
|
+
*/
|
|
52
|
+
typeCheck(filePath: string): Promise<{
|
|
53
|
+
valid: boolean;
|
|
54
|
+
errors: string[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Get current proof state (goals and hypotheses)
|
|
58
|
+
*/
|
|
59
|
+
getGoalState(_filePath: string, _line: number, _column: number): Promise<LeanGoalInfo>;
|
|
60
|
+
/**
|
|
61
|
+
* Run Lake build
|
|
62
|
+
*/
|
|
63
|
+
lakeBuild(projectPath?: string): Promise<LeanExecutionResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Get Lean version information
|
|
66
|
+
*/
|
|
67
|
+
getVersion(): Promise<LeanVersion>;
|
|
68
|
+
/**
|
|
69
|
+
* Parse version from Lean output
|
|
70
|
+
*/
|
|
71
|
+
private parseVersion;
|
|
72
|
+
/**
|
|
73
|
+
* Build Lean command arguments
|
|
74
|
+
*/
|
|
75
|
+
private buildLeanArgs;
|
|
76
|
+
/**
|
|
77
|
+
* Parse Lean error messages
|
|
78
|
+
*/
|
|
79
|
+
private parseErrors;
|
|
80
|
+
/**
|
|
81
|
+
* Check if Lean is available
|
|
82
|
+
*/
|
|
83
|
+
isAvailable(): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Get configuration
|
|
86
|
+
*/
|
|
87
|
+
getConfig(): LeanConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Update configuration
|
|
90
|
+
*/
|
|
91
|
+
updateConfig(config: Partial<LeanConfig>): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=LeanRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeanRunner.d.ts","sourceRoot":"","sources":["../../src/infrastructure/LeanRunner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG3D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,Y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