@polintpro/proposit-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +521 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/core/ArgumentEngine.d.ts +41 -0
- package/dist/lib/core/ArgumentEngine.d.ts.map +1 -0
- package/dist/lib/core/ArgumentEngine.js +408 -0
- package/dist/lib/core/ArgumentEngine.js.map +1 -0
- package/dist/lib/core/ExpressionManager.d.ts +19 -0
- package/dist/lib/core/ExpressionManager.d.ts.map +1 -0
- package/dist/lib/core/ExpressionManager.js +352 -0
- package/dist/lib/core/ExpressionManager.js.map +1 -0
- package/dist/lib/core/PremiseManager.d.ts +110 -0
- package/dist/lib/core/PremiseManager.d.ts.map +1 -0
- package/dist/lib/core/PremiseManager.js +541 -0
- package/dist/lib/core/PremiseManager.js.map +1 -0
- package/dist/lib/core/VariableManager.d.ts +17 -0
- package/dist/lib/core/VariableManager.d.ts.map +1 -0
- package/dist/lib/core/VariableManager.js +40 -0
- package/dist/lib/core/VariableManager.js.map +1 -0
- package/dist/lib/core/evaluation/shared.d.ts +6 -0
- package/dist/lib/core/evaluation/shared.d.ts.map +1 -0
- package/dist/lib/core/evaluation/shared.js +23 -0
- package/dist/lib/core/evaluation/shared.js.map +1 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/schemata/argument.d.ts +9 -0
- package/dist/lib/schemata/argument.d.ts.map +1 -0
- package/dist/lib/schemata/argument.js +9 -0
- package/dist/lib/schemata/argument.js.map +1 -0
- package/dist/lib/schemata/index.d.ts +4 -0
- package/dist/lib/schemata/index.d.ts.map +1 -0
- package/dist/lib/schemata/index.js +4 -0
- package/dist/lib/schemata/index.js.map +1 -0
- package/dist/lib/schemata/propositional.d.ts +107 -0
- package/dist/lib/schemata/propositional.d.ts.map +1 -0
- package/dist/lib/schemata/propositional.js +77 -0
- package/dist/lib/schemata/propositional.js.map +1 -0
- package/dist/lib/schemata/shared.d.ts +4 -0
- package/dist/lib/schemata/shared.d.ts.map +1 -0
- package/dist/lib/schemata/shared.js +6 -0
- package/dist/lib/schemata/shared.js.map +1 -0
- package/dist/lib/types/evaluation.d.ts +108 -0
- package/dist/lib/types/evaluation.d.ts.map +1 -0
- package/dist/lib/types/evaluation.js +2 -0
- package/dist/lib/types/evaluation.js.map +1 -0
- package/dist/lib/utils/collections.d.ts +6 -0
- package/dist/lib/utils/collections.d.ts.map +1 -0
- package/dist/lib/utils/collections.js +18 -0
- package/dist/lib/utils/collections.js.map +1 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +31 -0
- package/dist/lib/utils.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function makeValidationResult(issues) {
|
|
2
|
+
return {
|
|
3
|
+
ok: issues.every((issue) => issue.severity !== "error"),
|
|
4
|
+
issues,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function makeErrorIssue(issue) {
|
|
8
|
+
return { severity: "error", ...issue };
|
|
9
|
+
}
|
|
10
|
+
export function implicationValue(antecedent, consequent) {
|
|
11
|
+
return !antecedent || consequent;
|
|
12
|
+
}
|
|
13
|
+
export function buildDirectionalVacuity(antecedentTrue, consequentTrue) {
|
|
14
|
+
const implication = implicationValue(antecedentTrue, consequentTrue);
|
|
15
|
+
return {
|
|
16
|
+
antecedentTrue,
|
|
17
|
+
consequentTrue,
|
|
18
|
+
implicationValue: implication,
|
|
19
|
+
isVacuouslyTrue: !antecedentTrue,
|
|
20
|
+
fired: antecedentTrue,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/lib/core/evaluation/shared.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,oBAAoB,CAChC,MAA0B;IAE1B,OAAO;QACH,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC;QACvD,MAAM;KACT,CAAA;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAC1B,KAAyC;IAEzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC5B,UAAmB,EACnB,UAAmB;IAEnB,OAAO,CAAC,UAAU,IAAI,UAAU,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,uBAAuB,CACnC,cAAuB,EACvB,cAAuB;IAEvB,MAAM,WAAW,GAAG,gBAAgB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAA;IACpE,OAAO;QACH,cAAc;QACd,cAAc;QACd,gBAAgB,EAAE,WAAW;QAC7B,eAAe,EAAE,CAAC,cAAc;QAChC,KAAK,EAAE,cAAc;KACxB,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
export declare const ArgumentSchema: Type.TObject<{
|
|
3
|
+
id: Type.TString;
|
|
4
|
+
version: Type.TNumber;
|
|
5
|
+
title: Type.TString;
|
|
6
|
+
description: Type.TString;
|
|
7
|
+
}>;
|
|
8
|
+
export type TArgument = Static<typeof ArgumentSchema>;
|
|
9
|
+
//# sourceMappingURL=argument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument.d.ts","sourceRoot":"","sources":["../../../src/lib/schemata/argument.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AAG3C,eAAO,MAAM,cAAc;;;;;EAKzB,CAAA;AACF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argument.js","sourceRoot":"","sources":["../../../src/lib/schemata/argument.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAe,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;IACtB,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;IACpB,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;CAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/schemata/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/schemata/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import Type, { type Static } from "typebox";
|
|
2
|
+
export declare const PropositionalExpressionTypes: Type.TUnion<[Type.TLiteral<"variable">, Type.TLiteral<"operator">, Type.TLiteral<"formula">]>;
|
|
3
|
+
export type TPropositionalExpressionTypes = Static<typeof PropositionalExpressionTypes>;
|
|
4
|
+
export declare const PropositionalVariableExpressionSchema: Type.TObject<{
|
|
5
|
+
id: Type.TString;
|
|
6
|
+
argumentId: Type.TString;
|
|
7
|
+
argumentVersion: Type.TNumber;
|
|
8
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
9
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
10
|
+
type: Type.TLiteral<"variable">;
|
|
11
|
+
variableId: Type.TString;
|
|
12
|
+
}>;
|
|
13
|
+
export type TPropositionalVariableExpression = Static<typeof PropositionalVariableExpressionSchema>;
|
|
14
|
+
export declare const LogicalOperatorType: Type.TUnion<[Type.TLiteral<"not">, Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
15
|
+
export type TLogicalOperatorType = Static<typeof LogicalOperatorType>;
|
|
16
|
+
export declare const OperatorExpressionSchema: Type.TObject<{
|
|
17
|
+
id: Type.TString;
|
|
18
|
+
argumentId: Type.TString;
|
|
19
|
+
argumentVersion: Type.TNumber;
|
|
20
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
21
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
22
|
+
type: Type.TLiteral<"operator">;
|
|
23
|
+
operator: Type.TUnion<[Type.TLiteral<"not">, Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
24
|
+
}>;
|
|
25
|
+
export type TOperatorExpression = Static<typeof OperatorExpressionSchema>;
|
|
26
|
+
export declare const FormulaExpressionSchema: Type.TObject<{
|
|
27
|
+
id: Type.TString;
|
|
28
|
+
argumentId: Type.TString;
|
|
29
|
+
argumentVersion: Type.TNumber;
|
|
30
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
31
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
32
|
+
type: Type.TLiteral<"formula">;
|
|
33
|
+
}>;
|
|
34
|
+
export type TFormulaExpression = Static<typeof FormulaExpressionSchema>;
|
|
35
|
+
export declare const PropositionalExpressionSchema: Type.TUnion<[Type.TObject<{
|
|
36
|
+
id: Type.TString;
|
|
37
|
+
argumentId: Type.TString;
|
|
38
|
+
argumentVersion: Type.TNumber;
|
|
39
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
40
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
41
|
+
type: Type.TLiteral<"variable">;
|
|
42
|
+
variableId: Type.TString;
|
|
43
|
+
}>, Type.TObject<{
|
|
44
|
+
id: Type.TString;
|
|
45
|
+
argumentId: Type.TString;
|
|
46
|
+
argumentVersion: Type.TNumber;
|
|
47
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
48
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
49
|
+
type: Type.TLiteral<"operator">;
|
|
50
|
+
operator: Type.TUnion<[Type.TLiteral<"not">, Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
51
|
+
}>, Type.TObject<{
|
|
52
|
+
id: Type.TString;
|
|
53
|
+
argumentId: Type.TString;
|
|
54
|
+
argumentVersion: Type.TNumber;
|
|
55
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
56
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
57
|
+
type: Type.TLiteral<"formula">;
|
|
58
|
+
}>]>;
|
|
59
|
+
export type TPropositionalExpressionCombined = Static<typeof PropositionalExpressionSchema>;
|
|
60
|
+
export type TPropositionalExpression<T extends TPropositionalExpressionTypes = TPropositionalExpressionTypes> = Extract<TPropositionalExpressionCombined, {
|
|
61
|
+
type: T;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const PropositionalVariableSchema: Type.TObject<{
|
|
64
|
+
id: Type.TString;
|
|
65
|
+
argumentId: Type.TString;
|
|
66
|
+
argumentVersion: Type.TNumber;
|
|
67
|
+
symbol: Type.TString;
|
|
68
|
+
}>;
|
|
69
|
+
export type TPropositionalVariable = Static<typeof PropositionalVariableSchema>;
|
|
70
|
+
export declare const PremiseSchema: Type.TObject<{
|
|
71
|
+
id: Type.TString;
|
|
72
|
+
rootExpressionId: Type.TOptional<Type.TString>;
|
|
73
|
+
variables: Type.TArray<Type.TObject<{
|
|
74
|
+
id: Type.TString;
|
|
75
|
+
argumentId: Type.TString;
|
|
76
|
+
argumentVersion: Type.TNumber;
|
|
77
|
+
symbol: Type.TString;
|
|
78
|
+
}>>;
|
|
79
|
+
expressions: Type.TArray<Type.TUnion<[Type.TObject<{
|
|
80
|
+
id: Type.TString;
|
|
81
|
+
argumentId: Type.TString;
|
|
82
|
+
argumentVersion: Type.TNumber;
|
|
83
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
84
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
85
|
+
type: Type.TLiteral<"variable">;
|
|
86
|
+
variableId: Type.TString;
|
|
87
|
+
}>, Type.TObject<{
|
|
88
|
+
id: Type.TString;
|
|
89
|
+
argumentId: Type.TString;
|
|
90
|
+
argumentVersion: Type.TNumber;
|
|
91
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
92
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
93
|
+
type: Type.TLiteral<"operator">;
|
|
94
|
+
operator: Type.TUnion<[Type.TLiteral<"not">, Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
95
|
+
}>, Type.TObject<{
|
|
96
|
+
id: Type.TString;
|
|
97
|
+
argumentId: Type.TString;
|
|
98
|
+
argumentVersion: Type.TNumber;
|
|
99
|
+
parentId: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
100
|
+
position: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
101
|
+
type: Type.TLiteral<"formula">;
|
|
102
|
+
}>]>>;
|
|
103
|
+
type: Type.TUnion<[Type.TLiteral<"inference">, Type.TLiteral<"constraint">]>;
|
|
104
|
+
title: Type.TOptional<Type.TString>;
|
|
105
|
+
}>;
|
|
106
|
+
export type TPremise = Static<typeof PremiseSchema>;
|
|
107
|
+
//# sourceMappingURL=propositional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propositional.d.ts","sourceRoot":"","sources":["../../../src/lib/schemata/propositional.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AAO3C,eAAO,MAAM,4BAA4B,+FAIvC,CAAA;AACF,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAC9C,OAAO,4BAA4B,CACtC,CAAA;AAoBD,eAAO,MAAM,qCAAqC;;;;;;;;EAMjD,CAAA;AAED,MAAM,MAAM,gCAAgC,GAAG,MAAM,CACjD,OAAO,qCAAqC,CAC/C,CAAA;AAED,eAAO,MAAM,mBAAmB,gIAM9B,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAErE,eAAO,MAAM,wBAAwB;;;;;;;;EAMpC,CAAA;AACD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,eAAO,MAAM,uBAAuB;;;;;;;EAKnC,CAAA;AACD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;IAIxC,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,MAAM,CACjD,OAAO,6BAA6B,CACvC,CAAA;AAED,MAAM,MAAM,wBAAwB,CAChC,CAAC,SAAS,6BAA6B,GAAG,6BAA6B,IACvE,OAAO,CAAC,gCAAgC,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAAA;AAE1D,eAAO,MAAM,2BAA2B;;;;;EAKtC,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BxB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
import { UUID, Nullable } from "./shared";
|
|
3
|
+
const VariableType = Type.Literal("variable");
|
|
4
|
+
const OperatorType = Type.Literal("operator");
|
|
5
|
+
const FormulaType = Type.Literal("formula");
|
|
6
|
+
export const PropositionalExpressionTypes = Type.Union([
|
|
7
|
+
VariableType,
|
|
8
|
+
OperatorType,
|
|
9
|
+
FormulaType,
|
|
10
|
+
]);
|
|
11
|
+
const BasePropositionalExpressionSchema = Type.Object({
|
|
12
|
+
id: UUID,
|
|
13
|
+
argumentId: UUID,
|
|
14
|
+
argumentVersion: Type.Number(),
|
|
15
|
+
parentId: Nullable(UUID, {
|
|
16
|
+
description: "The ID of the parent operator expression, or null if this is a top-level expression.",
|
|
17
|
+
}),
|
|
18
|
+
position: Nullable(Type.Integer({
|
|
19
|
+
minimum: 0,
|
|
20
|
+
description: "The ordering of this expression among its siblings under the same parent. Must be unique within (parentId, argumentId, argumentVersion).",
|
|
21
|
+
})),
|
|
22
|
+
});
|
|
23
|
+
export const PropositionalVariableExpressionSchema = Type.Interface([BasePropositionalExpressionSchema], {
|
|
24
|
+
type: VariableType,
|
|
25
|
+
variableId: UUID,
|
|
26
|
+
});
|
|
27
|
+
export const LogicalOperatorType = Type.Union([
|
|
28
|
+
Type.Literal("not"), // unary
|
|
29
|
+
Type.Literal("and"), // variadic (≥2)
|
|
30
|
+
Type.Literal("or"), // variadic (≥2)
|
|
31
|
+
Type.Literal("implies"), // binary (ordered)
|
|
32
|
+
Type.Literal("iff"), // binary (unordered but fixed 2)
|
|
33
|
+
]);
|
|
34
|
+
export const OperatorExpressionSchema = Type.Interface([BasePropositionalExpressionSchema], {
|
|
35
|
+
type: OperatorType,
|
|
36
|
+
operator: LogicalOperatorType,
|
|
37
|
+
});
|
|
38
|
+
export const FormulaExpressionSchema = Type.Interface([BasePropositionalExpressionSchema], {
|
|
39
|
+
type: FormulaType,
|
|
40
|
+
});
|
|
41
|
+
export const PropositionalExpressionSchema = Type.Union([
|
|
42
|
+
PropositionalVariableExpressionSchema,
|
|
43
|
+
OperatorExpressionSchema,
|
|
44
|
+
FormulaExpressionSchema,
|
|
45
|
+
]);
|
|
46
|
+
export const PropositionalVariableSchema = Type.Object({
|
|
47
|
+
id: UUID,
|
|
48
|
+
argumentId: UUID,
|
|
49
|
+
argumentVersion: Type.Number(),
|
|
50
|
+
symbol: Type.String(),
|
|
51
|
+
});
|
|
52
|
+
export const PremiseSchema = Type.Object({
|
|
53
|
+
// Auto-generated UUID
|
|
54
|
+
id: UUID,
|
|
55
|
+
// If the premise has expressions in it, this is the ID of the root expression
|
|
56
|
+
// which must be a relation operator if the type is "inference", else. it can
|
|
57
|
+
// be any type of expression.
|
|
58
|
+
rootExpressionId: Type.Optional(UUID),
|
|
59
|
+
variables: Type.Array(PropositionalVariableSchema, {
|
|
60
|
+
description: "All variables referenced in this premise.",
|
|
61
|
+
}),
|
|
62
|
+
expressions: Type.Array(PropositionalExpressionSchema, {
|
|
63
|
+
description: "All expressions that are part of this premise, including sub-expressions. The root of the premise will have a null parentId.",
|
|
64
|
+
}),
|
|
65
|
+
type: Type.Union([
|
|
66
|
+
Type.Literal("inference", {
|
|
67
|
+
description: "A premise whose core operator is one of inference like implies or iff",
|
|
68
|
+
}),
|
|
69
|
+
Type.Literal("constraint", {
|
|
70
|
+
description: "A premise without an inference operator, it restricts the possible valuations of variables but is not part of the chain of logical reasoning.",
|
|
71
|
+
}),
|
|
72
|
+
]),
|
|
73
|
+
title: Type.Optional(Type.String({
|
|
74
|
+
description: "An optional title for this premise, for display purposes.",
|
|
75
|
+
})),
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=propositional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propositional.js","sourceRoot":"","sources":["../../../src/lib/schemata/propositional.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAe,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEzC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AAE3C,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC;IACnD,YAAY;IACZ,YAAY;IACZ,WAAW;CACd,CAAC,CAAA;AAKF,MAAM,iCAAiC,GAAG,IAAI,CAAC,MAAM,CAAC;IAClD,EAAE,EAAE,IAAI;IACR,UAAU,EAAE,IAAI;IAChB,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE;IAC9B,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE;QACrB,WAAW,EACP,sFAAsF;KAC7F,CAAC;IAEF,QAAQ,EAAE,Q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C,MAAM,EAAE;CACxB,CAAC,CAAA;AAIF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,sBAAsB;IACtB,EAAE,EAAE,IAAI;IACR,8EAA8E;IAC9E,6EAA6E;IAC7E,6BAA6B;IAC7B,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IACrC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,2BAA2B,EAAE;QAC/C,WAAW,EAAE,2CAA2C;KAC3D,CAAC;IACF,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,6BAA6B,EAAE;QACnD,WAAW,EACP,8HAA8H;KACrI,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;QACb,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YACtB,WAAW,EACP,uEAAuE;SAC9E,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;YACvB,WAAW,EACP,+IAA+I;SACtJ,CAAC;KACL,CAAC;IACF,KAAK,EAAE,IAAI,CAAC,QAAQ,CAChB,IAAI,CAAC,MAAM,CAAC;QACR,WAAW,EACP,2DAA2D;KAClE,CAAC,CACL;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import Type, { type TSchema, type TSchemaOptions } from "typebox";
|
|
2
|
+
export declare const Nullable: <T extends TSchema>(T: T, options?: Omit<TSchemaOptions, "default">) => Type.TUnion<[T, Type.TNull]>;
|
|
3
|
+
export declare const UUID: Type.TString;
|
|
4
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/lib/schemata/shared.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAEjE,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,OAAO,EACtC,GAAG,CAAC,EACJ,UAAU,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,iCAG5C,CAAA;AACD,eAAO,MAAM,IAAI,cAAgB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Type, {} from "typebox";
|
|
2
|
+
export const Nullable = (T, options) => {
|
|
3
|
+
return Type.Union([T, Type.Null()], { ...options, default: null });
|
|
4
|
+
};
|
|
5
|
+
export const UUID = Type.String(); // `${string}-${string}-${string}-${string}-${string}`
|
|
6
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/lib/schemata/shared.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAqC,MAAM,SAAS,CAAA;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,CACpB,CAAI,EACJ,OAAyC,EAC3C,EAAE;IACA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;AACtE,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA,CAAC,sDAAsD"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { TArgument, TPremise } from "../schemata";
|
|
2
|
+
export type TPremiseRole = "supporting" | "conclusion";
|
|
3
|
+
export interface TArgumentRoleState {
|
|
4
|
+
supportingPremiseIds: string[];
|
|
5
|
+
conclusionPremiseId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TArgumentEngineData {
|
|
8
|
+
argument: TArgument;
|
|
9
|
+
premises: TPremise[];
|
|
10
|
+
roles: TArgumentRoleState;
|
|
11
|
+
}
|
|
12
|
+
export type TVariableAssignment = Record<string, boolean>;
|
|
13
|
+
export type TValidationSeverity = "error" | "warning";
|
|
14
|
+
export type TValidationCode = "ARGUMENT_NO_CONCLUSION" | "ARGUMENT_CONCLUSION_NOT_FOUND" | "ARGUMENT_SUPPORTING_PREMISE_NOT_FOUND" | "ARGUMENT_ROLE_OVERLAP" | "ARGUMENT_VARIABLE_ID_SYMBOL_MISMATCH" | "ARGUMENT_VARIABLE_SYMBOL_AMBIGUOUS" | "PREMISE_EMPTY" | "PREMISE_ROOT_MISSING" | "PREMISE_ROOT_MISMATCH" | "EXPR_CHILD_COUNT_INVALID" | "EXPR_BINARY_POSITIONS_INVALID" | "EXPR_VARIABLE_UNDECLARED" | "ASSIGNMENT_MISSING_VARIABLE" | "ASSIGNMENT_UNKNOWN_VARIABLE";
|
|
15
|
+
export interface TValidationIssue {
|
|
16
|
+
code: TValidationCode;
|
|
17
|
+
severity: TValidationSeverity;
|
|
18
|
+
message: string;
|
|
19
|
+
premiseId?: string;
|
|
20
|
+
expressionId?: string;
|
|
21
|
+
variableId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TValidationResult {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
issues: TValidationIssue[];
|
|
26
|
+
}
|
|
27
|
+
export interface TDirectionalVacuity {
|
|
28
|
+
antecedentTrue: boolean;
|
|
29
|
+
consequentTrue: boolean;
|
|
30
|
+
implicationValue: boolean;
|
|
31
|
+
isVacuouslyTrue: boolean;
|
|
32
|
+
fired: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type TPremiseInferenceDiagnostic = {
|
|
35
|
+
kind: "implies";
|
|
36
|
+
premiseId: string;
|
|
37
|
+
rootExpressionId: string;
|
|
38
|
+
leftValue: boolean;
|
|
39
|
+
rightValue: boolean;
|
|
40
|
+
rootValue: boolean;
|
|
41
|
+
antecedentTrue: boolean;
|
|
42
|
+
consequentTrue: boolean;
|
|
43
|
+
isVacuouslyTrue: boolean;
|
|
44
|
+
fired: boolean;
|
|
45
|
+
firedAndHeld: boolean;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "iff";
|
|
48
|
+
premiseId: string;
|
|
49
|
+
rootExpressionId: string;
|
|
50
|
+
leftValue: boolean;
|
|
51
|
+
rightValue: boolean;
|
|
52
|
+
rootValue: boolean;
|
|
53
|
+
leftToRight: TDirectionalVacuity;
|
|
54
|
+
rightToLeft: TDirectionalVacuity;
|
|
55
|
+
bothSidesTrue: boolean;
|
|
56
|
+
bothSidesFalse: boolean;
|
|
57
|
+
};
|
|
58
|
+
export interface TPremiseEvaluationResult {
|
|
59
|
+
premiseId: string;
|
|
60
|
+
premiseType: "inference" | "constraint";
|
|
61
|
+
rootExpressionId?: string;
|
|
62
|
+
rootValue?: boolean;
|
|
63
|
+
expressionValues: Record<string, boolean>;
|
|
64
|
+
variableValues: Record<string, boolean>;
|
|
65
|
+
inferenceDiagnostic?: TPremiseInferenceDiagnostic;
|
|
66
|
+
}
|
|
67
|
+
export interface TArgumentEvaluationOptions {
|
|
68
|
+
strictUnknownAssignmentKeys?: boolean;
|
|
69
|
+
includeExpressionValues?: boolean;
|
|
70
|
+
includeDiagnostics?: boolean;
|
|
71
|
+
validateFirst?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface TArgumentEvaluationResult {
|
|
74
|
+
ok: boolean;
|
|
75
|
+
validation?: TValidationResult;
|
|
76
|
+
assignment?: TVariableAssignment;
|
|
77
|
+
referencedVariableIds?: string[];
|
|
78
|
+
conclusion?: TPremiseEvaluationResult;
|
|
79
|
+
supportingPremises?: TPremiseEvaluationResult[];
|
|
80
|
+
constraintPremises?: TPremiseEvaluationResult[];
|
|
81
|
+
isAdmissibleAssignment?: boolean;
|
|
82
|
+
allSupportingPremisesTrue?: boolean;
|
|
83
|
+
conclusionTrue?: boolean;
|
|
84
|
+
isCounterexample?: boolean;
|
|
85
|
+
preservesTruthUnderAssignment?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface TValidityCheckOptions {
|
|
88
|
+
mode?: "firstCounterexample" | "exhaustive";
|
|
89
|
+
maxVariables?: number;
|
|
90
|
+
maxAssignmentsChecked?: number;
|
|
91
|
+
includeCounterexampleEvaluations?: boolean;
|
|
92
|
+
validateFirst?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface TCounterexample {
|
|
95
|
+
assignment: TVariableAssignment;
|
|
96
|
+
result: TArgumentEvaluationResult;
|
|
97
|
+
}
|
|
98
|
+
export interface TValidityCheckResult {
|
|
99
|
+
ok: boolean;
|
|
100
|
+
validation?: TValidationResult;
|
|
101
|
+
isValid?: boolean;
|
|
102
|
+
checkedVariableIds?: string[];
|
|
103
|
+
numAssignmentsChecked?: number;
|
|
104
|
+
numAdmissibleAssignments?: number;
|
|
105
|
+
counterexamples?: TCounterexample[];
|
|
106
|
+
truncated?: boolean;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=evaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.d.ts","sourceRoot":"","sources":["../../../src/lib/types/evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,YAAY,CAAA;AAEtD,MAAM,WAAW,kBAAkB;IAE/B,oBAAoB,EAAE,MAAM,EAAE,CAAA;IAE9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAEhC,QAAQ,EAAE,SAAS,CAAA;IAEnB,QAAQ,EAAE,QAAQ,EAAE,CAAA;IAEpB,KAAK,EAAE,kBAAkB,CAAA;CAC5B;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,SAAS,CAAA;AAErD,MAAM,MAAM,eAAe,GACrB,wBAAwB,GACxB,+BAA+B,GAC/B,uCAAuC,GACvC,uBAAuB,GACvB,sCAAsC,GACtC,oCAAoC,GACpC,eAA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IAE3C,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B,gCAAgC,CAAC,EAAE,OAAO,CAAA;IAE1C,aAAa,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,eAAe;IAE5B,UAAU,EAAE,mBAAmB,CAAA;IAE/B,MAAM,EAAE,yBAAyB,CAAA;CACpC;AAED,MAAM,WAAW,oBAAoB;IAEjC,EAAE,EAAE,OAAO,CAAA;IAEX,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAE9B,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE7B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B,wBAAwB,CAAC,EAAE,MAAM,CAAA;IAEjC,eAAe,CAAC,EAAE,eAAe,EAAE,CAAA;IAEnC,SAAS,CAAC,EAAE,OAAO,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.js","sourceRoot":"","sources":["../../../src/lib/types/evaluation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, makeDefault: () => V): V;
|
|
2
|
+
export declare function sortedCopyById<T extends {
|
|
3
|
+
id: string;
|
|
4
|
+
}>(items: T[]): T[];
|
|
5
|
+
export declare function sortedUnique(values: Iterable<string>): string[];
|
|
6
|
+
//# sourceMappingURL=collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/collections.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC5B,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,GAAG,EAAE,CAAC,EACN,WAAW,EAAE,MAAM,CAAC,GACrB,CAAC,CASH;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAIxE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAE/D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function getOrCreate(map, key, makeDefault) {
|
|
2
|
+
const existing = map.get(key);
|
|
3
|
+
if (existing !== undefined) {
|
|
4
|
+
return existing;
|
|
5
|
+
}
|
|
6
|
+
const value = makeDefault();
|
|
7
|
+
map.set(key, value);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
export function sortedCopyById(items) {
|
|
11
|
+
return [...items]
|
|
12
|
+
.map((item) => ({ ...item }))
|
|
13
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
14
|
+
}
|
|
15
|
+
export function sortedUnique(values) {
|
|
16
|
+
return Array.from(new Set(values)).sort((a, b) => a.localeCompare(b));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../../src/lib/utils/collections.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CACvB,GAAc,EACd,GAAM,EACN,WAAoB;IAEpB,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAA;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,EAAE,CAAA;IAC3B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACnB,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAA2B,KAAU;IAC/D,OAAO,CAAC,GAAG,KAAK,CAAC;SACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;SAC5B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAwB;IACjD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;AACzE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type DefaultValueFactory<K, V> = (key?: K) => V;
|
|
2
|
+
export declare class DefaultMap<K, V> extends Map<K, V> {
|
|
3
|
+
private mkDefault;
|
|
4
|
+
private limit;
|
|
5
|
+
constructor(mkDefault: DefaultValueFactory<K, V>, entries?: Iterable<[K, V]>, limit?: number);
|
|
6
|
+
get(key: K): V;
|
|
7
|
+
set(key: K, value: V): this;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAC/C,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,KAAK,CAAQ;gBAGjB,SAAS,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EACpC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC1B,KAAK,SAAK;IAYP,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;IAOd,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;CAS9B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class DefaultMap extends Map {
|
|
2
|
+
mkDefault;
|
|
3
|
+
limit;
|
|
4
|
+
constructor(mkDefault, entries, limit = -1) {
|
|
5
|
+
/**
|
|
6
|
+
* mkDefault is a function which (optionally) takes one argument, a value passed as the key,
|
|
7
|
+
* and returns a value which to use if that key is not present in the map. The function may
|
|
8
|
+
* throw an error if the key is invalid or forbidden to limit the scope of values in the map.
|
|
9
|
+
*/
|
|
10
|
+
super(entries);
|
|
11
|
+
this.mkDefault = mkDefault;
|
|
12
|
+
this.limit = limit;
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
if (!this.has(key)) {
|
|
16
|
+
this.set(key, this.mkDefault(key));
|
|
17
|
+
}
|
|
18
|
+
return super.get(key);
|
|
19
|
+
}
|
|
20
|
+
set(key, value) {
|
|
21
|
+
if (this.limit >= 0 && this.size + 1 >= this.limit) {
|
|
22
|
+
// Remove the oldest entry when the limit is reached
|
|
23
|
+
// This implementation uses the first entry, which is the oldest in insertion order
|
|
24
|
+
const oldestKey = this.keys().next().value;
|
|
25
|
+
if (oldestKey !== undefined)
|
|
26
|
+
this.delete(oldestKey);
|
|
27
|
+
}
|
|
28
|
+
return super.set(key, value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AACA,MAAM,OAAO,UAAiB,SAAQ,GAAS;IACnC,SAAS,CAA2B;IACpC,KAAK,CAAQ;IAErB,YACI,SAAoC,EACpC,OAA0B,EAC1B,KAAK,GAAG,CAAC,CAAC;QAEV;;;;WAIG;QACH,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACtB,CAAC;IAEM,GAAG,CAAC,GAAM;QACb,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAA;IAC1B,CAAC;IAEM,GAAG,CAAC,GAAM,EAAE,KAAQ;QACvB,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACjD,oDAAoD;YACpD,mFAAmF;YACnF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAC1C,IAAI,SAAS,KAAK,SAAS;gBAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAChC,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@polintpro/proposit-core",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Core engine for building and manipulating propositional logic arguments.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/polintpro/proposit-core.git"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^25.2.3",
|
|
27
|
+
"eslint": "^9.39.2",
|
|
28
|
+
"globals": "^16.5.0",
|
|
29
|
+
"prettier": "^3.8.1",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"typescript-eslint": "^8.55.0",
|
|
32
|
+
"vitest": "^4.0.18"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"typebox": "^1.1.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "pnpm tsc -p tsconfig.build.json",
|
|
39
|
+
"typecheck": "pnpm tsc -p tsconfig.json",
|
|
40
|
+
"lint": "pnpm run prettify:check && pnpm eslint .",
|
|
41
|
+
"prettify": "pnpm prettier -w .",
|
|
42
|
+
"prettify:check": "pnpm prettier --check .",
|
|
43
|
+
"test": "pnpm vitest run",
|
|
44
|
+
"check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run build"
|
|
45
|
+
}
|
|
46
|
+
}
|