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
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Every error the ground engine and its data layer raise has a stable code and its parameters, so an
3
+ * interface can word it in its own language. `Error.message` is the English wording below.
4
+ */
5
+ /** Parameters per problem code. */
6
+ export interface GroundProblemParams {
7
+ readonly 'parse-unexpected-character': {
8
+ readonly source: string;
9
+ readonly position: number;
10
+ readonly character: string;
11
+ };
12
+ readonly 'parse-unexpected-token': {
13
+ readonly source: string;
14
+ readonly position: number;
15
+ readonly token: string;
16
+ };
17
+ readonly 'parse-unexpected-end': {
18
+ readonly source: string;
19
+ readonly position: number;
20
+ };
21
+ readonly 'parse-expected': {
22
+ readonly source: string;
23
+ readonly position: number;
24
+ readonly expected: string;
25
+ };
26
+ /** A name that is no individual, property, relation, definition or bound variable. */
27
+ readonly 'unknown-symbol': {
28
+ readonly name: string;
29
+ readonly formula: string;
30
+ };
31
+ readonly 'wrong-arity': {
32
+ readonly name: string;
33
+ readonly expected: number;
34
+ readonly got: number;
35
+ readonly formula: string;
36
+ };
37
+ /** A property or relation symbol where an individual is needed, or the other way round. */
38
+ readonly 'wrong-sort': {
39
+ readonly name: string;
40
+ readonly expected: 'individual' | 'property' | 'relation';
41
+ readonly formula: string;
42
+ };
43
+ /** A free variable in a formula that must be closed (a target, a preset's fact). */
44
+ readonly 'free-variable': {
45
+ readonly variable: string;
46
+ readonly formula: string;
47
+ };
48
+ readonly 'recursive-definition': {
49
+ readonly name: string;
50
+ };
51
+ readonly 'duplicate-id': {
52
+ readonly id: string;
53
+ };
54
+ readonly 'unknown-individual': {
55
+ readonly id: string;
56
+ };
57
+ readonly 'unknown-relation': {
58
+ readonly id: string;
59
+ };
60
+ readonly 'unknown-proposal': {
61
+ readonly id: string;
62
+ };
63
+ readonly 'unknown-claim': {
64
+ readonly id: string;
65
+ };
66
+ readonly 'unknown-variant': {
67
+ readonly definition: string;
68
+ readonly variant: string;
69
+ };
70
+ readonly 'unknown-premise': {
71
+ readonly key: string;
72
+ };
73
+ readonly 'bad-premise-value': {
74
+ readonly key: string;
75
+ readonly value: string;
76
+ readonly allowed: readonly string[];
77
+ };
78
+ readonly 'too-many-individuals': {
79
+ readonly count: number;
80
+ readonly limit: number;
81
+ };
82
+ readonly 'too-many-symbols': {
83
+ readonly count: number;
84
+ readonly limit: number;
85
+ };
86
+ readonly 'too-many-facts': {
87
+ readonly count: number;
88
+ readonly limit: number;
89
+ };
90
+ readonly 'not-json': {
91
+ readonly detail: string;
92
+ };
93
+ readonly 'too-large': Record<string, never>;
94
+ /** A component given a preset id the case does not have. */
95
+ readonly 'unknown-preset': {
96
+ readonly id: string;
97
+ };
98
+ /** A preset's `expect` keys belong to another kind of query. */
99
+ readonly 'expect-kind': {
100
+ readonly preset: string;
101
+ readonly kind: string;
102
+ };
103
+ /** A property gives both or neither of `holds` and `define` (a relation: `pairs` and `define`). */
104
+ readonly 'extension-source': {
105
+ readonly id: string;
106
+ };
107
+ /** Any other schema complaint, already worded per locale. */
108
+ readonly schema: {
109
+ readonly message: {
110
+ readonly 'zh-TW': string;
111
+ readonly en: string;
112
+ };
113
+ };
114
+ }
115
+ export type GroundProblemCode = keyof GroundProblemParams;
116
+ /** One problem: its code, parameters and, when known, where it sits (a path into the document, e.g. `ground.targets.0`). */
117
+ export type GroundProblem = {
118
+ readonly [K in GroundProblemCode]: {
119
+ readonly code: K;
120
+ readonly params: GroundProblemParams[K];
121
+ readonly where?: string;
122
+ };
123
+ }[GroundProblemCode];
124
+ export declare function groundProblem<K extends GroundProblemCode>(code: K, params: GroundProblemParams[K], where?: string): GroundProblem;
125
+ /** Wording per code; the interface supplies one per locale. */
126
+ export interface GroundProblemWording {
127
+ readonly messages: {
128
+ readonly [K in GroundProblemCode]: (params: GroundProblemParams[K]) => string;
129
+ };
130
+ readonly join: (where: string, message: string) => string;
131
+ }
132
+ export declare const GROUND_PROBLEMS_EN: GroundProblemWording;
133
+ /** The problem worded by `wording` (English by default). */
134
+ export declare function groundProblemText(p: GroundProblem, wording?: GroundProblemWording): string;
135
+ /** An error carrying a {@link GroundProblem}; its message is the English wording. */
136
+ export declare class GroundError extends Error {
137
+ readonly problem: GroundProblem;
138
+ constructor(p: GroundProblem);
139
+ }
140
+ export declare function groundFail<K extends GroundProblemCode>(code: K, params: GroundProblemParams[K], where?: string): never;
141
+ /** The problem behind `error`, when it is one of ours. */
142
+ export declare function groundProblemOf(error: unknown): GroundProblem | undefined;
@@ -0,0 +1,25 @@
1
+ import type { FiniteStructure } from '../../logic/structure.js';
2
+ import type { Formula, Pred } from './formula.js';
3
+ import type { Premises } from './premises.js';
4
+ import type { RangeName } from './syntax.js';
5
+ /**
6
+ * Truth on a finite structure. First-order quantifiers range over the individuals; second-order
7
+ * ones over the case's listed properties or relations only, as the `scope` premise admits them (a
8
+ * finite stand-in for "all properties", which the figures say in words).
9
+ */
10
+ export interface Interpretation {
11
+ /** The structure, its haecceities (`=o`) appended to the properties when the case makes them available. */
12
+ readonly structure: FiniteStructure;
13
+ /** What each second-order range covers under the premises. */
14
+ readonly ranges: Readonly<Record<RangeName, readonly Pred[]>>;
15
+ /** The names instances are taken over, in order (every individual's id first). */
16
+ readonly names: readonly string[];
17
+ }
18
+ /** The ranges `scope` gives: Qual the qualitative properties; Prop those, every listed property, or those and the haecceities; Rel every relation. */
19
+ export declare function interpretation(structure: FiniteStructure, premises: Pick<Premises, 'scope'>): Interpretation;
20
+ type Value = string | Pred;
21
+ /** Whether the closed formula `f` is true on the interpretation. */
22
+ export declare function holds(i: Interpretation, f: Formula): boolean;
23
+ /** Whether `f` is true with its free variables assigned (individual ids for first-order ones, predicates for second-order ones). */
24
+ export declare function holdsWith(i: Interpretation, f: Formula, assignment: Readonly<Record<string, Value>>): boolean;
25
+ export {};
@@ -0,0 +1,61 @@
1
+ import type { Interpretation } from './evaluate.js';
2
+ import type { Formula } from './formula.js';
3
+ import type { Premises } from './premises.js';
4
+ /**
5
+ * The facts of a grounding derivation and their direct full grounds. Starting from the targets and
6
+ * the claims, every true compound fact is split downwards by the rules the premises switch on, until
7
+ * atomic facts, negated atomic facts and the facts the claims start from; a claim links what it
8
+ * grounds to its grounds. Only true facts get grounds (ground is factive), and facts are individuated
9
+ * by their sentences (`terms`: [a = b] is [b = a]).
10
+ */
11
+ export type LogicalRule = 'conjunction' | 'disjunction' | 'existential' | 'universal' | 'equivalents';
12
+ /** A logical rule, or `claim:<id>`. */
13
+ export type RuleId = LogicalRule | `claim:${string}`;
14
+ export interface FactNode {
15
+ readonly key: string;
16
+ readonly formula: Formula;
17
+ readonly truth: boolean;
18
+ }
19
+ /** One direct full ground of a fact (or, for a `partial` claim, facts that are only partial grounds). */
20
+ export interface GroundSet {
21
+ readonly grounded: number;
22
+ readonly members: readonly number[];
23
+ readonly rule: RuleId;
24
+ readonly partial: boolean;
25
+ /** For `equivalents`: the equivalent fact whose grounds these are. */
26
+ readonly via?: number;
27
+ }
28
+ /** A claim instantiated over the names, with its formulas resolved. */
29
+ export interface ClaimInstance {
30
+ readonly claim: string;
31
+ readonly grounded: Formula;
32
+ /** Each alternative full ground (one per `some` predicate that makes it hold), or the partial grounds. */
33
+ readonly alternatives: readonly (readonly Formula[])[];
34
+ readonly partial: boolean;
35
+ }
36
+ export interface GroundGraph {
37
+ readonly facts: readonly FactNode[];
38
+ readonly sets: readonly GroundSet[];
39
+ /** Per fact, the indexes in `sets` of its grounds. */
40
+ readonly groundsOf: readonly (readonly number[])[];
41
+ /** Claim instances whose grounded fact is true but none of whose grounds all hold. */
42
+ readonly claimFailures: readonly {
43
+ readonly claim: string;
44
+ readonly grounded: number;
45
+ readonly facts: readonly Formula[];
46
+ }[];
47
+ readonly index: ReadonlyMap<string, number>;
48
+ }
49
+ /** The most facts a derivation may have. */
50
+ export declare const MAX_FACTS = 1500;
51
+ interface Candidate {
52
+ readonly members: readonly Formula[];
53
+ readonly rule: LogicalRule;
54
+ }
55
+ /** The direct full grounds the logical rules give a true fact. */
56
+ export declare function logicalGrounds(f: Formula, i: Interpretation, premises: Premises): Candidate[];
57
+ /** The equivalent the `equivalents` rule reads a conditional or biconditional by: ¬A ∨ B, or (A ∧ B) ∨ (¬A ∧ ¬B). */
58
+ export declare function equivalentOf(f: Formula): Formula | undefined;
59
+ /** Build the derivation from the targets and the claim instances. Throws `too-many-facts` past {@link MAX_FACTS}. */
60
+ export declare function buildGroundGraph(i: Interpretation, premises: Premises, targets: readonly Formula[], claims: readonly ClaimInstance[]): GroundGraph;
61
+ export {};
@@ -0,0 +1,100 @@
1
+ import type { RangeName } from './syntax.js';
2
+ /**
3
+ * Formulas after `resolve`: every name is known to be an individual's name, a property, a relation
4
+ * or a variable, and every definition is expanded (the expansion keeps a `def` note, so a fact such as
5
+ * Irr(R) can still be shown as [R is irreflexive]). Pure data; equality of facts goes through
6
+ * {@link factKey}.
7
+ */
8
+ export type Term = {
9
+ readonly kind: 'var';
10
+ readonly name: string;
11
+ } | {
12
+ readonly kind: 'name';
13
+ readonly name: string;
14
+ };
15
+ export type PredSort = 'property' | 'relation';
16
+ export type Pred = {
17
+ readonly kind: 'prop';
18
+ readonly id: string;
19
+ } | {
20
+ readonly kind: 'rel';
21
+ readonly id: string;
22
+ } | {
23
+ readonly kind: 'var';
24
+ readonly name: string;
25
+ readonly sort: PredSort;
26
+ };
27
+ /** What a definition was applied to, for display. */
28
+ export type DefArg = Term | Pred;
29
+ export interface DefNote {
30
+ readonly name: string;
31
+ readonly args: readonly DefArg[];
32
+ }
33
+ export type Binary = 'and' | 'or' | 'imp' | 'iff';
34
+ type Node = {
35
+ readonly op: 'true';
36
+ } | {
37
+ readonly op: 'false';
38
+ } | {
39
+ readonly op: 'pred';
40
+ readonly pred: Pred;
41
+ readonly args: readonly Term[];
42
+ } | {
43
+ readonly op: 'eq';
44
+ readonly left: Term;
45
+ readonly right: Term;
46
+ }
47
+ /** The existence predicate Ea. */
48
+ | {
49
+ readonly op: 'E';
50
+ readonly arg: Term;
51
+ } | {
52
+ readonly op: 'not';
53
+ readonly arg: Formula;
54
+ } | {
55
+ readonly op: Binary;
56
+ readonly left: Formula;
57
+ readonly right: Formula;
58
+ } | {
59
+ readonly op: 'forall' | 'exists';
60
+ readonly variable: string;
61
+ readonly restrict?: Formula;
62
+ readonly body: Formula;
63
+ } | {
64
+ readonly op: 'forall2' | 'exists2';
65
+ readonly variable: string;
66
+ readonly sort: PredSort;
67
+ readonly range: RangeName;
68
+ readonly body: Formula;
69
+ };
70
+ export type Formula = Node & {
71
+ readonly def?: DefNote;
72
+ };
73
+ export declare const isQuantifier1: (f: Formula) => f is Extract<Formula, {
74
+ op: 'forall' | 'exists';
75
+ }>;
76
+ export declare const isQuantifier2: (f: Formula) => f is Extract<Formula, {
77
+ op: 'forall2' | 'exists2';
78
+ }>;
79
+ /** A value a variable can be replaced by: a name for a first-order variable, a predicate for a second-order one. */
80
+ export type Value = Term | Pred;
81
+ /**
82
+ * `f` with the free occurrences of `variable` replaced by `value`. Values are closed (names and
83
+ * predicate constants), so no capture can happen.
84
+ */
85
+ export declare function substitute(f: Formula, variable: string, value: Value): Formula;
86
+ /** The free variables of `f`, first and second order, in order of first appearance. */
87
+ export declare function freeVariables(f: Formula): string[];
88
+ /**
89
+ * A fact's identity when facts are individuated by the sentences that state them (`terms`): the
90
+ * structure of the formula with its names, ignoring display notes, and with the two sides of every
91
+ * identity in a fixed order, so [a = b] and [b = a] are one fact. Bound variables are renamed by
92
+ * depth, so ∃y(y = a) and ∃z(z = a) are one fact too.
93
+ */
94
+ export declare function factKey(f: Formula): string;
95
+ /** The names (individual names) that occur in `f`, in order of appearance. */
96
+ export declare function namesIn(f: Formula): string[];
97
+ export declare const not: (arg: Formula) => Formula;
98
+ export declare const and: (left: Formula, right: Formula) => Formula;
99
+ export declare const or: (left: Formula, right: Formula) => Formula;
100
+ export {};
@@ -0,0 +1,26 @@
1
+ export type { GroundProblem, GroundProblemCode, GroundProblemParams, GroundProblemWording } from './errors.js';
2
+ export { GROUND_PROBLEMS_EN, GroundError, groundProblem, groundProblemOf, groundProblemText } from './errors.js';
3
+ export type { RangeName, RawFormula } from './syntax.js';
4
+ export { IDENTIFIER_PATTERN, RANGE_NAMES, parseRaw } from './syntax.js';
5
+ export type { DefArg, DefNote, Formula, Pred, Term } from './formula.js';
6
+ export { factKey, freeVariables, namesIn, substitute } from './formula.js';
7
+ export type { DefSpec, Vocabulary } from './resolve.js';
8
+ export { BUILTIN_DEFS, resolveFormula } from './resolve.js';
9
+ export type { FixedPremise, OnOff, PremiseSettings, PremiseSpace, Premises } from './premises.js';
10
+ export { FIXED_PREMISES, PREMISE_VALUES, applySettings, defaultPremises, premiseDiff, premiseKeys, premiseValue, premiseValues } from './premises.js';
11
+ export type { Interpretation } from './evaluate.js';
12
+ export { holds, holdsWith, interpretation } from './evaluate.js';
13
+ export type { Printed, Symbols } from './print.js';
14
+ export { PLAIN_SYMBOLS, printFact, printFormula, printPred, printTerm } from './print.js';
15
+ export type { AbsoluteWitness, Discernment, PropertyRow, RelationRow } from './discern.js';
16
+ export { discern } from './discern.js';
17
+ export type { ClauseResult, ClauseSpec, ProposalResult, ProposalSpec, ProposalVerdict } from './proposals.js';
18
+ export { BUILTIN_PROPOSALS, PROPOSAL_VERDICTS, proposalVerdict } from './proposals.js';
19
+ export type { ClaimInstance, FactNode, GroundGraph, GroundSet, LogicalRule, RuleId } from './facts.js';
20
+ export { MAX_FACTS, buildGroundGraph, equivalentOf, logicalGrounds } from './facts.js';
21
+ export type { ChainRow } from './closure.js';
22
+ export { chainRows, chainRules, components, partialGrounds, selfGrounding, shortestCycle, successors } from './closure.js';
23
+ export type { Automorphism, FiniteStructure, StructureProperty, StructureRelation } from '../../logic/structure.js';
24
+ export { MAX_AUTOMORPHISM_INDIVIDUALS, automorphisms, sameOrbit } from '../../logic/structure.js';
25
+ export type { RelationCheck, RelationProperty } from '../../logic/relations.js';
26
+ export { checkRelation } from '../../logic/relations.js';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The premises (rule switches) a reader turns on and off. Each fixed key has its values, the
3
+ * default first; a case overrides the defaults and a preset overrides the case. Definitions with
4
+ * variants add `def:<name>` keys and every claim a `claim:<id>` key.
5
+ */
6
+ export type OnOff = 'on' | 'off';
7
+ /** Fixed premise keys and their values, the default first. */
8
+ export declare const PREMISE_VALUES: {
9
+ /** A, B < A ∧ B. */
10
+ readonly conjunction: readonly ["on", "off"];
11
+ /** Each true disjunct fully grounds a disjunction; both together too. */
12
+ readonly disjunction: readonly ["on", "off"];
13
+ /** Each true instance fully grounds an existential. */
14
+ readonly existential: readonly ["on", "off"];
15
+ /** All instances fully ground a universal; `restricted` reads ∀x(ψ → φ) as (∀x : ψ)φ and ∃x(ψ ∧ φ) as (∃x : ψ)φ. */
16
+ readonly universal: readonly ["unrestricted", "restricted"];
17
+ /** A → B shares the grounds of ¬A ∨ B, A ↔ B those of (A ∧ B) ∨ (¬A ∧ ¬B). */
18
+ readonly equivalents: readonly ["on", "off"];
19
+ /** Partial ground is transitive. */
20
+ readonly transitivity: readonly ["on", "off"];
21
+ /** A full ground that obtains necessitates what it grounds (the discernibility verdicts). */
22
+ readonly necessitation: readonly ["on", "off"];
23
+ /** "a exists": ∃y(y = a), or the predicate Ea. */
24
+ readonly existence: readonly ["quantified", "predicate"];
25
+ /** The properties `Prop` ranges over: the qualitative ones, every listed one, or those and the haecceities. */
26
+ readonly scope: readonly ["qualitative", "nonhaecceitistic", "all"];
27
+ };
28
+ export type FixedPremise = keyof typeof PREMISE_VALUES;
29
+ export declare const FIXED_PREMISES: FixedPremise[];
30
+ export type Premises = {
31
+ readonly [K in FixedPremise]: (typeof PREMISE_VALUES)[K][number];
32
+ } & {
33
+ /** Definition name → its chosen variant. */
34
+ readonly defs: Readonly<Record<string, string>>;
35
+ /** Claim id → on. */
36
+ readonly claims: Readonly<Record<string, boolean>>;
37
+ };
38
+ /** Premises as a case or preset writes them: `{ "equivalents": "off", "def:Irr": "negation", "claim:weak-distinct": "on" }`. */
39
+ export type PremiseSettings = Readonly<Record<string, string>>;
40
+ /** What the premises of one case can be: its definitions' variants and its claims. */
41
+ export interface PremiseSpace {
42
+ readonly defs: Readonly<Record<string, {
43
+ readonly variants: readonly string[];
44
+ readonly default: string;
45
+ }>>;
46
+ readonly claims: Readonly<Record<string, boolean>>;
47
+ }
48
+ export declare function defaultPremises(space: PremiseSpace): Premises;
49
+ /** Every premise key of `space`: the fixed ones, then `def:` and `claim:` keys. */
50
+ export declare function premiseKeys(space: PremiseSpace): string[];
51
+ /** The values premise `key` takes in `space`, the default first. */
52
+ export declare function premiseValues(space: PremiseSpace, key: string): readonly string[];
53
+ /** `base` with `settings` applied; throws on an unknown key or value. */
54
+ export declare function applySettings(base: Premises, settings: PremiseSettings | undefined, space: PremiseSpace): Premises;
55
+ /** The value of premise `key` in `p`, as written. */
56
+ export declare function premiseValue(p: Premises, key: string): string;
57
+ /** The keys on which `a` and `b` differ. */
58
+ export declare function premiseDiff(space: PremiseSpace, a: Premises, b: Premises): string[];
@@ -0,0 +1,29 @@
1
+ import type { Formula } from './formula.js';
2
+ /**
3
+ * Facts and formulas written out for display, in plain text and in LaTeX, with the letters the case
4
+ * gives its names, properties and relations (`symbol`), so a fact reads [Rab] as the article writes it.
5
+ * A predicate and its arguments run together when every symbol is one letter (Rab), else take
6
+ * brackets (Iron(a)). A definition such as Irr(R) may be shown by its label ([R is irreflexive]).
7
+ */
8
+ export interface Printed {
9
+ readonly text: string;
10
+ readonly latex: string;
11
+ }
12
+ export interface Symbols {
13
+ /** An individual name's symbol. */
14
+ readonly term: (name: string) => string;
15
+ /** A property or relation id's symbol; haecceities `=o` are written λx.(x = o) by the printer. */
16
+ readonly pred: (id: string) => string;
17
+ /** A definition's label with its arguments printed, or undefined to write the expansion. */
18
+ readonly defLabel?: (name: string, args: readonly Printed[]) => Printed | undefined;
19
+ }
20
+ /** Symbols that are the ids themselves. */
21
+ export declare const PLAIN_SYMBOLS: Symbols;
22
+ /** A formula without the fact brackets. */
23
+ export declare function printFormula(f: Formula, symbols?: Symbols): Printed;
24
+ /** A fact: the formula in square brackets, [Rab]. */
25
+ export declare function printFact(f: Formula, symbols?: Symbols): Printed;
26
+ /** A predicate by itself (a witness relation or property): its symbol, or λx.(x = a) for a haecceity. */
27
+ export declare function printPred(id: string, symbols?: Symbols): Printed;
28
+ /** An individual name by its symbol. */
29
+ export declare function printTerm(name: string, symbols?: Symbols): Printed;
@@ -0,0 +1,56 @@
1
+ import type { Interpretation } from './evaluate.js';
2
+ import type { Formula } from './formula.js';
3
+ import type { Premises } from './premises.js';
4
+ import type { Vocabulary } from './resolve.js';
5
+ import type { RangeName } from './syntax.js';
6
+ /**
7
+ * Proposals: a pair of grounding clauses over the variables x and y. If x = y, [x = y] is fully
8
+ * grounded in the identity clause's facts; if x ≠ y, [x ≠ y] in the distinctness clause's. `some`
9
+ * lets a clause hold for some predicate of a range (weak discernibility: some R with [Rxy] and
10
+ * [R is irreflexive]). The verdict for a pair says whether the proposal explains the case's setting.
11
+ */
12
+ export interface ClauseSpec {
13
+ /** The full ground: formulas in x, y and the `some` variables. Empty: the zero ground. */
14
+ readonly full: readonly string[];
15
+ readonly some?: Readonly<Record<string, RangeName>>;
16
+ }
17
+ export interface ProposalSpec {
18
+ readonly id: string;
19
+ readonly identity: ClauseSpec;
20
+ readonly distinctness: ClauseSpec;
21
+ }
22
+ /** The three proposals every case has. The property proposal quantifies over `Prop`, so the `scope` premise decides whether haecceities count. */
23
+ export declare const BUILTIN_PROPOSALS: readonly ProposalSpec[];
24
+ export type ProposalVerdict = 'explained' | 'no-ground' | 'necessitation-conflict' | 'trivial' | 'same-ground';
25
+ export declare const PROPOSAL_VERDICTS: readonly ["explained", "no-ground", "necessitation-conflict", "trivial", "same-ground"];
26
+ export interface ClauseResult {
27
+ /** Every ground fact holds (for some predicate of the range, with `some`). */
28
+ readonly holds: boolean;
29
+ /** It holds with `Prop` narrowed to the qualitative properties. */
30
+ readonly qualitativeHolds: boolean;
31
+ /** The ground facts for the pair, with the witness substituted when there is one (else the first candidate). */
32
+ readonly facts: readonly Formula[];
33
+ readonly truth: readonly boolean[];
34
+ /** The `some` predicate that makes it hold. */
35
+ readonly witness?: string;
36
+ /** The ground speaks of y: only then can its holding necessitate the identity of x with y. */
37
+ readonly mentionsY: boolean;
38
+ }
39
+ export interface ProposalResult {
40
+ readonly id: string;
41
+ readonly same: boolean;
42
+ readonly identity: ClauseResult;
43
+ readonly distinctness: ClauseResult;
44
+ readonly verdict: ProposalVerdict;
45
+ /** Necessitation is off, the pair is distinct, and the identity clause's ground holds: no longer forced to identity, still no ground for distinctness. */
46
+ readonly necessitationOff: boolean;
47
+ }
48
+ /** The clause formulas, resolved with x, y and the `some` variables free. */
49
+ export declare function clauseFormulas(clause: ClauseSpec, vocab: Vocabulary, premises: Premises): Formula[];
50
+ /** The clause's ground facts for x := a, y := b, one set per `some` predicate (one set without `some`). */
51
+ export declare function clauseInstances(clause: ClauseSpec, formulas: readonly Formula[], i: Interpretation, a: string, b: string): {
52
+ readonly witness?: string;
53
+ readonly facts: Formula[];
54
+ }[];
55
+ /** The proposal's verdict on the names `a`, `b` of `i` under `premises`. */
56
+ export declare function proposalVerdict(spec: ProposalSpec, i: Interpretation, vocab: Vocabulary, premises: Premises, a: string, b: string): ProposalResult;
@@ -0,0 +1,46 @@
1
+ import type { Formula, Pred, PredSort, Term } from './formula.js';
2
+ import type { Premises } from './premises.js';
3
+ /**
4
+ * Settles what each name in a raw formula means against a case's vocabulary, and expands
5
+ * definitions (with the variant the premises choose). Built in: `Refl(R)` (∀x Rxx), `Irr(R)` with the
6
+ * variants `conditional` (∀x∀y(Rxy → x ≠ y), the default) and `negation` (∀x¬Rxx), chosen by
7
+ * `def:Irr`, and `Exists(x)`, read as ∃y(y = x) or Ex by the `existence` premise. A case may override
8
+ * them.
9
+ */
10
+ export interface DefSpec {
11
+ readonly name: string;
12
+ readonly params: readonly string[];
13
+ /** Variant → body source; a definition without variants has the one variant `default`. */
14
+ readonly variants: Readonly<Record<string, string>>;
15
+ readonly defaultVariant: string;
16
+ /** The premise that picks the variant: `def:<name>`, or `existence` for `Exists`. */
17
+ readonly premise: string;
18
+ }
19
+ export interface Vocabulary {
20
+ /** Individual names. */
21
+ readonly names: ReadonlySet<string>;
22
+ readonly properties: ReadonlySet<string>;
23
+ readonly relations: ReadonlySet<string>;
24
+ readonly defs: ReadonlyMap<string, DefSpec>;
25
+ }
26
+ export declare const BUILTIN_DEFS: readonly DefSpec[];
27
+ /** A definition key as a case writes it, `Name(p1, p2)`, split into name and parameters. */
28
+ export declare function parseDefHead(head: string): {
29
+ readonly name: string;
30
+ readonly params: readonly string[];
31
+ } | undefined;
32
+ /** The variant of `def` the premises choose. */
33
+ export declare function chosenVariant(def: DefSpec, premises: Premises): string;
34
+ export type Binding = {
35
+ readonly kind: 'term';
36
+ readonly term: Term;
37
+ } | {
38
+ readonly kind: 'pred';
39
+ readonly pred: Pred;
40
+ };
41
+ /** Variables already in force: schema variables of a claim or proposal, or a definition's parameters. */
42
+ export type Env = ReadonlyMap<string, Binding>;
43
+ /** Schema variables as an environment: first-order ones (`x`, `y`) and second-order ones by sort. */
44
+ export declare function schemaEnv(vars: Readonly<Record<string, 'individual' | PredSort>>): Env;
45
+ /** Parse and resolve `source` against `vocab`, with `env` in force (schema variables). Throws a `GroundError`. */
46
+ export declare function resolveFormula(source: string, vocab: Vocabulary, premises: Premises, env?: Env): Formula;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The authoring syntax of the ground figures, ASCII and Unicode alike: atoms `Iron(castor)`,
3
+ * `d2(castor, pollux)`, `E(a)`; identity `a = b`, `a != b`, `a ≠ b`; `~` `¬`, `&` `∧`, `|` `∨`,
4
+ * `->` `→`, `<->` `↔`; `forall x φ` `∀x φ`, `exists x φ` `∃x φ`; restricted `(forall x : ψ) φ`;
5
+ * second-order `forall X in Prop φ` over `Qual`, `Prop` or `Rel`; `true`, `false`.
6
+ *
7
+ * A quantifier binds as tightly as ¬: its scope is the one formula after it, so
8
+ * `exists X in Qual (X(x) & ~X(y)) | exists X in Qual (~X(x) & X(y))` is a disjunction of two
9
+ * quantified formulas. Then ∧, ∨, → (to the right) and ↔ (to the right), loosest last.
10
+ *
11
+ * The parser builds a raw tree of names. What a name means (an individual, a property, a relation, a
12
+ * definition, a bound variable) is settled against a case by `resolve`.
13
+ */
14
+ /** The second-order ranges: qualitative properties, the properties the `scope` premise admits, all relations. */
15
+ export type RangeName = 'Qual' | 'Prop' | 'Rel';
16
+ export declare const RANGE_NAMES: readonly RangeName[];
17
+ export type RawBinary = 'and' | 'or' | 'imp' | 'iff';
18
+ export type RawFormula = {
19
+ readonly op: 'true';
20
+ } | {
21
+ readonly op: 'false';
22
+ }
23
+ /** `name(args)`: a property, a relation, `E`, a definition, or a second-order variable applied. */
24
+ | {
25
+ readonly op: 'app';
26
+ readonly name: string;
27
+ readonly args: readonly string[];
28
+ } | {
29
+ readonly op: 'eq';
30
+ readonly left: string;
31
+ readonly right: string;
32
+ } | {
33
+ readonly op: 'not';
34
+ readonly arg: RawFormula;
35
+ } | {
36
+ readonly op: RawBinary;
37
+ readonly left: RawFormula;
38
+ readonly right: RawFormula;
39
+ } | {
40
+ readonly op: 'forall' | 'exists';
41
+ readonly variable: string;
42
+ readonly restrict?: RawFormula;
43
+ readonly body: RawFormula;
44
+ } | {
45
+ readonly op: 'forall2' | 'exists2';
46
+ readonly variable: string;
47
+ readonly range: RangeName;
48
+ readonly body: RawFormula;
49
+ };
50
+ /** Identifiers: a letter or underscore, then letters, digits or underscores. */
51
+ export declare const IDENTIFIER_PATTERN: RegExp;
52
+ /** Words with a fixed meaning in formulas. */
53
+ export declare const RESERVED_WORDS: ReadonlySet<string>;
54
+ /** Parse the authoring syntax into a raw tree; throws a `GroundError` with the position on bad input. */
55
+ export declare function parseRaw(source: string): RawFormula;
@@ -0,0 +1,2 @@
1
+ import type { GroundMessages } from './zh.js';
2
+ export declare const GROUND_EN: GroundMessages;
@@ -0,0 +1,14 @@
1
+ import type { Locale } from '../../engine/types.js';
2
+ import type { GroundProblem } from '../engine/errors.js';
3
+ import type { GroundMessages } from './zh.js';
4
+ /**
5
+ * The ground figures' text, in Traditional Chinese (zh.ts, the default) and English (en.ts). The
6
+ * language comes from the same {@link useLocale} as the other figures; the tables stay apart so no
7
+ * family loads another's.
8
+ */
9
+ export type { GroundMessages };
10
+ export declare const GROUND_MESSAGES: Readonly<Record<Locale, GroundMessages>>;
11
+ export declare function useGroundMessages(): GroundMessages;
12
+ export declare function groundProblemMessage(p: GroundProblem, t: GroundMessages): string;
13
+ /** Any thrown value as text: our problems per locale, anything else by its own message. */
14
+ export declare function groundErrorMessage(error: unknown, t: GroundMessages): string;