@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.
Files changed (89) hide show
  1. package/dist/converters/EarsToLeanConverter.d.ts +61 -0
  2. package/dist/converters/EarsToLeanConverter.d.ts.map +1 -0
  3. package/dist/converters/EarsToLeanConverter.js +300 -0
  4. package/dist/converters/EarsToLeanConverter.js.map +1 -0
  5. package/dist/converters/TypeScriptSpecifier.d.ts +63 -0
  6. package/dist/converters/TypeScriptSpecifier.d.ts.map +1 -0
  7. package/dist/converters/TypeScriptSpecifier.js +307 -0
  8. package/dist/converters/TypeScriptSpecifier.js.map +1 -0
  9. package/dist/converters/index.d.ts +7 -0
  10. package/dist/converters/index.d.ts.map +1 -0
  11. package/dist/converters/index.js +7 -0
  12. package/dist/converters/index.js.map +1 -0
  13. package/dist/environment/LeanEnvironmentDetector.d.ts +57 -0
  14. package/dist/environment/LeanEnvironmentDetector.d.ts.map +1 -0
  15. package/dist/environment/LeanEnvironmentDetector.js +221 -0
  16. package/dist/environment/LeanEnvironmentDetector.js.map +1 -0
  17. package/dist/environment/LeanProjectInitializer.d.ts +49 -0
  18. package/dist/environment/LeanProjectInitializer.d.ts.map +1 -0
  19. package/dist/environment/LeanProjectInitializer.js +232 -0
  20. package/dist/environment/LeanProjectInitializer.js.map +1 -0
  21. package/dist/environment/index.d.ts +7 -0
  22. package/dist/environment/index.d.ts.map +1 -0
  23. package/dist/environment/index.js +7 -0
  24. package/dist/environment/index.js.map +1 -0
  25. package/dist/errors.d.ts +141 -0
  26. package/dist/errors.d.ts.map +1 -0
  27. package/dist/errors.js +254 -0
  28. package/dist/errors.js.map +1 -0
  29. package/dist/hybrid/HybridVerifier.d.ts +113 -0
  30. package/dist/hybrid/HybridVerifier.d.ts.map +1 -0
  31. package/dist/hybrid/HybridVerifier.js +247 -0
  32. package/dist/hybrid/HybridVerifier.js.map +1 -0
  33. package/dist/hybrid/index.d.ts +6 -0
  34. package/dist/hybrid/index.d.ts.map +1 -0
  35. package/dist/hybrid/index.js +6 -0
  36. package/dist/hybrid/index.js.map +1 -0
  37. package/dist/index.d.ts +21 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +50 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/infrastructure/LeanFileGenerator.d.ts +70 -0
  42. package/dist/infrastructure/LeanFileGenerator.d.ts.map +1 -0
  43. package/dist/infrastructure/LeanFileGenerator.js +253 -0
  44. package/dist/infrastructure/LeanFileGenerator.js.map +1 -0
  45. package/dist/infrastructure/LeanRunner.d.ts +93 -0
  46. package/dist/infrastructure/LeanRunner.d.ts.map +1 -0
  47. package/dist/infrastructure/LeanRunner.js +296 -0
  48. package/dist/infrastructure/LeanRunner.js.map +1 -0
  49. package/dist/infrastructure/index.d.ts +7 -0
  50. package/dist/infrastructure/index.d.ts.map +1 -0
  51. package/dist/infrastructure/index.js +7 -0
  52. package/dist/infrastructure/index.js.map +1 -0
  53. package/dist/integration/LeanIntegration.d.ts +138 -0
  54. package/dist/integration/LeanIntegration.d.ts.map +1 -0
  55. package/dist/integration/LeanIntegration.js +352 -0
  56. package/dist/integration/LeanIntegration.js.map +1 -0
  57. package/dist/proof/ProofGenerator.d.ts +53 -0
  58. package/dist/proof/ProofGenerator.d.ts.map +1 -0
  59. package/dist/proof/ProofGenerator.js +324 -0
  60. package/dist/proof/ProofGenerator.js.map +1 -0
  61. package/dist/proof/ReProverClient.d.ts +58 -0
  62. package/dist/proof/ReProverClient.d.ts.map +1 -0
  63. package/dist/proof/ReProverClient.js +260 -0
  64. package/dist/proof/ReProverClient.js.map +1 -0
  65. package/dist/proof/index.d.ts +7 -0
  66. package/dist/proof/index.d.ts.map +1 -0
  67. package/dist/proof/index.js +7 -0
  68. package/dist/proof/index.js.map +1 -0
  69. package/dist/reporting/VerificationReporter.d.ts +89 -0
  70. package/dist/reporting/VerificationReporter.d.ts.map +1 -0
  71. package/dist/reporting/VerificationReporter.js +296 -0
  72. package/dist/reporting/VerificationReporter.js.map +1 -0
  73. package/dist/reporting/index.d.ts +6 -0
  74. package/dist/reporting/index.d.ts.map +1 -0
  75. package/dist/reporting/index.js +6 -0
  76. package/dist/reporting/index.js.map +1 -0
  77. package/dist/traceability/TraceabilityManager.d.ts +104 -0
  78. package/dist/traceability/TraceabilityManager.d.ts.map +1 -0
  79. package/dist/traceability/TraceabilityManager.js +299 -0
  80. package/dist/traceability/TraceabilityManager.js.map +1 -0
  81. package/dist/traceability/index.d.ts +6 -0
  82. package/dist/traceability/index.d.ts.map +1 -0
  83. package/dist/traceability/index.js +6 -0
  84. package/dist/traceability/index.js.map +1 -0
  85. package/dist/types.d.ts +466 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +17 -0
  88. package/dist/types.js.map +1 -0
  89. package/package.json +78 -0
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @fileoverview EARS to Lean converter
3
+ * @module @nahisaho/musubix-lean/converters
4
+ * @traceability REQ-LEAN-CONV-001 to REQ-LEAN-CONV-005
5
+ */
6
+ import { type Result } from 'neverthrow';
7
+ import type { EarsRequirement, EarsPattern, EarsParsedComponents, LeanTheorem } from '../types.js';
8
+ import { EarsConversionError, EarsParseError } from '../errors.js';
9
+ /**
10
+ * Parse EARS requirement text into components
11
+ * @traceability REQ-LEAN-CONV-001
12
+ */
13
+ export declare function parseEarsRequirement(text: string): Result<EarsParsedComponents, EarsParseError>;
14
+ /**
15
+ * Build Lean theorem from EARS components
16
+ * @traceability REQ-LEAN-CONV-001
17
+ */
18
+ export declare function buildLeanTheorem(components: EarsParsedComponents, requirementId: string, sourceText: string): LeanTheorem;
19
+ /**
20
+ * Convert EARS requirement to Lean theorem
21
+ * @traceability REQ-LEAN-CONV-001
22
+ */
23
+ export declare function convertEarsToLean(requirement: EarsRequirement): Result<LeanTheorem, EarsConversionError>;
24
+ /**
25
+ * Convert raw EARS text to Lean theorem
26
+ */
27
+ export declare function convertEarsTextToLean(id: string, text: string): Result<LeanTheorem, EarsParseError | EarsConversionError>;
28
+ /**
29
+ * Detect EARS pattern from text
30
+ */
31
+ export declare function detectEarsPattern(text: string): EarsPattern | null;
32
+ /**
33
+ * EarsToLeanConverter class implementation
34
+ * @traceability REQ-LEAN-CONV-001
35
+ */
36
+ export declare class EarsToLeanConverter {
37
+ /**
38
+ * Convert EARS requirement to Lean theorem
39
+ */
40
+ convert(requirement: EarsRequirement): Result<LeanTheorem, EarsConversionError>;
41
+ /**
42
+ * Parse EARS text into components
43
+ */
44
+ parseEars(text: string): Result<EarsParsedComponents, EarsParseError>;
45
+ /**
46
+ * Build theorem from parsed components
47
+ */
48
+ buildTheorem(components: EarsParsedComponents, reqId: string, sourceText?: string): LeanTheorem;
49
+ /**
50
+ * Batch convert multiple requirements
51
+ * @traceability REQ-LEAN-ERR-002
52
+ */
53
+ convertBatch(requirements: EarsRequirement[]): {
54
+ successes: LeanTheorem[];
55
+ failures: {
56
+ id: string;
57
+ error: string;
58
+ }[];
59
+ };
60
+ }
61
+ //# sourceMappingURL=EarsToLeanConverter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EarsToLeanConverter.d.ts","sourceRoot":"","sources":["../../src/converters/EarsToLeanConverter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,WAAW,EAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAanE;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAmE9C;AAuBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,WAAW,CAwHb;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,eAAe,GAC3B,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAwB1C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GACX,MAAM,CAAC,WAAW,EAAE,cAAc,GAAG,mBAAmB,CAAC,CAc3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAGlE;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B;;OAEG;IACH,OAAO,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAI/E;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,oBAAoB,EAAE,cAAc,CAAC;IAIrE;;OAEG;IACH,YAAY,CACV,UAAU,EAAE,oBAAoB,EAChC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,GACtB,WAAW;IAId;;;OAGG;IACH,YAAY,CACV,YAAY,EAAE,eAAe,EAAE,GAC9B;QAAE,SAAS,EAAE,WAAW,EAAE,CAAC;QAAC,QAAQ,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE;CAkB3E"}
@@ -0,0 +1,300 @@
1
+ /**
2
+ * @fileoverview EARS to Lean converter
3
+ * @module @nahisaho/musubix-lean/converters
4
+ * @traceability REQ-LEAN-CONV-001 to REQ-LEAN-CONV-005
5
+ */
6
+ import { ok, err } from 'neverthrow';
7
+ import { EarsConversionError, EarsParseError } from '../errors.js';
8
+ /**
9
+ * EARS pattern regex definitions
10
+ */
11
+ const EARS_PATTERNS = {
12
+ ubiquitous: /^THE\s+(.+?)\s+SHALL\s+(.+)$/i,
13
+ eventDriven: /^WHEN\s+(.+?),?\s+THE\s+(.+?)\s+SHALL\s+(.+)$/i,
14
+ stateDriven: /^WHILE\s+(.+?),?\s+THE\s+(.+?)\s+SHALL\s+(.+)$/i,
15
+ unwanted: /^THE\s+(.+?)\s+SHALL\s+NOT\s+(.+)$/i,
16
+ optional: /^IF\s+(.+?),?\s+THEN\s+THE\s+(.+?)\s+SHALL\s+(.+)$/i,
17
+ };
18
+ /**
19
+ * Parse EARS requirement text into components
20
+ * @traceability REQ-LEAN-CONV-001
21
+ */
22
+ export function parseEarsRequirement(text) {
23
+ const trimmedText = text.trim();
24
+ // Try Unwanted pattern first (SHALL NOT before SHALL)
25
+ const unwantedMatch = trimmedText.match(EARS_PATTERNS.unwanted);
26
+ if (unwantedMatch) {
27
+ return ok({
28
+ pattern: 'unwanted',
29
+ subject: unwantedMatch[1].trim(),
30
+ action: unwantedMatch[2].trim(),
31
+ negated: true,
32
+ });
33
+ }
34
+ // Try Event-driven pattern
35
+ const eventMatch = trimmedText.match(EARS_PATTERNS.eventDriven);
36
+ if (eventMatch) {
37
+ return ok({
38
+ pattern: 'event-driven',
39
+ trigger: eventMatch[1].trim(),
40
+ subject: eventMatch[2].trim(),
41
+ action: eventMatch[3].trim(),
42
+ negated: false,
43
+ });
44
+ }
45
+ // Try State-driven pattern
46
+ const stateMatch = trimmedText.match(EARS_PATTERNS.stateDriven);
47
+ if (stateMatch) {
48
+ return ok({
49
+ pattern: 'state-driven',
50
+ state: stateMatch[1].trim(),
51
+ subject: stateMatch[2].trim(),
52
+ action: stateMatch[3].trim(),
53
+ negated: false,
54
+ });
55
+ }
56
+ // Try Optional pattern
57
+ const optionalMatch = trimmedText.match(EARS_PATTERNS.optional);
58
+ if (optionalMatch) {
59
+ return ok({
60
+ pattern: 'optional',
61
+ condition: optionalMatch[1].trim(),
62
+ subject: optionalMatch[2].trim(),
63
+ action: optionalMatch[3].trim(),
64
+ negated: false,
65
+ });
66
+ }
67
+ // Try Ubiquitous pattern
68
+ const ubiquitousMatch = trimmedText.match(EARS_PATTERNS.ubiquitous);
69
+ if (ubiquitousMatch) {
70
+ return ok({
71
+ pattern: 'ubiquitous',
72
+ subject: ubiquitousMatch[1].trim(),
73
+ action: ubiquitousMatch[2].trim(),
74
+ negated: false,
75
+ });
76
+ }
77
+ return err(new EarsParseError(text, 'Text does not match any EARS pattern (Ubiquitous, Event-driven, State-driven, Unwanted, or Optional)'));
78
+ }
79
+ /**
80
+ * Convert natural language to Lean identifier
81
+ */
82
+ function toLeanIdentifier(text) {
83
+ return text
84
+ .toLowerCase()
85
+ .replace(/[^a-z0-9\s]/g, '')
86
+ .split(/\s+/)
87
+ .filter((s) => s.length > 0)
88
+ .map((s, i) => (i === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1)))
89
+ .join('');
90
+ }
91
+ /**
92
+ * Convert natural language to Lean predicate name
93
+ */
94
+ function toLeanPredicateName(text) {
95
+ const base = toLeanIdentifier(text);
96
+ return base.charAt(0).toUpperCase() + base.slice(1);
97
+ }
98
+ /**
99
+ * Build Lean theorem from EARS components
100
+ * @traceability REQ-LEAN-CONV-001
101
+ */
102
+ export function buildLeanTheorem(components, requirementId, sourceText) {
103
+ const theoremName = `req_${requirementId.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()}`;
104
+ const hypotheses = [];
105
+ let conclusion;
106
+ let leanCode;
107
+ const subjectPred = toLeanPredicateName(components.subject);
108
+ const actionPred = toLeanPredicateName(components.action);
109
+ switch (components.pattern) {
110
+ case 'ubiquitous':
111
+ // THE [system] SHALL [requirement]
112
+ // ∀ x, System x → Action x
113
+ conclusion = {
114
+ type: `∀ x, ${subjectPred} x → ${actionPred} x`,
115
+ leanCode: `∀ x, ${subjectPred} x → ${actionPred} x`,
116
+ };
117
+ leanCode = `
118
+ /-- ${sourceText}
119
+ @requirement ${requirementId}
120
+ -/
121
+ theorem ${theoremName} : ∀ x, ${subjectPred} x → ${actionPred} x := by
122
+ intro x h_system
123
+ sorry -- TODO: Complete proof
124
+ `;
125
+ break;
126
+ case 'event-driven':
127
+ // WHEN [event], THE [system] SHALL [response]
128
+ // event → response
129
+ hypotheses.push({
130
+ name: 'h_event',
131
+ type: toLeanPredicateName(components.trigger || ''),
132
+ leanCode: `h_event : ${toLeanPredicateName(components.trigger || '')}`,
133
+ });
134
+ conclusion = {
135
+ type: actionPred,
136
+ leanCode: actionPred,
137
+ };
138
+ leanCode = `
139
+ /-- ${sourceText}
140
+ @requirement ${requirementId}
141
+ -/
142
+ theorem ${theoremName} (h_event : ${toLeanPredicateName(components.trigger || '')}) : ${actionPred} := by
143
+ sorry -- TODO: Complete proof
144
+ `;
145
+ break;
146
+ case 'state-driven':
147
+ // WHILE [state], THE [system] SHALL [response]
148
+ // state → invariant_preserved
149
+ hypotheses.push({
150
+ name: 'h_state',
151
+ type: toLeanPredicateName(components.state || ''),
152
+ leanCode: `h_state : ${toLeanPredicateName(components.state || '')}`,
153
+ });
154
+ conclusion = {
155
+ type: `${actionPred} ∧ ${toLeanPredicateName(components.state || '')}`,
156
+ leanCode: `${actionPred} ∧ ${toLeanPredicateName(components.state || '')}`,
157
+ };
158
+ leanCode = `
159
+ /-- ${sourceText}
160
+ @requirement ${requirementId}
161
+ -/
162
+ theorem ${theoremName} (h_state : ${toLeanPredicateName(components.state || '')}) : ${actionPred} ∧ ${toLeanPredicateName(components.state || '')} := by
163
+ constructor
164
+ · sorry -- TODO: Prove action
165
+ · exact h_state
166
+ `;
167
+ break;
168
+ case 'unwanted':
169
+ // THE [system] SHALL NOT [behavior]
170
+ // ¬ unwanted_behavior
171
+ conclusion = {
172
+ type: `¬ ${actionPred}`,
173
+ leanCode: `¬ ${actionPred}`,
174
+ };
175
+ leanCode = `
176
+ /-- ${sourceText}
177
+ @requirement ${requirementId}
178
+ -/
179
+ theorem ${theoremName} : ¬ ${actionPred} := by
180
+ intro h_unwanted
181
+ sorry -- TODO: Derive contradiction
182
+ `;
183
+ break;
184
+ case 'optional':
185
+ // IF [condition], THEN THE [system] SHALL [response]
186
+ // condition → response
187
+ hypotheses.push({
188
+ name: 'h_cond',
189
+ type: toLeanPredicateName(components.condition || ''),
190
+ leanCode: `h_cond : ${toLeanPredicateName(components.condition || '')}`,
191
+ });
192
+ conclusion = {
193
+ type: actionPred,
194
+ leanCode: actionPred,
195
+ };
196
+ leanCode = `
197
+ /-- ${sourceText}
198
+ @requirement ${requirementId}
199
+ -/
200
+ theorem ${theoremName} (h_cond : ${toLeanPredicateName(components.condition || '')}) : ${actionPred} := by
201
+ sorry -- TODO: Complete proof
202
+ `;
203
+ break;
204
+ }
205
+ return {
206
+ id: requirementId,
207
+ name: theoremName,
208
+ statement: conclusion.leanCode,
209
+ requirementId,
210
+ hypotheses,
211
+ conclusion,
212
+ sourceText,
213
+ leanCode,
214
+ };
215
+ }
216
+ /**
217
+ * Convert EARS requirement to Lean theorem
218
+ * @traceability REQ-LEAN-CONV-001
219
+ */
220
+ export function convertEarsToLean(requirement) {
221
+ try {
222
+ if (!requirement.parsed) {
223
+ return err(new EarsConversionError(requirement.id, 'Requirement has no parsed components'));
224
+ }
225
+ const theorem = buildLeanTheorem(requirement.parsed, requirement.id, requirement.text);
226
+ return ok(theorem);
227
+ }
228
+ catch (error) {
229
+ return err(new EarsConversionError(requirement.id, error instanceof Error ? error.message : String(error)));
230
+ }
231
+ }
232
+ /**
233
+ * Convert raw EARS text to Lean theorem
234
+ */
235
+ export function convertEarsTextToLean(id, text) {
236
+ const parseResult = parseEarsRequirement(text);
237
+ if (parseResult.isErr()) {
238
+ return err(parseResult.error);
239
+ }
240
+ const requirement = {
241
+ id,
242
+ pattern: parseResult.value.pattern,
243
+ text,
244
+ parsed: parseResult.value,
245
+ };
246
+ return convertEarsToLean(requirement);
247
+ }
248
+ /**
249
+ * Detect EARS pattern from text
250
+ */
251
+ export function detectEarsPattern(text) {
252
+ const result = parseEarsRequirement(text);
253
+ return result.isOk() ? result.value.pattern : null;
254
+ }
255
+ /**
256
+ * EarsToLeanConverter class implementation
257
+ * @traceability REQ-LEAN-CONV-001
258
+ */
259
+ export class EarsToLeanConverter {
260
+ /**
261
+ * Convert EARS requirement to Lean theorem
262
+ */
263
+ convert(requirement) {
264
+ return convertEarsToLean(requirement);
265
+ }
266
+ /**
267
+ * Parse EARS text into components
268
+ */
269
+ parseEars(text) {
270
+ return parseEarsRequirement(text);
271
+ }
272
+ /**
273
+ * Build theorem from parsed components
274
+ */
275
+ buildTheorem(components, reqId, sourceText = '') {
276
+ return buildLeanTheorem(components, reqId, sourceText);
277
+ }
278
+ /**
279
+ * Batch convert multiple requirements
280
+ * @traceability REQ-LEAN-ERR-002
281
+ */
282
+ convertBatch(requirements) {
283
+ const successes = [];
284
+ const failures = [];
285
+ for (const req of requirements) {
286
+ const result = this.convert(req);
287
+ if (result.isOk()) {
288
+ successes.push(result.value);
289
+ }
290
+ else {
291
+ failures.push({
292
+ id: req.id,
293
+ error: result.error.message,
294
+ });
295
+ }
296
+ }
297
+ return { successes, failures };
298
+ }
299
+ }
300
+ //# sourceMappingURL=EarsToLeanConverter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EarsToLeanConverter.js","sourceRoot":"","sources":["../../src/converters/EarsToLeanConverter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;AASlD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnE;;GAEG;AACH,MAAM,aAAa,GAAG;IACpB,UAAU,EAAE,+BAA+B;IAC3C,WAAW,EAAE,gDAAgD;IAC7D,WAAW,EAAE,iDAAiD;IAC9D,QAAQ,EAAE,qCAAqC;IAC/C,QAAQ,EAAE,qDAAqD;CAChE,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY;IAEZ,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEhC,sDAAsD;IACtD,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,a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AAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC;oBACZ,EAAE,EAAE,GAAG,CAAC,EAAE;oBACV,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;iBAC5B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;IACjC,CAAC;CACF"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @fileoverview TypeScript to Lean specification converter
3
+ * @module @nahisaho/musubix-lean/converters
4
+ * @traceability REQ-LEAN-TS-001 to REQ-LEAN-TS-004
5
+ */
6
+ import { type Result } from 'neverthrow';
7
+ import type { TypeScriptFunction, TypeScriptParameter, LeanFunctionSpec, Precondition, Postcondition, Invariant } from '../types.js';
8
+ import { TypeScriptSpecificationError } from '../errors.js';
9
+ /**
10
+ * Convert TypeScript type to Lean type
11
+ * @traceability REQ-LEAN-TS-001
12
+ */
13
+ export declare function convertTypeToLean(tsType: string): string;
14
+ /**
15
+ * Build Lean function specification from TypeScript function
16
+ * @traceability REQ-LEAN-TS-001
17
+ */
18
+ export declare function buildFunctionSpec(func: TypeScriptFunction): Result<LeanFunctionSpec, TypeScriptSpecificationError>;
19
+ /**
20
+ * Extract preconditions from JSDoc comments
21
+ * @traceability REQ-LEAN-TS-002
22
+ */
23
+ export declare function extractPreconditionsFromJSDoc(jsdoc: string): Precondition[];
24
+ /**
25
+ * Extract postconditions from JSDoc comments
26
+ * @traceability REQ-LEAN-TS-003
27
+ */
28
+ export declare function extractPostconditionsFromJSDoc(jsdoc: string): Postcondition[];
29
+ /**
30
+ * Extract invariants from JSDoc comments
31
+ * @traceability REQ-LEAN-TS-004
32
+ */
33
+ export declare function extractInvariantsFromJSDoc(jsdoc: string): Invariant[];
34
+ /**
35
+ * TypeScriptSpecifier class implementation
36
+ * @traceability REQ-LEAN-TS-001
37
+ */
38
+ export declare class TypeScriptSpecifier {
39
+ /**
40
+ * Specify a TypeScript function as Lean specification
41
+ */
42
+ specify(func: TypeScriptFunction): Result<LeanFunctionSpec, TypeScriptSpecificationError>;
43
+ /**
44
+ * Extract function signature info (simplified)
45
+ */
46
+ extractSignature(_code: string, _funcName: string): {
47
+ params: TypeScriptParameter[];
48
+ returnType: string;
49
+ };
50
+ /**
51
+ * Infer preconditions from function body
52
+ */
53
+ inferPreconditions(_func: TypeScriptFunction): Precondition[];
54
+ /**
55
+ * Infer postconditions from function body
56
+ */
57
+ inferPostconditions(_func: TypeScriptFunction): Postcondition[];
58
+ /**
59
+ * Convert type to Lean
60
+ */
61
+ convertType(tsType: string): string;
62
+ }
63
+ //# sourceMappingURL=TypeScriptSpecifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeScriptSpecifier.d.ts","sourceRoot":"","sources":["../../src/converters/TypeScriptSpecifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAGhB,YAAY,EACZ,aAAa,EACb,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAqB5D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAkExD;AAuED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,kBAAkB,GACvB,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,CA+CxD;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAyB3E;AAED;;;GAGG;AACH,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