logic-atlas 0.25.0 → 0.26.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.
Files changed (81) hide show
  1. package/CITATION.cff +2 -2
  2. package/README.md +8 -4
  3. package/dist/case.js +1 -1
  4. package/dist/chunks/{CasePage-R2k_0lls.js → CasePage-CbCDu1FO.js} +3 -3
  5. package/dist/chunks/{CasePage-R2k_0lls.js.map → CasePage-CbCDu1FO.js.map} +1 -1
  6. package/dist/chunks/{CausalPlayground-Cd7Sok3F.js → CausalPlayground-D93D0ceE.js} +5 -5
  7. package/dist/chunks/{CausalPlayground-Cd7Sok3F.js.map → CausalPlayground-D93D0ceE.js.map} +1 -1
  8. package/dist/chunks/{CiteBlock-irdT1sjg.js → CiteBlock-DMFqM7ZM.js} +2 -2
  9. package/dist/chunks/{CiteBlock-irdT1sjg.js.map → CiteBlock-DMFqM7ZM.js.map} +1 -1
  10. package/dist/chunks/{ConservativeExtension-BX4EtG16.js → ConservativeExtension-Cofe92ak.js} +2 -2
  11. package/dist/chunks/{ConservativeExtension-BX4EtG16.js.map → ConservativeExtension-Cofe92ak.js.map} +1 -1
  12. package/dist/chunks/{ExportMenu-B5HoqaQl.js → ExportMenu-DaLZ5rBJ.js} +3 -3
  13. package/dist/chunks/{ExportMenu-B5HoqaQl.js.map → ExportMenu-DaLZ5rBJ.js.map} +1 -1
  14. package/dist/chunks/{GraphBox-Tg3kDWNT.js → GraphBox-DjjoWUU0.js} +3 -3
  15. package/dist/chunks/{GraphBox-Tg3kDWNT.js.map → GraphBox-DjjoWUU0.js.map} +1 -1
  16. package/dist/chunks/{IdentifyPanel-BVmZsWGN.js → IdentifyPanel-CoPC-Okk.js} +3 -3
  17. package/dist/chunks/{IdentifyPanel-BVmZsWGN.js.map → IdentifyPanel-CoPC-Okk.js.map} +1 -1
  18. package/dist/chunks/{ModelEditor-oAvvVqX5.js → ModelEditor-A6kk6Si5.js} +2 -2
  19. package/dist/chunks/{ModelEditor-oAvvVqX5.js.map → ModelEditor-A6kk6Si5.js.map} +1 -1
  20. package/dist/chunks/{ProbabilityPanel-8-cC68rq.js → ProbabilityPanel-DKTFYU-j.js} +5 -5
  21. package/dist/chunks/{ProbabilityPanel-8-cC68rq.js.map → ProbabilityPanel-DKTFYU-j.js.map} +1 -1
  22. package/dist/chunks/{RulesPanel-Cr6R9xCK.js → RulesPanel-B6X9O0he.js} +3 -3
  23. package/dist/chunks/{RulesPanel-Cr6R9xCK.js.map → RulesPanel-B6X9O0he.js.map} +1 -1
  24. package/dist/chunks/SignalGraph-CWPf_sG8.js +1412 -0
  25. package/dist/chunks/SignalGraph-CWPf_sG8.js.map +1 -0
  26. package/dist/chunks/{SliderList-BrILQCA4.js → SliderList-DmDURTeF.js} +2 -2
  27. package/dist/chunks/{SliderList-BrILQCA4.js.map → SliderList-DmDURTeF.js.map} +1 -1
  28. package/dist/chunks/{WorldLanes-kxYTRnB5.js → WorldLanes-DDtJZqcA.js} +2 -2
  29. package/dist/chunks/{WorldLanes-kxYTRnB5.js.map → WorldLanes-DDtJZqcA.js.map} +1 -1
  30. package/dist/chunks/{cite-B6emUIEW.js → cite-QzNc24r2.js} +2 -2
  31. package/dist/chunks/{cite-B6emUIEW.js.map → cite-QzNc24r2.js.map} +1 -1
  32. package/dist/chunks/{export-image-IsI6PVd9.js → export-image-BBHOXOis.js} +3 -3
  33. package/dist/chunks/{export-image-IsI6PVd9.js.map → export-image-BBHOXOis.js.map} +1 -1
  34. package/dist/cite.js +1 -1
  35. package/dist/editor.js +1 -1
  36. package/dist/extension.js +1 -1
  37. package/dist/ground-cases.js +767 -0
  38. package/dist/ground-cases.js.map +1 -0
  39. package/dist/ground.css +2 -0
  40. package/dist/ground.js +3829 -0
  41. package/dist/ground.js.map +1 -0
  42. package/dist/identify.js +1 -1
  43. package/dist/index.js +8 -8
  44. package/dist/lanes.js +1 -1
  45. package/dist/playground.js +1 -1
  46. package/dist/probability.js +1 -1
  47. package/dist/style.css +1 -1
  48. package/dist/types/ground/cases/index.d.ts +7 -0
  49. package/dist/types/ground/components/DiscernibilityPanel.d.ts +35 -0
  50. package/dist/types/ground/components/GroundChecker.d.ts +16 -0
  51. package/dist/types/ground/components/ProposalTable.d.ts +20 -0
  52. package/dist/types/ground/components/StructureView.d.ts +21 -0
  53. package/dist/types/ground/components/case-text.d.ts +32 -0
  54. package/dist/types/ground/components/parts.d.ts +59 -0
  55. package/dist/types/ground/components/structure-layout.d.ts +59 -0
  56. package/dist/types/ground/components/use-premises.d.ts +21 -0
  57. package/dist/types/ground/data/analyze.d.ts +41 -0
  58. package/dist/types/ground/data/case.d.ts +52 -0
  59. package/dist/types/ground/data/load.d.ts +30 -0
  60. package/dist/types/ground/data/presets.d.ts +32 -0
  61. package/dist/types/ground/data/schema.d.ts +303 -0
  62. package/dist/types/ground/engine/closure.d.ts +34 -0
  63. package/dist/types/ground/engine/discern.d.ts +84 -0
  64. package/dist/types/ground/engine/errors.d.ts +142 -0
  65. package/dist/types/ground/engine/evaluate.d.ts +25 -0
  66. package/dist/types/ground/engine/facts.d.ts +61 -0
  67. package/dist/types/ground/engine/formula.d.ts +100 -0
  68. package/dist/types/ground/engine/index.d.ts +26 -0
  69. package/dist/types/ground/engine/premises.d.ts +58 -0
  70. package/dist/types/ground/engine/print.d.ts +29 -0
  71. package/dist/types/ground/engine/proposals.d.ts +56 -0
  72. package/dist/types/ground/engine/resolve.d.ts +46 -0
  73. package/dist/types/ground/engine/syntax.d.ts +55 -0
  74. package/dist/types/ground/i18n/en.d.ts +2 -0
  75. package/dist/types/ground/i18n/messages.d.ts +14 -0
  76. package/dist/types/ground/i18n/zh.d.ts +95 -0
  77. package/dist/types/ground/index.d.ts +22 -0
  78. package/dist/types/logic/structure.d.ts +72 -0
  79. package/package.json +12 -3
  80. package/dist/chunks/SignalGraph-yoGcj7jf.js +0 -1405
  81. package/dist/chunks/SignalGraph-yoGcj7jf.js.map +0 -1
