occam-verify-cli 1.0.405 → 1.0.415
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/lib/constants.js +1 -5
- package/lib/context/file.js +7 -8
- package/lib/context/local.js +3 -3
- package/lib/context/release.js +2 -2
- package/lib/context/temporary.js +103 -54
- package/lib/mixins/statement/verify.js +2 -2
- package/lib/mixins/step/unify.js +2 -2
- package/lib/node/argument.js +2 -2
- package/lib/node/assumption.js +6 -6
- package/lib/node/frame.js +19 -7
- package/lib/node/judgement.js +8 -1
- package/lib/node/statement.js +34 -15
- package/lib/node/substitution/term.js +3 -11
- package/lib/node/term.js +20 -8
- package/lib/nonTerminalNode.js +3 -3
- package/lib/ontology/assertion/contained.js +7 -7
- package/lib/ontology/assertion/defined.js +8 -8
- package/lib/ontology/assertion/subproof.js +3 -3
- package/lib/ontology/assumption.js +49 -45
- package/lib/ontology/combinator.js +3 -3
- package/lib/ontology/constructor.js +3 -3
- package/lib/ontology/declaration/combinator.js +3 -3
- package/lib/ontology/declaration/constructor.js +3 -3
- package/lib/ontology/equality.js +4 -4
- package/lib/ontology/equivalence.js +2 -2
- package/lib/ontology/frame.js +37 -12
- package/lib/ontology/judgement.js +13 -6
- package/lib/ontology/metavariable.js +75 -76
- package/lib/ontology/propertyRelation.js +2 -2
- package/lib/ontology/reference.js +33 -4
- package/lib/ontology/signature.js +2 -2
- package/lib/ontology/statement.js +33 -8
- package/lib/ontology/step.js +4 -4
- package/lib/ontology/substitution/frame.js +13 -15
- package/lib/ontology/substitution/statement.js +31 -32
- package/lib/ontology/substitution/term.js +26 -25
- package/lib/ontology/substitution.js +2 -2
- package/lib/ontology/substitutions.js +4 -4
- package/lib/ontology/term.js +26 -12
- package/lib/ontology/variable.js +2 -2
- package/lib/process/equate.js +322 -0
- package/lib/process/unify.js +623 -0
- package/lib/process/verify.js +612 -0
- package/lib/utilities/brackets.js +3 -8
- package/lib/utilities/context.js +4 -14
- package/lib/utilities/json.js +18 -1
- package/lib/utilities/pass.js +68 -0
- package/lib/utilities/substitutions.js +11 -16
- package/package.json +11 -11
- package/src/constants.js +0 -1
- package/src/context/file.js +8 -8
- package/src/context/local.js +2 -2
- package/src/context/release.js +1 -1
- package/src/context/temporary.js +124 -54
- package/src/mixins/statement/verify.js +3 -1
- package/src/mixins/step/unify.js +0 -1
- package/src/node/argument.js +1 -1
- package/src/node/assumption.js +4 -4
- package/src/node/frame.js +19 -5
- package/src/node/judgement.js +7 -0
- package/src/node/statement.js +35 -13
- package/src/node/substitution/term.js +4 -14
- package/src/node/term.js +20 -6
- package/src/nonTerminalNode.js +1 -1
- package/src/ontology/assertion/contained.js +6 -6
- package/src/ontology/assertion/defined.js +7 -7
- package/src/ontology/assertion/subproof.js +1 -1
- package/src/ontology/assumption.js +52 -57
- package/src/ontology/combinator.js +1 -1
- package/src/ontology/constructor.js +1 -1
- package/src/ontology/declaration/combinator.js +2 -3
- package/src/ontology/declaration/constructor.js +2 -2
- package/src/ontology/equality.js +3 -3
- package/src/ontology/equivalence.js +1 -1
- package/src/ontology/frame.js +44 -10
- package/src/ontology/judgement.js +8 -3
- package/src/ontology/metavariable.js +108 -102
- package/src/ontology/propertyRelation.js +3 -2
- package/src/ontology/reference.js +39 -1
- package/src/ontology/signature.js +3 -3
- package/src/ontology/statement.js +38 -4
- package/src/ontology/step.js +7 -7
- package/src/ontology/substitution/frame.js +13 -17
- package/src/ontology/substitution/statement.js +45 -48
- package/src/ontology/substitution/term.js +19 -19
- package/src/ontology/substitution.js +3 -2
- package/src/ontology/substitutions.js +3 -3
- package/src/ontology/term.js +26 -5
- package/src/ontology/variable.js +3 -2
- package/src/process/equate.js +212 -0
- package/src/process/unify.js +634 -0
- package/src/process/verify.js +584 -0
- package/src/utilities/brackets.js +2 -11
- package/src/utilities/context.js +1 -21
- package/src/utilities/json.js +19 -0
- package/src/utilities/{unifier.js → pass.js} +17 -1
- package/src/utilities/substitutions.js +10 -20
- package/lib/unifier/equantional.js +0 -170
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/unifier/metaLevel.js +0 -197
- package/lib/unifier/metavariable.js +0 -140
- package/lib/unifier/statementWithCombinator.js +0 -177
- package/lib/unifier/termWithConstructor.js +0 -145
- package/lib/unifier.js +0 -241
- package/lib/utilities/arguments.js +0 -28
- package/lib/utilities/frame.js +0 -18
- package/lib/utilities/metavariable.js +0 -18
- package/lib/utilities/statement.js +0 -18
- package/lib/utilities/unification.js +0 -109
- package/lib/utilities/unifier.js +0 -51
- package/lib/utilities/variable.js +0 -18
- package/lib/verifier/combinator.js +0 -158
- package/lib/verifier/constructor.js +0 -230
- package/lib/verifier/topLevel.js +0 -242
- package/lib/verifier.js +0 -219
- package/src/unifier/equantional.js +0 -90
- package/src/unifier/intrinsicLevel.js +0 -52
- package/src/unifier/metaLevel.js +0 -151
- package/src/unifier/metavariable.js +0 -50
- package/src/unifier/statementWithCombinator.js +0 -114
- package/src/unifier/termWithConstructor.js +0 -56
- package/src/unifier.js +0 -183
- package/src/utilities/arguments.js +0 -21
- package/src/utilities/frame.js +0 -13
- package/src/utilities/metavariable.js +0 -13
- package/src/utilities/statement.js +0 -13
- package/src/utilities/unification.js +0 -136
- package/src/utilities/variable.js +0 -13
- package/src/verifier/combinator.js +0 -72
- package/src/verifier/constructor.js +0 -96
- package/src/verifier/topLevel.js +0 -204
- package/src/verifier.js +0 -150
package/src/unifier/metaLevel.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Unifier from "../unifier";
|
|
4
|
-
import ontology from "../ontology";
|
|
5
|
-
|
|
6
|
-
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/metavariable";
|
|
8
|
-
|
|
9
|
-
const termNodeQuery = nodeQuery("/term"),
|
|
10
|
-
frameNodeQuery = nodeQuery("/frame"),
|
|
11
|
-
statementNodeQuery = nodeQuery("/statement"),
|
|
12
|
-
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
13
|
-
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
14
|
-
assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!"),
|
|
15
|
-
frameAssumptionMetavariableNodeQuery = nodeQuery("/frame/assumption!/metavariable!");
|
|
16
|
-
|
|
17
|
-
class MetaLevelUnifier extends Unifier {
|
|
18
|
-
unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
|
|
19
|
-
let unifiesAtMetaLevel;
|
|
20
|
-
|
|
21
|
-
const nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
|
|
22
|
-
|
|
23
|
-
unifiesAtMetaLevel = nonTerminalNodeUnifies; ///
|
|
24
|
-
|
|
25
|
-
return unifiesAtMetaLevel;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static maps = [
|
|
29
|
-
{
|
|
30
|
-
generalNodeQuery: statementMetavariableNodeQuery,
|
|
31
|
-
specificNodeQuery: statementNodeQuery,
|
|
32
|
-
unify: (generalStatementMetavariableNode, specificStatementNode, substitutions, generalContext, specificContext) => {
|
|
33
|
-
let statementUnifies;
|
|
34
|
-
|
|
35
|
-
let context,
|
|
36
|
-
statement,
|
|
37
|
-
statementNode;
|
|
38
|
-
|
|
39
|
-
context = generalContext; ///
|
|
40
|
-
|
|
41
|
-
const metavariableNode = generalStatementMetavariableNode, ///
|
|
42
|
-
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
43
|
-
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
44
|
-
|
|
45
|
-
const metavariableNodeParentNode = metavariableNode.getParentNode();
|
|
46
|
-
|
|
47
|
-
statementNode = metavariableNodeParentNode; ///
|
|
48
|
-
|
|
49
|
-
statement = context.findStatementByStatementNode(statementNode);
|
|
50
|
-
|
|
51
|
-
const { TermSubstitution, FrameSubstitution } = ontology,
|
|
52
|
-
frameSubstitution = FrameSubstitution.fromStatement(statement, context),
|
|
53
|
-
termSubstitution = TermSubstitution.fromStatement(statement, context),
|
|
54
|
-
substitution = (frameSubstitution || termSubstitution);
|
|
55
|
-
|
|
56
|
-
context = specificContext; ///
|
|
57
|
-
|
|
58
|
-
statementNode = specificStatementNode; ///
|
|
59
|
-
|
|
60
|
-
statement = context.findStatementByStatementNode(statementNode);
|
|
61
|
-
|
|
62
|
-
statementUnifies = metavariable.unifyStatement(statement, substitution, substitutions, generalContext, specificContext);
|
|
63
|
-
|
|
64
|
-
return statementUnifies;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
generalNodeQuery: frameAssumptionMetavariableNodeQuery,
|
|
69
|
-
specificNodeQuery: frameNodeQuery,
|
|
70
|
-
unify: (generalFrameAssumptionMetavariableNode, specificFrameNode, substitutions, generalContext, specificContext) => {
|
|
71
|
-
let frameUnifies;
|
|
72
|
-
|
|
73
|
-
const frameNode = specificFrameNode, ///
|
|
74
|
-
metavariableNode = generalFrameAssumptionMetavariableNode, ///
|
|
75
|
-
metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
|
|
76
|
-
|
|
77
|
-
let context;
|
|
78
|
-
|
|
79
|
-
context = generalContext; ///
|
|
80
|
-
|
|
81
|
-
const metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
82
|
-
|
|
83
|
-
context = specificContext; ///
|
|
84
|
-
|
|
85
|
-
const frame = context.findFrameByFrameNode(frameNode);
|
|
86
|
-
|
|
87
|
-
frameUnifies = metavariable.unifyFrame(frame, substitutions, generalContext, specificContext);
|
|
88
|
-
|
|
89
|
-
return frameUnifies;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
generalNodeQuery: termVariableNodeQuery,
|
|
94
|
-
specificNodeQuery: termNodeQuery,
|
|
95
|
-
unify: (generalTermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
|
|
96
|
-
let termUnifies;
|
|
97
|
-
|
|
98
|
-
const termNode = specificTermNode, ///
|
|
99
|
-
variableNode = generalTermVariableNode, ///
|
|
100
|
-
variableIdentifier = variableNode.getVariableIdentifier();
|
|
101
|
-
|
|
102
|
-
let context;
|
|
103
|
-
|
|
104
|
-
context = generalContext; ///
|
|
105
|
-
|
|
106
|
-
const variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
107
|
-
|
|
108
|
-
context = specificContext; ///
|
|
109
|
-
|
|
110
|
-
const term = context.findTermByTermNode(termNode);
|
|
111
|
-
|
|
112
|
-
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
113
|
-
|
|
114
|
-
return termUnifies;
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
generalNodeQuery: assumptionMetavariableNodeQuery,
|
|
119
|
-
specificNodeQuery: assumptionMetavariableNodeQuery,
|
|
120
|
-
unify: (generalAssumptionMetavariableNode, specificAssumptionMetavariableNode, substitutions, generalContext, specificContext) => {
|
|
121
|
-
let referenceUnifies;
|
|
122
|
-
|
|
123
|
-
const { Reference } = ontology;
|
|
124
|
-
|
|
125
|
-
let context,
|
|
126
|
-
metavariableNode;
|
|
127
|
-
|
|
128
|
-
context = generalContext; ///
|
|
129
|
-
|
|
130
|
-
metavariableNode = generalAssumptionMetavariableNode; ///
|
|
131
|
-
|
|
132
|
-
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
133
|
-
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
134
|
-
|
|
135
|
-
context = specificContext; ///
|
|
136
|
-
|
|
137
|
-
metavariableNode = specificAssumptionMetavariableNode; ///
|
|
138
|
-
|
|
139
|
-
const reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
140
|
-
|
|
141
|
-
referenceUnifies = metavariable.unifyReference(reference, substitutions, generalContext, specificContext);
|
|
142
|
-
|
|
143
|
-
return referenceUnifies;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const metaLevelUnifier = new MetaLevelUnifier();
|
|
150
|
-
|
|
151
|
-
export default metaLevelUnifier;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import ontology from "../ontology";
|
|
4
|
-
import Unifier from "../unifier";
|
|
5
|
-
|
|
6
|
-
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
|
|
8
|
-
const typeNodeQuery = nodeQuery("/type"),
|
|
9
|
-
termNodeQuery = nodeQuery("/term");
|
|
10
|
-
|
|
11
|
-
class MetavariableUnifier extends Unifier {
|
|
12
|
-
unify(generalMetavariableNode, specificMetavariableNode, generalContext, specificContext) {
|
|
13
|
-
let metavariableUnifies;
|
|
14
|
-
|
|
15
|
-
const generalNonTerminalNode = generalMetavariableNode, ///
|
|
16
|
-
specificNonTerminalNode = specificMetavariableNode, ///
|
|
17
|
-
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, generalContext, specificContext);
|
|
18
|
-
|
|
19
|
-
metavariableUnifies = nonTerminalNodeUnifies; ///
|
|
20
|
-
|
|
21
|
-
return metavariableUnifies;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static maps = [
|
|
25
|
-
{
|
|
26
|
-
generalNodeQuery: typeNodeQuery,
|
|
27
|
-
specificNodeQuery: termNodeQuery,
|
|
28
|
-
unify: (generalTypeNode, specificTermNode, generalContext, specificContext) => {
|
|
29
|
-
let termUnifies;
|
|
30
|
-
|
|
31
|
-
const { Term } = ontology,
|
|
32
|
-
typeNode = generalTypeNode, ///
|
|
33
|
-
termNode = specificTermNode, ///
|
|
34
|
-
nominalTypeName = typeNode.getNominalTypeName(),
|
|
35
|
-
type = generalContext.findTypeByNominalTypeName(nominalTypeName),
|
|
36
|
-
context = specificContext, ///
|
|
37
|
-
term = Term.fromTermNode(termNode, context),
|
|
38
|
-
termVerifiesGivenType = term.verifyGivenType(type, generalContext, specificContext);
|
|
39
|
-
|
|
40
|
-
termUnifies = termVerifiesGivenType; ///
|
|
41
|
-
|
|
42
|
-
return termUnifies;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const metavariableUnifier = new MetavariableUnifier();
|
|
49
|
-
|
|
50
|
-
export default metavariableUnifier;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import ontology from "../ontology";
|
|
4
|
-
import Unifier from "../unifier";
|
|
5
|
-
|
|
6
|
-
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
|
|
8
|
-
const termNodeQuery = nodeQuery("/term"),
|
|
9
|
-
typeNodeQuery = nodeQuery("/type"),
|
|
10
|
-
frameNodeQuery = nodeQuery("/frame"),
|
|
11
|
-
metaTypeNodeQuery = nodeQuery("/metaType"),
|
|
12
|
-
statementNodeQuery = nodeQuery("/statement");
|
|
13
|
-
|
|
14
|
-
class StatementWithCombinatorUnifier extends Unifier {
|
|
15
|
-
unify(combinatorStatementNode, statementNode, assignments, stated, generalContext, specificContext) {
|
|
16
|
-
let statementUnifiesWithCombinator;
|
|
17
|
-
|
|
18
|
-
const generalNonTerminalNode = combinatorStatementNode, ///
|
|
19
|
-
specificNonTerminalNode = statementNode, ///
|
|
20
|
-
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, assignments, stated, generalContext, specificContext);
|
|
21
|
-
|
|
22
|
-
statementUnifiesWithCombinator = nonTerminalNodeUnifies; ///
|
|
23
|
-
|
|
24
|
-
return statementUnifiesWithCombinator;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
static maps = [
|
|
28
|
-
{
|
|
29
|
-
generalNodeQuery: metaTypeNodeQuery,
|
|
30
|
-
specificNodeQuery: statementNodeQuery,
|
|
31
|
-
unify: (generalMetaTypeNode, specificStatementNode, assignments, stated, generalContext, specificContext) => {
|
|
32
|
-
let unifies;
|
|
33
|
-
|
|
34
|
-
const { Statement, MetaType } = ontology,
|
|
35
|
-
metaTypeNode = generalMetaTypeNode, ///
|
|
36
|
-
statementNode = specificStatementNode; ///
|
|
37
|
-
|
|
38
|
-
let context;
|
|
39
|
-
|
|
40
|
-
context = generalContext; ///
|
|
41
|
-
|
|
42
|
-
const metaType = MetaType.fromMetaTypeNode(metaTypeNode, context);
|
|
43
|
-
|
|
44
|
-
context = specificContext; ///
|
|
45
|
-
|
|
46
|
-
const statement = Statement.fromStatementNode(statementNode, context),
|
|
47
|
-
statementVerifiesGivenType = statement.verifyGivenMetaType(metaType, assignments, stated, context);
|
|
48
|
-
|
|
49
|
-
unifies = statementVerifiesGivenType;
|
|
50
|
-
|
|
51
|
-
return unifies;
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
generalNodeQuery: metaTypeNodeQuery,
|
|
56
|
-
specificNodeQuery: frameNodeQuery,
|
|
57
|
-
unify: (generalMetaTypeNode, specificFrameNode, assignments, stated, generalContext, specificContext) => {
|
|
58
|
-
let unifies;
|
|
59
|
-
|
|
60
|
-
const { Frame, MetaType } = ontology,
|
|
61
|
-
metaTypeNode = generalMetaTypeNode, ///
|
|
62
|
-
frameNode = specificFrameNode; ///
|
|
63
|
-
|
|
64
|
-
let context;
|
|
65
|
-
|
|
66
|
-
context = generalContext; ///
|
|
67
|
-
|
|
68
|
-
const metaType = MetaType.fromMetaTypeNode(metaTypeNode, context);
|
|
69
|
-
|
|
70
|
-
context = specificContext; ///
|
|
71
|
-
|
|
72
|
-
const frame = Frame.fromFrameNode(frameNode, context),
|
|
73
|
-
frameVerifiesGivenType = frame.verifyGivenMetaType(metaType, assignments, stated, context);
|
|
74
|
-
|
|
75
|
-
unifies = frameVerifiesGivenType;
|
|
76
|
-
|
|
77
|
-
return unifies;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
generalNodeQuery: typeNodeQuery,
|
|
82
|
-
specificNodeQuery: termNodeQuery,
|
|
83
|
-
unify: (generalTypeNode, specificTermNode, assignments, stated, generalContext, specificContext) => {
|
|
84
|
-
let unifies = false;
|
|
85
|
-
|
|
86
|
-
const { Term } = ontology,
|
|
87
|
-
typeNode = generalTypeNode, ///
|
|
88
|
-
termNode = specificTermNode, ///
|
|
89
|
-
nominalTypeName = typeNode.getNominalTypeName();
|
|
90
|
-
|
|
91
|
-
let context;
|
|
92
|
-
|
|
93
|
-
context = generalContext; ///
|
|
94
|
-
|
|
95
|
-
const type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
96
|
-
|
|
97
|
-
context = specificContext; ///
|
|
98
|
-
|
|
99
|
-
const term = Term.fromTermNode(termNode, context),
|
|
100
|
-
termVerifiesGivenType = term.verifyGivenType(type, generalContext, specificContext);
|
|
101
|
-
|
|
102
|
-
if (termVerifiesGivenType) {
|
|
103
|
-
unifies = true;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return unifies;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const statementWithCombinatorUnifier = new StatementWithCombinatorUnifier();
|
|
113
|
-
|
|
114
|
-
export default statementWithCombinatorUnifier;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import ontology from "../ontology";
|
|
4
|
-
import Unifier from "../unifier";
|
|
5
|
-
|
|
6
|
-
import { nodeQuery } from "../utilities/query";
|
|
7
|
-
|
|
8
|
-
const termNodeQuery = nodeQuery("/term"),
|
|
9
|
-
typeNodeQuery = nodeQuery("/type");
|
|
10
|
-
|
|
11
|
-
class TermWithConstructorUnifier extends Unifier {
|
|
12
|
-
unify(constructorTermNode, termNode, context) {
|
|
13
|
-
let termUnifiesWithConstructor;
|
|
14
|
-
|
|
15
|
-
const generalNonTerminalNode = constructorTermNode, ///
|
|
16
|
-
specificNonTerminalNode = termNode, ///
|
|
17
|
-
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, context);
|
|
18
|
-
|
|
19
|
-
termUnifiesWithConstructor = nonTerminalNodeUnifies; ///
|
|
20
|
-
|
|
21
|
-
return termUnifiesWithConstructor;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
static maps = [
|
|
25
|
-
{
|
|
26
|
-
generalNodeQuery: typeNodeQuery,
|
|
27
|
-
specificNodeQuery: termNodeQuery,
|
|
28
|
-
unify: (generalTypeNode, specificTermNode, context) => {
|
|
29
|
-
let unifies = false;
|
|
30
|
-
|
|
31
|
-
const { Term } = ontology,
|
|
32
|
-
typeNode = generalTypeNode, ///
|
|
33
|
-
nominalTypeName = typeNode.getNominalTypeName(),
|
|
34
|
-
type = context.findTypeByNominalTypeName(nominalTypeName);
|
|
35
|
-
|
|
36
|
-
if (type !== null) {
|
|
37
|
-
const termNode = specificTermNode, ///
|
|
38
|
-
term = Term.fromTermNode(termNode, context),
|
|
39
|
-
generalContext = context, ///
|
|
40
|
-
specificContext = context, ///
|
|
41
|
-
termVerifiesGivenType = term.verifyGivenType(type, generalContext, specificContext);
|
|
42
|
-
|
|
43
|
-
if (termVerifiesGivenType) {
|
|
44
|
-
unifies = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return unifies;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const termWithConstructorUnifier = new TermWithConstructorUnifier();
|
|
55
|
-
|
|
56
|
-
export default termWithConstructorUnifier;
|
package/src/unifier.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nodeQuery } from "./utilities/query";
|
|
4
|
-
import { isLastRemainingArgumentFunction } from "./utilities/arguments";
|
|
5
|
-
import { terminalNodeMapFromNodes, areTerminalNodeMapsEqual } from "./utilities/unifier";
|
|
6
|
-
|
|
7
|
-
const nonTerminalNodeQuery = nodeQuery("/*");
|
|
8
|
-
|
|
9
|
-
export default class Unifier {
|
|
10
|
-
unify(generalNode, specificNode, ...remainingArguments) {
|
|
11
|
-
let unifies;
|
|
12
|
-
|
|
13
|
-
const nodeUnifies = this.unifyNode(generalNode, specificNode, ...remainingArguments);
|
|
14
|
-
|
|
15
|
-
unifies = nodeUnifies; ///
|
|
16
|
-
|
|
17
|
-
return unifies;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
unifyNode(generalNode, specificNode, ...remainingArguments) {
|
|
21
|
-
let nodeUnifies = false;
|
|
22
|
-
|
|
23
|
-
const generalNodeTerminalNode = generalNode.isTerminalNode(),
|
|
24
|
-
specificNodeTerminalNode = specificNode.isTerminalNode(),
|
|
25
|
-
generalNodeNonTerminalNode = generalNode.isNonTerminalNode(),
|
|
26
|
-
specificNodeNonTerminalNode = specificNode.isNonTerminalNode();
|
|
27
|
-
|
|
28
|
-
if (false) {
|
|
29
|
-
///
|
|
30
|
-
} else if (generalNodeTerminalNode && specificNodeTerminalNode) {
|
|
31
|
-
const generalTerminalNode = generalNode, ///
|
|
32
|
-
specificTerminalNode = specificNode, ///
|
|
33
|
-
terminalNodeUnifies = this.unifyTerminalNode(generalTerminalNode, specificTerminalNode, ...remainingArguments);
|
|
34
|
-
|
|
35
|
-
nodeUnifies = terminalNodeUnifies; ///
|
|
36
|
-
} else if (generalNodeNonTerminalNode && specificNodeNonTerminalNode) {
|
|
37
|
-
const generalNonTerminalNode = generalNode, ///
|
|
38
|
-
specificNonTerminalNode = specificNode, ///
|
|
39
|
-
nonTerminalNodeUnifies = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, ...remainingArguments);
|
|
40
|
-
|
|
41
|
-
nodeUnifies = nonTerminalNodeUnifies; ///
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return nodeUnifies;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
unifyChildNodes(generalChildNodes, specificChildNodes, ...remainingArguments) {
|
|
48
|
-
let childNodesUnify = false;
|
|
49
|
-
|
|
50
|
-
const generalChildNodesLength = generalChildNodes.length,
|
|
51
|
-
specificChildNodesLength = specificChildNodes.length;
|
|
52
|
-
|
|
53
|
-
if (generalChildNodesLength === specificChildNodesLength) {
|
|
54
|
-
const specificTerminalNodeMap = terminalNodeMapFromNodes(specificChildNodes),
|
|
55
|
-
generalTerminalNodeMap = terminalNodeMapFromNodes(generalChildNodes),
|
|
56
|
-
terminalNodeMapsEqual = areTerminalNodeMapsEqual(generalTerminalNodeMap, specificTerminalNodeMap);
|
|
57
|
-
|
|
58
|
-
if (terminalNodeMapsEqual) {
|
|
59
|
-
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
60
|
-
|
|
61
|
-
if (lastRemainingArgumentFunction) {
|
|
62
|
-
const index = 0,
|
|
63
|
-
childNodesUnifyAhead = this.unifyChildNodesAhead(index, generalChildNodes, specificChildNodes,...remainingArguments);
|
|
64
|
-
|
|
65
|
-
childNodesUnify = childNodesUnifyAhead; ///
|
|
66
|
-
} else {
|
|
67
|
-
childNodesUnify = generalChildNodes.every((generalChildNode, index) => {
|
|
68
|
-
const specificChildNode = specificChildNodes[index],
|
|
69
|
-
specificNode = specificChildNode, ///
|
|
70
|
-
generalNode = generalChildNode, ///
|
|
71
|
-
nodeUnifies = this.unifyNode(generalNode, specificNode, ...remainingArguments);
|
|
72
|
-
|
|
73
|
-
if (nodeUnifies) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return childNodesUnify;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
unifyTerminalNode(generalTerminalNode, specificTerminalNode, ...remainingArguments) { ///
|
|
85
|
-
let terminalNodeUnifies;
|
|
86
|
-
|
|
87
|
-
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
88
|
-
|
|
89
|
-
if (lastRemainingArgumentFunction) {
|
|
90
|
-
const unifyAhead = remainingArguments.pop(),
|
|
91
|
-
unifiesAhead = unifyAhead();
|
|
92
|
-
|
|
93
|
-
terminalNodeUnifies = unifiesAhead; ///
|
|
94
|
-
|
|
95
|
-
remainingArguments.push(unifiesAhead);
|
|
96
|
-
} else {
|
|
97
|
-
terminalNodeUnifies = true;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return terminalNodeUnifies;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, ...remainingArguments) {
|
|
104
|
-
let nonTerminalNodeUnifies;
|
|
105
|
-
|
|
106
|
-
let { maps } = this.constructor;
|
|
107
|
-
|
|
108
|
-
maps = [ ///
|
|
109
|
-
...maps,
|
|
110
|
-
{
|
|
111
|
-
generalNodeQuery: nonTerminalNodeQuery,
|
|
112
|
-
specificNodeQuery: nonTerminalNodeQuery,
|
|
113
|
-
unify: (generalNode, specificNode, ...remainingArguments) => {
|
|
114
|
-
let nonTerminalNodeUnifies;
|
|
115
|
-
|
|
116
|
-
const generalNonTerminalNodeRuleName = generalNonTerminalNode.getRuleName(), ///
|
|
117
|
-
specificNonTerminalNodeRuleName = specificNonTerminalNode.getRuleName(); ///
|
|
118
|
-
|
|
119
|
-
if (generalNonTerminalNodeRuleName === specificNonTerminalNodeRuleName) {
|
|
120
|
-
const generalNonTerminalNodeChildNodes = generalNonTerminalNode.getChildNodes(),
|
|
121
|
-
specificNonTerminalNodeChildNode = specificNonTerminalNode.getChildNodes(),
|
|
122
|
-
generalChildNodes = generalNonTerminalNodeChildNodes, ///
|
|
123
|
-
specificChildNodes = specificNonTerminalNodeChildNode, ///
|
|
124
|
-
childNodesUnify = this.unifyChildNodes(generalChildNodes, specificChildNodes, ...remainingArguments);
|
|
125
|
-
|
|
126
|
-
nonTerminalNodeUnifies = childNodesUnify; ///
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return nonTerminalNodeUnifies;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
]
|
|
133
|
-
|
|
134
|
-
let nodeUnifies = false;
|
|
135
|
-
|
|
136
|
-
maps.some((map) => {
|
|
137
|
-
const { generalNodeQuery, specificNodeQuery, unify } = map;
|
|
138
|
-
|
|
139
|
-
const generalNode = generalNodeQuery(generalNonTerminalNode), ///
|
|
140
|
-
specificNode = specificNodeQuery(specificNonTerminalNode); ///
|
|
141
|
-
|
|
142
|
-
if ((generalNode !== null) && (specificNode !== null)) {
|
|
143
|
-
nodeUnifies = unify(generalNode, specificNode, ...remainingArguments);
|
|
144
|
-
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
nonTerminalNodeUnifies = nodeUnifies; ///
|
|
150
|
-
|
|
151
|
-
return nonTerminalNodeUnifies;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
unifyChildNodesAhead(index, generalChildNodes, specificChildNodes, ...remainingArguments) {
|
|
155
|
-
let childNodesUnify;
|
|
156
|
-
|
|
157
|
-
const unifyAhead = remainingArguments.pop(), ///
|
|
158
|
-
generalChildNodesLength = generalChildNodes.length;
|
|
159
|
-
|
|
160
|
-
if (index === generalChildNodesLength) {
|
|
161
|
-
const unifiesAhead = unifyAhead();
|
|
162
|
-
|
|
163
|
-
childNodesUnify = unifiesAhead; ///
|
|
164
|
-
} else {
|
|
165
|
-
const generalChildNode = generalChildNodes[index],
|
|
166
|
-
specificChildNode = specificChildNodes[index],
|
|
167
|
-
generalNode = generalChildNode, ///
|
|
168
|
-
specificNode = specificChildNode, ///
|
|
169
|
-
nodeUnifies = this.unifyNode(generalNode, specificNode, ...remainingArguments, () => {
|
|
170
|
-
remainingArguments.push(unifyAhead); ///
|
|
171
|
-
|
|
172
|
-
const aheadIndex = index + 1,
|
|
173
|
-
childNodesUnifyAhead = this.unifyChildNodesAhead(aheadIndex, generalChildNodes, specificChildNodes, ...remainingArguments);
|
|
174
|
-
|
|
175
|
-
return childNodesUnifyAhead;
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
childNodesUnify = nodeUnifies; ///
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return childNodesUnify;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
|
-
import { FUNCTION } from "../constants";
|
|
6
|
-
|
|
7
|
-
const { last } = arrayUtilities;
|
|
8
|
-
|
|
9
|
-
export function isLastRemainingArgumentFunction(remainingArguments) {
|
|
10
|
-
let lastRemainingArgumentFunction = false;
|
|
11
|
-
|
|
12
|
-
const remainingArgumentsLength = remainingArguments.length;
|
|
13
|
-
|
|
14
|
-
if (remainingArgumentsLength > 0) {
|
|
15
|
-
const lastRemainingArgument = last(remainingArguments);
|
|
16
|
-
|
|
17
|
-
lastRemainingArgumentFunction = (typeof lastRemainingArgument === FUNCTION);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return lastRemainingArgumentFunction;
|
|
21
|
-
}
|
package/src/utilities/frame.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nodeQuery } from "../utilities/query";
|
|
4
|
-
|
|
5
|
-
const frameMetavariableNameNodeQuery = nodeQuery("/frame/assumption!/metavariable!/@name!");
|
|
6
|
-
|
|
7
|
-
export function frameMetavariableNameFromFrameNode(frmaeNode) {
|
|
8
|
-
const frameMetavariableNameTerminalNode = frameMetavariableNameNodeQuery(frmaeNode),
|
|
9
|
-
frameMetavariableNameTerminalNodeContent = frameMetavariableNameTerminalNode.getContent(),
|
|
10
|
-
frameMetavariableName = frameMetavariableNameTerminalNodeContent; ///
|
|
11
|
-
|
|
12
|
-
return frameMetavariableName;
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nodeQuery } from "../utilities/query";
|
|
4
|
-
|
|
5
|
-
const metavariableNameNodeQuery = nodeQuery("/metavariable/@name!");
|
|
6
|
-
|
|
7
|
-
export function metavariableNameFromMetavariableNode(metavariableNode) {
|
|
8
|
-
const metavariableNameTerminalNode = metavariableNameNodeQuery(metavariableNode),
|
|
9
|
-
metavariableNameTerminalNodeContent = metavariableNameTerminalNode.getContent(),
|
|
10
|
-
metavariableName = metavariableNameTerminalNodeContent; ///
|
|
11
|
-
|
|
12
|
-
return metavariableName;
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { nodeQuery } from "../utilities/query";
|
|
4
|
-
|
|
5
|
-
const statementMetavariableNameNodeQuery = nodeQuery("/statement/metavariable!/@name!");
|
|
6
|
-
|
|
7
|
-
export function statementMetavariableNameFromFrameNode(frmaeNode) {
|
|
8
|
-
const statementMetavariableNameTerminalNode = statementMetavariableNameNodeQuery(frmaeNode),
|
|
9
|
-
statementMetavariableNameTerminalNodeContent = statementMetavariableNameTerminalNode.getContent(),
|
|
10
|
-
statementMetavariableName = statementMetavariableNameTerminalNodeContent; ///
|
|
11
|
-
|
|
12
|
-
return statementMetavariableName;
|
|
13
|
-
}
|