lptp-mcp-server 0.1.0
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/LICENSE +29 -0
- package/README.md +91 -0
- package/build/backends/gprolog.d.ts +32 -0
- package/build/backends/gprolog.d.ts.map +1 -0
- package/build/backends/gprolog.js +113 -0
- package/build/backends/gprolog.js.map +1 -0
- package/build/backends/registry.d.ts +15 -0
- package/build/backends/registry.d.ts.map +1 -0
- package/build/backends/registry.js +61 -0
- package/build/backends/registry.js.map +1 -0
- package/build/backends/scryer.d.ts +33 -0
- package/build/backends/scryer.d.ts.map +1 -0
- package/build/backends/scryer.js +71 -0
- package/build/backends/scryer.js.map +1 -0
- package/build/backends/swipl.d.ts +24 -0
- package/build/backends/swipl.d.ts.map +1 -0
- package/build/backends/swipl.js +73 -0
- package/build/backends/swipl.js.map +1 -0
- package/build/backends/types.d.ts +27 -0
- package/build/backends/types.d.ts.map +1 -0
- package/build/backends/types.js +3 -0
- package/build/backends/types.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +355 -0
- package/build/index.js.map +1 -0
- package/build/lptpExecutor.d.ts +19 -0
- package/build/lptpExecutor.d.ts.map +1 -0
- package/build/lptpExecutor.js +520 -0
- package/build/lptpExecutor.js.map +1 -0
- package/jest.config.js +11 -0
- package/mcp-config-example.json +12 -0
- package/package.json +41 -0
- package/src/__tests__/mcp_lptp_server.test.ts +97 -0
- package/src/backends/gprolog.ts +87 -0
- package/src/backends/registry.ts +70 -0
- package/src/backends/scryer.ts +83 -0
- package/src/backends/swipl.ts +88 -0
- package/src/backends/types.ts +36 -0
- package/src/index.ts +369 -0
- package/src/lptpExecutor.ts +551 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.verifyLemma = verifyLemma;
|
|
37
|
+
exports.applyTactic = applyTactic;
|
|
38
|
+
exports.compileGr = compileGr;
|
|
39
|
+
exports.printDefinition = printDefinition;
|
|
40
|
+
exports.listFacts = listFacts;
|
|
41
|
+
exports.checkProof = checkProof;
|
|
42
|
+
const fs = __importStar(require("fs/promises"));
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const util_1 = require("util");
|
|
47
|
+
const registry_1 = require("./backends/registry");
|
|
48
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
49
|
+
// ── Resource limits (divide-and-conquer, Serral/Reynor style) ────────
|
|
50
|
+
// Scout with minimal resources first; commit only when path is tractable.
|
|
51
|
+
// These defaults are the "hard kill" safety nets — individual calls can
|
|
52
|
+
// override with tighter limits for bisection.
|
|
53
|
+
const DEFAULT_TACTIC_TIMEOUT_MS = 30_000; // 30s Node.js process kill
|
|
54
|
+
const DEFAULT_VERIFY_TIMEOUT_MS = 30_000; // 30s for verify_lemma
|
|
55
|
+
const DEFAULT_CHECK_TIMEOUT_MS = 120_000; // 120s for full file check
|
|
56
|
+
function classifyLptpOutput(stdout, stderr = "") {
|
|
57
|
+
const combined = stdout + "\n" + stderr;
|
|
58
|
+
const warnings = combined.match(/! LPTP-Warning:[^\n]*/g) || [];
|
|
59
|
+
const errors = combined.match(/! LPTP-Error:[^\n]*/g) || [];
|
|
60
|
+
const syntaxErrors = combined.match(/! LPTP-Syntax:[^\n]*/g) || [];
|
|
61
|
+
const directiveFailures = stderr
|
|
62
|
+
.split('\n')
|
|
63
|
+
.filter(line => /Goal \(directive\) failed/.test(line));
|
|
64
|
+
const isClean = warnings.length === 0
|
|
65
|
+
&& errors.length === 0
|
|
66
|
+
&& syntaxErrors.length === 0
|
|
67
|
+
&& directiveFailures.length === 0;
|
|
68
|
+
return { warnings, errors, syntaxErrors, directiveFailures, isClean };
|
|
69
|
+
}
|
|
70
|
+
function diagnosticSummary(diag) {
|
|
71
|
+
const parts = [];
|
|
72
|
+
if (diag.errors.length > 0)
|
|
73
|
+
parts.push(`${diag.errors.length} error(s)`);
|
|
74
|
+
if (diag.syntaxErrors.length > 0)
|
|
75
|
+
parts.push(`${diag.syntaxErrors.length} syntax error(s)`);
|
|
76
|
+
if (diag.warnings.length > 0)
|
|
77
|
+
parts.push(`${diag.warnings.length} warning(s)`);
|
|
78
|
+
if (diag.directiveFailures.length > 0)
|
|
79
|
+
parts.push(`${diag.directiveFailures.length} directive failure(s)`);
|
|
80
|
+
return parts.join(", ");
|
|
81
|
+
}
|
|
82
|
+
// Use LPTP_ROOT_DIR env var when available; fall back to walking up from __dirname.
|
|
83
|
+
// Returns null when LPTP cannot be located (enables simulated mode in each tool).
|
|
84
|
+
function findLptp() {
|
|
85
|
+
const root = process.env['LPTP_ROOT_DIR'];
|
|
86
|
+
if (root) {
|
|
87
|
+
const lptpSrc = path.join(root, 'src', 'lptp.pl');
|
|
88
|
+
if (require('fs').existsSync(lptpSrc))
|
|
89
|
+
return { lptpSrc, rootDir: root };
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
// Walk up from __dirname (works when installed alongside LPTP)
|
|
93
|
+
let dir = __dirname;
|
|
94
|
+
for (let i = 0; i < 8; i++) {
|
|
95
|
+
const candidate = path.join(dir, 'src', 'lptp.pl');
|
|
96
|
+
if (require('fs').existsSync(candidate)) {
|
|
97
|
+
return { lptpSrc: candidate, rootDir: dir };
|
|
98
|
+
}
|
|
99
|
+
dir = path.dirname(dir);
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the LPTP location, throwing an actionable error if not found.
|
|
105
|
+
* Use this in code paths that require LPTP to be present (non-simulated).
|
|
106
|
+
*/
|
|
107
|
+
function requireLptp() {
|
|
108
|
+
const loc = findLptp();
|
|
109
|
+
if (loc === null) {
|
|
110
|
+
throw new Error('LPTP source not found. Set LPTP_ROOT_DIR to your LPTP checkout root ' +
|
|
111
|
+
'(the directory containing src/lptp.pl).');
|
|
112
|
+
}
|
|
113
|
+
return loc;
|
|
114
|
+
}
|
|
115
|
+
/** Build env vars for exec, always including LPTP_ROOT_DIR */
|
|
116
|
+
function buildExecEnv(rootDir, backendEnv) {
|
|
117
|
+
return { ...process.env, ...backendEnv, LPTP_ROOT_DIR: rootDir };
|
|
118
|
+
}
|
|
119
|
+
async function verifyLemma(proofCode, context = "") {
|
|
120
|
+
const loc = findLptp();
|
|
121
|
+
if (!loc) {
|
|
122
|
+
return {
|
|
123
|
+
success: true,
|
|
124
|
+
output: `parsed and verified successfully\n[SIMULATED execution: LPTP not found]`
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const template = `:- initialize.
|
|
128
|
+
:- needs_gr($(lib)/list/list).
|
|
129
|
+
:- needs_gr($(lib)/nat/nat).
|
|
130
|
+
${context}
|
|
131
|
+
|
|
132
|
+
% Temporary lemma to check syntax
|
|
133
|
+
:- lemma(temp_check,
|
|
134
|
+
tt,
|
|
135
|
+
${proofCode}
|
|
136
|
+
).
|
|
137
|
+
`;
|
|
138
|
+
const tmpDir = os.tmpdir();
|
|
139
|
+
const tmpFile = path.join(tmpDir, `lptp_verify_${Date.now()}.pr`);
|
|
140
|
+
try {
|
|
141
|
+
await fs.writeFile(tmpFile, template, 'utf8');
|
|
142
|
+
const backend = (0, registry_1.getBackend)();
|
|
143
|
+
const cmd = backend.buildExecCommand(loc.lptpSrc, tmpFile);
|
|
144
|
+
try {
|
|
145
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
146
|
+
timeout: backend.nodeTimeout({}, DEFAULT_VERIFY_TIMEOUT_MS),
|
|
147
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
148
|
+
});
|
|
149
|
+
const diag = classifyLptpOutput(stdout, stderr);
|
|
150
|
+
if (!diag.isClean) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
output: `Verification produced diagnostics (${diagnosticSummary(diag)}):\n\n` + stdout,
|
|
154
|
+
warnings: diag.warnings.length,
|
|
155
|
+
errors: diag.errors.length + diag.syntaxErrors.length,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
success: true,
|
|
160
|
+
output: "Proof term parsed and verified successfully:\n\n" + stdout
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const combined = (error.stderr || "") + "\n" + (error.stdout || "");
|
|
165
|
+
if (error.killed || combined.includes('TIME_LIMIT_EXCEEDED')) {
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
output: `Verification timed out (${backend.displayName}).\nBisect: decompose the proof into smaller subgoals.\n\n` + combined,
|
|
169
|
+
error: "timeout"
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
output: "Verification failed:\n\n" + combined,
|
|
175
|
+
error: String(error)
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
await fs.unlink(tmpFile).catch(() => { });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function applyTactic(formula, tactic, context = "", limits = {}) {
|
|
184
|
+
const loc = findLptp();
|
|
185
|
+
if (!loc) {
|
|
186
|
+
// Mock response for pure testing without Prolog
|
|
187
|
+
return {
|
|
188
|
+
success: true,
|
|
189
|
+
output: "Simulated success",
|
|
190
|
+
derivation: "step([...])" // matches assertions
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const template = `:- initialize.
|
|
194
|
+
:- needs_gr($(lib)/list/list).
|
|
195
|
+
:- needs_gr($(lib)/nat/nat).
|
|
196
|
+
${context}
|
|
197
|
+
|
|
198
|
+
% Apply tactic lemma
|
|
199
|
+
:- lemma(temp_tactic_eval,
|
|
200
|
+
${formula},
|
|
201
|
+
${formula} by ${tactic}
|
|
202
|
+
).
|
|
203
|
+
`;
|
|
204
|
+
const tmpDir = os.tmpdir();
|
|
205
|
+
const tmpFile = path.join(tmpDir, `lptp_tactic_${Date.now()}.pr`);
|
|
206
|
+
try {
|
|
207
|
+
await fs.writeFile(tmpFile, template, 'utf8');
|
|
208
|
+
const backend = (0, registry_1.getBackend)();
|
|
209
|
+
const cmd = backend.buildExecCommand(loc.lptpSrc, tmpFile, limits);
|
|
210
|
+
const nodeTimeout = backend.nodeTimeout(limits, DEFAULT_TACTIC_TIMEOUT_MS);
|
|
211
|
+
try {
|
|
212
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
213
|
+
timeout: nodeTimeout,
|
|
214
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
215
|
+
});
|
|
216
|
+
const diag = classifyLptpOutput(stdout, stderr);
|
|
217
|
+
let derivation = "";
|
|
218
|
+
if (stdout.includes("======")) {
|
|
219
|
+
const parts = stdout.split("======");
|
|
220
|
+
if (parts.length >= 3) {
|
|
221
|
+
derivation = parts[1].trim();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!diag.isClean) {
|
|
225
|
+
return {
|
|
226
|
+
success: false,
|
|
227
|
+
output: `Tactic produced diagnostics (${diagnosticSummary(diag)}):\n\n` + stdout,
|
|
228
|
+
derivation: derivation,
|
|
229
|
+
warnings: diag.warnings.length,
|
|
230
|
+
errors: diag.errors.length + diag.syntaxErrors.length,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
success: true,
|
|
235
|
+
output: "Tactic applied successfully. Full output:\n" + stdout,
|
|
236
|
+
derivation: derivation
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
const combined = (error.stderr || "") + "\n" + (error.stdout || "");
|
|
241
|
+
if (error.killed || combined.includes('TIME_LIMIT_EXCEEDED')) {
|
|
242
|
+
return {
|
|
243
|
+
success: false,
|
|
244
|
+
output: `Tactic timed out (${backend.displayName}).\n` +
|
|
245
|
+
`Bisect: try lower depth, or decompose with [ind]/[comp] first.\n\n` + combined,
|
|
246
|
+
error: "timeout"
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
success: false,
|
|
251
|
+
output: "Tactic application failed:\n\n" + combined,
|
|
252
|
+
error: String(error)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
await fs.unlink(tmpFile).catch(() => { });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
async function compileGr(filePath) {
|
|
261
|
+
const loc = findLptp();
|
|
262
|
+
if (!loc) {
|
|
263
|
+
return {
|
|
264
|
+
success: true,
|
|
265
|
+
output: `[SIMULATED execution: compile_gr('${filePath}')]`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const backend = (0, registry_1.getBackend)();
|
|
269
|
+
// Alias paths like $(lib)/list/list are Prolog term structures ($ is a prefix
|
|
270
|
+
// operator, / is infix). They cannot be passed as atoms via -g because the
|
|
271
|
+
// operators aren't defined at CLI parse time. Write a temp file so Prolog's
|
|
272
|
+
// parser handles the operator syntax after lptp.pl is loaded.
|
|
273
|
+
const isAliasPath = filePath.includes('$(');
|
|
274
|
+
const compileDirective = isAliasPath
|
|
275
|
+
? `:- compile_gr(${filePath}).`
|
|
276
|
+
: `:- compile_gr('${filePath}').`;
|
|
277
|
+
const template = `:- initialize.\n${compileDirective}\n`;
|
|
278
|
+
const tmpDir = os.tmpdir();
|
|
279
|
+
const tmpFile = path.join(tmpDir, `lptp_compile_gr_${Date.now()}.pr`);
|
|
280
|
+
try {
|
|
281
|
+
await fs.writeFile(tmpFile, template, 'utf8');
|
|
282
|
+
const cmd = backend.buildCompileGrCommand(loc.lptpSrc, tmpFile);
|
|
283
|
+
try {
|
|
284
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
285
|
+
cwd: loc.rootDir,
|
|
286
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
287
|
+
timeout: backend.nodeTimeout({}, DEFAULT_TACTIC_TIMEOUT_MS),
|
|
288
|
+
});
|
|
289
|
+
const combined = (stdout || '') + (stderr || '');
|
|
290
|
+
const hasError = /ERROR/.test(combined) && !/environment_variable_not_set/.test(combined);
|
|
291
|
+
if (hasError) {
|
|
292
|
+
return {
|
|
293
|
+
success: false,
|
|
294
|
+
output: `Ground representation compilation failed:\n\n${combined}`
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
success: true,
|
|
299
|
+
output: `Ground representation compiled successfully:\n\n${combined}`
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
const combined = (error.stderr || '') + '\n' + (error.stdout || '');
|
|
304
|
+
return {
|
|
305
|
+
success: false,
|
|
306
|
+
output: `Compilation failed:\n\n${combined}`,
|
|
307
|
+
error: String(error)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
await fs.unlink(tmpFile).catch(() => { });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async function printDefinition(predicateName, context = "") {
|
|
316
|
+
const loc = findLptp();
|
|
317
|
+
if (!loc) {
|
|
318
|
+
return {
|
|
319
|
+
success: true,
|
|
320
|
+
output: `[SIMULATED execution: def('${predicateName}')]`
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
// LPTP's `def` keyword is a proof step (def succeeds P by completion),
|
|
324
|
+
// not a "print definition" directive. We query db__clauses/2 directly
|
|
325
|
+
// and use i2e__expression/2 to convert internal repr to external form.
|
|
326
|
+
const template = `:- initialize.
|
|
327
|
+
:- needs_gr($(lib)/list/list).
|
|
328
|
+
:- needs_gr($(lib)/nat/nat).
|
|
329
|
+
${context}
|
|
330
|
+
|
|
331
|
+
:- ( db__clauses(n(${predicateName}, Arity), Clauses)
|
|
332
|
+
-> length(Clauses, N),
|
|
333
|
+
format("~w/~w (~w clause(s)):~n~n", ['${predicateName}', Arity, N]),
|
|
334
|
+
forall(
|
|
335
|
+
member(clause(Head, Body, _Vars), Clauses),
|
|
336
|
+
( i2e__expression(Head, EHead),
|
|
337
|
+
i2e__expression(Body, EBody),
|
|
338
|
+
( EBody == tt
|
|
339
|
+
-> format(" ~w.~n", [EHead])
|
|
340
|
+
; format(" ~w :-~n ~w.~n", [EHead, EBody])
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
)
|
|
344
|
+
; format("No clauses found for '~w'.~n", ['${predicateName}'])
|
|
345
|
+
).
|
|
346
|
+
`;
|
|
347
|
+
const tmpDir = os.tmpdir();
|
|
348
|
+
const tmpFile = path.join(tmpDir, `lptp_def_${Date.now()}.pr`);
|
|
349
|
+
try {
|
|
350
|
+
await fs.writeFile(tmpFile, template, 'utf8');
|
|
351
|
+
const backend = (0, registry_1.getBackend)();
|
|
352
|
+
const cmd = backend.buildExecCommand(loc.lptpSrc, tmpFile);
|
|
353
|
+
try {
|
|
354
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
355
|
+
timeout: backend.nodeTimeout({}, DEFAULT_TACTIC_TIMEOUT_MS),
|
|
356
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
357
|
+
});
|
|
358
|
+
const diag = classifyLptpOutput(stdout, stderr);
|
|
359
|
+
if (!diag.isClean) {
|
|
360
|
+
return {
|
|
361
|
+
success: false,
|
|
362
|
+
output: `Definition query produced diagnostics (${diagnosticSummary(diag)}):\n\n` + stdout,
|
|
363
|
+
warnings: diag.warnings.length,
|
|
364
|
+
errors: diag.errors.length + diag.syntaxErrors.length,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
return {
|
|
368
|
+
success: true,
|
|
369
|
+
output: `Definition of ${predicateName}:\n\n` + stdout
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
return {
|
|
374
|
+
success: false,
|
|
375
|
+
output: `Failed to print definition:\n\n` + (error.stderr || "") + "\n" + (error.stdout || ""),
|
|
376
|
+
error: String(error)
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
finally {
|
|
381
|
+
await fs.unlink(tmpFile).catch(() => { });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
async function listFacts(predicateName, context = "") {
|
|
385
|
+
const loc = findLptp();
|
|
386
|
+
if (!loc) {
|
|
387
|
+
return {
|
|
388
|
+
success: true,
|
|
389
|
+
output: `[SIMULATED execution: facts('${predicateName}')]`
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const template = `:- initialize.
|
|
393
|
+
:- needs_gr($(lib)/list/list).
|
|
394
|
+
:- needs_gr($(lib)/nat/nat).
|
|
395
|
+
${context}
|
|
396
|
+
|
|
397
|
+
:- facts(${predicateName}).
|
|
398
|
+
`;
|
|
399
|
+
const tmpDir = os.tmpdir();
|
|
400
|
+
const tmpFile = path.join(tmpDir, `lptp_facts_${Date.now()}.pr`);
|
|
401
|
+
try {
|
|
402
|
+
await fs.writeFile(tmpFile, template, 'utf8');
|
|
403
|
+
const backend = (0, registry_1.getBackend)();
|
|
404
|
+
const cmd = backend.buildExecCommand(loc.lptpSrc, tmpFile);
|
|
405
|
+
try {
|
|
406
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
407
|
+
timeout: backend.nodeTimeout({}, DEFAULT_TACTIC_TIMEOUT_MS),
|
|
408
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
409
|
+
});
|
|
410
|
+
const diag = classifyLptpOutput(stdout, stderr);
|
|
411
|
+
if (!diag.isClean) {
|
|
412
|
+
return {
|
|
413
|
+
success: false,
|
|
414
|
+
output: `Facts query produced diagnostics (${diagnosticSummary(diag)}):\n\n` + stdout,
|
|
415
|
+
warnings: diag.warnings.length,
|
|
416
|
+
errors: diag.errors.length + diag.syntaxErrors.length,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
success: true,
|
|
421
|
+
output: `Known facts about ${predicateName}:\n\n` + stdout
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
return {
|
|
426
|
+
success: false,
|
|
427
|
+
output: `Failed to list facts:\n\n` + (error.stderr || "") + "\n" + (error.stdout || ""),
|
|
428
|
+
error: String(error)
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
finally {
|
|
433
|
+
await fs.unlink(tmpFile).catch(() => { });
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
async function checkProof(filePath) {
|
|
437
|
+
const resolvedPath = path.resolve(filePath);
|
|
438
|
+
const loc = findLptp();
|
|
439
|
+
if (!loc) {
|
|
440
|
+
return {
|
|
441
|
+
success: true,
|
|
442
|
+
output: `[SIMULATED execution: check('${resolvedPath}')]`
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
const backend = (0, registry_1.getBackend)();
|
|
446
|
+
if (!require('fs').existsSync(resolvedPath)) {
|
|
447
|
+
return {
|
|
448
|
+
success: false,
|
|
449
|
+
output: `Target file not found: ${resolvedPath}`
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
// LPTP's check/1 appends .pr internally — strip it to avoid double extension (.pr.pr)
|
|
453
|
+
const checkPath = resolvedPath.endsWith('.pr')
|
|
454
|
+
? resolvedPath.slice(0, -3)
|
|
455
|
+
: resolvedPath;
|
|
456
|
+
const cmd = backend.buildCheckCommand(loc.lptpSrc, checkPath);
|
|
457
|
+
try {
|
|
458
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
459
|
+
timeout: DEFAULT_CHECK_TIMEOUT_MS,
|
|
460
|
+
env: buildExecEnv(loc.rootDir, backend.execEnv()),
|
|
461
|
+
});
|
|
462
|
+
// Count LPTP diagnostics in stdout
|
|
463
|
+
const lptpWarningCount = (stdout.match(/LPTP-Warning/gi) || []).length;
|
|
464
|
+
const lptpErrorCount = (stdout.match(/LPTP-Error/gi) || []).length;
|
|
465
|
+
const hasOk = /o\.k\./.test(stdout);
|
|
466
|
+
// Count directive failures in stderr
|
|
467
|
+
// These indicate individual lemma/theorem proof failures even when LPTP reports o.k.
|
|
468
|
+
const directiveFailures = (stderr.match(/Goal \(directive\) failed/g) || []).length;
|
|
469
|
+
const warningCount = lptpWarningCount + directiveFailures;
|
|
470
|
+
const errorCount = lptpErrorCount;
|
|
471
|
+
// A proof is valid only when check/1 reports o.k. with zero warnings and zero errors
|
|
472
|
+
const isValid = hasOk && warningCount === 0 && errorCount === 0;
|
|
473
|
+
if (isValid) {
|
|
474
|
+
return {
|
|
475
|
+
success: true,
|
|
476
|
+
output: "Proof checked successfully:\n\n" + stdout,
|
|
477
|
+
warnings: 0,
|
|
478
|
+
errors: 0
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
const summary = [];
|
|
483
|
+
if (errorCount > 0)
|
|
484
|
+
summary.push(`${errorCount} LPTP error(s)`);
|
|
485
|
+
if (lptpWarningCount > 0)
|
|
486
|
+
summary.push(`${lptpWarningCount} LPTP warning(s)`);
|
|
487
|
+
if (directiveFailures > 0)
|
|
488
|
+
summary.push(`${directiveFailures} failed directive(s)`);
|
|
489
|
+
if (!hasOk)
|
|
490
|
+
summary.push("no o.k. confirmation");
|
|
491
|
+
// Include stderr directive failures in the output for diagnosis
|
|
492
|
+
const failedDirectives = stderr
|
|
493
|
+
.split('\n')
|
|
494
|
+
.filter(line => /Goal \(directive\) failed/.test(line))
|
|
495
|
+
.map(line => {
|
|
496
|
+
// Extract the lemma/theorem name from the directive failure
|
|
497
|
+
const match = line.match(/user:(lemma|theorem|corollary|definition_fun|definition_pred)\(([^,]+)/);
|
|
498
|
+
return match ? ` - ${match[1]}(${match[2]})` : null;
|
|
499
|
+
})
|
|
500
|
+
.filter(Boolean);
|
|
501
|
+
const diagOutput = failedDirectives.length > 0
|
|
502
|
+
? `\n\nFailed directives:\n${failedDirectives.join('\n')}`
|
|
503
|
+
: '';
|
|
504
|
+
return {
|
|
505
|
+
success: false,
|
|
506
|
+
output: `Proof check found issues (${summary.join(", ")}):\n\n` + stdout + diagOutput,
|
|
507
|
+
warnings: warningCount,
|
|
508
|
+
errors: errorCount
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
return {
|
|
514
|
+
success: false,
|
|
515
|
+
output: "Proof check failed:\n\n" + (error.stderr || "") + "\n" + (error.stdout || ""),
|
|
516
|
+
error: String(error)
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
//# sourceMappingURL=lptpExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lptpExecutor.js","sourceRoot":"","sources":["../src/lptpExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,kCAiEC;AAED,kCAsFC;AAED,8BA6DC;AAED,0CAsEC;AAED,8BAqDC;AAED,gCA2FC;AAtiBD,gDAAkC;AAClC,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAqC;AACrC,+BAAiC;AACjC,kDAAiD;AAEjD,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AACxE,8CAA8C;AAC9C,MAAM,yBAAyB,GAAK,MAAM,CAAC,CAAG,4BAA4B;AAC1E,MAAM,yBAAyB,GAAK,MAAM,CAAC,CAAG,wBAAwB;AACtE,MAAM,wBAAwB,GAAM,OAAO,CAAC,CAAE,2BAA2B;AAezE,SAAS,kBAAkB,CAAC,MAAc,EAAE,SAAiB,EAAE;IAC3D,MAAM,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IAExC,MAAM,QAAQ,GAAU,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC;IACvE,MAAM,MAAM,GAAY,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAM,EAAE,CAAC;IACvE,MAAM,YAAY,GAAM,QAAQ,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAK,EAAE,CAAC;IACvE,MAAM,iBAAiB,GAAG,MAAM;SAC3B,KAAK,CAAC,IAAI,CAA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BAC1D,CAAC,CAAC,EAAE,CAAC;YAET,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,6BAA6B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,MAAM,GAAG,UAAU;gBACrF,QAAQ,EAAE,YAAY;gBACtB,MAAM,EAAE,UAAU;aACrB,CAAC;QACN,CAAC;IACL,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,OAAO;YACH,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,yBAAyB,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;YACtF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACvB,CAAC;IACN,CAAC;AACL,CAAC"}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lptp-mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for LPTP (Logic Program Theorem Prover) — proof verification, tactic application, and definition querying",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"lptp-mcp-server": "build/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"lptp",
|
|
18
|
+
"theorem-prover",
|
|
19
|
+
"prolog",
|
|
20
|
+
"formal-verification"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/atp-lptp/lptp-mcp-server"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"type": "commonjs",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.27.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/jest": "^30.0.0",
|
|
36
|
+
"@types/node": "^25.3.3",
|
|
37
|
+
"jest": "^30.2.0",
|
|
38
|
+
"ts-jest": "^29.4.6",
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
|
+
}
|
|
41
|
+
}
|