package/dist/ground.js ADDED
@@ -0,0 +1,3829 @@
1
+ import e from "zod/v4/locales/zh-TW.js";
2
+ import { z as t } from "zod";
3
+ import { Fragment as n, createContext as r, createElement as i, useContext as a, useMemo as o, useState as s } from "react";
4
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
5
+ import d from "katex";
6
+ // src/ground/engine/errors.ts
7
+ function f(e, t, n) {
8
+ return n === void 0 ? {
9
+ code: e,
10
+ params: t
11
+ } : {
12
+ code: e,
13
+ params: t,
14
+ where: n
15
+ };
16
+ }
17
+ var p = (e) => ` at position ${e.position + 1} of ${JSON.stringify(e.source)}`, m = {
18
+ join: (e, t) => `${e}: ${t}`,
19
+ messages: {
20
+ "parse-unexpected-character": (e) => `unexpected character ${e.character}${p(e)}`,
21
+ "parse-unexpected-token": (e) => `unexpected ${e.token}${p(e)}`,
22
+ "parse-unexpected-end": (e) => `the formula ends too early${p(e)}`,
23
+ "parse-expected": (e) => `expected ${e.expected}${p(e)}`,
24
+ "unknown-symbol": (e) => `${e.name} is no individual, property, relation, definition or bound variable in ${JSON.stringify(e.formula)}`,
25
+ "wrong-arity": (e) => `${e.name} takes ${e.expected} argument(s), not ${e.got}, in ${JSON.stringify(e.formula)}`,
26
+ "wrong-sort": (e) => `${e.name} must be ${e.expected === "individual" ? "an individual" : `a ${e.expected}`} in ${JSON.stringify(e.formula)}`,
27
+ "free-variable": (e) => `${e.variable} is free in ${JSON.stringify(e.formula)}, which must be closed`,
28
+ "recursive-definition": (e) => `the definition ${e.name} uses itself`,
29
+ "duplicate-id": (e) => `${e.id} is used twice`,
30
+ "unknown-individual": (e) => `no individual ${e.id}`,
31
+ "unknown-relation": (e) => `no relation ${e.id}`,
32
+ "unknown-proposal": (e) => `no proposal ${e.id}`,
33
+ "unknown-claim": (e) => `no claim ${e.id}`,
34
+ "unknown-variant": (e) => `the definition ${e.definition} has no variant ${e.variant}`,
35
+ "unknown-premise": (e) => `no premise ${e.key}`,
36
+ "bad-premise-value": (e) => `${e.key} cannot be ${e.value}; it is one of ${e.allowed.join(", ")}`,
37
+ "too-many-individuals": (e) => `${e.count} individuals; the limit is ${e.limit}`,
38
+ "too-many-symbols": (e) => `${e.count} properties and relations; the limit is ${e.limit}`,
39
+ "too-many-facts": (e) => `${e.count} facts; the limit is ${e.limit}`,
40
+ "not-json": (e) => `not JSON: ${e.detail}`,
41
+ "too-large": () => "the document is too large",
42
+ "unknown-preset": (e) => `no preset ${e.id}`,
43
+ "expect-kind": (e) => `preset ${e.preset} expects results a ${e.kind} query does not give`,
44
+ "extension-source": (e) => `${e.id} needs exactly one of its extension and define`,
45
+ schema: (e) => e.message.en
46
+ }
47
+ };
48
+ function h(e, t = m) {
49
+ let n = t.messages[e.code](e.params);
50
+ return e.where === void 0 ? n : t.join(e.where, n);
51
+ }
52
+ var g = class extends Error {
53
+ problem;
54
+ constructor(e) {
55
+ super(h(e)), this.name = "GroundError", this.problem = e;
56
+ }
57
+ };
58
+ function _(e, t, n) {
59
+ throw new g(f(e, t, n));
60
+ }
61
+ function v(e) {
62
+ return e instanceof g ? e.problem : void 0;
63
+ }
64
+ // src/ground/engine/formula.ts
65
+ var ee = (e) => e.op === "forall" || e.op === "exists";
66
+ function y(e, t, n) {
67
+ return e.kind === "var" && e.name === t ? n : e;
68
+ }
69
+ function b(e, t, n) {
70
+ return e.kind === "var" && e.name === t ? n : e;
71
+ }
72
+ function x(e, t, n) {
73
+ return e.kind === "name" || e.kind === "prop" || e.kind === "rel" ? e : e.kind === "var" && "sort" in e ? b(e, t, n) : y(e, t, n);
74
+ }
75
+ function S(e, t, n) {
76
+ let r = e.def === void 0 ? void 0 : {
77
+ name: e.def.name,
78
+ args: e.def.args.map((e) => x(e, t, n))
79
+ }, i = (e) => r === void 0 ? e : {
80
+ ...e,
81
+ def: r
82
+ };
83
+ switch (e.op) {
84
+ case "true":
85
+ case "false": return e;
86
+ case "pred": return i({
87
+ op: "pred",
88
+ pred: b(e.pred, t, n),
89
+ args: e.args.map((e) => y(e, t, n))
90
+ });
91
+ case "eq": return i({
92
+ op: "eq",
93
+ left: y(e.left, t, n),
94
+ right: y(e.right, t, n)
95
+ });
96
+ case "E": return i({
97
+ op: "E",
98
+ arg: y(e.arg, t, n)
99
+ });
100
+ case "not": return i({
101
+ op: "not",
102
+ arg: S(e.arg, t, n)
103
+ });
104
+ case "and":
105
+ case "or":
106
+ case "imp":
107
+ case "iff": return i({
108
+ op: e.op,
109
+ left: S(e.left, t, n),
110
+ right: S(e.right, t, n)
111
+ });
112
+ case "forall":
113
+ case "exists": return e.variable === t ? e : i({
114
+ op: e.op,
115
+ variable: e.variable,
116
+ ...e.restrict === void 0 ? {} : { restrict: S(e.restrict, t, n) },
117
+ body: S(e.body, t, n)
118
+ });
119
+ case "forall2":
120
+ case "exists2": return e.variable === t ? e : i({
121
+ op: e.op,
122
+ variable: e.variable,
123
+ sort: e.sort,
124
+ range: e.range,
125
+ body: S(e.body, t, n)
126
+ });
127
+ }
128
+ }
129
+ function C(e) {
130
+ let t = [], n = (e, n) => {
131
+ !n.has(e) && !t.includes(e) && t.push(e);
132
+ }, r = (e, t) => {
133
+ e.kind === "var" && n(e.name, t);
134
+ }, i = (e, t) => {
135
+ switch (e.op) {
136
+ case "true":
137
+ case "false": return;
138
+ case "pred":
139
+ e.pred.kind === "var" && n(e.pred.name, t);
140
+ for (let n of e.args) r(n, t);
141
+ return;
142
+ case "eq":
143
+ r(e.left, t), r(e.right, t);
144
+ return;
145
+ case "E":
146
+ r(e.arg, t);
147
+ return;
148
+ case "not":
149
+ i(e.arg, t);
150
+ return;
151
+ case "and":
152
+ case "or":
153
+ case "imp":
154
+ case "iff":
155
+ i(e.left, t), i(e.right, t);
156
+ return;
157
+ default: {
158
+ let n = new Set(t).add(e.variable);
159
+ ee(e) && e.restrict !== void 0 && i(e.restrict, n), i(e.body, n);
160
+ }
161
+ }
162
+ };
163
+ return i(e, /* @__PURE__ */ new Set()), t;
164
+ }
165
+ function te(e) {
166
+ return e.kind === "var" ? `?${e.name}` : e.name;
167
+ }
168
+ function ne(e) {
169
+ return e.kind === "var" ? `?${e.name}` : e.id;
170
+ }
171
+ function re(e) {
172
+ let t = (e, n) => {
173
+ let r = (e) => e.kind === "var" && n.includes(e.name) ? `#${n.length - n.lastIndexOf(e.name)}` : te(e), i = (e) => e.kind === "var" && n.includes(e.name) ? `#${n.length - n.lastIndexOf(e.name)}` : ne(e);
174
+ switch (e.op) {
175
+ case "true":
176
+ case "false": return e.op;
177
+ case "pred": return `${i(e.pred)}(${e.args.map(r).join(",")})`;
178
+ case "eq": {
179
+ let [t, n] = [r(e.left), r(e.right)].sort();
180
+ return `${t}=${n}`;
181
+ }
182
+ case "E": return `E(${r(e.arg)})`;
183
+ case "not": return `~${t(e.arg, n)}`;
184
+ case "and":
185
+ case "or":
186
+ case "imp":
187
+ case "iff": return `(${t(e.left, n)} ${e.op} ${t(e.right, n)})`;
188
+ case "forall":
189
+ case "exists": {
190
+ let r = [...n, e.variable], i = e.restrict === void 0 ? "" : `:${t(e.restrict, r)}`;
191
+ return `${e.op}${i}.${t(e.body, r)}`;
192
+ }
193
+ case "forall2":
194
+ case "exists2": return `${e.op}[${e.range}].${t(e.body, [...n, e.variable])}`;
195
+ }
196
+ };
197
+ return t(e, []);
198
+ }
199
+ function ie(e) {
200
+ let t = [], n = (e) => {
201
+ e.kind === "name" && !t.includes(e.name) && t.push(e.name);
202
+ }, r = (e) => {
203
+ switch (e.op) {
204
+ case "pred":
205
+ e.args.forEach(n);
206
+ return;
207
+ case "eq":
208
+ n(e.left), n(e.right);
209
+ return;
210
+ case "E":
211
+ n(e.arg);
212
+ return;
213
+ case "not":
214
+ r(e.arg);
215
+ return;
216
+ case "and":
217
+ case "or":
218
+ case "imp":
219
+ case "iff":
220
+ r(e.left), r(e.right);
221
+ return;
222
+ case "forall":
223
+ case "exists":
224
+ e.restrict !== void 0 && r(e.restrict), r(e.body);
225
+ return;
226
+ case "forall2":
227
+ case "exists2":
228
+ r(e.body);
229
+ return;
230
+ }
231
+ };
232
+ return r(e), t;
233
+ }
234
+ var ae = (e) => ({
235
+ op: "not",
236
+ arg: e
237
+ }), oe = (e, t) => ({
238
+ op: "and",
239
+ left: e,
240
+ right: t
241
+ }), se = (e, t) => ({
242
+ op: "or",
243
+ left: e,
244
+ right: t
245
+ }), w = {
246
+ conjunction: ["on", "off"],
247
+ disjunction: ["on", "off"],
248
+ existential: ["on", "off"],
249
+ universal: ["unrestricted", "restricted"],
250
+ equivalents: ["on", "off"],
251
+ transitivity: ["on", "off"],
252
+ necessitation: ["on", "off"],
253
+ existence: ["quantified", "predicate"],
254
+ scope: [
255
+ "qualitative",
256
+ "nonhaecceitistic",
257
+ "all"
258
+ ]
259
+ }, ce = Object.keys(w);
260
+ function le(e) {
261
+ return {
262
+ ...Object.fromEntries(ce.map((e) => [e, w[e][0]])),
263
+ defs: Object.fromEntries(Object.entries(e.defs).map(([e, t]) => [e, t.default])),
264
+ claims: { ...e.claims }
265
+ };
266
+ }
267
+ function ue(e) {
268
+ return [
269
+ ...ce,
270
+ ...Object.keys(e.defs).map((e) => `def:${e}`),
271
+ ...Object.keys(e.claims).map((e) => `claim:${e}`)
272
+ ];
273
+ }
274
+ function de(e, t) {
275
+ if (t in w) return w[t];
276
+ if (t.startsWith("def:")) {
277
+ let n = e.defs[t.slice(4)];
278
+ return n === void 0 && _("unknown-premise", { key: t }), [n.default, ...n.variants.filter((e) => e !== n.default)];
279
+ }
280
+ if (t.startsWith("claim:")) return t.slice(6) in e.claims || _("unknown-premise", { key: t }), ["on", "off"];
281
+ _("unknown-premise", { key: t });
282
+ }
283
+ function fe(e, t, n) {
284
+ if (t === void 0) return e;
285
+ let r = e;
286
+ for (let [e, i] of Object.entries(t)) {
287
+ let t = de(n, e);
288
+ t.includes(i) || _("bad-premise-value", {
289
+ key: e,
290
+ value: i,
291
+ allowed: t
292
+ }), r = e.startsWith("def:") ? {
293
+ ...r,
294
+ defs: {
295
+ ...r.defs,
296
+ [e.slice(4)]: i
297
+ }
298
+ } : e.startsWith("claim:") ? {
299
+ ...r,
300
+ claims: {
301
+ ...r.claims,
302
+ [e.slice(6)]: i === "on"
303
+ }
304
+ } : {
305
+ ...r,
306
+ [e]: i
307
+ };
308
+ }
309
+ return r;
310
+ }
311
+ function pe(e, t) {
312
+ return t.startsWith("def:") ? e.defs[t.slice(4)] ?? "" : t.startsWith("claim:") ? e.claims[t.slice(6)] === !0 ? "on" : "off" : e[t] ?? "";
313
+ }
314
+ function me(e, t, n) {
315
+ return ue(e).filter((e) => pe(t, e) !== pe(n, e));
316
+ }
317
+ // src/logic/structure.ts
318
+ var he = 8;
319
+ function T(e, t) {
320
+ let n = e.names[t];
321
+ return n === void 0 ? e.individuals.includes(t) ? t : void 0 : n;
322
+ }
323
+ function ge(e) {
324
+ let t = [...e.individuals];
325
+ for (let n of Object.keys(e.names)) t.includes(n) || t.push(n);
326
+ return t;
327
+ }
328
+ function _e(e, t) {
329
+ return e.properties.find((e) => e.id === t);
330
+ }
331
+ function ve(e, t) {
332
+ return e.relations.find((e) => e.id === t);
333
+ }
334
+ function E(e, t) {
335
+ return e.extension.includes(t);
336
+ }
337
+ function D(e, t, n) {
338
+ return e.pairs.some(([e, r]) => e === t && r === n);
339
+ }
340
+ function ye(e, t) {
341
+ return {
342
+ elements: e.individuals,
343
+ pairs: t.pairs
344
+ };
345
+ }
346
+ function be(e) {
347
+ return e.individuals.map((e) => ({
348
+ id: `=${e}`,
349
+ qualitative: !1,
350
+ extension: [e],
351
+ haecceityOf: e
352
+ }));
353
+ }
354
+ function xe(e, t = !0) {
355
+ let n = e.individuals;
356
+ if (n.length > 8) throw RangeError(`${n.length} individuals; the limit is 8`);
357
+ let r = e.properties.filter((e) => !t || e.qualitative).map((e) => new Set(e.extension)), i = e.relations.filter((e) => !t || e.qualitative).map((e) => new Set(e.pairs.map(([e, t]) => `${e}\u0000${t}`))), a = [], o = [], s = /* @__PURE__ */ new Set(), c = (e) => {
358
+ let t = n[e], a = o[e];
359
+ for (let e of r) if (e.has(t) !== e.has(a)) return !1;
360
+ for (let r of i) for (let i = 0; i <= e; i++) {
361
+ let e = n[i], s = o[i];
362
+ if (r.has(`${t}\u0000${e}`) !== r.has(`${a}\u0000${s}`) || r.has(`${e}\u0000${t}`) !== r.has(`${s}\u0000${a}`)) return !1;
363
+ }
364
+ return !0;
365
+ }, l = (e) => {
366
+ if (e === n.length) a.push(Object.fromEntries(n.map((e, t) => [e, o[t]])));
367
+ else for (let t of n) s.has(t) || (o[e] = t, c(e) && (s.add(t), l(e + 1), s.delete(t)));
368
+ };
369
+ return l(0), a;
370
+ }
371
+ function Se(e, t, n, r = xe(e)) {
372
+ return r.some((e) => e[t] === n);
373
+ }
374
+ // src/ground/engine/evaluate.ts
375
+ function O(e, t) {
376
+ let n = e.properties.filter((e) => e.haecceityOf === void 0), r = n.filter((e) => e.qualitative).map((e) => ({
377
+ kind: "prop",
378
+ id: e.id
379
+ }));
380
+ return {
381
+ structure: e,
382
+ ranges: {
383
+ Qual: r,
384
+ Prop: t.scope === "qualitative" ? r : (t.scope === "nonhaecceitistic" ? n : e.properties).map((e) => ({
385
+ kind: "prop",
386
+ id: e.id
387
+ })),
388
+ Rel: e.relations.map((e) => ({
389
+ kind: "rel",
390
+ id: e.id
391
+ }))
392
+ },
393
+ names: ge(e)
394
+ };
395
+ }
396
+ function Ce(e, t, n) {
397
+ if (t.kind === "var") {
398
+ let e = n.get(t.name);
399
+ if (typeof e != "string") throw Error(`unbound variable ${t.name}`);
400
+ return e;
401
+ }
402
+ let r = T(e.structure, t.name);
403
+ if (r === void 0) throw Error(`no individual named ${t.name}`);
404
+ return r;
405
+ }
406
+ function we(e, t) {
407
+ if (e.kind !== "var") return e;
408
+ let n = t.get(e.name);
409
+ if (n === void 0 || typeof n == "string" || n.kind === "var") throw Error(`unbound variable ${e.name}`);
410
+ return n;
411
+ }
412
+ function k(e, t, n) {
413
+ switch (t.op) {
414
+ case "true": return !0;
415
+ case "false": return !1;
416
+ case "pred": {
417
+ let r = we(t.pred, n), i = t.args.map((t) => Ce(e, t, n));
418
+ if (r.kind === "prop") {
419
+ let t = _e(e.structure, r.id);
420
+ return t !== void 0 && E(t, i[0]);
421
+ }
422
+ let a = ve(e.structure, r.id);
423
+ return a !== void 0 && D(a, i[0], i[1]);
424
+ }
425
+ case "eq": return Ce(e, t.left, n) === Ce(e, t.right, n);
426
+ case "E": return e.structure.individuals.includes(Ce(e, t.arg, n));
427
+ case "not": return !k(e, t.arg, n);
428
+ case "and": return k(e, t.left, n) && k(e, t.right, n);
429
+ case "or": return k(e, t.left, n) || k(e, t.right, n);
430
+ case "imp": return !k(e, t.left, n) || k(e, t.right, n);
431
+ case "iff": return k(e, t.left, n) === k(e, t.right, n);
432
+ case "forall":
433
+ case "exists": {
434
+ let r = (r) => {
435
+ let i = new Map(n).set(t.variable, r);
436
+ return t.restrict !== void 0 && !k(e, t.restrict, i) ? t.op === "forall" : k(e, t.body, i);
437
+ };
438
+ return t.op === "forall" ? e.structure.individuals.every(r) : e.structure.individuals.some(r);
439
+ }
440
+ case "forall2":
441
+ case "exists2": {
442
+ let r = (r) => k(e, t.body, new Map(n).set(t.variable, r)), i = e.ranges[t.range];
443
+ return t.op === "forall2" ? i.every(r) : i.some(r);
444
+ }
445
+ }
446
+ }
447
+ function A(e, t) {
448
+ return k(e, t, /* @__PURE__ */ new Map());
449
+ }
450
+ function Te(e, t, n) {
451
+ return k(e, t, new Map(Object.entries(n)));
452
+ }
453
+ // src/ground/engine/syntax.ts
454
+ var Ee = [
455
+ "Qual",
456
+ "Prop",
457
+ "Rel"
458
+ ], De = /^[A-Za-z_][A-Za-z0-9_]*$/, Oe = /* @__PURE__ */ new Set([
459
+ "forall",
460
+ "exists",
461
+ "in",
462
+ "true",
463
+ "false",
464
+ "E",
465
+ ...Ee
466
+ ]), ke = [
467
+ ["<->", "iff"],
468
+ ["->", "imp"],
469
+ ["!=", "neq"],
470
+ ["~", "not"],
471
+ ["¬", "not"],
472
+ ["&", "and"],
473
+ ["∧", "and"],
474
+ ["|", "or"],
475
+ ["∨", "or"],
476
+ ["→", "imp"],
477
+ ["↔", "iff"],
478
+ ["≠", "neq"],
479
+ ["=", "eq"],
480
+ ["∀", "forall"],
481
+ ["∃", "exists"],
482
+ ["(", "("],
483
+ [")", ")"],
484
+ [",", ","],
485
+ [":", ":"]
486
+ ], Ae = {
487
+ forall: "forall",
488
+ exists: "exists",
489
+ in: "in",
490
+ true: "true",
491
+ false: "false"
492
+ };
493
+ function je(e) {
494
+ let t = [], n = 0;
495
+ outer: for (; n < e.length;) {
496
+ let r = e[n];
497
+ if (/\s/.test(r)) {
498
+ n += 1;
499
+ continue;
500
+ }
501
+ let i = /^[A-Za-z_][A-Za-z0-9_]*/.exec(e.slice(n));
502
+ if (i !== null) {
503
+ let e = i[0];
504
+ t.push({
505
+ kind: Ae[e] ?? "id",
506
+ text: e,
507
+ position: n
508
+ }), n += e.length;
509
+ } else {
510
+ for (let [r, i] of ke) if (e.startsWith(r, n)) {
511
+ t.push({
512
+ kind: i,
513
+ text: r,
514
+ position: n
515
+ }), n += r.length;
516
+ continue outer;
517
+ }
518
+ _("parse-unexpected-character", {
519
+ source: e,
520
+ position: n,
521
+ character: r
522
+ });
523
+ }
524
+ }
525
+ return t;
526
+ }
527
+ var Me = {
528
+ and: 4,
529
+ or: 3,
530
+ imp: 2,
531
+ iff: 1
532
+ }, Ne = class {
533
+ i = 0;
534
+ source;
535
+ tokens;
536
+ constructor(e, t) {
537
+ this.source = e, this.tokens = t;
538
+ }
539
+ parse() {
540
+ let e = this.binary(1), t = this.tokens[this.i];
541
+ return t !== void 0 && _("parse-unexpected-token", {
542
+ source: this.source,
543
+ position: t.position,
544
+ token: t.text
545
+ }), e;
546
+ }
547
+ peek(e = 0) {
548
+ return this.tokens[this.i + e];
549
+ }
550
+ expect(e, t) {
551
+ let n = this.peek();
552
+ return n === void 0 && _("parse-unexpected-end", {
553
+ source: this.source,
554
+ position: this.source.length
555
+ }), n.kind !== e && _("parse-expected", {
556
+ source: this.source,
557
+ position: n.position,
558
+ expected: t
559
+ }), this.i += 1, n;
560
+ }
561
+ identifier(e = "a name") {
562
+ return this.expect("id", e).text;
563
+ }
564
+ binary(e) {
565
+ let t = this.unary();
566
+ for (;;) {
567
+ let n = this.peek();
568
+ if (n === void 0 || !(n.kind in Me)) return t;
569
+ let r = n.kind, i = Me[r];
570
+ if (i < e) return t;
571
+ this.i += 1;
572
+ let a = this.binary(r === "imp" || r === "iff" ? i : i + 1);
573
+ t = {
574
+ op: r,
575
+ left: t,
576
+ right: a
577
+ };
578
+ }
579
+ }
580
+ unary() {
581
+ let e = this.peek();
582
+ if (e === void 0 && _("parse-unexpected-end", {
583
+ source: this.source,
584
+ position: this.source.length
585
+ }), e.kind === "not") return this.i += 1, {
586
+ op: "not",
587
+ arg: this.unary()
588
+ };
589
+ if (e.kind === "forall" || e.kind === "exists") return this.i += 1, this.quantifier(e.kind);
590
+ if (e.kind === "(") {
591
+ let e = this.peek(1), t = this.peek(2);
592
+ if ((e?.kind === "forall" || e?.kind === "exists") && t?.kind === "id" && this.peek(3)?.kind === ":") {
593
+ this.i += 4;
594
+ let n = this.binary(1);
595
+ return this.expect(")", ")"), {
596
+ op: e.kind,
597
+ variable: t.text,
598
+ restrict: n,
599
+ body: this.unary()
600
+ };
601
+ }
602
+ this.i += 1;
603
+ let n = this.binary(1);
604
+ return this.expect(")", ")"), n;
605
+ }
606
+ if (e.kind === "true" || e.kind === "false") return this.i += 1, { op: e.kind };
607
+ if (e.kind === "id") return this.atomic();
608
+ _("parse-unexpected-token", {
609
+ source: this.source,
610
+ position: e.position,
611
+ token: e.text
612
+ });
613
+ }
614
+ quantifier(e) {
615
+ let t = this.identifier("a variable");
616
+ if (this.peek()?.kind === "in") {
617
+ this.i += 1;
618
+ let n = this.identifier("Qual, Prop or Rel");
619
+ return Ee.includes(n) || _("parse-expected", {
620
+ source: this.source,
621
+ position: this.tokens[this.i - 1].position,
622
+ expected: "Qual, Prop or Rel"
623
+ }), {
624
+ op: e === "forall" ? "forall2" : "exists2",
625
+ variable: t,
626
+ range: n,
627
+ body: this.unary()
628
+ };
629
+ }
630
+ return {
631
+ op: e,
632
+ variable: t,
633
+ body: this.unary()
634
+ };
635
+ }
636
+ atomic() {
637
+ let e = this.identifier(), t = this.peek();
638
+ if (t?.kind === "(") {
639
+ this.i += 1;
640
+ let t = [this.identifier("an argument")];
641
+ for (; this.peek()?.kind === ",";) this.i += 1, t.push(this.identifier("an argument"));
642
+ return this.expect(")", ")"), {
643
+ op: "app",
644
+ name: e,
645
+ args: t
646
+ };
647
+ }
648
+ if (t?.kind === "eq" || t?.kind === "neq") {
649
+ this.i += 1;
650
+ let n = {
651
+ op: "eq",
652
+ left: e,
653
+ right: this.identifier("a name")
654
+ };
655
+ return t.kind === "eq" ? n : {
656
+ op: "not",
657
+ arg: n
658
+ };
659
+ }
660
+ t === void 0 && _("parse-unexpected-end", {
661
+ source: this.source,
662
+ position: this.source.length
663
+ }), _("parse-expected", {
664
+ source: this.source,
665
+ position: t.position,
666
+ expected: "( or ="
667
+ });
668
+ }
669
+ };
670
+ function Pe(e) {
671
+ return new Ne(e, je(e)).parse();
672
+ }
673
+ // src/ground/engine/resolve.ts
674
+ var Fe = [
675
+ {
676
+ name: "Refl",
677
+ params: ["R"],
678
+ variants: { default: "forall x R(x, x)" },
679
+ defaultVariant: "default",
680
+ premise: "def:Refl"
681
+ },
682
+ {
683
+ name: "Irr",
684
+ params: ["R"],
685
+ variants: {
686
+ conditional: "forall x forall y (R(x, y) -> x != y)",
687
+ negation: "forall x ~R(x, x)"
688
+ },
689
+ defaultVariant: "conditional",
690
+ premise: "def:Irr"
691
+ },
692
+ {
693
+ name: "Exists",
694
+ params: ["x"],
695
+ variants: {
696
+ quantified: "exists y (y = x)",
697
+ predicate: "E(x)"
698
+ },
699
+ defaultVariant: "quantified",
700
+ premise: "existence"
701
+ }
702
+ ];
703
+ function Ie(e) {
704
+ let t = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*([A-Za-z_][A-Za-z0-9_]*(?:\s*,\s*[A-Za-z_][A-Za-z0-9_]*)*)\s*\)\s*$/.exec(e);
705
+ if (t !== null) return {
706
+ name: t[1],
707
+ params: t[2].split(",").map((e) => e.trim())
708
+ };
709
+ }
710
+ function Le(e, t) {
711
+ return e.premise === "existence" ? e.variants[t.existence] === void 0 ? e.defaultVariant : t.existence : t.defs[e.name] ?? e.defaultVariant;
712
+ }
713
+ var Re = /* @__PURE__ */ new Map();
714
+ function ze(e) {
715
+ let t = Re.get(e);
716
+ return t === void 0 && (t = Pe(e), Re.size > 500 && Re.clear(), Re.set(e, t)), t;
717
+ }
718
+ function j(e) {
719
+ return new Map(Object.entries(e).map(([e, t]) => t === "individual" ? [e, {
720
+ kind: "term",
721
+ term: {
722
+ kind: "var",
723
+ name: e
724
+ }
725
+ }] : [e, {
726
+ kind: "pred",
727
+ pred: {
728
+ kind: "var",
729
+ name: e,
730
+ sort: t
731
+ }
732
+ }]));
733
+ }
734
+ var Be = class e {
735
+ vocab;
736
+ premises;
737
+ source;
738
+ constructor(e, t, n) {
739
+ this.vocab = e, this.premises = t, this.source = n;
740
+ }
741
+ run(e, t, n) {
742
+ switch (e.op) {
743
+ case "true":
744
+ case "false": return { op: e.op };
745
+ case "eq": return {
746
+ op: "eq",
747
+ left: this.term(e.left, t),
748
+ right: this.term(e.right, t)
749
+ };
750
+ case "not": return {
751
+ op: "not",
752
+ arg: this.run(e.arg, t, n)
753
+ };
754
+ case "and":
755
+ case "or":
756
+ case "imp":
757
+ case "iff": return {
758
+ op: e.op,
759
+ left: this.run(e.left, t, n),
760
+ right: this.run(e.right, t, n)
761
+ };
762
+ case "forall":
763
+ case "exists": {
764
+ let r = Ve(e.variable, t), i = new Map(t).set(e.variable, {
765
+ kind: "term",
766
+ term: {
767
+ kind: "var",
768
+ name: r
769
+ }
770
+ }), a = e.restrict === void 0 ? void 0 : this.run(e.restrict, i, n);
771
+ return {
772
+ op: e.op,
773
+ variable: r,
774
+ ...a === void 0 ? {} : { restrict: a },
775
+ body: this.run(e.body, i, n)
776
+ };
777
+ }
778
+ case "forall2":
779
+ case "exists2": {
780
+ let r = Ve(e.variable, t), i = e.range === "Rel" ? "relation" : "property", a = new Map(t).set(e.variable, {
781
+ kind: "pred",
782
+ pred: {
783
+ kind: "var",
784
+ name: r,
785
+ sort: i
786
+ }
787
+ });
788
+ return {
789
+ op: e.op,
790
+ variable: r,
791
+ sort: i,
792
+ range: e.range,
793
+ body: this.run(e.body, a, n)
794
+ };
795
+ }
796
+ case "app": return this.app(e.name, e.args, t, n);
797
+ }
798
+ }
799
+ app(e, t, n, r) {
800
+ let i = n.get(e);
801
+ if (i !== void 0) return i.kind === "term" && _("wrong-sort", {
802
+ name: e,
803
+ expected: "property",
804
+ formula: this.source
805
+ }), this.atom(e, i.pred, t, n);
806
+ let a = this.vocab.defs.get(e);
807
+ if (a !== void 0) return this.expand(a, t, n, r);
808
+ if (e === "E") return this.arity(e, 1, t), {
809
+ op: "E",
810
+ arg: this.term(t[0], n)
811
+ };
812
+ if (this.vocab.properties.has(e)) return this.atom(e, {
813
+ kind: "prop",
814
+ id: e
815
+ }, t, n);
816
+ if (this.vocab.relations.has(e)) return this.atom(e, {
817
+ kind: "rel",
818
+ id: e
819
+ }, t, n);
820
+ this.vocab.names.has(e) && _("wrong-sort", {
821
+ name: e,
822
+ expected: "property",
823
+ formula: this.source
824
+ }), _("unknown-symbol", {
825
+ name: e,
826
+ formula: this.source
827
+ });
828
+ }
829
+ atom(e, t, n, r) {
830
+ let i = t.kind === "var" ? t.sort : t.kind === "prop" ? "property" : "relation";
831
+ return this.arity(e, i === "property" ? 1 : 2, n), {
832
+ op: "pred",
833
+ pred: t,
834
+ args: n.map((e) => this.term(e, r))
835
+ };
836
+ }
837
+ arity(e, t, n) {
838
+ n.length !== t && _("wrong-arity", {
839
+ name: e,
840
+ expected: t,
841
+ got: n.length,
842
+ formula: this.source
843
+ });
844
+ }
845
+ term(e, t) {
846
+ let n = t.get(e);
847
+ if (n !== void 0) return n.kind === "pred" && _("wrong-sort", {
848
+ name: e,
849
+ expected: "individual",
850
+ formula: this.source
851
+ }), n.term;
852
+ if (this.vocab.names.has(e)) return {
853
+ kind: "name",
854
+ name: e
855
+ };
856
+ (this.vocab.properties.has(e) || this.vocab.relations.has(e)) && _("wrong-sort", {
857
+ name: e,
858
+ expected: "individual",
859
+ formula: this.source
860
+ }), _("unknown-symbol", {
861
+ name: e,
862
+ formula: this.source
863
+ });
864
+ }
865
+ argument(e, t) {
866
+ let n = t.get(e);
867
+ if (n !== void 0) return n;
868
+ if (this.vocab.names.has(e)) return {
869
+ kind: "term",
870
+ term: {
871
+ kind: "name",
872
+ name: e
873
+ }
874
+ };
875
+ if (this.vocab.properties.has(e)) return {
876
+ kind: "pred",
877
+ pred: {
878
+ kind: "prop",
879
+ id: e
880
+ }
881
+ };
882
+ if (this.vocab.relations.has(e)) return {
883
+ kind: "pred",
884
+ pred: {
885
+ kind: "rel",
886
+ id: e
887
+ }
888
+ };
889
+ _("unknown-symbol", {
890
+ name: e,
891
+ formula: this.source
892
+ });
893
+ }
894
+ expand(t, n, r, i) {
895
+ i.includes(t.name) && _("recursive-definition", { name: t.name }), this.arity(t.name, t.params.length, n);
896
+ let a = n.map((e) => this.argument(e, r)), o = new Map(t.params.map((e, t) => [e, a[t]])), s = t.variants[Le(t, this.premises)], c = new e(this.vocab, this.premises, s).run(ze(s), o, [...i, t.name]), l = a.map((e) => e.kind === "term" ? e.term : e.pred);
897
+ return {
898
+ ...c,
899
+ def: {
900
+ name: t.name,
901
+ args: l
902
+ }
903
+ };
904
+ }
905
+ };
906
+ function Ve(e, t) {
907
+ let n = /* @__PURE__ */ new Set();
908
+ for (let [r, i] of t) r !== e && (i.kind === "term" && i.term.kind === "var" && n.add(i.term.name), i.kind === "pred" && i.pred.kind === "var" && n.add(i.pred.name));
909
+ if (!n.has(e)) return e;
910
+ for (let t = 1;; t++) if (!n.has(`${e}${t}`)) return `${e}${t}`;
911
+ }
912
+ function M(e, t, n, r = /* @__PURE__ */ new Map()) {
913
+ return new Be(t, n, e).run(ze(e), r, []);
914
+ }
915
+ // src/ground/engine/proposals.ts
916
+ var He = [
917
+ {
918
+ id: "property",
919
+ identity: { full: ["forall X in Prop (X(x) <-> X(y))"] },
920
+ distinctness: { full: ["exists X in Prop (X(x) & ~X(y)) | exists X in Prop (~X(x) & X(y))"] }
921
+ },
922
+ {
923
+ id: "weak",
924
+ identity: { full: ["forall R in Rel (R(x, y) -> Refl(R))"] },
925
+ distinctness: {
926
+ full: ["R(x, y)", "Irr(R)"],
927
+ some: { R: "Rel" }
928
+ }
929
+ },
930
+ {
931
+ id: "existence",
932
+ identity: { full: ["Exists(x)"] },
933
+ distinctness: { full: ["Exists(x)", "Exists(y)"] }
934
+ }
935
+ ], Ue = [
936
+ "explained",
937
+ "no-ground",
938
+ "necessitation-conflict",
939
+ "trivial",
940
+ "same-ground"
941
+ ];
942
+ function We(e, t, n) {
943
+ let r = {
944
+ x: "individual",
945
+ y: "individual"
946
+ };
947
+ for (let [t, n] of Object.entries(e.some ?? {})) r[t] = n === "Rel" ? "relation" : "property";
948
+ return e.full.map((e) => M(e, t, n, j(r)));
949
+ }
950
+ function Ge(e, t, n, r, i) {
951
+ let a = [{ facts: t.map((e) => S(S(e, "x", {
952
+ kind: "name",
953
+ name: r
954
+ }), "y", {
955
+ kind: "name",
956
+ name: i
957
+ })) }];
958
+ for (let [t, r] of Object.entries(e.some ?? {})) a = a.flatMap((e) => n.ranges[r].map((n) => ({
959
+ witness: n.kind === "var" ? e.witness : n.id,
960
+ facts: e.facts.map((e) => S(e, t, n))
961
+ })));
962
+ return a;
963
+ }
964
+ function Ke(e, t, n, r, i, a) {
965
+ let o = Ge(e, t, n, i, a), s = o.find((e) => e.facts.every((e) => A(n, e))), c = s ?? o[0] ?? { facts: [] }, l = Ge(e, t, r, i, a).some((e) => e.facts.every((e) => A(r, e)));
966
+ return {
967
+ holds: s !== void 0,
968
+ qualitativeHolds: l,
969
+ facts: c.facts,
970
+ truth: c.facts.map((e) => A(n, e)),
971
+ ...s?.witness === void 0 ? {} : { witness: s.witness },
972
+ mentionsY: t.some((e) => C(e).includes("y"))
973
+ };
974
+ }
975
+ var qe = (e, t) => JSON.stringify([[...e.full].sort(), e.some ?? {}]) === JSON.stringify([[...t.full].sort(), t.some ?? {}]);
976
+ function Je(e, t, n, r, i, a) {
977
+ let o = T(t.structure, i), s = T(t.structure, a);
978
+ o === void 0 && _("unknown-individual", { id: i }), s === void 0 && _("unknown-individual", { id: a });
979
+ let c = o === s, l = r.scope === "qualitative" ? t : O(t.structure, { scope: "qualitative" }), u = Ke(e.identity, We(e.identity, n, r), t, l, i, a), d = Ke(e.distinctness, We(e.distinctness, n, r), t, l, i, a), f = c ? u : d, p = r.necessitation === "on", m;
980
+ return m = !c && p && u.holds && u.mentionsY ? "necessitation-conflict" : f.holds ? qe(e.identity, e.distinctness) ? "same-ground" : f.qualitativeHolds ? "explained" : "trivial" : "no-ground", {
981
+ id: e.id,
982
+ same: c,
983
+ identity: u,
984
+ distinctness: d,
985
+ verdict: m,
986
+ necessitationOff: !c && !p && u.holds && u.mentionsY && !d.holds
987
+ };
988
+ }
989
+ // src/ground/data/case.ts
990
+ var Ye = 24;
991
+ function Xe(e) {
992
+ let t = new Map(Fe.map((e) => [e.name, e])), n = {};
993
+ for (let [r, i] of Object.entries(e.defs)) {
994
+ let e = Ie(r);
995
+ e === void 0 && _("parse-expected", {
996
+ source: r,
997
+ position: 0,
998
+ expected: "Name(params)"
999
+ }, `defs.${r}`), typeof i == "string" ? t.set(e.name, {
1000
+ name: e.name,
1001
+ params: e.params,
1002
+ variants: { default: i },
1003
+ defaultVariant: "default",
1004
+ premise: `def:${e.name}`
1005
+ }) : (i.default in i.variants || _("unknown-variant", {
1006
+ definition: e.name,
1007
+ variant: i.default
1008
+ }, `defs.${r}.default`), t.set(e.name, {
1009
+ name: e.name,
1010
+ params: e.params,
1011
+ variants: i.variants,
1012
+ defaultVariant: i.default,
1013
+ premise: `def:${e.name}`
1014
+ }), i.label !== void 0 && (n[e.name] = i.label));
1015
+ }
1016
+ return {
1017
+ defs: t,
1018
+ labels: n
1019
+ };
1020
+ }
1021
+ function Ze(e, t) {
1022
+ let n = [], r = (e) => t.names.has(e) || t.properties.has(e) || t.relations.has(e) || t.defs.has(e) || Oe.has(e), i = (e, t) => {
1023
+ t.has(e) || r(e) || n.includes(e) || n.push(e);
1024
+ }, a = (e, t) => {
1025
+ switch (e.op) {
1026
+ case "app":
1027
+ for (let n of e.args) i(n, t);
1028
+ return;
1029
+ case "eq":
1030
+ i(e.left, t), i(e.right, t);
1031
+ return;
1032
+ case "not":
1033
+ a(e.arg, t);
1034
+ return;
1035
+ case "and":
1036
+ case "or":
1037
+ case "imp":
1038
+ case "iff":
1039
+ a(e.left, t), a(e.right, t);
1040
+ return;
1041
+ case "forall":
1042
+ case "exists":
1043
+ case "forall2":
1044
+ case "exists2": {
1045
+ let n = new Set(t).add(e.variable);
1046
+ "restrict" in e && e.restrict !== void 0 && a(e.restrict, n), a(e.body, n);
1047
+ return;
1048
+ }
1049
+ }
1050
+ };
1051
+ return a(e, /* @__PURE__ */ new Set()), n;
1052
+ }
1053
+ function Qe(e, t, n) {
1054
+ let r = e.structure, i = r.individuals.map((e) => e.id), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1055
+ r.properties.forEach((e, t) => {
1056
+ e.holds === void 0 == (e.define === void 0) && _("extension-source", { id: e.id }, `structure.properties.${t}`), e.holds !== void 0 && a.set(e.id, {
1057
+ id: e.id,
1058
+ qualitative: e.qualitative,
1059
+ extension: e.holds
1060
+ });
1061
+ }), r.relations.forEach((e, t) => {
1062
+ e.pairs === void 0 == (e.define === void 0) && _("extension-source", { id: e.id }, `structure.relations.${t}`), e.pairs !== void 0 && o.set(e.id, {
1063
+ id: e.id,
1064
+ qualitative: e.qualitative,
1065
+ pairs: e.pairs
1066
+ });
1067
+ });
1068
+ let s = () => O({
1069
+ individuals: i,
1070
+ names: r.names,
1071
+ properties: [...a.values()],
1072
+ relations: [...o.values()]
1073
+ }, n), c = (e, r, i) => {
1074
+ let a = M(e, t, n, j(Object.fromEntries(r.map((e) => [e, "individual"])))), o = C(a).find((e) => !r.includes(e));
1075
+ return o !== void 0 && _("free-variable", {
1076
+ variable: o,
1077
+ formula: e
1078
+ }, i), a;
1079
+ };
1080
+ r.properties.forEach((e, t) => {
1081
+ if (e.define === void 0) return;
1082
+ let n = c(e.define, ["x"], `structure.properties.${t}.define`), r = s();
1083
+ a.set(e.id, {
1084
+ id: e.id,
1085
+ qualitative: e.qualitative,
1086
+ extension: i.filter((e) => Te(r, n, { x: e }))
1087
+ });
1088
+ }), r.relations.forEach((e, t) => {
1089
+ if (e.define === void 0) return;
1090
+ let n = c(e.define, ["x", "y"], `structure.relations.${t}.define`), r = s(), a = i.flatMap((e) => i.filter((t) => Te(r, n, {
1091
+ x: e,
1092
+ y: t
1093
+ })).map((t) => [e, t]));
1094
+ o.set(e.id, {
1095
+ id: e.id,
1096
+ qualitative: e.qualitative,
1097
+ pairs: a
1098
+ });
1099
+ });
1100
+ let l = {
1101
+ individuals: i,
1102
+ names: r.names,
1103
+ properties: r.properties.map((e) => a.get(e.id)),
1104
+ relations: r.relations.map((e) => o.get(e.id))
1105
+ };
1106
+ return r.haecceities === "available" ? {
1107
+ ...l,
1108
+ properties: [...l.properties, ...be(l)]
1109
+ } : l;
1110
+ }
1111
+ function $e(e) {
1112
+ let t = e.structure;
1113
+ t.individuals.length > 8 && _("too-many-individuals", {
1114
+ count: t.individuals.length,
1115
+ limit: 8
1116
+ }, "structure.individuals"), t.properties.length + t.relations.length > 24 && _("too-many-symbols", {
1117
+ count: t.properties.length + t.relations.length,
1118
+ limit: 24
1119
+ }, "structure");
1120
+ let { defs: n, labels: r } = Xe(e), i = /* @__PURE__ */ new Set(), a = (e, t) => {
1121
+ (i.has(e) || Oe.has(e) || n.has(e)) && _("duplicate-id", { id: e }, t), i.add(e);
1122
+ };
1123
+ t.individuals.forEach((e, t) => a(e.id, `structure.individuals.${t}.id`));
1124
+ for (let e of Object.keys(t.names)) a(e, `structure.names.${e}`);
1125
+ t.properties.forEach((e, t) => a(e.id, `structure.properties.${t}.id`)), t.relations.forEach((e, t) => a(e.id, `structure.relations.${t}.id`));
1126
+ let o = new Set(t.individuals.map((e) => e.id)), s = (e, t) => {
1127
+ o.has(e) || _("unknown-individual", { id: e }, t);
1128
+ };
1129
+ for (let [e, n] of Object.entries(t.names)) s(n, `structure.names.${e}`);
1130
+ t.properties.forEach((e, t) => e.holds?.forEach((e, n) => s(e, `structure.properties.${t}.holds.${n}`))), t.relations.forEach((e, t) => e.pairs?.forEach(([e, n], r) => (s(e, `structure.relations.${t}.pairs.${r}.0`), s(n, `structure.relations.${t}.pairs.${r}.1`))));
1131
+ let c = {
1132
+ names: /* @__PURE__ */ new Set([...o, ...Object.keys(t.names)]),
1133
+ properties: new Set(t.properties.map((e) => e.id)),
1134
+ relations: new Set(t.relations.map((e) => e.id)),
1135
+ defs: n
1136
+ }, l = [...He.map((e) => ({
1137
+ ...e,
1138
+ builtin: !0
1139
+ })), ...e.proposals.map((e) => ({
1140
+ ...e,
1141
+ builtin: !1
1142
+ }))], u = /* @__PURE__ */ new Set();
1143
+ l.forEach((e, t) => {
1144
+ u.has(e.id) && _("duplicate-id", { id: e.id }, `proposals.${t - He.length}.id`), u.add(e.id);
1145
+ });
1146
+ let d = /* @__PURE__ */ new Set(), f = e.ground.claims.map((e, t) => {
1147
+ d.has(e.id) && _("duplicate-id", { id: e.id }, `ground.claims.${t}.id`), d.add(e.id);
1148
+ let n = e.label === void 0 ? {} : { label: e.label };
1149
+ if ("proposal" in e) {
1150
+ let r = l.find((t) => t.id === e.proposal);
1151
+ r === void 0 && _("unknown-proposal", { id: e.proposal }, `ground.claims.${t}.proposal`);
1152
+ let i = r[e.clause];
1153
+ return {
1154
+ id: e.id,
1155
+ grounded: e.clause === "identity" ? "x = y" : "x != y",
1156
+ full: i.full,
1157
+ ...i.some === void 0 ? {} : { some: i.some },
1158
+ vars: ["x", "y"],
1159
+ proposal: {
1160
+ id: r.id,
1161
+ clause: e.clause
1162
+ },
1163
+ ...n
1164
+ };
1165
+ }
1166
+ return {
1167
+ id: e.id,
1168
+ grounded: e.grounded,
1169
+ ...e.full === void 0 ? {} : { full: e.full },
1170
+ ...e.partial === void 0 ? {} : { partial: e.partial },
1171
+ ...e.some === void 0 ? {} : { some: e.some },
1172
+ vars: Ze(Pe(e.grounded), c),
1173
+ ...n
1174
+ };
1175
+ }), p = {
1176
+ defs: Object.fromEntries([...n.values()].filter((e) => Object.keys(e.variants).length > 1 && e.premise.startsWith("def:")).map((e) => [e.name, {
1177
+ variants: Object.keys(e.variants),
1178
+ default: e.defaultVariant
1179
+ }])),
1180
+ claims: Object.fromEntries(f.map((e) => [e.id, !0]))
1181
+ }, m = fe(le(p), e.premises, p);
1182
+ return {
1183
+ doc: e,
1184
+ structure: Qe(e, c, m),
1185
+ vocab: c,
1186
+ space: p,
1187
+ defaults: m,
1188
+ proposals: l,
1189
+ claims: f,
1190
+ defLabels: r
1191
+ };
1192
+ }
1193
+ function et(e, t, n, r) {
1194
+ let i = Object.fromEntries(t.vars.map((e) => [e, "individual"]));
1195
+ for (let [e, n] of Object.entries(t.some ?? {})) i[e] = n === "Rel" ? "relation" : "property";
1196
+ let a = j(i), o = M(t.grounded, e.vocab, n, a), s = t.partial !== void 0, c = (t.partial ?? t.full ?? []).map((t) => M(t, e.vocab, n, a)), l = [{}];
1197
+ for (let e of t.vars) l = l.flatMap((t) => r.names.map((n) => ({
1198
+ ...t,
1199
+ [e]: n
1200
+ })));
1201
+ return l.map((e) => {
1202
+ let n = (t) => Object.entries(e).reduce((e, [t, n]) => S(e, t, {
1203
+ kind: "name",
1204
+ name: n
1205
+ }), t), i = [c.map(n)];
1206
+ for (let [e, n] of Object.entries(t.some ?? {})) i = i.flatMap((t) => r.ranges[n].map((n) => t.map((t) => S(t, e, n))));
1207
+ return {
1208
+ claim: t.id,
1209
+ grounded: n(o),
1210
+ alternatives: i,
1211
+ partial: s
1212
+ };
1213
+ });
1214
+ }
1215
+ function tt(e, t) {
1216
+ return fe(e.defaults, t, e.space);
1217
+ }
1218
+ // src/ground/data/schema.ts
1219
+ var N = t.union([t.string(), t.object({
1220
+ "zh-TW": t.string(),
1221
+ en: t.string()
1222
+ }).strict()]), P = t.string().regex(De), nt = t.object({
1223
+ id: P,
1224
+ symbol: t.string().min(1).optional(),
1225
+ label: N.optional()
1226
+ }).strict(), rt = t.object({
1227
+ id: P,
1228
+ symbol: t.string().min(1).optional(),
1229
+ qualitative: t.boolean(),
1230
+ label: N.optional(),
1231
+ holds: t.array(P).optional(),
1232
+ define: t.string().optional()
1233
+ }).strict(), it = t.object({
1234
+ id: P,
1235
+ symbol: t.string().min(1).optional(),
1236
+ qualitative: t.boolean(),
1237
+ label: N.optional(),
1238
+ pairs: t.array(t.tuple([P, P])).optional(),
1239
+ define: t.string().optional()
1240
+ }).strict(), at = t.object({
1241
+ individuals: t.array(nt).min(1),
1242
+ names: t.record(P, P).default({}),
1243
+ properties: t.array(rt).default([]),
1244
+ relations: t.array(it).default([]),
1245
+ haecceities: t.enum(["none", "available"]).default("none")
1246
+ }).strict(), ot = t.union([t.string(), t.object({
1247
+ variants: t.record(t.string().regex(De), t.string()),
1248
+ default: t.string(),
1249
+ label: N.optional()
1250
+ }).strict()]), st = t.enum(Ee), ct = t.object({
1251
+ full: t.array(t.string()),
1252
+ some: t.record(P, st).optional()
1253
+ }).strict(), lt = t.object({
1254
+ id: P,
1255
+ label: N,
1256
+ identity: ct,
1257
+ distinctness: ct
1258
+ }).strict(), F = t.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/), ut = t.object({
1259
+ id: F,
1260
+ proposal: P,
1261
+ clause: t.enum(["identity", "distinctness"]),
1262
+ label: N.optional()
1263
+ }).strict(), dt = t.object({
1264
+ id: F,
1265
+ grounded: t.string(),
1266
+ full: t.array(t.string()).optional(),
1267
+ partial: t.array(t.string()).optional(),
1268
+ some: t.record(P, st).optional(),
1269
+ label: N.optional()
1270
+ }).strict(), ft = t.record(t.string(), t.string()), pt = t.object({
1271
+ shared: t.boolean().optional(),
1272
+ propertyDiscernible: t.boolean().optional(),
1273
+ absolute: t.boolean().optional(),
1274
+ relative: t.boolean().optional(),
1275
+ weak: t.boolean().optional(),
1276
+ irreflexiveWitness: P.nullable().optional(),
1277
+ allReflexive: t.boolean().optional(),
1278
+ proposals: t.record(P, t.enum(Ue)).optional(),
1279
+ clauses: t.record(P, t.object({
1280
+ identity: t.boolean().optional(),
1281
+ distinctness: t.boolean().optional()
1282
+ }).strict()).optional()
1283
+ }).strict(), mt = t.object({
1284
+ selfGround: t.boolean().optional(),
1285
+ selfGroundFact: t.string().optional(),
1286
+ chainRules: t.array(t.string()).optional(),
1287
+ partial: t.array(t.string()).optional(),
1288
+ notPartial: t.array(t.string()).optional(),
1289
+ fullGrounds: t.array(t.array(t.string())).optional(),
1290
+ claimFails: t.array(F).optional()
1291
+ }).strict(), ht = t.discriminatedUnion("kind", [
1292
+ t.object({
1293
+ kind: t.literal("pair"),
1294
+ pair: t.tuple([P, P])
1295
+ }).strict(),
1296
+ t.object({
1297
+ kind: t.literal("cycle"),
1298
+ target: t.string().optional()
1299
+ }).strict(),
1300
+ t.object({
1301
+ kind: t.literal("grounds"),
1302
+ target: t.string()
1303
+ }).strict()
1304
+ ]), gt = t.object({
1305
+ id: F,
1306
+ label: N,
1307
+ premises: ft.optional(),
1308
+ query: ht,
1309
+ test: N.optional(),
1310
+ expect: t.union([pt, mt])
1311
+ }).strict(), _t = t.object({
1312
+ kind: t.literal("ground-case"),
1313
+ id: t.string().regex(/^[a-z0-9][a-z0-9-]*$/),
1314
+ title: N,
1315
+ sources: t.array(t.object({
1316
+ cite: t.string(),
1317
+ pages: t.string().optional()
1318
+ }).strict()).default([]),
1319
+ structure: at,
1320
+ defs: t.record(t.string(), ot).default({}),
1321
+ proposals: t.array(lt).default([]),
1322
+ ground: t.object({
1323
+ claims: t.array(t.union([ut, dt])).default([]),
1324
+ targets: t.array(t.string()).default([])
1325
+ }).strict().default({
1326
+ claims: [],
1327
+ targets: []
1328
+ }),
1329
+ premises: ft.default({}),
1330
+ switches: t.array(t.string()).optional(),
1331
+ presets: t.array(gt).default([])
1332
+ }).strict(), vt = Object.keys(pt.shape), yt = 2e5, bt = e().localeError;
1333
+ function xt(e) {
1334
+ return e.issues.map((e) => {
1335
+ let t = bt(e);
1336
+ return f("schema", { message: {
1337
+ "zh-TW": typeof t == "string" ? t : t?.message ?? e.message,
1338
+ en: e.message
1339
+ } }, e.path.map(String).join("."));
1340
+ });
1341
+ }
1342
+ function I(e, t, n) {
1343
+ try {
1344
+ return n();
1345
+ } catch (n) {
1346
+ let r = v(n);
1347
+ if (r === void 0) throw n;
1348
+ e.push(r.where === void 0 ? {
1349
+ ...r,
1350
+ where: t
1351
+ } : r);
1352
+ return;
1353
+ }
1354
+ }
1355
+ function L(e, t, n = e.defaults) {
1356
+ let r = M(t, e.vocab, n), i = C(r)[0];
1357
+ return i !== void 0 && _("free-variable", {
1358
+ variable: i,
1359
+ formula: t
1360
+ }), r;
1361
+ }
1362
+ function St(e) {
1363
+ let t = [], n = I(t, "structure", () => $e(e));
1364
+ if (n === void 0) return { problems: t };
1365
+ n.proposals.forEach((e, r) => {
1366
+ if (!e.builtin) for (let i of ["identity", "distinctness"]) {
1367
+ let a = {
1368
+ x: "individual",
1369
+ y: "individual"
1370
+ };
1371
+ for (let [t, n] of Object.entries(e[i].some ?? {})) a[t] = n === "Rel" ? "relation" : "property";
1372
+ e[i].full.forEach((e, o) => I(t, `proposals.${r - He.length}.${i}.full.${o}`, () => M(e, n.vocab, n.defaults, j(a))));
1373
+ }
1374
+ }), n.claims.forEach((e, r) => {
1375
+ let i = Object.fromEntries(e.vars.map((e) => [e, "individual"]));
1376
+ for (let [t, n] of Object.entries(e.some ?? {})) i[t] = n === "Rel" ? "relation" : "property";
1377
+ let a = j(i);
1378
+ if (e.proposal === void 0) {
1379
+ I(t, `ground.claims.${r}.grounded`, () => M(e.grounded, n.vocab, n.defaults, a));
1380
+ for (let i of ["full", "partial"]) e[i]?.forEach((e, o) => I(t, `ground.claims.${r}.${i}.${o}`, () => M(e, n.vocab, n.defaults, a)));
1381
+ }
1382
+ }), e.ground.targets.forEach((e, r) => I(t, `ground.targets.${r}`, () => L(n, e))), e.switches !== void 0 && e.switches.forEach((e, r) => I(t, `switches.${r}`, () => de(n.space, e)));
1383
+ let r = /* @__PURE__ */ new Set();
1384
+ return e.presets.forEach((e, i) => {
1385
+ let a = `presets.${i}`;
1386
+ r.has(e.id) && t.push(f("duplicate-id", { id: e.id }, `${a}.id`)), r.add(e.id);
1387
+ let o = I(t, `${a}.premises`, () => fe(n.defaults, e.premises, n.space));
1388
+ if (o === void 0) return;
1389
+ let s = e.expect, c = e.query.kind === "pair";
1390
+ if (Object.keys(s).some((e) => vt.includes(e) !== c) && t.push(f("expect-kind", {
1391
+ preset: e.id,
1392
+ kind: e.query.kind
1393
+ }, `${a}.expect`)), e.query.kind === "pair") {
1394
+ for (let [r, i] of e.query.pair.entries()) n.vocab.names.has(i) || t.push(f("unknown-individual", { id: i }, `${a}.query.pair.${r}`));
1395
+ for (let e of ["proposals", "clauses"]) for (let r of Object.keys(s[e] ?? {})) n.proposals.some((e) => e.id === r) || t.push(f("unknown-proposal", { id: r }, `${a}.expect.${e}.${r}`));
1396
+ return;
1397
+ }
1398
+ let l = e.query.target;
1399
+ l !== void 0 && I(t, `${a}.query.target`, () => L(n, l, o));
1400
+ let u = [];
1401
+ typeof s.selfGroundFact == "string" && u.push(["selfGroundFact", s.selfGroundFact]);
1402
+ for (let e of ["partial", "notPartial"]) (s[e] ?? []).forEach((t, n) => u.push([`${e}.${n}`, t]));
1403
+ (s.fullGrounds ?? []).forEach((e, t) => e.forEach((e, n) => u.push([`fullGrounds.${t}.${n}`, e])));
1404
+ for (let [e, r] of u) I(t, `${a}.expect.${e}`, () => L(n, r, o));
1405
+ (s.claimFails ?? []).forEach((e, r) => {
1406
+ n.claims.some((t) => t.id === e) || t.push(f("unknown-claim", { id: e }, `${a}.expect.claimFails.${r}`));
1407
+ });
1408
+ }), t.length === 0 ? {
1409
+ problems: t,
1410
+ compiled: n
1411
+ } : { problems: t };
1412
+ }
1413
+ function R(e) {
1414
+ let t = e;
1415
+ if (typeof e == "string") {
1416
+ if (e.length > 2e5) return {
1417
+ ok: !1,
1418
+ errors: [f("too-large", {})]
1419
+ };
1420
+ try {
1421
+ t = JSON.parse(e);
1422
+ } catch (e) {
1423
+ return {
1424
+ ok: !1,
1425
+ errors: [f("not-json", { detail: e.message })]
1426
+ };
1427
+ }
1428
+ }
1429
+ let n = _t.safeParse(t);
1430
+ if (!n.success) return {
1431
+ ok: !1,
1432
+ errors: xt(n.error)
1433
+ };
1434
+ let { problems: r, compiled: i } = St(n.data);
1435
+ return i === void 0 ? {
1436
+ ok: !1,
1437
+ errors: r
1438
+ } : {
1439
+ ok: !0,
1440
+ doc: n.data,
1441
+ compiled: i
1442
+ };
1443
+ }
1444
+ function z(e, t) {
1445
+ if (e !== void 0) return typeof e == "string" ? e : e[t];
1446
+ }
1447
+ // src/components/i18n/messages.ts
1448
+ var Ct = "zh-TW", wt = {
1449
+ "zh-TW": "中文",
1450
+ en: "English"
1451
+ }, Tt = r(Ct);
1452
+ function Et({ locale: e, children: t }) {
1453
+ return i(Tt.Provider, { value: e }, t);
1454
+ }
1455
+ function Dt({ locale: e, children: t }) {
1456
+ return e === void 0 ? t : i(Tt.Provider, { value: e }, t);
1457
+ }
1458
+ function Ot() {
1459
+ return a(Tt);
1460
+ }
1461
+ // src/ground/i18n/en.ts
1462
+ var kt = (e) => e.join(", "), At = {
1463
+ explained: "explained",
1464
+ "no-ground": "no ground",
1465
+ "necessitation-conflict": "conflicts with the case",
1466
+ trivial: "trivial",
1467
+ "same-ground": "same ground"
1468
+ }, jt = (e) => ({
1469
+ text: e,
1470
+ latex: `\\text{${e}}`
1471
+ }), Mt = {
1472
+ locale: "en",
1473
+ problems: m,
1474
+ docInvalid: "This case cannot be drawn:",
1475
+ yes: "yes",
1476
+ no: "no",
1477
+ structure: (e) => `Case structure, ${e} individuals`,
1478
+ individual: (e, t) => t.length === 0 ? e : `${e}: ${kt(t)}`,
1479
+ selectIndividual: (e) => `Select ${e}`,
1480
+ relationLabel: (e, t) => t === e ? e : `${e}: ${t}`,
1481
+ relationLegend: "Relations",
1482
+ nonQualitative: "non-qualitative",
1483
+ holdsFacts: "Holds:",
1484
+ pairHeading: (e, t) => `${e} and ${t}`,
1485
+ sameIndividual: "The two names refer to one individual",
1486
+ distinctIndividuals: "The two names refer to different individuals",
1487
+ pickPair: "Click two individuals to pick a pair",
1488
+ propertiesHeading: "Properties",
1489
+ propertyColumn: "Property",
1490
+ kindColumn: "Kind",
1491
+ qualitative: "qualitative",
1492
+ haecceity: "haecceity",
1493
+ sharesAll: "They share every qualitative property",
1494
+ sharesNotAll: "A qualitative property belongs to one of them only",
1495
+ discernHeading: "Discernibility",
1496
+ discernKinds: {
1497
+ property: "Discernible by a property",
1498
+ absolute: "Absolutely discernible",
1499
+ relative: "Relatively discernible",
1500
+ weak: "Weakly discernible"
1501
+ },
1502
+ witnessProperty: (e, t) => `only ${t} is “${e}”`,
1503
+ witnessProfile: (e, t, n, r) => `only ${r} ${t ? "bears" : "is borne"} “${e}” ${t ? "to" : "by"} ${n === void 0 ? "something" : `something “${n}”`}`,
1504
+ witnessStructure: (e) => `only by the whole structure (profile round ${e})`,
1505
+ witnessRelation: (e) => `by “${e}”`,
1506
+ relationsHeading: "Relations between them",
1507
+ relationColumn: "Relation",
1508
+ woerner: "Wörner’s four facts",
1509
+ irreflexiveCheck: "Irreflexive on the domain",
1510
+ reflexiveCheck: "Reflexive on the domain",
1511
+ checkHolds: "holds",
1512
+ checkFails: (e) => `fails: ${e} bears it to itself`,
1513
+ checkFailsReflexive: (e) => `fails: ${e} does not bear it to itself`,
1514
+ irreflexiveWitness: (e) => `Irreflexive witness: ${e}`,
1515
+ noIrreflexiveWitness: "No irreflexive relation holds between them",
1516
+ proposalsHeading: "Verdicts of the proposals",
1517
+ proposalColumn: "Proposal",
1518
+ verdictColumn: "Verdict",
1519
+ identityClause: "Identity clause",
1520
+ distinctnessClause: "Distinctness clause",
1521
+ clauseHolds: "ground obtains",
1522
+ clauseFails: "ground does not obtain",
1523
+ proposalNames: {
1524
+ property: "property proposal",
1525
+ weak: "weak-discernibility proposal",
1526
+ existence: "existence proposal"
1527
+ },
1528
+ verdict: At,
1529
+ verdictReason: (e, t, n) => {
1530
+ switch (e) {
1531
+ case "explained": return t ? "the identity clause’s ground obtains" : "the distinctness clause’s ground obtains";
1532
+ case "no-ground": return n ? "identity no longer follows, but there is still no ground for distinctness" : t ? "the identity clause’s ground does not obtain" : "the distinctness clause’s ground does not obtain";
1533
+ case "necessitation-conflict": return "the identity clause’s ground obtains; by grounding necessitation they would be identical, against the case";
1534
+ case "trivial": return "it obtains only through non-qualitative properties or haecceities";
1535
+ case "same-ground": return "identity and distinctness have the same full ground";
1536
+ }
1537
+ },
1538
+ scopeNote: "“All properties” and “all relations” cover only the properties and relations this case lists.",
1539
+ premisesHeading: "Premises",
1540
+ premiseNames: {
1541
+ conjunction: "Conjuncts ground a conjunction",
1542
+ disjunction: "True disjuncts ground a disjunction",
1543
+ existential: "Instances ground an existential",
1544
+ universal: "Range of universals",
1545
+ equivalents: "Equivalents share grounds",
1546
+ transitivity: "Partial ground is transitive",
1547
+ necessitation: "Grounding necessitation",
1548
+ existence: "Reading of existence",
1549
+ scope: "Range of properties"
1550
+ },
1551
+ defNoun: (e) => e === "Irr" ? "irreflexivity" : e === "Refl" ? "reflexivity" : e,
1552
+ defPremise: (e) => e === "Irr" ? "Definition of irreflexivity" : e === "Refl" ? "Definition of reflexivity" : `Definition of ${e}`,
1553
+ claimPremise: (e) => e,
1554
+ premiseValues: {
1555
+ on: "on",
1556
+ off: "off",
1557
+ unrestricted: "unrestricted",
1558
+ restricted: "restricted",
1559
+ quantified: "∃y(y=a)",
1560
+ predicate: "Ea",
1561
+ qualitative: "qualitative",
1562
+ nonhaecceitistic: "with non-qualitative",
1563
+ all: "with haecceities",
1564
+ conditional: "∀x∀y(Rxy→x≠y)",
1565
+ negation: "∀x¬Rxx"
1566
+ },
1567
+ defLabels: {
1568
+ Irr: (e) => {
1569
+ let t = e[0] ?? jt("R");
1570
+ return {
1571
+ text: `${t.text} is irreflexive`,
1572
+ latex: `${t.latex}\\text{ is irreflexive}`
1573
+ };
1574
+ },
1575
+ Refl: (e) => {
1576
+ let t = e[0] ?? jt("R");
1577
+ return {
1578
+ text: `${t.text} is reflexive`,
1579
+ latex: `${t.latex}\\text{ is reflexive}`
1580
+ };
1581
+ }
1582
+ },
1583
+ targetHeading: "Target",
1584
+ selfGrounds: "partially grounds itself, against the irreflexivity of ground",
1585
+ otherSelfGrounds: (e) => `The target does not ground itself, but ${e} partially grounds itself, against the irreflexivity of ground`,
1586
+ noSelfGround: "No fact partially grounds itself",
1587
+ chainHeading: "Chain",
1588
+ rules: {
1589
+ conjunction: "conjuncts ground a conjunction",
1590
+ disjunction: "a true disjunct grounds a disjunction",
1591
+ existential: "an instance grounds an existential fact",
1592
+ universal: "instances partially ground a universal fact",
1593
+ equivalents: "equivalents have the same grounds",
1594
+ transitivity: "transitivity"
1595
+ },
1596
+ mergedSteps: (e) => ` (${e} steps merged)`,
1597
+ claimRule: (e) => e,
1598
+ clauseClaim: (e, t) => `${e} (${t})`,
1599
+ directGrounds: "Direct grounds of",
1600
+ zeroGround: "the empty set",
1601
+ partialHeading: (e) => `Partial grounds of the target (${e})`,
1602
+ noPartial: "The target has no ground",
1603
+ claimFailure: (e, t) => `“${e}”: ${t} is true, but the claim’s ground does not obtain`,
1604
+ variantsAgree: (e) => `The definitions of ${e} agree on this structure`,
1605
+ variantsDiffer: (e) => `The definitions of ${e} differ on this structure`,
1606
+ showGrounds: (e) => `Show the grounds of ${e}`,
1607
+ presetsHeading: "Presets",
1608
+ presetCheck: (e, t, n) => `Check “${e}”: expected ${t ? "yes" : "no"}, got ${n ? "yes" : "no"}`,
1609
+ presetMatches: "match",
1610
+ presetDiffers: "mismatch",
1611
+ presetResult: (e, t) => `Check “${e}”: ${t ? "the result matches the expectation" : "the result does not match the expectation"}`,
1612
+ finiteNote: "Computed under the current premises on this finite structure.",
1613
+ tableCaption: "Verdicts of the proposals",
1614
+ caseColumn: "Case",
1615
+ expand: (e, t) => `Show the details of ${e} under the ${t}`
1616
+ }, Nt = (e) => `(第 ${e.position + 1} 個字)`, Pt = (e) => e.join("、"), Ft = {
1617
+ join: (e, t) => `${e}:${t}`,
1618
+ messages: {
1619
+ "parse-unexpected-character": (e) => `看不懂字元 ${e.character}${Nt(e)}`,
1620
+ "parse-unexpected-token": (e) => `多出了 ${e.token}${Nt(e)}`,
1621
+ "parse-unexpected-end": (e) => `公式還沒寫完${Nt(e)}`,
1622
+ "parse-expected": (e) => `這裡要有 ${e.expected}${Nt(e)}`,
1623
+ "unknown-symbol": (e) => `${e.name} 不是對象、性質、關係、定義或約束變數(${e.formula})`,
1624
+ "wrong-arity": (e) => `${e.name} 要 ${e.expected} 個論元,這裡有 ${e.got} 個(${e.formula})`,
1625
+ "wrong-sort": (e) => `${e.name} 在這裡必須是${e.expected === "individual" ? "對象" : e.expected === "property" ? "性質" : "關係"}(${e.formula})`,
1626
+ "free-variable": (e) => `${e.formula} 必須是閉語句,但 ${e.variable} 是自由變數`,
1627
+ "recursive-definition": (e) => `定義 ${e.name} 用到了自己`,
1628
+ "duplicate-id": (e) => `${e.id} 用了兩次`,
1629
+ "unknown-individual": (e) => `沒有對象 ${e.id}`,
1630
+ "unknown-relation": (e) => `沒有關係 ${e.id}`,
1631
+ "unknown-proposal": (e) => `沒有方案 ${e.id}`,
1632
+ "unknown-claim": (e) => `沒有主張 ${e.id}`,
1633
+ "unknown-variant": (e) => `定義 ${e.definition} 沒有變體 ${e.variant}`,
1634
+ "unknown-premise": (e) => `沒有前提 ${e.key}`,
1635
+ "bad-premise-value": (e) => `${e.key} 不能是 ${e.value},只能是 ${Pt(e.allowed)}`,
1636
+ "too-many-individuals": (e) => `有 ${e.count} 個對象,上限是 ${e.limit} 個`,
1637
+ "too-many-symbols": (e) => `性質與關係共 ${e.count} 個,上限是 ${e.limit} 個`,
1638
+ "too-many-facts": (e) => `事實超過 ${e.limit} 項`,
1639
+ "not-json": (e) => `不是 JSON:${e.detail}`,
1640
+ "too-large": () => "文件太大了",
1641
+ "unknown-preset": (e) => `沒有預設 ${e.id}`,
1642
+ "expect-kind": (e) => `預設 ${e.preset} 的預期不是 ${e.kind} 查詢回答得了的`,
1643
+ "extension-source": (e) => `${e.id} 要給外延或 define 其中一個`,
1644
+ schema: (e) => e.message["zh-TW"]
1645
+ }
1646
+ }, It = {
1647
+ explained: "說明了",
1648
+ "no-ground": "沒有立基",
1649
+ "necessitation-conflict": "與設定衝突",
1650
+ trivial: "瑣碎",
1651
+ "same-ground": "立基相同"
1652
+ }, Lt = (e) => ({
1653
+ text: e,
1654
+ latex: `\\text{${e}}`
1655
+ }), Rt = {
1656
+ "zh-TW": {
1657
+ locale: "zh-TW",
1658
+ problems: Ft,
1659
+ docInvalid: "這個案例無法繪出:",
1660
+ yes: "是",
1661
+ no: "否",
1662
+ structure: (e) => `案例結構,${e} 個對象`,
1663
+ individual: (e, t) => t.length === 0 ? e : `${e}:${Pt(t)}`,
1664
+ selectIndividual: (e) => `選擇 ${e}`,
1665
+ relationLabel: (e, t) => t === e ? e : `${e}:${t}`,
1666
+ relationLegend: "關係",
1667
+ nonQualitative: "非質性",
1668
+ holdsFacts: "成立:",
1669
+ pairHeading: (e, t) => `${e} 與 ${t}`,
1670
+ sameIndividual: "兩個名稱指同一個對象",
1671
+ distinctIndividuals: "兩個名稱指不同的對象",
1672
+ pickPair: "點兩個對象選一對",
1673
+ propertiesHeading: "性質",
1674
+ propertyColumn: "性質",
1675
+ kindColumn: "種類",
1676
+ qualitative: "質性",
1677
+ haecceity: "此性",
1678
+ sharesAll: "共有一切質性性質",
1679
+ sharesNotAll: "有一項質性性質只屬於其中一方",
1680
+ discernHeading: "可分辨性",
1681
+ discernKinds: {
1682
+ property: "性質可分辨",
1683
+ absolute: "絕對可分辨",
1684
+ relative: "相對可分辨",
1685
+ weak: "弱可分辨"
1686
+ },
1687
+ witnessProperty: (e, t) => `只有 ${t} 有「${e}」`,
1688
+ witnessProfile: (e, t, n, r) => `只有 ${r} ${t ? "對" : "被"}某個${n === void 0 ? "東西" : `「${n}」的東西`}有「${e}」`,
1689
+ witnessStructure: (e) => `只能以整個結構區分(第 ${e} 輪輪廓)`,
1690
+ witnessRelation: (e) => `以「${e}」`,
1691
+ relationsHeading: "兩者之間的關係",
1692
+ relationColumn: "關係",
1693
+ woerner: "Wörner 的四項事實",
1694
+ irreflexiveCheck: "在論域上非自反",
1695
+ reflexiveCheck: "在論域上自反",
1696
+ checkHolds: "成立",
1697
+ checkFails: (e) => `不成立:${e} 與自身也有此關係`,
1698
+ checkFailsReflexive: (e) => `不成立:${e} 與自身沒有此關係`,
1699
+ irreflexiveWitness: (e) => `非自反證人:${e}`,
1700
+ noIrreflexiveWitness: "兩者之間沒有非自反的關係",
1701
+ proposalsHeading: "方案的判決",
1702
+ proposalColumn: "方案",
1703
+ verdictColumn: "判決",
1704
+ identityClause: "同一條款",
1705
+ distinctnessClause: "相異條款",
1706
+ clauseHolds: "立基成立",
1707
+ clauseFails: "立基不成立",
1708
+ proposalNames: {
1709
+ property: "性質方案",
1710
+ weak: "弱可分辨性方案",
1711
+ existence: "存在方案"
1712
+ },
1713
+ verdict: It,
1714
+ verdictReason: (e, t, n) => {
1715
+ switch (e) {
1716
+ case "explained": return t ? "同一條款的立基成立" : "相異條款的立基成立";
1717
+ case "no-ground": return n ? "不再推出同一,但仍說不出相異的立基" : t ? "同一條款的立基不成立" : "相異條款的立基不成立";
1718
+ case "necessitation-conflict": return "同一條款的立基成立;依立基的必然性會判為同一,與設定衝突";
1719
+ case "trivial": return "只靠非質性性質或此性才成立";
1720
+ case "same-ground": return "同一與相異有相同的完整立基";
1721
+ }
1722
+ },
1723
+ scopeNote: "「所有性質」「所有關係」只涵蓋這個案例列出的性質與關係。",
1724
+ premisesHeading: "前提",
1725
+ premiseNames: {
1726
+ conjunction: "連言以連言項為立基",
1727
+ disjunction: "真選言項立基選言",
1728
+ existential: "存在式以實例為立基",
1729
+ universal: "全稱式的範圍",
1730
+ equivalents: "等值式共享立基",
1731
+ transitivity: "部分立基遞移",
1732
+ necessitation: "立基的必然性",
1733
+ existence: "存在的讀法",
1734
+ scope: "性質的範圍"
1735
+ },
1736
+ defNoun: (e) => e === "Irr" ? "非自反性" : e === "Refl" ? "自反性" : e,
1737
+ defPremise: (e) => e === "Irr" ? "非自反性的定義" : e === "Refl" ? "自反性的定義" : `${e} 的定義`,
1738
+ claimPremise: (e) => e,
1739
+ premiseValues: {
1740
+ on: "開",
1741
+ off: "關",
1742
+ unrestricted: "不受限",
1743
+ restricted: "受限",
1744
+ quantified: "∃y(y=a)",
1745
+ predicate: "Ea",
1746
+ qualitative: "質性",
1747
+ nonhaecceitistic: "含非質性",
1748
+ all: "含此性",
1749
+ conditional: "∀x∀y(Rxy→x≠y)",
1750
+ negation: "∀x¬Rxx"
1751
+ },
1752
+ defLabels: {
1753
+ Irr: (e) => {
1754
+ let t = e[0] ?? Lt("R");
1755
+ return {
1756
+ text: `${t.text} 是非自反的`,
1757
+ latex: `${t.latex}\\text{ 是非自反的}`
1758
+ };
1759
+ },
1760
+ Refl: (e) => {
1761
+ let t = e[0] ?? Lt("R");
1762
+ return {
1763
+ text: `${t.text} 是自反的`,
1764
+ latex: `${t.latex}\\text{ 是自反的}`
1765
+ };
1766
+ }
1767
+ },
1768
+ targetHeading: "目標",
1769
+ selfGrounds: "部分立基自身,違反立基的非自反性",
1770
+ otherSelfGrounds: (e) => `目標沒有部分立基自身,但 ${e} 部分立基自身,違反立基的非自反性`,
1771
+ noSelfGround: "沒有事實部分立基自身",
1772
+ chainHeading: "立基鏈",
1773
+ rules: {
1774
+ conjunction: "連言以連言項為立基",
1775
+ disjunction: "真選言項立基選言",
1776
+ existential: "存在事實以實例為立基",
1777
+ universal: "全稱事實以實例為部分立基",
1778
+ equivalents: "等值的兩式有相同的立基",
1779
+ transitivity: "遞移性"
1780
+ },
1781
+ mergedSteps: (e) => `(合併 ${e} 步)`,
1782
+ claimRule: (e) => e,
1783
+ clauseClaim: (e, t) => `${e}(${t === "identity" ? "同一" : "相異"})`,
1784
+ directGrounds: "直接立基:",
1785
+ zeroGround: "空集合",
1786
+ partialHeading: (e) => `目標的部分立基(${e} 項)`,
1787
+ noPartial: "目標沒有立基",
1788
+ claimFailure: (e, t) => `「${e}」:${t} 為真,但這條主張的立基不成立`,
1789
+ variantsAgree: (e) => `${e}的各個定義在這個結構上同真同假`,
1790
+ variantsDiffer: (e) => `${e}的各個定義在這個結構上真值不同`,
1791
+ showGrounds: (e) => `展開 ${e} 的立基`,
1792
+ presetsHeading: "預設",
1793
+ presetCheck: (e, t, n) => `檢查「${e}」:預期 ${t ? "是" : "否"},結果 ${n ? "是" : "否"}`,
1794
+ presetMatches: "相符",
1795
+ presetDiffers: "不符",
1796
+ presetResult: (e, t) => `檢查「${e}」:${t ? "結果與預期相符" : "結果與預期不符"}`,
1797
+ finiteNote: "以上依目前的前提,在這個有限結構上計算。",
1798
+ tableCaption: "各方案的判決",
1799
+ caseColumn: "案例",
1800
+ expand: (e, t) => `展開 ${e} 在${t}下的細節`
1801
+ },
1802
+ en: Mt
1803
+ };
1804
+ function B() {
1805
+ return Rt[Ot()];
1806
+ }
1807
+ function zt(e, t) {
1808
+ return h(e, t.problems);
1809
+ }
1810
+ function Bt(e, t) {
1811
+ let n = v(e);
1812
+ return n === void 0 ? e instanceof Error ? e.message : String(e) : zt(n, t);
1813
+ }
1814
+ // src/components/shared/parts.tsx
1815
+ function Vt({ label: e, options: t, value: n, onChange: r, className: i }) {
1816
+ return /* @__PURE__ */ l("div", {
1817
+ className: `ca-seg ${i ?? ""}`,
1818
+ role: "group",
1819
+ "aria-label": e,
1820
+ children: t.map((e) => /* @__PURE__ */ l("button", {
1821
+ type: "button",
1822
+ className: "ca-seg-item",
1823
+ "aria-pressed": e.value === n,
1824
+ onClick: () => r(e.value),
1825
+ children: e.label
1826
+ }, e.value))
1827
+ });
1828
+ }
1829
+ // src/components/text/tex-html.ts
1830
+ function Ht(e) {
1831
+ return d.renderToString(e, {
1832
+ throwOnError: !1,
1833
+ output: "html",
1834
+ strict: "ignore",
1835
+ trust: !1
1836
+ });
1837
+ }
1838
+ // src/components/text/Tex.tsx
1839
+ function Ut({ tex: e, text: t }) {
1840
+ return /* @__PURE__ */ l("span", {
1841
+ className: "ca-tex",
1842
+ role: "math",
1843
+ "aria-label": t,
1844
+ "data-text": t,
1845
+ "data-tex": e,
1846
+ dangerouslySetInnerHTML: { __html: Ht(e) }
1847
+ });
1848
+ }
1849
+ // src/ground/engine/print.ts
1850
+ var V = {
1851
+ term: (e) => e,
1852
+ pred: (e) => e
1853
+ }, Wt = {
1854
+ true: 5,
1855
+ false: 5,
1856
+ pred: 5,
1857
+ eq: 5,
1858
+ E: 5,
1859
+ not: 5,
1860
+ forall: 5,
1861
+ exists: 5,
1862
+ forall2: 5,
1863
+ exists2: 5,
1864
+ and: 4,
1865
+ or: 3,
1866
+ imp: 2,
1867
+ iff: 1
1868
+ }, H = {
1869
+ not: "¬",
1870
+ and: " ∧ ",
1871
+ or: " ∨ ",
1872
+ imp: " → ",
1873
+ iff: " ↔ ",
1874
+ forall: "∀",
1875
+ exists: "∃",
1876
+ eq: " = ",
1877
+ neq: " ≠ ",
1878
+ true: "⊤",
1879
+ false: "⊥"
1880
+ }, U = {
1881
+ not: "\\neg ",
1882
+ and: " \\land ",
1883
+ or: " \\lor ",
1884
+ imp: " \\to ",
1885
+ iff: " \\leftrightarrow ",
1886
+ forall: "\\forall ",
1887
+ exists: "\\exists ",
1888
+ eq: " = ",
1889
+ neq: " \\neq ",
1890
+ true: "\\top",
1891
+ false: "\\bot"
1892
+ }, Gt = "₀₁₂₃₄₅₆₇₈₉";
1893
+ function W(e) {
1894
+ let t = /^(.*?[^0-9])([0-9]+)$/.exec(e);
1895
+ return t === null ? e : `${t[1]}${[...t[2]].map((e) => Gt[Number(e)]).join("")}`;
1896
+ }
1897
+ function G(e) {
1898
+ let t = /^(.*?[^0-9])([0-9]+)$/.exec(e), n = t === null ? e : t[1], r = t === null ? "" : `_{${t[2]}}`, i = n.replace(/([#$%&_{}])/g, "\\$1");
1899
+ return `${/^[A-Za-z]$/.test(n) ? n : /^[A-Za-z][A-Za-z']*$/.test(n) ? `\\mathrm{${i}}` : `\\text{${i}}`}${r}`;
1900
+ }
1901
+ var Kt = class {
1902
+ symbols;
1903
+ constructor(e) {
1904
+ this.symbols = e;
1905
+ }
1906
+ termSym(e) {
1907
+ return e.kind === "var" ? e.name : this.symbols.term(e.name);
1908
+ }
1909
+ predSym(e) {
1910
+ return e.kind === "var" ? e.name : e.id.startsWith("=") ? "" : this.symbols.pred(e.id);
1911
+ }
1912
+ labelOf(e) {
1913
+ if (e.def === void 0 || this.symbols.defLabel === void 0) return;
1914
+ let t = e.def.args.map((e) => {
1915
+ let t = "sort" in e || e.kind === "prop" || e.kind === "rel" ? this.predSym(e) : this.termSym(e);
1916
+ return {
1917
+ text: W(t),
1918
+ latex: G(t)
1919
+ };
1920
+ });
1921
+ return this.symbols.defLabel(e.def.name, t);
1922
+ }
1923
+ formula(e) {
1924
+ let t = this.labelOf(e);
1925
+ if (t !== void 0) return t;
1926
+ switch (e.op) {
1927
+ case "true":
1928
+ case "false": return {
1929
+ text: H[e.op],
1930
+ latex: U[e.op]
1931
+ };
1932
+ case "pred": return this.atom(e.pred, e.args);
1933
+ case "eq": return this.eq(e.left, e.right, !1);
1934
+ case "E": {
1935
+ let t = this.termSym(e.arg);
1936
+ return t.length === 1 ? {
1937
+ text: `E${t}`,
1938
+ latex: `E${G(t)}`
1939
+ } : {
1940
+ text: `E(${W(t)})`,
1941
+ latex: `E(${G(t)})`
1942
+ };
1943
+ }
1944
+ case "not": {
1945
+ if (e.arg.op === "eq" && this.labelOf(e.arg) === void 0) return this.eq(e.arg.left, e.arg.right, !0);
1946
+ let t = this.child(e.arg, 5, !1);
1947
+ return {
1948
+ text: `${H.not}${t.text}`,
1949
+ latex: `${U.not}${t.latex}`
1950
+ };
1951
+ }
1952
+ case "and":
1953
+ case "or":
1954
+ case "imp":
1955
+ case "iff": {
1956
+ let t = Wt[e.op], n = e.op === "and" || e.op === "or", r = this.child(e.left, t, !n), i = this.child(e.right, t, n || e.op === "imp" || e.op === "iff");
1957
+ return {
1958
+ text: `${r.text}${H[e.op]}${i.text}`,
1959
+ latex: `${r.latex}${U[e.op]}${i.latex}`
1960
+ };
1961
+ }
1962
+ case "forall":
1963
+ case "exists": {
1964
+ let t = e.op, n = W(e.variable), r = G(e.variable), i = this.quantBody(e.body);
1965
+ if (e.restrict !== void 0) {
1966
+ let a = this.formula(e.restrict);
1967
+ return {
1968
+ text: `(${H[t]}${n} : ${a.text})${i.text}`,
1969
+ latex: `(${U[t]}${r}{:}\\,${a.latex})${i.latex}`
1970
+ };
1971
+ }
1972
+ return {
1973
+ text: `${H[t]}${n}${i.text}`,
1974
+ latex: `${U[t]}${r}${i.latex}`
1975
+ };
1976
+ }
1977
+ case "forall2":
1978
+ case "exists2": {
1979
+ let t = e.op === "forall2" ? "forall" : "exists", n = this.quantBody(e.body);
1980
+ return {
1981
+ text: `${H[t]}${W(e.variable)}${n.text}`,
1982
+ latex: `${U[t]}${G(e.variable)}${n.latex}`
1983
+ };
1984
+ }
1985
+ }
1986
+ }
1987
+ quantBody(e) {
1988
+ let t = this.formula(e), n = this.labelOf(e) !== void 0;
1989
+ return n || Wt[e.op] === 5 && e.op !== "eq" && (e.op !== "not" || e.arg.op !== "eq") ? !n && (e.op === "forall" || e.op === "exists" || e.op === "forall2" || e.op === "exists2" || e.op === "not") ? t : {
1990
+ text: ` ${t.text}`,
1991
+ latex: `\\,${t.latex}`
1992
+ } : {
1993
+ text: `(${t.text})`,
1994
+ latex: `\\,(${t.latex})`
1995
+ };
1996
+ }
1997
+ child(e, t, n) {
1998
+ let r = this.formula(e), i = this.labelOf(e) !== void 0, a = i ? 5 : Wt[e.op], o = !i && (e.op === "eq" || e.op === "not" && e.arg.op === "eq");
1999
+ return a < t || a === t && n && a < 5 || o && t === 5 ? {
2000
+ text: `(${r.text})`,
2001
+ latex: `(${r.latex})`
2002
+ } : r;
2003
+ }
2004
+ eq(e, t, n) {
2005
+ let r = this.termSym(e), i = this.termSym(t), a = n ? "neq" : "eq";
2006
+ return {
2007
+ text: `${W(r)}${H[a]}${W(i)}`,
2008
+ latex: `${G(r)}${U[a]}${G(i)}`
2009
+ };
2010
+ }
2011
+ atom(e, t) {
2012
+ let n = t.map((e) => this.termSym(e));
2013
+ if (e.kind === "prop" && e.id.startsWith("=")) {
2014
+ let t = this.symbols.term(e.id.slice(1)), r = {
2015
+ text: `λx.(x = ${W(t)})`,
2016
+ latex: `\\lambda x.(x = ${G(t)})`
2017
+ };
2018
+ return {
2019
+ text: `[${r.text}]${n.map(W).join("")}`,
2020
+ latex: `[${r.latex}]${n.map(G).join("")}`
2021
+ };
2022
+ }
2023
+ let r = this.predSym(e);
2024
+ return r.length === 1 && n.every((e) => e.length === 1) ? {
2025
+ text: `${r}${n.join("")}`,
2026
+ latex: `${r}${n.join("")}`
2027
+ } : {
2028
+ text: `${W(r)}(${n.map(W).join(", ")})`,
2029
+ latex: `${G(r)}(${n.map(G).join(", ")})`
2030
+ };
2031
+ }
2032
+ };
2033
+ function qt(e, t = V) {
2034
+ return new Kt(t).formula(e);
2035
+ }
2036
+ function K(e, t = V) {
2037
+ let n = qt(e, t);
2038
+ return {
2039
+ text: `[${n.text}]`,
2040
+ latex: `[${n.latex}]`
2041
+ };
2042
+ }
2043
+ function Jt(e, t = V) {
2044
+ if (e.startsWith("=")) {
2045
+ let n = t.term(e.slice(1));
2046
+ return {
2047
+ text: `λx.(x = ${W(n)})`,
2048
+ latex: `\\lambda x.(x = ${G(n)})`
2049
+ };
2050
+ }
2051
+ let n = t.pred(e);
2052
+ return {
2053
+ text: W(n),
2054
+ latex: G(n)
2055
+ };
2056
+ }
2057
+ function Yt(e, t = V) {
2058
+ let n = t.term(e);
2059
+ return {
2060
+ text: W(n),
2061
+ latex: G(n)
2062
+ };
2063
+ }
2064
+ // src/ground/components/case-text.ts
2065
+ function Xt(e) {
2066
+ return o(() => {
2067
+ let t = R(e);
2068
+ return t.ok ? {
2069
+ ok: !0,
2070
+ c: t.compiled
2071
+ } : {
2072
+ ok: !1,
2073
+ errors: t.errors
2074
+ };
2075
+ }, [e]);
2076
+ }
2077
+ function Zt(e, t, n) {
2078
+ let r = e.doc.presets.filter((e) => n.includes(e.query.kind));
2079
+ if (t === void 0 || t === !0) return {
2080
+ presets: r,
2081
+ errors: []
2082
+ };
2083
+ if (t === !1) return {
2084
+ presets: [],
2085
+ errors: []
2086
+ };
2087
+ let i = [], a = [];
2088
+ return t.forEach((t, n) => {
2089
+ if (typeof t == "string") {
2090
+ let r = e.doc.presets.find((e) => e.id === t);
2091
+ r === void 0 ? i.push(f("unknown-preset", { id: t }, `presets.${n}`)) : a.push(r);
2092
+ return;
2093
+ }
2094
+ let r = gt.safeParse(t);
2095
+ r.success ? a.push(r.data) : i.push(f("schema", { message: {
2096
+ "zh-TW": r.error.issues[0]?.message ?? "",
2097
+ en: r.error.issues[0]?.message ?? ""
2098
+ } }, `presets.${n}`));
2099
+ }), {
2100
+ presets: a,
2101
+ errors: i
2102
+ };
2103
+ }
2104
+ function Qt(e, t) {
2105
+ let n = e.doc.structure, r = new Map(n.individuals.map((e) => [e.id, e.symbol ?? e.id])), i = new Map([...n.properties, ...n.relations].map((e) => [e.id, e.symbol ?? e.id]));
2106
+ return {
2107
+ term: (e) => r.get(e) ?? e,
2108
+ pred: (e) => i.get(e) ?? e,
2109
+ defLabel: (n, r) => {
2110
+ let i = z(e.defLabels[n], t.locale);
2111
+ return i === void 0 ? t.defLabels[n]?.(r) : $t(i, e.vocab.defs.get(n)?.params ?? [], r);
2112
+ }
2113
+ };
2114
+ }
2115
+ function $t(e, t, n) {
2116
+ let r = e.split(/\{([A-Za-z_][A-Za-z0-9_]*)\}/), i = "", a = "";
2117
+ return r.forEach((e, r) => {
2118
+ if (r % 2 == 0) {
2119
+ i += e, e !== "" && (a += `\\text{${e.replace(/([\\{}])/g, "\\$1")}}`);
2120
+ return;
2121
+ }
2122
+ let o = n[t.indexOf(e)];
2123
+ i += o?.text ?? e, a += o?.latex ?? e;
2124
+ }), {
2125
+ text: i,
2126
+ latex: a
2127
+ };
2128
+ }
2129
+ function q(e, t, n) {
2130
+ let r = e.doc.structure, i = [
2131
+ ...r.individuals,
2132
+ ...r.properties,
2133
+ ...r.relations
2134
+ ].find((e) => e.id === t);
2135
+ return i === void 0 ? t.startsWith("=") ? Jt(t, Qt(e, n)).text : t : z(i.label, n.locale) ?? i.symbol ?? t;
2136
+ }
2137
+ function en(e, t, n) {
2138
+ return t.startsWith("def:") ? n.defPremise(t.slice(4)) : t.startsWith("claim:") ? tn(e, t.slice(6), n) : n.premiseNames[t] ?? t;
2139
+ }
2140
+ function tn(e, t, n) {
2141
+ let r = e.claims.find((e) => e.id === t);
2142
+ if (r === void 0) return t;
2143
+ let i = z(r.label, n.locale);
2144
+ return i === void 0 ? r.proposal === void 0 ? t : n.clauseClaim(nn(e, r.proposal.id, n), r.proposal.clause) : i;
2145
+ }
2146
+ function nn(e, t, n) {
2147
+ return z(e.proposals.find((e) => e.id === t)?.label, n.locale) ?? n.proposalNames[t] ?? t;
2148
+ }
2149
+ // src/ground/components/parts.tsx
2150
+ function rn({ locale: e, name: t, caption: n, children: r }) {
2151
+ return /* @__PURE__ */ l(Dt, {
2152
+ locale: e,
2153
+ children: /* @__PURE__ */ l(an, {
2154
+ name: t,
2155
+ caption: n,
2156
+ children: r
2157
+ })
2158
+ });
2159
+ }
2160
+ function an({ name: e, caption: t, children: n }) {
2161
+ let r = B();
2162
+ return /* @__PURE__ */ u("figure", {
2163
+ className: `ca-root not-prose ca-ground ca-ground-${e}`,
2164
+ lang: r.locale,
2165
+ children: [n, t !== void 0 && /* @__PURE__ */ l("figcaption", {
2166
+ className: "ca-ground-caption ca-muted",
2167
+ children: t
2168
+ })]
2169
+ });
2170
+ }
2171
+ function J({ problems: e }) {
2172
+ let t = B();
2173
+ return /* @__PURE__ */ u("div", {
2174
+ className: "ca-editor-errors ca-doc-error",
2175
+ role: "alert",
2176
+ "data-code": e[0]?.code,
2177
+ children: [/* @__PURE__ */ l("p", { children: t.docInvalid }), /* @__PURE__ */ l("ul", { children: e.map((e, n) => /* @__PURE__ */ u("li", { children: [
2178
+ /* @__PURE__ */ l("code", {
2179
+ className: "ca-mono",
2180
+ children: e.code
2181
+ }),
2182
+ " ",
2183
+ zt(e, t)
2184
+ ] }, `${e.code}-${n}`)) })]
2185
+ });
2186
+ }
2187
+ function on({ fact: e, symbols: t }) {
2188
+ let n = K(e, t);
2189
+ return /* @__PURE__ */ l(Ut, {
2190
+ tex: n.latex,
2191
+ text: n.text
2192
+ });
2193
+ }
2194
+ function sn({ c: e, keys: t, values: n, onChange: r }) {
2195
+ let i = B();
2196
+ return t.length === 0 ? null : /* @__PURE__ */ l("div", {
2197
+ className: "ca-ground-switches",
2198
+ role: "group",
2199
+ "aria-label": i.premisesHeading,
2200
+ children: t.map((t) => {
2201
+ let a = en(e, t, i);
2202
+ return /* @__PURE__ */ u("div", {
2203
+ className: "ca-ground-switch",
2204
+ "data-premise": t,
2205
+ children: [/* @__PURE__ */ l("span", {
2206
+ className: "ca-ground-switch-label",
2207
+ children: a
2208
+ }), /* @__PURE__ */ l(Vt, {
2209
+ label: a,
2210
+ options: de(e.space, t).map((e) => ({
2211
+ value: e,
2212
+ label: i.premiseValues[e] ?? e
2213
+ })),
2214
+ value: n[t] ?? "",
2215
+ onChange: (e) => r(t, e)
2216
+ })]
2217
+ }, t);
2218
+ })
2219
+ });
2220
+ }
2221
+ function cn({ presets: e, active: t, onPick: n, mismatches: r }) {
2222
+ let i = B();
2223
+ if (e.length === 0) return null;
2224
+ let a = e.find((e) => e.id === t), o = a === void 0 ? void 0 : z(a.test, i.locale) ?? z(a.label, i.locale) ?? a.id;
2225
+ return /* @__PURE__ */ u("div", {
2226
+ className: "ca-ground-presets",
2227
+ children: [/* @__PURE__ */ l("div", {
2228
+ className: "ca-ground-preset-list",
2229
+ role: "group",
2230
+ "aria-label": i.presetsHeading,
2231
+ children: e.map((e) => /* @__PURE__ */ l("button", {
2232
+ type: "button",
2233
+ className: "ca-ground-preset",
2234
+ "data-preset": e.id,
2235
+ "aria-pressed": e.id === t,
2236
+ onClick: () => n(e),
2237
+ children: z(e.label, i.locale)
2238
+ }, e.id))
2239
+ }), a !== void 0 && o !== void 0 && r !== void 0 && /* @__PURE__ */ l("p", {
2240
+ className: "ca-ground-preset-check ca-small",
2241
+ "data-ok": r.length === 0 ? "true" : "false",
2242
+ "aria-live": "polite",
2243
+ children: i.presetResult(o, r.length === 0)
2244
+ })]
2245
+ });
2246
+ }
2247
+ function ln({ value: e }) {
2248
+ let t = B();
2249
+ return /* @__PURE__ */ l("span", {
2250
+ className: "ca-ground-yn",
2251
+ "data-value": e ? "yes" : "no",
2252
+ children: e ? t.yes : t.no
2253
+ });
2254
+ }
2255
+ // src/components/text/text-measure.ts
2256
+ function Y(e, t) {
2257
+ let n = 0;
2258
+ for (let r of e) {
2259
+ let e = r.codePointAt(0) ?? 0;
2260
+ n += e > 11903 || ",。:;()「」?!…—=/、《》・".includes(r) ? t : t * .6;
2261
+ }
2262
+ return n;
2263
+ }
2264
+ // src/components/graph/signal-shapes.ts
2265
+ function un(e, t, n) {
2266
+ let r = Math.hypot(t, n) || 1, i = t / r, a = n / r, o = e.x - 9 * i, s = e.y - 9 * a;
2267
+ return `M${e.x} ${e.y}L${o - 3.6 * a} ${s + 3.6 * i}L${o + 3.6 * a} ${s - 3.6 * i}z`;
2268
+ }
2269
+ var dn = 13, fn = 17, pn = 200, mn = 34;
2270
+ function hn(e) {
2271
+ if (e <= 4) return Array.from({ length: e }, (e, t) => ({
2272
+ x: t * pn,
2273
+ y: 0
2274
+ }));
2275
+ let t = pn * e / (2 * Math.PI);
2276
+ return Array.from({ length: e }, (n, r) => ({
2277
+ x: t * Math.cos(2 * Math.PI * r / e - Math.PI / 2),
2278
+ y: t * Math.sin(2 * Math.PI * r / e - Math.PI / 2)
2279
+ }));
2280
+ }
2281
+ function gn(e) {
2282
+ let t = hn(e.individuals.length), n = new Map(e.individuals.map((e, n) => [e.id, t[n]])), r = e.individuals.map((e, n) => {
2283
+ let r = t[n], i = e.properties.map((e, t) => ({
2284
+ text: e.label,
2285
+ qualitative: e.qualitative,
2286
+ y: r.y + 20 + 34 + t * fn,
2287
+ w: Y(e.label, 12) + 10
2288
+ }));
2289
+ return {
2290
+ id: e.id,
2291
+ cx: r.x,
2292
+ cy: r.y,
2293
+ symbol: e.symbol,
2294
+ name: e.name,
2295
+ lines: i
2296
+ };
2297
+ }), i = /* @__PURE__ */ new Map(), a = [];
2298
+ for (let t of e.relations) {
2299
+ let e = new Set(t.pairs.map(([e, t]) => `${e}\u0000${t}`)), r = /* @__PURE__ */ new Set();
2300
+ for (let [o, s] of t.pairs) {
2301
+ let c = n.get(o), l = n.get(s);
2302
+ if (c === void 0 || l === void 0) continue;
2303
+ let u = Y(t.label, 12) + 12;
2304
+ if (o === s) {
2305
+ let e = `${t.id}:${o}`;
2306
+ if (r.has(e)) continue;
2307
+ r.add(e);
2308
+ let n = i.get(`${o}\u0000${o}`) ?? 0;
2309
+ i.set(`${o}\u0000${o}`, n + 1);
2310
+ let s = mn + n * 22, l = `M${c.x - 8} ${c.y - 20 + 2}C${c.x - 26} ${c.y - 20 - s} ${c.x + 26} ${c.y - 20 - s} ${c.x + 8} ${c.y - 20 + 2}`, u = Y(t.symbol, 12) + 12;
2311
+ a.push({
2312
+ key: e,
2313
+ relation: t.id,
2314
+ from: o,
2315
+ to: o,
2316
+ path: l,
2317
+ heads: [un({
2318
+ x: c.x + 8,
2319
+ y: c.y - 20 + 2
2320
+ }, -6, 14)],
2321
+ label: {
2322
+ x: c.x,
2323
+ y: c.y - 20 - s * .75,
2324
+ text: t.symbol,
2325
+ w: u
2326
+ }
2327
+ });
2328
+ continue;
2329
+ }
2330
+ let d = o < s ? `${o}\u0000${s}` : `${s}\u0000${o}`, f = `${t.id}:${d}`;
2331
+ if (r.has(f)) continue;
2332
+ r.add(f);
2333
+ let p = e.has(`${s}\u0000${o}`), m = i.get(d) ?? 0;
2334
+ i.set(d, m + 1);
2335
+ let h = l.x - c.x, g = l.y - c.y, _ = Math.hypot(h, g) || 1, v = h / _, ee = g / _, y = m === 0 ? 0 : (m % 2 == 1 ? -1 : 1) * Math.ceil(m / 2) * 30, b = {
2336
+ x: c.x + v * 20,
2337
+ y: c.y + ee * 20
2338
+ }, x = {
2339
+ x: l.x - v * 21,
2340
+ y: l.y - ee * 21
2341
+ }, S = {
2342
+ x: (b.x + x.x) / 2 - ee * y,
2343
+ y: (b.y + x.y) / 2 + v * y
2344
+ }, C = y === 0 ? `M${b.x} ${b.y}L${x.x} ${x.y}` : `M${b.x} ${b.y}Q${2 * S.x - (b.x + x.x) / 2} ${2 * S.y - (b.y + x.y) / 2} ${x.x} ${x.y}`, te = p ? [] : [un(x, x.x - S.x, x.y - S.y)];
2345
+ a.push({
2346
+ key: f,
2347
+ relation: t.id,
2348
+ from: o,
2349
+ to: s,
2350
+ path: C,
2351
+ heads: te,
2352
+ label: {
2353
+ x: S.x,
2354
+ y: S.y,
2355
+ text: t.label,
2356
+ w: u
2357
+ }
2358
+ });
2359
+ }
2360
+ }
2361
+ let o = [...r.flatMap((e) => [
2362
+ e.cx - 20,
2363
+ e.cx + 20,
2364
+ ...e.lines.map((t) => e.cx - t.w / 2),
2365
+ ...e.lines.map((t) => e.cx + t.w / 2),
2366
+ e.cx - Y(e.name, dn) / 2,
2367
+ e.cx + Y(e.name, dn) / 2
2368
+ ]), ...a.flatMap((e) => [e.label.x - e.label.w / 2, e.label.x + e.label.w / 2])], s = [...r.flatMap((e) => [
2369
+ e.cy - 20,
2370
+ e.cy + 20 + fn + 4,
2371
+ ...e.lines.map((e) => e.y + 5)
2372
+ ]), ...a.flatMap((e) => [e.label.y - 10, e.label.y + 10])], c = Math.min(...o) - 8, l = Math.min(...s) - 8, u = Math.max(...o) + 8 - c, d = Math.max(...s) + 8 - l;
2373
+ return {
2374
+ width: Math.round(u),
2375
+ height: Math.round(d),
2376
+ viewBox: `${c.toFixed(1)} ${l.toFixed(1)} ${u.toFixed(1)} ${d.toFixed(1)}`,
2377
+ individuals: r,
2378
+ edges: a
2379
+ };
2380
+ }
2381
+ // src/ground/components/StructureView.tsx
2382
+ function _n(e) {
2383
+ return /* @__PURE__ */ l(rn, {
2384
+ locale: e.locale,
2385
+ name: "structure",
2386
+ caption: e.caption,
2387
+ children: /* @__PURE__ */ l(vn, { ...e })
2388
+ });
2389
+ }
2390
+ function vn({ doc: e, highlight: t }) {
2391
+ let n = Xt(e);
2392
+ return n.ok ? /* @__PURE__ */ l(yn, {
2393
+ c: n.c,
2394
+ highlight: t
2395
+ }) : /* @__PURE__ */ l(J, { problems: n.errors });
2396
+ }
2397
+ function yn({ c: e, highlight: t, onSelect: n }) {
2398
+ let r = B(), i = e.doc.structure, a = gn({
2399
+ individuals: i.individuals.map((t) => ({
2400
+ id: t.id,
2401
+ symbol: t.symbol ?? t.id,
2402
+ name: z(t.label, r.locale) ?? t.id,
2403
+ properties: e.structure.properties.filter((e) => e.haecceityOf === void 0 && e.extension.includes(t.id)).map((t) => ({
2404
+ label: q(e, t.id, r),
2405
+ qualitative: t.qualitative
2406
+ }))
2407
+ })),
2408
+ relations: e.structure.relations.map((t) => ({
2409
+ id: t.id,
2410
+ symbol: i.relations.find((e) => e.id === t.id)?.symbol ?? t.id,
2411
+ label: r.relationLabel(i.relations.find((e) => e.id === t.id)?.symbol ?? t.id, q(e, t.id, r)),
2412
+ pairs: t.pairs
2413
+ }))
2414
+ }), o = (e) => (t) => {
2415
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), n?.(e));
2416
+ };
2417
+ return /* @__PURE__ */ u("svg", {
2418
+ className: "ca-ground-structure",
2419
+ viewBox: a.viewBox,
2420
+ width: a.width,
2421
+ role: "group",
2422
+ "aria-label": r.structure(i.individuals.length),
2423
+ children: [/* @__PURE__ */ u("g", {
2424
+ "aria-hidden": "true",
2425
+ children: [a.edges.map((e) => /* @__PURE__ */ u("g", {
2426
+ className: "ca-ground-edge",
2427
+ "data-relation": e.relation,
2428
+ "data-from": e.from,
2429
+ "data-to": e.to,
2430
+ children: [/* @__PURE__ */ l("path", {
2431
+ d: e.path,
2432
+ fill: "none"
2433
+ }), e.heads.map((e, t) => /* @__PURE__ */ l("path", {
2434
+ d: e,
2435
+ className: "ca-ground-head"
2436
+ }, t))]
2437
+ }, e.key)), a.edges.map((e) => /* @__PURE__ */ u("g", {
2438
+ className: "ca-ground-edge-label",
2439
+ children: [/* @__PURE__ */ l("rect", {
2440
+ x: e.label.x - e.label.w / 2,
2441
+ y: e.label.y - 9,
2442
+ width: e.label.w,
2443
+ height: 18,
2444
+ rx: "9"
2445
+ }), /* @__PURE__ */ l("text", {
2446
+ x: e.label.x,
2447
+ y: e.label.y + 4,
2448
+ textAnchor: "middle",
2449
+ children: e.label.text
2450
+ })]
2451
+ }, `${e.key}-label`))]
2452
+ }), a.individuals.map((e) => /* @__PURE__ */ u("g", {
2453
+ className: "ca-ground-individual",
2454
+ "data-individual": e.id,
2455
+ "data-highlight": t?.includes(e.id) === !0 ? "true" : void 0,
2456
+ role: n === void 0 ? "img" : "button",
2457
+ tabIndex: n === void 0 ? void 0 : 0,
2458
+ "aria-label": n === void 0 ? r.individual(e.name, e.lines.map((e) => e.text)) : r.selectIndividual(e.name),
2459
+ "aria-pressed": n === void 0 ? void 0 : t?.includes(e.id) === !0,
2460
+ onClick: n === void 0 ? void 0 : () => n(e.id),
2461
+ onKeyDown: n === void 0 ? void 0 : o(e.id),
2462
+ children: [
2463
+ /* @__PURE__ */ l("circle", {
2464
+ cx: e.cx,
2465
+ cy: e.cy,
2466
+ r: 20,
2467
+ className: "ca-ground-disc"
2468
+ }),
2469
+ /* @__PURE__ */ l("text", {
2470
+ x: e.cx,
2471
+ y: e.cy + 5,
2472
+ textAnchor: "middle",
2473
+ className: "ca-ground-symbol",
2474
+ children: e.symbol
2475
+ }),
2476
+ /* @__PURE__ */ l("text", {
2477
+ x: e.cx,
2478
+ y: e.cy + 20 + 16,
2479
+ textAnchor: "middle",
2480
+ className: "ca-ground-name",
2481
+ children: e.name
2482
+ }),
2483
+ e.lines.map((t) => /* @__PURE__ */ u("g", {
2484
+ className: "ca-ground-prop",
2485
+ "data-qualitative": t.qualitative ? "true" : "false",
2486
+ children: [!t.qualitative && /* @__PURE__ */ l("rect", {
2487
+ x: e.cx - t.w / 2,
2488
+ y: t.y - 12,
2489
+ width: t.w,
2490
+ height: 16,
2491
+ rx: "2"
2492
+ }), /* @__PURE__ */ l("text", {
2493
+ x: e.cx,
2494
+ y: t.y,
2495
+ textAnchor: "middle",
2496
+ children: t.text
2497
+ })]
2498
+ }, t.text))
2499
+ ]
2500
+ }, e.id))]
2501
+ });
2502
+ }
2503
+ // src/ground/engine/closure.ts
2504
+ function bn(e) {
2505
+ let t = e.facts.map(() => []);
2506
+ for (let n of e.sets) for (let e of n.members) t[e].includes(n.grounded) || t[e].push(n.grounded);
2507
+ return t;
2508
+ }
2509
+ function xn(e) {
2510
+ let t = e.length, n = Array.from({ length: t }, () => -1), r = Array.from({ length: t }, () => 0), i = Array.from({ length: t }, () => !1), a = [], o = [], s = 0;
2511
+ for (let c = 0; c < t; c++) {
2512
+ if (n[c] !== -1) continue;
2513
+ let t = [[c, 0]];
2514
+ for (n[c] = r[c] = s++, a.push(c), i[c] = !0; t.length > 0;) {
2515
+ let c = t[t.length - 1], [l, u] = c, d = e[l];
2516
+ if (u < d.length) {
2517
+ c[1] = u + 1;
2518
+ let e = d[u];
2519
+ n[e] === -1 ? (n[e] = r[e] = s++, a.push(e), i[e] = !0, t.push([e, 0])) : i[e] && (r[l] = Math.min(r[l], n[e]));
2520
+ continue;
2521
+ }
2522
+ t.pop();
2523
+ let f = t[t.length - 1];
2524
+ if (f !== void 0 && (r[f[0]] = Math.min(r[f[0]], r[l])), r[l] === n[l]) {
2525
+ let e = [];
2526
+ for (;;) {
2527
+ let t = a.pop();
2528
+ if (i[t] = !1, e.push(t), t === l) break;
2529
+ }
2530
+ o.push(e.sort((e, t) => e - t));
2531
+ }
2532
+ }
2533
+ }
2534
+ return o;
2535
+ }
2536
+ function Sn(e, t) {
2537
+ let n = bn(e), r = (e) => n[e].includes(e);
2538
+ if (!t) return e.facts.map((e, t) => t).filter(r);
2539
+ let i = /* @__PURE__ */ new Set();
2540
+ for (let e of xn(n)) if (e.length > 1 || r(e[0])) for (let t of e) i.add(t);
2541
+ return [...i].sort((e, t) => e - t);
2542
+ }
2543
+ function Cn(e, t, n) {
2544
+ let r = bn(e);
2545
+ if (r[t].includes(t)) return [t, t];
2546
+ if (!n) return;
2547
+ let i = /* @__PURE__ */ new Map(), a = [t];
2548
+ for (let e = 0; e < a.length; e++) {
2549
+ let n = a[e];
2550
+ for (let e of [...r[n]].sort((e, t) => e - t)) {
2551
+ if (e === t) {
2552
+ let e = [t];
2553
+ for (let r = n; r !== t; r = i.get(r)) e.push(r);
2554
+ return e.push(t), e.reverse();
2555
+ }
2556
+ i.has(e) || e === t || (i.set(e, n), a.push(e));
2557
+ }
2558
+ }
2559
+ }
2560
+ function wn(e, t, n) {
2561
+ let r = /* @__PURE__ */ new Set();
2562
+ for (let n of e.groundsOf[t] ?? []) for (let t of e.sets[n].members) r.add(t);
2563
+ if (!n) return [...r].sort((e, t) => e - t);
2564
+ let i = /* @__PURE__ */ new Set(), a = [...r];
2565
+ for (; a.length > 0;) {
2566
+ let t = a.pop();
2567
+ if (!i.has(t)) {
2568
+ i.add(t);
2569
+ for (let n of e.groundsOf[t] ?? []) for (let t of e.sets[n].members) i.has(t) || a.push(t);
2570
+ }
2571
+ }
2572
+ return [...i].sort((e, t) => e - t);
2573
+ }
2574
+ function Tn(e, t, n) {
2575
+ let r = (e.groundsOf[n] ?? []).map((t) => e.sets[t]).filter((e) => e.members.includes(t)), i = r.find((e) => !e.partial) ?? r[0];
2576
+ if (i === void 0) throw Error(`no ground of ${n} contains ${t}`);
2577
+ return i;
2578
+ }
2579
+ function En(e, t) {
2580
+ let n = [];
2581
+ for (let r = 0; r + 1 < t.length; r++) {
2582
+ let i = t[r], a = t[r + 1], o = Tn(e, i, a);
2583
+ if (o.rule === "equivalents" && o.via !== void 0) {
2584
+ let t = (e.groundsOf[o.via] ?? []).map((t) => e.sets[t]).find((e) => e.members.includes(i));
2585
+ t !== void 0 && n.push({
2586
+ from: i,
2587
+ to: o.via,
2588
+ rule: t.rule,
2589
+ steps: 1,
2590
+ through: []
2591
+ });
2592
+ }
2593
+ n.push({
2594
+ from: i,
2595
+ to: a,
2596
+ rule: o.rule,
2597
+ steps: 1,
2598
+ through: []
2599
+ });
2600
+ }
2601
+ let r = [];
2602
+ for (let e of n) {
2603
+ let t = r[r.length - 1];
2604
+ t !== void 0 && t.rule === e.rule && t.to === e.from && (e.rule === "universal" || e.rule === "existential") ? r[r.length - 1] = {
2605
+ from: t.from,
2606
+ to: e.to,
2607
+ rule: e.rule,
2608
+ steps: t.steps + e.steps,
2609
+ through: [...t.through, t.to]
2610
+ } : r.push(e);
2611
+ }
2612
+ return t.length > 2 && r.push({
2613
+ from: t[0],
2614
+ to: t[0],
2615
+ rule: "transitivity",
2616
+ steps: 1,
2617
+ through: []
2618
+ }), r;
2619
+ }
2620
+ function Dn(e) {
2621
+ return e.filter((e) => e.rule !== "transitivity").map((e) => e.rule);
2622
+ }
2623
+ // src/logic/relations.ts
2624
+ var X = { holds: !0 };
2625
+ function Z(...e) {
2626
+ return {
2627
+ holds: !1,
2628
+ witness: e
2629
+ };
2630
+ }
2631
+ function On(e) {
2632
+ let t = new Set(e.pairs.map(([e, t]) => `${e}\u0000${t}`));
2633
+ return (e, n) => t.has(`${e}\u0000${n}`);
2634
+ }
2635
+ function kn(e, t) {
2636
+ let n = On(e), r = e.elements;
2637
+ switch (t) {
2638
+ case "serial":
2639
+ for (let e of r) if (!r.some((t) => n(e, t))) return Z(e);
2640
+ return X;
2641
+ case "reflexive":
2642
+ for (let e of r) if (!n(e, e)) return Z(e);
2643
+ return X;
2644
+ case "irreflexive":
2645
+ for (let e of r) if (n(e, e)) return Z(e);
2646
+ return X;
2647
+ case "symmetric":
2648
+ for (let e of r) for (let t of r) if (n(e, t) && !n(t, e)) return Z(e, t);
2649
+ return X;
2650
+ case "transitive":
2651
+ for (let e of r) for (let t of r) for (let i of r) if (n(e, t) && n(t, i) && !n(e, i)) return Z(e, t, i);
2652
+ return X;
2653
+ case "euclidean":
2654
+ for (let e of r) for (let t of r) for (let i of r) if (n(e, t) && n(e, i) && !n(t, i)) return Z(e, t, i);
2655
+ return X;
2656
+ }
2657
+ }
2658
+ // src/ground/engine/discern.ts
2659
+ function An(e, t, n, r) {
2660
+ let i = ye(e, t);
2661
+ return {
2662
+ id: t.id,
2663
+ qualitative: t.qualitative,
2664
+ ab: D(t, n, r),
2665
+ ba: D(t, r, n),
2666
+ notAa: !D(t, n, n),
2667
+ notBb: !D(t, r, r),
2668
+ irreflexive: kn(i, "irreflexive"),
2669
+ reflexive: kn(i, "reflexive")
2670
+ };
2671
+ }
2672
+ function jn(e, t, n) {
2673
+ let r = e.properties.filter((e) => e.qualitative), i = e.relations.filter((e) => e.qualitative), a = new Map(e.individuals.map((e) => [e, r.map((t) => E(t, e) ? "1" : "0").join("") + i.map((t) => D(t, e, e) ? "1" : "0").join("")]));
2674
+ for (let r = 0; r <= e.individuals.length; r++) {
2675
+ if (a.get(t) !== a.get(n)) return r;
2676
+ let o = /* @__PURE__ */ new Map();
2677
+ for (let t of e.individuals) {
2678
+ let n = i.map((n) => {
2679
+ let r = e.individuals.filter((e) => e !== t && D(n, t, e)).map((e) => a.get(e)).sort(), i = e.individuals.filter((e) => e !== t && D(n, e, t)).map((e) => a.get(e)).sort();
2680
+ return `${r.join(",")}|${i.join(",")}`;
2681
+ });
2682
+ o.set(t, `${a.get(t)}{${n.join(";")}}`);
2683
+ }
2684
+ a = o;
2685
+ }
2686
+ }
2687
+ function Mn(e, t, n) {
2688
+ let r = e.properties.filter((e) => e.qualitative), i = e.relations.filter((e) => e.qualitative);
2689
+ for (let e of r) if (E(e, t) !== E(e, n)) return {
2690
+ kind: "property",
2691
+ property: e.id,
2692
+ of: E(e, t) ? "a" : "b"
2693
+ };
2694
+ let a = (t, n, r, i) => e.individuals.some((e) => (n === "out" ? D(t, r, e) : D(t, e, r)) && (i === void 0 || i(e)));
2695
+ for (let e of i) for (let i of ["out", "in"]) {
2696
+ let o = a(e, i, t);
2697
+ if (o !== a(e, i, n)) return {
2698
+ kind: "profile",
2699
+ relation: e.id,
2700
+ direction: i,
2701
+ of: o ? "a" : "b"
2702
+ };
2703
+ for (let o of r) {
2704
+ let r = (e) => E(o, e), s = a(e, i, t, r);
2705
+ if (s !== a(e, i, n, r)) return {
2706
+ kind: "profile",
2707
+ relation: e.id,
2708
+ direction: i,
2709
+ property: o.id,
2710
+ of: s ? "a" : "b"
2711
+ };
2712
+ }
2713
+ }
2714
+ return {
2715
+ kind: "structure",
2716
+ depth: jn(e, t, n) ?? e.individuals.length
2717
+ };
2718
+ }
2719
+ function Nn(e, t, n, r) {
2720
+ let i = T(e, t), a = T(e, n);
2721
+ i === void 0 && _("unknown-individual", { id: t }), a === void 0 && _("unknown-individual", { id: n });
2722
+ let o = i === a, s = e.properties.map((e) => ({
2723
+ id: e.id,
2724
+ qualitative: e.qualitative,
2725
+ haecceity: e.haecceityOf !== void 0,
2726
+ a: E(e, i),
2727
+ b: E(e, a)
2728
+ })), c = s.find((e) => e.qualitative && e.a !== e.b), l = e.relations.map((t) => An(e, t, i, a)), u = l.filter((e) => e.qualitative), d = u.find((e) => e.ab && !e.ba), f = o ? void 0 : u.find((e) => e.ab && (e.notAa || e.notBb)), p = !o && !Se(e, i, a, r ?? xe(e)), m = l.find((e) => e.ab && e.irreflexive.holds);
2729
+ return {
2730
+ a: t,
2731
+ b: n,
2732
+ same: o,
2733
+ properties: s,
2734
+ sharesQualitative: c === void 0,
2735
+ propertyDiscernible: c === void 0 ? { holds: !1 } : {
2736
+ holds: !0,
2737
+ witness: c.id
2738
+ },
2739
+ absolute: p ? {
2740
+ holds: !0,
2741
+ witness: Mn(e, i, a)
2742
+ } : { holds: !1 },
2743
+ relative: d === void 0 ? { holds: !1 } : {
2744
+ holds: !0,
2745
+ witness: d.id
2746
+ },
2747
+ weak: f === void 0 ? { holds: !1 } : {
2748
+ holds: !0,
2749
+ witness: f.id
2750
+ },
2751
+ relations: l,
2752
+ ...m === void 0 ? {} : { irreflexiveWitness: m.id },
2753
+ allReflexive: l.filter((e) => e.ab).every((e) => e.reflexive.holds)
2754
+ };
2755
+ }
2756
+ // src/ground/engine/facts.ts
2757
+ var Pn = 1500;
2758
+ function Fn(e) {
2759
+ if (e.restrict !== void 0) return {
2760
+ psi: e.restrict,
2761
+ phi: e.body
2762
+ };
2763
+ if (e.op === "forall" && e.body.op === "imp" && e.body.def === void 0 || e.op === "exists" && e.body.op === "and" && e.body.def === void 0) return {
2764
+ psi: e.body.left,
2765
+ phi: e.body.right
2766
+ };
2767
+ }
2768
+ function In(e, t, n) {
2769
+ let r = (e) => A(t, e);
2770
+ switch (e.op) {
2771
+ case "and": return n.conjunction === "on" ? [{
2772
+ members: [e.left, e.right],
2773
+ rule: "conjunction"
2774
+ }] : [];
2775
+ case "or": {
2776
+ if (n.disjunction !== "on") return [];
2777
+ let t = [], i = r(e.left), a = r(e.right);
2778
+ return i && t.push({
2779
+ members: [e.left],
2780
+ rule: "disjunction"
2781
+ }), a && t.push({
2782
+ members: [e.right],
2783
+ rule: "disjunction"
2784
+ }), i && a && t.push({
2785
+ members: [e.left, e.right],
2786
+ rule: "disjunction"
2787
+ }), t;
2788
+ }
2789
+ case "forall":
2790
+ case "exists": {
2791
+ let i = n.universal === "restricted" ? Fn(e) : void 0, a = t.names.map((e) => ({
2792
+ kind: "name",
2793
+ name: e
2794
+ })), o = (t, n) => S(t, e.variable, n);
2795
+ return e.op === "forall" ? i === void 0 ? [{
2796
+ members: a.map((t) => e.restrict === void 0 ? o(e.body, t) : {
2797
+ op: "imp",
2798
+ left: o(e.restrict, t),
2799
+ right: o(e.body, t)
2800
+ }),
2801
+ rule: "universal"
2802
+ }] : [{
2803
+ members: a.filter((e) => r(o(i.psi, e))).map((e) => o(i.phi, e)),
2804
+ rule: "universal"
2805
+ }] : n.existential === "on" ? i === void 0 ? a.map((t) => e.restrict === void 0 ? o(e.body, t) : oe(o(e.restrict, t), o(e.body, t))).filter(r).map((e) => ({
2806
+ members: [e],
2807
+ rule: "existential"
2808
+ })) : a.filter((e) => r(o(i.psi, e)) && r(o(i.phi, e))).map((e) => ({
2809
+ members: [o(i.phi, e)],
2810
+ rule: "existential"
2811
+ })) : [];
2812
+ }
2813
+ case "forall2":
2814
+ case "exists2": {
2815
+ let i = t.ranges[e.range].map((t) => S(e.body, e.variable, t));
2816
+ return e.op === "forall2" ? [{
2817
+ members: i,
2818
+ rule: "universal"
2819
+ }] : n.existential === "on" ? i.filter(r).map((e) => ({
2820
+ members: [e],
2821
+ rule: "existential"
2822
+ })) : [];
2823
+ }
2824
+ default: return [];
2825
+ }
2826
+ }
2827
+ function Ln(e) {
2828
+ if (e.op === "imp") return se(ae(e.left), e.right);
2829
+ if (e.op === "iff") return se(oe(e.left, e.right), oe(ae(e.left), ae(e.right)));
2830
+ }
2831
+ function Rn(e, t, n, r) {
2832
+ let i = [], a = /* @__PURE__ */ new Map(), o = [], s = [], c = /* @__PURE__ */ new Set(), l = [], u = [], d = (t) => {
2833
+ let n = re(t), r = a.get(n);
2834
+ if (r !== void 0) return r;
2835
+ i.length >= 1500 && _("too-many-facts", {
2836
+ count: i.length + 1,
2837
+ limit: Pn
2838
+ });
2839
+ let o = i.length;
2840
+ return i.push({
2841
+ key: n,
2842
+ formula: t,
2843
+ truth: A(e, t)
2844
+ }), a.set(n, o), s.push([]), l.push(o), o;
2845
+ }, f = (e, t, n, r, i) => {
2846
+ let a = t.map(d), l = `${e}|${n}|${r ? "p" : "f"}|${[...new Set(a)].sort((e, t) => e - t).join(",")}`;
2847
+ c.has(l) || (c.add(l), s[e]?.push(o.length), o.push({
2848
+ grounded: e,
2849
+ members: [...new Set(a)],
2850
+ rule: n,
2851
+ partial: r,
2852
+ ...i === void 0 ? {} : { via: i }
2853
+ }));
2854
+ };
2855
+ for (let e of n) d(e);
2856
+ for (let t of r) {
2857
+ if (!A(e, t.grounded)) continue;
2858
+ let n = d(t.grounded), r = t.alternatives.filter((t) => t.every((t) => A(e, t))), i = `claim:${t.claim}`;
2859
+ if (t.partial) {
2860
+ let r = (t.alternatives[0] ?? []).filter((t) => A(e, t));
2861
+ r.length > 0 ? f(n, r, i, !0) : u.push({
2862
+ claim: t.claim,
2863
+ grounded: n,
2864
+ facts: t.alternatives[0] ?? []
2865
+ });
2866
+ } else {
2867
+ r.length === 0 && u.push({
2868
+ claim: t.claim,
2869
+ grounded: n,
2870
+ facts: t.alternatives[0] ?? []
2871
+ });
2872
+ for (let e of r) f(n, e, i, !1);
2873
+ }
2874
+ }
2875
+ for (let n = 0; n < l.length; n++) {
2876
+ let r = l[n], a = i[r];
2877
+ if (!a.truth) continue;
2878
+ for (let n of In(a.formula, e, t)) f(r, n.members, n.rule, !1);
2879
+ let o = t.equivalents === "on" ? Ln(a.formula) : void 0;
2880
+ if (o !== void 0) {
2881
+ let n = d(o);
2882
+ for (let i of In(o, e, t)) f(r, i.members, "equivalents", !1, n);
2883
+ }
2884
+ }
2885
+ return {
2886
+ facts: i,
2887
+ sets: o,
2888
+ groundsOf: s,
2889
+ claimFailures: u,
2890
+ index: a
2891
+ };
2892
+ }
2893
+ // src/ground/data/analyze.ts
2894
+ function Q(e, t, n, r, i) {
2895
+ let a = O(e.structure, t), o = i === void 0 ? e.proposals : i.map((t) => e.proposals.find((e) => e.id === t)).filter((e) => e !== void 0);
2896
+ return {
2897
+ discernment: Nn(e.structure, n, r),
2898
+ proposals: o.map((i) => Je(i, a, e.vocab, t, n, r))
2899
+ };
2900
+ }
2901
+ function zn(e, t, n, r) {
2902
+ let i = [];
2903
+ return r.facts.forEach((r, a) => {
2904
+ let o = r.formula.def;
2905
+ if (o === void 0) return;
2906
+ let s = e.space.defs[o.name]?.variants;
2907
+ if (s === void 0) return;
2908
+ let c = o.args.map((e) => e.kind === "name" ? e.name : e.kind === "prop" || e.kind === "rel" ? e.id : void 0);
2909
+ if (c.some((e) => e === void 0)) return;
2910
+ let l = `${o.name}(${c.join(", ")})`, u = Object.fromEntries(s.map((r) => [r, A(n, M(l, e.vocab, {
2911
+ ...t,
2912
+ defs: {
2913
+ ...t.defs,
2914
+ [o.name]: r
2915
+ }
2916
+ }))]));
2917
+ i.push({
2918
+ def: o.name,
2919
+ fact: a,
2920
+ values: u,
2921
+ agree: new Set(Object.values(u)).size === 1
2922
+ });
2923
+ }), i;
2924
+ }
2925
+ function Bn(e, t, n) {
2926
+ let r = O(e.structure, t), i = n ?? e.doc.ground.targets[0], a = i === void 0 ? void 0 : L(e, i, t), o = e.claims.filter((e) => t.claims[e.id] !== !1).flatMap((n) => et(e, n, t, r)), s = Rn(r, t, a === void 0 ? [] : [a], o), c = t.transitivity === "on", l = a === void 0 ? void 0 : s.index.get(re(a)), u = Sn(s, c), d, f;
2927
+ if (l !== void 0 && u.includes(l)) d = l, f = Cn(s, l, c);
2928
+ else for (let e of u) {
2929
+ let t = Cn(s, e, c);
2930
+ t !== void 0 && (f === void 0 || t.length < f.length) && (f = t, d = e);
2931
+ }
2932
+ return {
2933
+ interpretation: r,
2934
+ graph: s,
2935
+ ...l === void 0 ? {} : { target: l },
2936
+ transitive: c,
2937
+ selfGrounding: u,
2938
+ ...d === void 0 ? {} : { cycleFact: d },
2939
+ ...f === void 0 ? {} : {
2940
+ cycle: f,
2941
+ chain: En(s, f)
2942
+ },
2943
+ partial: l === void 0 ? [] : wn(s, l, c),
2944
+ variantNotes: zn(e, t, r, s)
2945
+ };
2946
+ }
2947
+ // src/ground/data/presets.ts
2948
+ function Vn(e, t) {
2949
+ return tt(e, t.premises);
2950
+ }
2951
+ function Hn(e) {
2952
+ let t = e.discernment;
2953
+ return {
2954
+ shared: t.sharesQualitative,
2955
+ propertyDiscernible: t.propertyDiscernible.holds,
2956
+ absolute: t.absolute.holds,
2957
+ relative: t.relative.holds,
2958
+ weak: t.weak.holds,
2959
+ irreflexiveWitness: t.irreflexiveWitness ?? null,
2960
+ allReflexive: t.allReflexive,
2961
+ proposals: Object.fromEntries(e.proposals.map((e) => [e.id, e.verdict])),
2962
+ clauses: Object.fromEntries(e.proposals.map((e) => [e.id, {
2963
+ identity: e.identity.holds,
2964
+ distinctness: e.distinctness.holds
2965
+ }]))
2966
+ };
2967
+ }
2968
+ function Un(e, t) {
2969
+ return e.length === t.length && [...e].sort().join("\0") === [...t].sort().join("\0");
2970
+ }
2971
+ function Wn(e, t, n, r, i) {
2972
+ let a = [], o = (e, t, n) => a.push({
2973
+ preset: i,
2974
+ key: e,
2975
+ expected: t,
2976
+ actual: n
2977
+ }), s = (n) => re(L(e, n, t)), c = n.graph.facts;
2978
+ if (r.selfGround !== void 0 && r.selfGround !== n.selfGrounding.length > 0 && o("selfGround", r.selfGround, n.selfGrounding.length > 0), r.selfGroundFact !== void 0) {
2979
+ let e = n.cycleFact === void 0 ? null : c[n.cycleFact]?.key;
2980
+ s(r.selfGroundFact) !== e && o("selfGroundFact", r.selfGroundFact, e);
2981
+ }
2982
+ if (r.chainRules !== void 0) {
2983
+ let e = (n.chain ?? []).filter((e) => e.rule !== "transitivity").map((e) => e.rule);
2984
+ e.join(",") !== r.chainRules.join(",") && o("chainRules", r.chainRules, e);
2985
+ }
2986
+ let l = new Set(n.partial.map((e) => c[e]?.key));
2987
+ for (let e of r.partial ?? []) l.has(s(e)) || o(`partial:${e}`, !0, !1);
2988
+ for (let e of r.notPartial ?? []) l.has(s(e)) && o(`notPartial:${e}`, !1, !0);
2989
+ if (r.fullGrounds !== void 0) {
2990
+ let e = (n.target === void 0 ? [] : (n.graph.groundsOf[n.target] ?? []).map((e) => n.graph.sets[e]).filter((e) => !e.partial)).map((e) => e.members.map((e) => c[e]?.key));
2991
+ for (let t of r.fullGrounds) {
2992
+ let n = t.map(s);
2993
+ e.some((e) => Un(e, n)) || o(`fullGrounds:${t.join(", ")}`, !0, !1);
2994
+ }
2995
+ }
2996
+ if (r.claimFails !== void 0) {
2997
+ let e = [...new Set(n.graph.claimFailures.map((e) => e.claim))].sort();
2998
+ Un(e, r.claimFails) || o("claimFails", [...r.claimFails].sort(), e);
2999
+ }
3000
+ return a;
3001
+ }
3002
+ function Gn(e, t, n) {
3003
+ let r = [], i = Hn(e);
3004
+ for (let e of [
3005
+ "shared",
3006
+ "propertyDiscernible",
3007
+ "absolute",
3008
+ "relative",
3009
+ "weak",
3010
+ "irreflexiveWitness",
3011
+ "allReflexive"
3012
+ ]) t[e] !== void 0 && t[e] !== i[e] && r.push({
3013
+ preset: n,
3014
+ key: e,
3015
+ expected: t[e],
3016
+ actual: i[e]
3017
+ });
3018
+ for (let [e, a] of Object.entries(t.proposals ?? {})) i.proposals[e] !== a && r.push({
3019
+ preset: n,
3020
+ key: `proposals.${e}`,
3021
+ expected: a,
3022
+ actual: i.proposals[e]
3023
+ });
3024
+ for (let [e, a] of Object.entries(t.clauses ?? {})) for (let t of ["identity", "distinctness"]) {
3025
+ let o = a[t];
3026
+ o !== void 0 && i.clauses[e]?.[t] !== o && r.push({
3027
+ preset: n,
3028
+ key: `clauses.${e}.${t}`,
3029
+ expected: o,
3030
+ actual: i.clauses[e]?.[t]
3031
+ });
3032
+ }
3033
+ return r;
3034
+ }
3035
+ function Kn(e, t) {
3036
+ let n = Vn(e, t), r = t.query;
3037
+ return r.kind === "pair" ? {
3038
+ kind: "pair",
3039
+ result: Q(e, n, r.pair[0], r.pair[1])
3040
+ } : {
3041
+ kind: "ground",
3042
+ result: Bn(e, n, r.target)
3043
+ };
3044
+ }
3045
+ function qn(e, t) {
3046
+ let n = Kn(e, t);
3047
+ return n.kind === "pair" ? Gn(n.result, t.expect, t.id) : Wn(e, Vn(e, t), n.result, t.expect, t.id);
3048
+ }
3049
+ function Jn(e) {
3050
+ let t;
3051
+ if (typeof e == "object" && e && "vocab" in e && "structure" in e && "doc" in e) t = e;
3052
+ else {
3053
+ let n = R(e);
3054
+ if (!n.ok) throw new g(n.errors[0]);
3055
+ t = n.compiled;
3056
+ }
3057
+ return t.doc.presets.flatMap((e) => qn(t, e));
3058
+ }
3059
+ // src/ground/components/use-premises.ts
3060
+ function Yn(e, t, n, r) {
3061
+ let i = t.find((e) => e.id === n), [a, c] = s(() => ({
3062
+ ...r,
3063
+ ...i?.premises
3064
+ })), [l, u] = s(i?.id), d = o(() => tt(e, a), [e, a]), f = t.find((e) => e.id === l), p = o(() => f === void 0 ? void 0 : qn(e, f), [e, f]), m = [
3065
+ ...Object.keys(d).filter((e) => e !== "defs" && e !== "claims"),
3066
+ ...Object.keys(d.defs).map((e) => `def:${e}`),
3067
+ ...Object.keys(d.claims).map((e) => `claim:${e}`)
3068
+ ];
3069
+ return {
3070
+ premises: d,
3071
+ values: Object.fromEntries(m.map((e) => [e, pe(d, e)])),
3072
+ active: f,
3073
+ mismatches: p,
3074
+ setPremise: (e, t) => {
3075
+ c((n) => ({
3076
+ ...n,
3077
+ [e]: t
3078
+ })), u(void 0);
3079
+ },
3080
+ pick: (e) => {
3081
+ c({
3082
+ ...r,
3083
+ ...e.premises
3084
+ }), u(e.id);
3085
+ },
3086
+ release: () => u(void 0)
3087
+ };
3088
+ }
3089
+ // src/ground/components/DiscernibilityPanel.tsx
3090
+ function Xn(e) {
3091
+ return /* @__PURE__ */ l(rn, {
3092
+ locale: e.locale,
3093
+ name: "discern",
3094
+ caption: e.caption,
3095
+ children: /* @__PURE__ */ l(Qn, { ...e })
3096
+ });
3097
+ }
3098
+ var Zn = ["pair"];
3099
+ function Qn(e) {
3100
+ let t = Xt(e.doc);
3101
+ if (!t.ok) return /* @__PURE__ */ l(J, { problems: t.errors });
3102
+ let { presets: n, errors: r } = Zt(t.c, e.presets, Zn);
3103
+ return r.length > 0 ? /* @__PURE__ */ l(J, { problems: r }) : /* @__PURE__ */ l($n, {
3104
+ ...e,
3105
+ c: t.c,
3106
+ presetList: n
3107
+ });
3108
+ }
3109
+ function $n(e) {
3110
+ let { c: t, presetList: n } = e, r = B(), i = Yn(t, n, e.initialPreset), [a, d] = s(() => {
3111
+ let r = (i.active ?? n[0])?.query;
3112
+ if (e.pair !== void 0) return e.pair;
3113
+ if (r?.kind === "pair") return r.pair;
3114
+ let a = t.doc.structure.individuals.map((e) => e.id);
3115
+ return [a[0], a[1] ?? a[0]];
3116
+ }), f = i.active?.query.kind === "pair" ? i.active.query.pair : a, p = o(() => {
3117
+ try {
3118
+ return {
3119
+ ok: !0,
3120
+ a: Q(t, i.premises, f[0], f[1], e.proposals)
3121
+ };
3122
+ } catch (e) {
3123
+ return {
3124
+ ok: !1,
3125
+ error: e
3126
+ };
3127
+ }
3128
+ }, [
3129
+ t,
3130
+ i.premises,
3131
+ f,
3132
+ e.proposals
3133
+ ]);
3134
+ if (!p.ok) {
3135
+ let e = v(p.error);
3136
+ return e === void 0 ? /* @__PURE__ */ l("p", {
3137
+ role: "alert",
3138
+ children: Bt(p.error, r)
3139
+ }) : /* @__PURE__ */ l(J, { problems: [e] });
3140
+ }
3141
+ return /* @__PURE__ */ u(c, { children: [
3142
+ /* @__PURE__ */ u("div", {
3143
+ className: "ca-ground-split",
3144
+ children: [/* @__PURE__ */ u("div", {
3145
+ className: "ca-ground-figure",
3146
+ children: [/* @__PURE__ */ l(yn, {
3147
+ c: t,
3148
+ highlight: f,
3149
+ onSelect: (e) => {
3150
+ d([f[1], e]), i.release();
3151
+ }
3152
+ }), /* @__PURE__ */ l("p", {
3153
+ className: "ca-small ca-muted",
3154
+ children: r.pickPair
3155
+ })]
3156
+ }), /* @__PURE__ */ l(nr, {
3157
+ c: t,
3158
+ a: p.a,
3159
+ t: r,
3160
+ scopeAll: i.premises.scope === "all"
3161
+ })]
3162
+ }),
3163
+ /* @__PURE__ */ l(sn, {
3164
+ c: t,
3165
+ keys: e.switches ?? ["scope", "necessitation"],
3166
+ values: i.values,
3167
+ onChange: i.setPremise
3168
+ }),
3169
+ /* @__PURE__ */ l(cn, {
3170
+ presets: n,
3171
+ active: i.active?.id,
3172
+ onPick: (e) => i.pick(e),
3173
+ mismatches: i.mismatches
3174
+ })
3175
+ ] });
3176
+ }
3177
+ function er(e, t, n, r) {
3178
+ return q(e, n === "a" ? t.a : t.b, r);
3179
+ }
3180
+ function tr(e, t, n, r) {
3181
+ return n.kind === "property" ? r.witnessProperty(q(e, n.property, r), er(e, t, n.of, r)) : n.kind === "profile" ? r.witnessProfile(q(e, n.relation, r), n.direction === "out", n.property === void 0 ? void 0 : q(e, n.property, r), er(e, t, n.of, r)) : r.witnessStructure(n.depth);
3182
+ }
3183
+ function nr({ c: e, a: t, t: n, scopeAll: r }) {
3184
+ let i = t.discernment, a = q(e, i.a, n), o = q(e, i.b, n), s = i.properties.filter((e) => !e.haecceity || r), c = [
3185
+ [
3186
+ "property",
3187
+ i.propertyDiscernible.holds,
3188
+ i.propertyDiscernible.witness === void 0 ? void 0 : n.witnessProperty(q(e, i.propertyDiscernible.witness, n), i.properties.find((e) => e.id === i.propertyDiscernible.witness)?.a === !0 ? a : o)
3189
+ ],
3190
+ [
3191
+ "absolute",
3192
+ i.absolute.holds,
3193
+ i.absolute.witness === void 0 ? void 0 : tr(e, i, i.absolute.witness, n)
3194
+ ],
3195
+ [
3196
+ "relative",
3197
+ i.relative.holds,
3198
+ i.relative.witness === void 0 ? void 0 : n.witnessRelation(q(e, i.relative.witness, n))
3199
+ ],
3200
+ [
3201
+ "weak",
3202
+ i.weak.holds,
3203
+ i.weak.witness === void 0 ? void 0 : n.witnessRelation(q(e, i.weak.witness, n))
3204
+ ]
3205
+ ], d = i.relations.filter((e) => e.ab || e.ba);
3206
+ return /* @__PURE__ */ u("div", {
3207
+ className: "ca-ground-side",
3208
+ "data-pair": `${i.a},${i.b}`,
3209
+ children: [
3210
+ /* @__PURE__ */ u("p", {
3211
+ className: "ca-ground-pair",
3212
+ children: [
3213
+ /* @__PURE__ */ l("strong", { children: n.pairHeading(a, o) }),
3214
+ " ",
3215
+ /* @__PURE__ */ l("span", {
3216
+ className: "ca-muted",
3217
+ children: i.same ? n.sameIndividual : n.distinctIndividuals
3218
+ })
3219
+ ]
3220
+ }),
3221
+ /* @__PURE__ */ l("div", {
3222
+ className: "ca-ground-scroll",
3223
+ children: /* @__PURE__ */ u("table", {
3224
+ className: "ca-ground-table",
3225
+ "data-table": "properties",
3226
+ children: [
3227
+ /* @__PURE__ */ l("caption", { children: n.propertiesHeading }),
3228
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [
3229
+ /* @__PURE__ */ l("th", {
3230
+ scope: "col",
3231
+ children: n.propertyColumn
3232
+ }),
3233
+ /* @__PURE__ */ l("th", {
3234
+ scope: "col",
3235
+ children: n.kindColumn
3236
+ }),
3237
+ /* @__PURE__ */ l("th", {
3238
+ scope: "col",
3239
+ children: a
3240
+ }),
3241
+ /* @__PURE__ */ l("th", {
3242
+ scope: "col",
3243
+ children: o
3244
+ })
3245
+ ] }) }),
3246
+ /* @__PURE__ */ l("tbody", { children: s.map((t) => /* @__PURE__ */ u("tr", {
3247
+ "data-property": t.id,
3248
+ "data-differs": t.a === t.b ? void 0 : "true",
3249
+ children: [
3250
+ /* @__PURE__ */ l("th", {
3251
+ scope: "row",
3252
+ children: q(e, t.id, n)
3253
+ }),
3254
+ /* @__PURE__ */ l("td", { children: t.haecceity ? n.haecceity : t.qualitative ? n.qualitative : n.nonQualitative }),
3255
+ /* @__PURE__ */ l("td", { children: /* @__PURE__ */ l(ln, { value: t.a }) }),
3256
+ /* @__PURE__ */ l("td", { children: /* @__PURE__ */ l(ln, { value: t.b }) })
3257
+ ]
3258
+ }, t.id)) })
3259
+ ]
3260
+ })
3261
+ }),
3262
+ /* @__PURE__ */ l("p", {
3263
+ className: "ca-small",
3264
+ "data-shares": i.sharesQualitative ? "true" : "false",
3265
+ children: i.sharesQualitative ? n.sharesAll : n.sharesNotAll
3266
+ }),
3267
+ /* @__PURE__ */ l("dl", {
3268
+ className: "ca-ground-kinds",
3269
+ "aria-label": n.discernHeading,
3270
+ children: c.map(([e, t, r]) => /* @__PURE__ */ u("div", {
3271
+ "data-kind": e,
3272
+ "data-holds": t ? "true" : "false",
3273
+ children: [/* @__PURE__ */ l("dt", { children: n.discernKinds[e] }), /* @__PURE__ */ u("dd", { children: [/* @__PURE__ */ l(ln, { value: t }), r !== void 0 && /* @__PURE__ */ u("span", {
3274
+ className: "ca-muted",
3275
+ children: [" ", r]
3276
+ })] })]
3277
+ }, e))
3278
+ }),
3279
+ d.length > 0 && /* @__PURE__ */ l(rr, {
3280
+ c: e,
3281
+ rows: d,
3282
+ t: n,
3283
+ nameA: a,
3284
+ nameB: o
3285
+ }),
3286
+ /* @__PURE__ */ l("p", {
3287
+ className: "ca-small",
3288
+ "data-witness": i.irreflexiveWitness ?? "",
3289
+ children: i.irreflexiveWitness === void 0 ? n.noIrreflexiveWitness : n.irreflexiveWitness(q(e, i.irreflexiveWitness, n))
3290
+ }),
3291
+ /* @__PURE__ */ l(ir, {
3292
+ c: e,
3293
+ results: t.proposals,
3294
+ t: n
3295
+ }),
3296
+ /* @__PURE__ */ u("p", {
3297
+ className: "ca-ground-note ca-small ca-muted",
3298
+ children: [
3299
+ n.scopeNote,
3300
+ " ",
3301
+ n.finiteNote
3302
+ ]
3303
+ })
3304
+ ]
3305
+ });
3306
+ }
3307
+ function rr({ c: e, rows: t, t: n, nameA: r, nameB: i }) {
3308
+ let a = (t) => e.doc.structure.relations.find((e) => e.id === t)?.symbol ?? t, o = (t, r) => {
3309
+ let i = t[r];
3310
+ if (i.holds) return n.checkHolds;
3311
+ let a = q(e, i.witness[0], n);
3312
+ return r === "irreflexive" ? n.checkFails(a) : n.checkFailsReflexive(a);
3313
+ };
3314
+ return /* @__PURE__ */ l("div", {
3315
+ className: "ca-ground-scroll",
3316
+ children: /* @__PURE__ */ u("table", {
3317
+ className: "ca-ground-table",
3318
+ "data-table": "relations",
3319
+ children: [
3320
+ /* @__PURE__ */ l("caption", { children: n.relationsHeading }),
3321
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [
3322
+ /* @__PURE__ */ l("th", {
3323
+ scope: "col",
3324
+ children: n.relationColumn
3325
+ }),
3326
+ /* @__PURE__ */ l("th", {
3327
+ scope: "col",
3328
+ title: n.woerner,
3329
+ children: `R(${r}, ${i})`
3330
+ }),
3331
+ /* @__PURE__ */ l("th", {
3332
+ scope: "col",
3333
+ children: `R(${i}, ${r})`
3334
+ }),
3335
+ /* @__PURE__ */ l("th", {
3336
+ scope: "col",
3337
+ children: `¬R(${r}, ${r})`
3338
+ }),
3339
+ /* @__PURE__ */ l("th", {
3340
+ scope: "col",
3341
+ children: `¬R(${i}, ${i})`
3342
+ }),
3343
+ /* @__PURE__ */ l("th", {
3344
+ scope: "col",
3345
+ children: n.irreflexiveCheck
3346
+ }),
3347
+ /* @__PURE__ */ l("th", {
3348
+ scope: "col",
3349
+ children: n.reflexiveCheck
3350
+ })
3351
+ ] }) }),
3352
+ /* @__PURE__ */ l("tbody", { children: t.map((t) => /* @__PURE__ */ u("tr", {
3353
+ "data-relation": t.id,
3354
+ "data-irreflexive": t.irreflexive.holds ? "true" : "false",
3355
+ children: [
3356
+ /* @__PURE__ */ l("th", {
3357
+ scope: "row",
3358
+ children: n.relationLabel(a(t.id), q(e, t.id, n))
3359
+ }),
3360
+ [
3361
+ t.ab,
3362
+ t.ba,
3363
+ t.notAa,
3364
+ t.notBb
3365
+ ].map((e, t) => /* @__PURE__ */ l("td", { children: /* @__PURE__ */ l(ln, { value: e }) }, t)),
3366
+ /* @__PURE__ */ l("td", { children: o(t, "irreflexive") }),
3367
+ /* @__PURE__ */ l("td", { children: o(t, "reflexive") })
3368
+ ]
3369
+ }, t.id)) })
3370
+ ]
3371
+ })
3372
+ });
3373
+ }
3374
+ function ir({ c: e, results: t, t: n }) {
3375
+ return /* @__PURE__ */ l("div", {
3376
+ className: "ca-ground-scroll",
3377
+ children: /* @__PURE__ */ u("table", {
3378
+ className: "ca-ground-table",
3379
+ "data-table": "proposals",
3380
+ children: [
3381
+ /* @__PURE__ */ l("caption", { children: n.proposalsHeading }),
3382
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [
3383
+ /* @__PURE__ */ l("th", {
3384
+ scope: "col",
3385
+ children: n.proposalColumn
3386
+ }),
3387
+ /* @__PURE__ */ l("th", {
3388
+ scope: "col",
3389
+ children: n.identityClause
3390
+ }),
3391
+ /* @__PURE__ */ l("th", {
3392
+ scope: "col",
3393
+ children: n.distinctnessClause
3394
+ }),
3395
+ /* @__PURE__ */ l("th", {
3396
+ scope: "col",
3397
+ children: n.verdictColumn
3398
+ })
3399
+ ] }) }),
3400
+ /* @__PURE__ */ l("tbody", { children: t.map((t) => /* @__PURE__ */ u("tr", {
3401
+ "data-proposal": t.id,
3402
+ "data-verdict": t.verdict,
3403
+ children: [
3404
+ /* @__PURE__ */ l("th", {
3405
+ scope: "row",
3406
+ children: nn(e, t.id, n)
3407
+ }),
3408
+ /* @__PURE__ */ l("td", { children: t.identity.holds ? n.clauseHolds : n.clauseFails }),
3409
+ /* @__PURE__ */ l("td", { children: t.distinctness.holds ? n.clauseHolds : n.clauseFails }),
3410
+ /* @__PURE__ */ l("td", { children: /* @__PURE__ */ l(ar, {
3411
+ result: t,
3412
+ t: n
3413
+ }) })
3414
+ ]
3415
+ }, t.id)) })
3416
+ ]
3417
+ })
3418
+ });
3419
+ }
3420
+ function ar({ result: e, t }) {
3421
+ return /* @__PURE__ */ u("span", {
3422
+ className: "ca-ground-verdict",
3423
+ "data-verdict": e.verdict,
3424
+ children: [/* @__PURE__ */ l("strong", { children: t.verdict[e.verdict] }), /* @__PURE__ */ u("span", {
3425
+ className: "ca-small ca-muted",
3426
+ children: [" ", t.verdictReason(e.verdict, e.same, e.necessitationOff)]
3427
+ })]
3428
+ });
3429
+ }
3430
+ // src/ground/components/ProposalTable.tsx
3431
+ function or(e) {
3432
+ return /* @__PURE__ */ l(rn, {
3433
+ locale: e.locale,
3434
+ name: "proposals",
3435
+ caption: e.caption,
3436
+ children: /* @__PURE__ */ l(cr, { ...e })
3437
+ });
3438
+ }
3439
+ var sr = [
3440
+ "property",
3441
+ "weak",
3442
+ "existence"
3443
+ ];
3444
+ function cr({ rows: e, proposals: t = sr }) {
3445
+ let r = B(), [i, a] = s(void 0), d = o(() => e.map((e, n) => {
3446
+ let r = R(e.doc);
3447
+ if (!r.ok) return {
3448
+ ok: !1,
3449
+ errors: r.errors.map((e) => ({
3450
+ ...e,
3451
+ where: `rows.${n}${e.where === void 0 ? "" : `.${e.where}`}`
3452
+ }))
3453
+ };
3454
+ try {
3455
+ let n = Q(r.compiled, tt(r.compiled, e.premises), e.pair[0], e.pair[1], t);
3456
+ return {
3457
+ ok: !0,
3458
+ c: r.compiled,
3459
+ a: n,
3460
+ label: e.label
3461
+ };
3462
+ } catch (e) {
3463
+ let t = v(e);
3464
+ if (t === void 0) throw e;
3465
+ return {
3466
+ ok: !1,
3467
+ errors: [{
3468
+ ...t,
3469
+ where: `rows.${n}`
3470
+ }]
3471
+ };
3472
+ }
3473
+ }), [e, t]), f = d.flatMap((e) => e.ok ? [] : e.errors);
3474
+ if (f.length > 0) return /* @__PURE__ */ l(J, { problems: f });
3475
+ let p = d, m = p[0], h = (e) => e.label ?? z(e.c.doc.title, r.locale) ?? e.c.doc.id, g = i === void 0 ? void 0 : p[Number(i.split(":")[0])];
3476
+ return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("div", {
3477
+ className: "ca-ground-scroll",
3478
+ children: /* @__PURE__ */ u("table", {
3479
+ className: "ca-ground-table ca-ground-matrix",
3480
+ children: [
3481
+ /* @__PURE__ */ l("caption", { children: r.tableCaption }),
3482
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [/* @__PURE__ */ l("th", {
3483
+ scope: "col",
3484
+ children: r.caseColumn
3485
+ }), t.map((e) => /* @__PURE__ */ l("th", {
3486
+ scope: "col",
3487
+ children: m === void 0 ? e : nn(m.c, e, r)
3488
+ }, e))] }) }),
3489
+ /* @__PURE__ */ l("tbody", { children: p.map((e, n) => /* @__PURE__ */ u("tr", {
3490
+ "data-row": n,
3491
+ children: [/* @__PURE__ */ u("th", {
3492
+ scope: "row",
3493
+ children: [h(e), /* @__PURE__ */ u("span", {
3494
+ className: "ca-small ca-muted",
3495
+ children: [" ", r.pairHeading(q(e.c, e.a.discernment.a, r), q(e.c, e.a.discernment.b, r))]
3496
+ })]
3497
+ }), t.map((t) => {
3498
+ let o = e.a.proposals.find((e) => e.id === t), s = `${n}:${t}`;
3499
+ return /* @__PURE__ */ l("td", {
3500
+ "data-proposal": t,
3501
+ "data-verdict": o?.verdict,
3502
+ children: o === void 0 ? "—" : /* @__PURE__ */ l("button", {
3503
+ type: "button",
3504
+ className: "ca-ground-cell",
3505
+ "aria-expanded": i === s,
3506
+ "aria-label": r.expand(h(e), nn(e.c, t, r)),
3507
+ onClick: () => a(i === s ? void 0 : s),
3508
+ children: /* @__PURE__ */ l(ar, {
3509
+ result: o,
3510
+ t: r
3511
+ })
3512
+ })
3513
+ }, t);
3514
+ })]
3515
+ }, n)) })
3516
+ ]
3517
+ })
3518
+ }), g !== void 0 && /* @__PURE__ */ l(n, { children: /* @__PURE__ */ l(nr, {
3519
+ c: g.c,
3520
+ a: g.a,
3521
+ t: r,
3522
+ scopeAll: !1
3523
+ }) }, i)] });
3524
+ }
3525
+ // src/ground/components/GroundChecker.tsx
3526
+ function lr(e) {
3527
+ return /* @__PURE__ */ l(rn, {
3528
+ locale: e.locale,
3529
+ name: "checker",
3530
+ caption: e.caption,
3531
+ children: /* @__PURE__ */ l(dr, { ...e })
3532
+ });
3533
+ }
3534
+ var ur = ["cycle", "grounds"];
3535
+ function dr(e) {
3536
+ let t = Xt(e.doc);
3537
+ if (!t.ok) return /* @__PURE__ */ l(J, { problems: t.errors });
3538
+ let { presets: n, errors: r } = Zt(t.c, e.presets, ur);
3539
+ return r.length > 0 ? /* @__PURE__ */ l(J, { problems: r }) : /* @__PURE__ */ l(mr, {
3540
+ ...e,
3541
+ c: t.c,
3542
+ presetList: n
3543
+ });
3544
+ }
3545
+ function fr(e) {
3546
+ return e.doc.switches ?? [
3547
+ "equivalents",
3548
+ "transitivity",
3549
+ "existence",
3550
+ ...Object.keys(e.space.defs).map((e) => `def:${e}`),
3551
+ ...e.claims.map((e) => `claim:${e.id}`)
3552
+ ];
3553
+ }
3554
+ function pr(e) {
3555
+ return e === void 0 || e.query.kind === "pair" ? void 0 : e.query.target;
3556
+ }
3557
+ function mr(e) {
3558
+ let { c: t, presetList: n } = e, r = B(), i = Yn(t, n, e.initialPreset), [a, d] = s(void 0), f = pr(i.active) ?? e.target, p = o(() => {
3559
+ try {
3560
+ return {
3561
+ ok: !0,
3562
+ a: Bn(t, i.premises, f)
3563
+ };
3564
+ } catch (e) {
3565
+ return {
3566
+ ok: !1,
3567
+ error: e
3568
+ };
3569
+ }
3570
+ }, [
3571
+ t,
3572
+ i.premises,
3573
+ f
3574
+ ]), m = Qt(t, r);
3575
+ if (!p.ok) {
3576
+ let e = v(p.error);
3577
+ return e === void 0 ? /* @__PURE__ */ l("p", {
3578
+ role: "alert",
3579
+ children: Bt(p.error, r)
3580
+ }) : /* @__PURE__ */ l(J, { problems: [e] });
3581
+ }
3582
+ let h = p.a, g = (e) => h.graph.facts[e]?.formula, _ = t.structure.relations.flatMap((e) => e.pairs.filter(([e, t]) => e !== t).map(([t, n]) => ({
3583
+ op: "pred",
3584
+ pred: {
3585
+ kind: "rel",
3586
+ id: e.id
3587
+ },
3588
+ args: [{
3589
+ kind: "name",
3590
+ name: t
3591
+ }, {
3592
+ kind: "name",
3593
+ name: n
3594
+ }]
3595
+ })));
3596
+ return /* @__PURE__ */ u(c, { children: [
3597
+ /* @__PURE__ */ l(sn, {
3598
+ c: t,
3599
+ keys: e.switches ?? fr(t),
3600
+ values: i.values,
3601
+ onChange: i.setPremise
3602
+ }),
3603
+ /* @__PURE__ */ u("div", {
3604
+ className: "ca-ground-strip",
3605
+ children: [/* @__PURE__ */ l(yn, { c: t }), _.length > 0 && /* @__PURE__ */ u("p", {
3606
+ className: "ca-small",
3607
+ children: [
3608
+ r.holdsFacts,
3609
+ " ",
3610
+ _.map((e, t) => /* @__PURE__ */ u("span", {
3611
+ className: "ca-ground-fact",
3612
+ children: [/* @__PURE__ */ l(on, {
3613
+ fact: e,
3614
+ symbols: m
3615
+ }), " "]
3616
+ }, t))
3617
+ ]
3618
+ })]
3619
+ }),
3620
+ /* @__PURE__ */ l(gr, {
3621
+ c: t,
3622
+ a: h,
3623
+ t: r,
3624
+ symbols: m,
3625
+ onPick: d
3626
+ }),
3627
+ a !== void 0 && g(a) !== void 0 && /* @__PURE__ */ l(vr, {
3628
+ c: t,
3629
+ a: h,
3630
+ fact: a,
3631
+ t: r,
3632
+ symbols: m,
3633
+ onPick: d
3634
+ }),
3635
+ /* @__PURE__ */ l(cn, {
3636
+ presets: n,
3637
+ active: i.active?.id,
3638
+ onPick: (e) => (i.pick(e), d(void 0)),
3639
+ mismatches: i.mismatches
3640
+ })
3641
+ ] });
3642
+ }
3643
+ function hr(e, t, n) {
3644
+ let r = t.rule.startsWith("claim:") ? n.claimRule(tn(e, t.rule.slice(6), n)) : n.rules[t.rule] ?? t.rule;
3645
+ return t.steps > 1 ? `${r}${n.mergedSteps(t.steps)}` : r;
3646
+ }
3647
+ function $({ a: e, n: t, symbols: n, t: r, onPick: i }) {
3648
+ let a = e.graph.facts[t]?.formula;
3649
+ return a === void 0 ? null : /* @__PURE__ */ l("button", {
3650
+ type: "button",
3651
+ className: "ca-ground-factbtn",
3652
+ "data-fact": t,
3653
+ "aria-label": r.showGrounds(K(a, n).text),
3654
+ onClick: () => i(t),
3655
+ children: /* @__PURE__ */ l(on, {
3656
+ fact: a,
3657
+ symbols: n
3658
+ })
3659
+ });
3660
+ }
3661
+ function gr({ c: e, a: t, t: n, symbols: r, onPick: i }) {
3662
+ let a = t.target, o = a !== void 0 && t.cycleFact === a, s = t.cycleFact !== void 0 && !o ? t.graph.facts[t.cycleFact]?.formula : void 0, d = o ? n.selfGrounds : s === void 0 ? n.noSelfGround : n.otherSelfGrounds(K(s, r).text);
3663
+ return /* @__PURE__ */ u("div", {
3664
+ className: "ca-ground-result",
3665
+ "data-self-ground": t.selfGrounding.length > 0 ? "true" : "false",
3666
+ children: [
3667
+ /* @__PURE__ */ u("p", {
3668
+ className: "ca-ground-verdict-line",
3669
+ "aria-live": "polite",
3670
+ children: [
3671
+ a !== void 0 && /* @__PURE__ */ u(c, { children: [
3672
+ /* @__PURE__ */ u("span", {
3673
+ className: "ca-muted",
3674
+ children: [n.targetHeading, " "]
3675
+ }),
3676
+ /* @__PURE__ */ l($, {
3677
+ a: t,
3678
+ n: a,
3679
+ symbols: r,
3680
+ t: n,
3681
+ onPick: i
3682
+ }),
3683
+ " "
3684
+ ] }),
3685
+ /* @__PURE__ */ l("span", {
3686
+ className: "ca-ground-mark",
3687
+ "data-value": t.selfGrounding.length > 0 ? "no" : "ok",
3688
+ "aria-hidden": "true",
3689
+ children: t.selfGrounding.length > 0 ? "✗" : "✓"
3690
+ }),
3691
+ " ",
3692
+ d
3693
+ ]
3694
+ }),
3695
+ t.chain !== void 0 && /* @__PURE__ */ l("ol", {
3696
+ className: "ca-ground-chain",
3697
+ "aria-label": n.chainHeading,
3698
+ children: t.chain.map((a, o) => /* @__PURE__ */ u("li", {
3699
+ "data-rule": a.rule,
3700
+ children: [/* @__PURE__ */ u("span", {
3701
+ className: "ca-ground-step",
3702
+ children: [
3703
+ /* @__PURE__ */ l($, {
3704
+ a: t,
3705
+ n: a.from,
3706
+ symbols: r,
3707
+ t: n,
3708
+ onPick: i
3709
+ }),
3710
+ " ",
3711
+ /* @__PURE__ */ l("span", {
3712
+ "aria-hidden": "true",
3713
+ children: "≺"
3714
+ }),
3715
+ " ",
3716
+ /* @__PURE__ */ l($, {
3717
+ a: t,
3718
+ n: a.to,
3719
+ symbols: r,
3720
+ t: n,
3721
+ onPick: i
3722
+ })
3723
+ ]
3724
+ }), /* @__PURE__ */ l("span", {
3725
+ className: "ca-ground-rule ca-muted",
3726
+ children: hr(e, a, n)
3727
+ })]
3728
+ }, o))
3729
+ }),
3730
+ t.chain === void 0 && a !== void 0 && /* @__PURE__ */ l(_r, {
3731
+ c: e,
3732
+ a: t,
3733
+ t: n,
3734
+ symbols: r,
3735
+ onPick: i
3736
+ }),
3737
+ t.graph.claimFailures.map((i, a) => {
3738
+ let o = t.graph.facts[i.grounded]?.formula;
3739
+ return o === void 0 ? null : /* @__PURE__ */ l("p", {
3740
+ className: "ca-small",
3741
+ "data-claim-fails": i.claim,
3742
+ children: n.claimFailure(tn(e, i.claim, n), K(o, r).text)
3743
+ }, a);
3744
+ }),
3745
+ t.variantNotes.map((e) => /* @__PURE__ */ l("p", {
3746
+ className: "ca-small ca-muted",
3747
+ "data-variants-agree": e.agree ? "true" : "false",
3748
+ children: e.agree ? n.variantsAgree(n.defNoun(e.def)) : n.variantsDiffer(n.defNoun(e.def))
3749
+ }, `${e.def}-${e.fact}`)),
3750
+ /* @__PURE__ */ l("p", {
3751
+ className: "ca-ground-note ca-small ca-muted",
3752
+ children: n.finiteNote
3753
+ })
3754
+ ]
3755
+ });
3756
+ }
3757
+ function _r({ c: e, a: t, t: n, symbols: r, onPick: i }) {
3758
+ return t.target === void 0 ? null : (t.graph.groundsOf[t.target] ?? []).length === 0 ? /* @__PURE__ */ l("p", {
3759
+ className: "ca-small",
3760
+ children: n.noPartial
3761
+ }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(vr, {
3762
+ c: e,
3763
+ a: t,
3764
+ fact: t.target,
3765
+ t: n,
3766
+ symbols: r,
3767
+ onPick: i
3768
+ }), /* @__PURE__ */ u("details", {
3769
+ className: "ca-ground-partial",
3770
+ children: [/* @__PURE__ */ l("summary", { children: n.partialHeading(t.partial.length) }), /* @__PURE__ */ l("p", { children: t.partial.map((e) => /* @__PURE__ */ u("span", {
3771
+ className: "ca-ground-fact",
3772
+ children: [/* @__PURE__ */ l($, {
3773
+ a: t,
3774
+ n: e,
3775
+ symbols: r,
3776
+ t: n,
3777
+ onPick: i
3778
+ }), " "]
3779
+ }, e)) })]
3780
+ })] });
3781
+ }
3782
+ function vr({ c: e, a: t, fact: n, t: r, symbols: i, onPick: a }) {
3783
+ let o = t.graph.facts[n]?.formula;
3784
+ if (o === void 0) return null;
3785
+ let s = (t.graph.groundsOf[n] ?? []).map((e) => t.graph.sets[e]);
3786
+ return /* @__PURE__ */ u("div", {
3787
+ className: "ca-ground-sets",
3788
+ "data-grounds-of": n,
3789
+ children: [/* @__PURE__ */ u("p", {
3790
+ className: "ca-small",
3791
+ children: [
3792
+ r.directGrounds,
3793
+ " ",
3794
+ /* @__PURE__ */ l(on, {
3795
+ fact: o,
3796
+ symbols: i
3797
+ })
3798
+ ]
3799
+ }), s.length === 0 ? /* @__PURE__ */ l("p", {
3800
+ className: "ca-small ca-muted",
3801
+ children: r.noPartial
3802
+ }) : /* @__PURE__ */ l("ul", { children: s.map((n, s) => /* @__PURE__ */ u("li", {
3803
+ "data-rule": n.rule,
3804
+ "data-partial": n.partial ? "true" : void 0,
3805
+ children: [n.members.length === 0 ? r.zeroGround : n.members.map((e) => /* @__PURE__ */ u("span", {
3806
+ className: "ca-ground-fact",
3807
+ children: [a === void 0 ? /* @__PURE__ */ l(on, {
3808
+ fact: t.graph.facts[e]?.formula ?? o,
3809
+ symbols: i
3810
+ }) : /* @__PURE__ */ l($, {
3811
+ a: t,
3812
+ n: e,
3813
+ symbols: i,
3814
+ t: r,
3815
+ onPick: a
3816
+ }), " "]
3817
+ }, e)), /* @__PURE__ */ l("span", {
3818
+ className: "ca-ground-rule ca-muted",
3819
+ children: hr(e, {
3820
+ rule: n.rule,
3821
+ steps: 1
3822
+ }, r)
3823
+ })]
3824
+ }, s)) })]
3825
+ });
3826
+ }
3827
+ export { Fe as BUILTIN_DEFS, He as BUILTIN_PROPOSALS, Ct as DEFAULT_LOCALE, Xn as DiscernibilityPanel, ce as FIXED_PREMISES, m as GROUND_PROBLEMS_EN, lr as GroundChecker, g as GroundError, De as IDENTIFIER_PATTERN, wt as LANGUAGE_NAMES, Et as LocaleProvider, he as MAX_AUTOMORPHISM_INDIVIDUALS, Pn as MAX_FACTS, yt as MAX_GROUND_DOC_CHARS, Ye as MAX_SYMBOLS, V as PLAIN_SYMBOLS, w as PREMISE_VALUES, Ue as PROPOSAL_VERDICTS, or as ProposalTable, Ee as RANGE_NAMES, _n as StructureView, Bn as analyzeGround, Q as analyzePair, fe as applySettings, xe as automorphisms, Rn as buildGroundGraph, En as chainRows, Dn as chainRules, St as checkGroundDoc, qn as checkPreset, Jn as checkPresets, kn as checkRelation, L as closedFormula, $e as compileCase, xn as components, le as defaultPremises, Nn as discern, Ln as equivalentOf, re as factKey, C as freeVariables, _t as groundCaseSchema, f as groundProblem, v as groundProblemOf, h as groundProblemText, z as groundText, A as holds, Te as holdsWith, O as interpretation, In as logicalGrounds, ie as namesIn, R as parseGroundJson, Pe as parseRaw, wn as partialGrounds, me as premiseDiff, ue as premiseKeys, pe as premiseValue, de as premiseValues, tt as premisesFor, gt as presetSchema, K as printFact, qt as printFormula, Jt as printPred, Yt as printTerm, Je as proposalVerdict, M as resolveFormula, Kn as runPreset, Se as sameOrbit, Sn as selfGrounding, Cn as shortestCycle, S as substitute, bn as successors };
3828
+
3829
+ //# sourceMappingURL=ground.js.map