MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / classifyEntry

Function classifyEntry

scripts/fungrim/guard-census.ts:80–125  ·  view source on GitHub ↗
(
  ce: ReturnType<typeof createEngine>,
  e: Entry
)

Source from the content-addressed store, hash-verified

78}
79
80function classifyEntry(
81 ce: ReturnType<typeof createEngine>,
82 e: Entry
83): EntryOutcome {
84 const conjuncts = conjunctsOf(e.assumptions);
85
86 ce.pushScope();
87 try {
88 let assumable = true;
89 let failure: EntryOutcome | undefined;
90
91 for (const c of conjuncts) {
92 let result: string;
93 try {
94 result = ce.assume(ce.expr(c as any, { canonical: !hasPartHead(c) }));
95 } catch {
96 assumable = false;
97 failure ??= 'assume-threw';
98 continue;
99 }
100 if (result !== 'ok' && result !== 'tautology') {
101 assumable = false;
102 if (result === 'contradiction') failure ??= 'contradiction';
103 else if (result === 'internal-error') failure ??= 'internal-error';
104 else failure ??= 'not-a-predicate';
105 }
106 }
107
108 if (!assumable) return failure!;
109
110 // Dischargeability: verify the full assumptions expression. Box
111 // canonically — verify() itself boxes raw, which would leave plain
112 // MathJSON unbound.
113 let verified: boolean | undefined;
114 try {
115 verified = ce.verify(ce.expr(e.assumptions as any));
116 } catch {
117 return 'verify-threw';
118 }
119 if (verified === true) return 'dischargeable';
120 if (verified === false) return 'verify-false';
121 return 'verify-undefined';
122 } finally {
123 ce.popScope();
124 }
125}
126
127function main(): void {
128 const corpus = loadCorpus(DATA_DIR);

Callers 1

mainFunction · 0.85

Calls 7

conjunctsOfFunction · 0.70
hasPartHeadFunction · 0.70
pushScopeMethod · 0.65
assumeMethod · 0.65
exprMethod · 0.65
verifyMethod · 0.65
popScopeMethod · 0.65

Tested by

no test coverage detected