occam-nominal 1.0.427 → 1.0.430

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "occam-nominal",
3
3
  "author": "James Smith",
4
- "version": "1.0.427",
4
+ "version": "1.0.430",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/occam-nominal",
7
7
  "description": "Occam's Nominal language.",
@@ -11,16 +11,16 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "necessary": "^17.6.3",
14
- "occam-furtle": "^3.0.436",
14
+ "occam-furtle": "^3.0.438",
15
15
  "occam-grammar-utilities": "^8.1.22",
16
- "occam-languages": "^2.2.53",
16
+ "occam-languages": "^2.2.55",
17
17
  "occam-query": "^4.1.203"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@swc/core": "1.13.20",
21
21
  "decaf-cli": "^1.0.37",
22
- "occam-model": "^1.0.570",
23
- "occam-server": "^7.0.70",
22
+ "occam-model": "^1.0.572",
23
+ "occam-server": "^7.0.72",
24
24
  "watchful-cli": "^1.7.102"
25
25
  },
26
26
  "scripts": {
@@ -621,17 +621,24 @@ export default class NominalFileContext extends FileContext {
621
621
 
622
622
  isLabelPresentByLabelNode(labelNode) {
623
623
  const labels = this.getLabels(),
624
- labelPresent = labels.some((label) => {
625
- const labelNodeMatches = label.matchLabelNode(labelNode);
624
+ labelPresent = labels.some((label) => {
625
+ const labelNodeMatches = label.matchLabelNode(labelNode);
626
626
 
627
- if (labelNodeMatches) {
628
- return true;
629
- }
630
- });
627
+ if (labelNodeMatches) {
628
+ return true;
629
+ }
630
+ });
631
631
 
632
632
  return labelPresent;
633
633
  }
634
634
 
635
+ isAxiomPresentByReference(reference) {
636
+ const axiom = this.findAxiomByReference(reference),
637
+ axiomPresent = (axiom !== null);
638
+
639
+ return axiomPresent;
640
+ }
641
+
635
642
  isTypePresentByTypeName(typeName, includeRelease = true) {
636
643
  const type = this.findTypeByTypeName(typeName, includeRelease),
637
644
  typePresent = (type !== null);
package/src/context.js CHANGED
@@ -417,9 +417,16 @@ export default class Context extends ContextBase {
417
417
  return declaredMetavariable;
418
418
  }
419
419
 
420
+ isAxiomPresentByReference(reference) {
421
+ const context = this.getContext(),
422
+ axiomPresent = context.isAxiomPresentByReference(reference);
423
+
424
+ return axiomPresent;
425
+ }
426
+
420
427
  isTermPresentByTermNode(termNode) {
421
428
  const context = this.getContext(),
422
- termPresent = context.isTermPresentByTermNode(termNode);
429
+ termPresent = context.isTermPresentByTermNode(termNode);
423
430
 
424
431
  return termPresent;
425
432
  }
@@ -5,23 +5,23 @@ import { breakPointUtilities } from "occam-languages";
5
5
  import Assertion from "../assertion";
6
6
 
7
7
  import { define } from "../../elements";
8
+ import { all, every } from "../../utilities/continuation";
8
9
  import { reconcile, instantiate } from "../../utilities/context";
9
10
  import { instantiateSignatureAssertion } from "../../process/instantiate";
10
- import { signatureFromSignatureAssertionNode, referenceFromSignatureAssertionNode, signatureAssertionFromStatementNode } from "../../utilities/element";
11
- import {all, exists} from "../../utilities/continuation";
11
+ import { termsFromSignatureAssertionNode, referenceFromSignatureAssertionNode, signatureAssertionFromStatementNode } from "../../utilities/element";
12
12
 
13
13
  const { breakPointFromJSON } = breakPointUtilities;
14
14
 
15
15
  export default define(class SignatureAssertion extends Assertion {
16
- constructor(context, string, node, breakPoint, signature, reference) {
16
+ constructor(context, string, node, breakPoint, terms, reference) {
17
17
  super(context, string, node, breakPoint);
18
18
 
19
- this.signature = signature;
19
+ this.terms = terms;
20
20
  this.reference = reference;
21
21
  }
22
22
 
23
- getSignature() {
24
- return this.signature;
23
+ getTerms() {
24
+ return this.terms;
25
25
  }
26
26
 
27
27
  getReference() {
@@ -55,11 +55,11 @@ export default define(class SignatureAssertion extends Assertion {
55
55
  } else {
56
56
  assertion = this; ///
57
57
 
58
- const validateSignature = this.validateSignature.bind(this),
58
+ const validateTerms = this.validateTerms.bind(this),
59
59
  validateReference = this.validateReference.bind(this);
60
60
 
61
61
  validates = all([
62
- validateSignature,
62
+ validateTerms,
63
63
  validateReference
64
64
  ], state, context, (state, context) => {
65
65
  let validates;
@@ -81,91 +81,91 @@ export default define(class SignatureAssertion extends Assertion {
81
81
  return validates;
82
82
  }
83
83
 
84
- validateSignature(context) {
85
- let signatureValidates = false;
84
+ validateTerm(term, terms, state, context, continuation) {
85
+ let termValidates;
86
86
 
87
- const signatureAssertionString = this.getString(); ///
87
+ const termString = term.getString(),
88
+ signatureAssertionString = this.getString(); ///
88
89
 
89
- context.trace(`Validating the '${signatureAssertionString}' signature assertion's signature...`);
90
+ context.trace(`Validating the '${signatureAssertionString}' signature assertion's '${termString}' term...`);
90
91
 
91
- const signature = this.signature.validate(state, context);
92
+ termValidates = term.validate(state, context, (term, context) => {
93
+ let validates;
92
94
 
93
- if (signature !== null) {
94
- this.signature = signature;
95
+ terms.push(term);
95
96
 
96
- signatureValidates = true;
97
- }
97
+ validates = continuation(terms, state, context);
98
+
99
+ return validates;
100
+ });
98
101
 
99
- if (signatureValidates) {
100
- context.debug(`...validated the '${signatureAssertionString}' signature assertion's signature.`);
102
+ if (termValidates) {
103
+ context.debug(`...validated the '${signatureAssertionString}' signature assertion's '${termString}' term.`);
101
104
  }
102
105
 
103
- return signatureValidates;
106
+ return termValidates;
104
107
  }
105
108
 
106
- validateReference(context) {
107
- let referenceVerifies = false;
109
+ validateTerms(state, context, continuation) {
110
+ let termsValidate;
108
111
 
109
112
  const signatureAssertionString = this.getString(); ///
110
113
 
111
- context.trace(`Validating the '${signatureAssertionString}' signature assertion's reference...`);
112
-
113
- const reference = this.reference.validate(state, context);
114
-
115
- if (reference !== null) {
116
- const axiom = context.findAxiomByReference(reference);
117
-
118
- if (axiom !== null) {
119
- const satisfiable = axiom.isSatisfiable();
120
-
121
- if (satisfiable) {
122
- const signatureUnifies = this.unifySignature(context);
114
+ context.trace(`Validating the '${signatureAssertionString}' signature assertion's terms...`);
123
115
 
124
- if (signatureUnifies) {
125
- this.reference = reference;
116
+ const terms = [],
117
+ validateTerm = this.validateTerm.bind(this);
126
118
 
127
- referenceVerifies = true;
128
- }
129
- } else {
130
- const axiomString = axiom.getString();
119
+ termsValidate = every(this.terms, validateTerm, terms, state, context, (terms, state, context) => {
120
+ let termsValidate;
131
121
 
132
- context.debug(`The '${axiomString}' axiom is not satisfiable.`);
133
- }
134
- } else {
135
- const referencdString = reference.getString();
122
+ termsValidate = continuation(state, context);
136
123
 
137
- context.debug(`There is no axiom for the '${referencdString}' reference.`);
124
+ if (termsValidate) {
125
+ this.terms = terms;
138
126
  }
139
- }
140
127
 
141
- if (referenceVerifies) {
142
- context.debug(`...validated the '${signatureAssertionString}' signature assertion's reference.`);
128
+ return termsValidate;
129
+ });
130
+
131
+ if (termsValidate){
132
+ context.debug(`...validated the '${signatureAssertionString}' signature assertion's terms.`);
143
133
  }
144
134
 
145
- return referenceVerifies;
135
+ return termsValidate
146
136
  }
147
137
 
148
- unifySignature(context) {
149
- let signatureUnifies;
138
+ validateReference(state, context, continuation) {
139
+ let referenceValidates;
150
140
 
151
141
  const signatureAssertionString = this.getString(); ///
152
142
 
153
- context.trace(`Unifying the '${signatureAssertionString}' signature assertion's signature...`);
143
+ context.trace(`Validating the '${signatureAssertionString}' signature assertion's reference...`);
154
144
 
155
- return reconcile((context) => {
156
- const axiom = context.findAxiomByReference(this.reference);
145
+ referenceValidates = this.reference.validate(state, context, (reference, context) => {
146
+ let validates = false;
157
147
 
158
- signatureUnifies = axiom.unifySignature(this.signature, context);
159
- }, context);
148
+ const asiomPresent = context.isAxiomPresentByReference(reference);
149
+
150
+ if (asiomPresent) {
151
+ this.reference = reference;
152
+
153
+ validates = continuation(state, context);
154
+ }
160
155
 
161
- if (signatureUnifies) {
162
- context.debug(`...unified the '${signatureAssertionString}' signature assertion's signature.`);
156
+ return validates;
157
+ });
158
+
159
+ if (referenceValidates) {
160
+ context.debug(`...validated the '${signatureAssertionString}' signature assertion's reference.`);
163
161
  }
164
162
 
165
- return signatureUnifies;
163
+ return referenceValidates;
166
164
  }
167
165
 
168
- async unifyClaim(claim, context) {
166
+ unifyClaim(claim, context) {
167
+ debugger
168
+
169
169
  let claimUnifies;
170
170
 
171
171
  const claimString = claim.getString(),
@@ -173,12 +173,12 @@ export default define(class SignatureAssertion extends Assertion {
173
173
 
174
174
  context.trace(`Unifying the '${claimString}' claim with the '${signatureAssertionString}' signature assertion...`);
175
175
 
176
- await reconcile(async (context) => {
176
+ reconcile((context) => {
177
177
  const axiom = context.findAxiomByReference(this.reference);
178
178
 
179
179
  axiom.unifySignature(this.signature, context);
180
180
 
181
- claimUnifies = await axiom.unifyClaim(claim, context);
181
+ claimUnifies = axiom.unifyClaim(claim, context);
182
182
  }, context);
183
183
 
184
184
  if (claimUnifies) {
@@ -188,18 +188,23 @@ export default define(class SignatureAssertion extends Assertion {
188
188
  return claimUnifies;
189
189
  }
190
190
 
191
- async unifyStepAndFactOrSubproofs(step, factOrSubproofs, context) {
192
- let stepAndFactOrSubproofsUnify;
191
+ unifyStepAndFactOrSubproofs(step, factOrSubproofs, context, continuation) {
192
+ let stepAndFactOrSubproofsUnify = false;
193
193
 
194
- await reconcile(async (context) => {
195
- const axiom = context.findAxiomByReference(this.reference);
194
+ return reconcile((context) => {
195
+ const axiom = context.findAxiomByReference(this.reference),
196
+ signatureAssertion = this; ///
196
197
 
197
- axiom.unifySignature(this.signature, context);
198
+ return axiom.unifySignatureAssertion(signatureAssertion, context, (signatureAssertionUnifies) => {
199
+ if (!signatureAssertionUnifies) {
200
+ return continuation(stepAndFactOrSubproofsUnify);
201
+ }
198
202
 
199
- stepAndFactOrSubproofsUnify = await axiom.unifyStepAndFactOrSubproofs(step, factOrSubproofs, context);
200
- }, context);
203
+ debugger
201
204
 
202
- return stepAndFactOrSubproofsUnify;
205
+ // stepAndFactOrSubproofsUnify = axiom.unifyStepAndFactOrSubproofs(step, factOrSubproofs, context);
206
+ });
207
+ }, context);
203
208
  }
204
209
 
205
210
  static name = "SignatureAssertion";
@@ -215,12 +220,12 @@ export default define(class SignatureAssertion extends Assertion {
215
220
  definedAssertionNode = instantiateSignatureAssertion(string, context),
216
221
  node = definedAssertionNode, ///
217
222
  breakPoint = breakPointFromJSON(json),
218
- signature = signatureFromSignatureAssertionNode(definedAssertionNode, context),
223
+ terms = termsFromSignatureAssertionNode(definedAssertionNode, context),
219
224
  reference = referenceFromSignatureAssertionNode(definedAssertionNode, context);
220
225
 
221
226
  context = null;
222
227
 
223
- signatureAssertion = new SignatureAssertion(context, string, node, breakPoint, signature, reference);
228
+ signatureAssertion = new SignatureAssertion(context, string, node, breakPoint, terms, reference);
224
229
  }, context);
225
230
  }
226
231
 
@@ -60,13 +60,12 @@ export default define(class Axiom extends Claim {
60
60
  return continuation(signatureVerifies);
61
61
  }
62
62
 
63
- const axiomString = this.getString(); ///
63
+ const signature = this.getSignature(),
64
+ axiomString = this.getString(); ///
64
65
 
65
66
  context.trace(`Verifying the '${axiomString}' axiom's signature...`);
66
67
 
67
- const signature = this.getSignature();
68
-
69
- signature.verify(context, (signatureVerifies) => {
68
+ return signature.verify(context, (signatureVerifies) => {
70
69
  if (signatureVerifies) {
71
70
  context.trace(`...verified the '${axiomString}' axiom's signature.`);
72
71
  }
@@ -75,30 +74,66 @@ export default define(class Axiom extends Claim {
75
74
  });
76
75
  }
77
76
 
78
- unifySignature(signature, context) {
79
- let signatureUnifies;
77
+ unifyClaim(claim, context) {
78
+ debugger
79
+
80
+ let claimUnifies = false;
80
81
 
81
82
  const axiomString = this.getString(), ///
82
- signatureString = signature.getString();
83
+ claimString = claim.getString();
83
84
 
84
- context.trace(`Unifying the '${signatureString}' signature with the '${axiomString}' axiom...`);
85
+ context.trace(`Unifying the '${claimString}' claim with the '${axiomString}' axiom...`);
85
86
 
86
- const specificSignature = signature; ///
87
+ const deduction = claim.getDeduction(),
88
+ deductionUnifies = this.unifyDeduction(deduction, context);
87
89
 
88
- signature = this.getSignature();
90
+ if (deductionUnifies) {
91
+ const hypothesesDischarges = claim.dischargeHypotheses(context);
89
92
 
90
- const generalSignature = signature; ///
93
+ if (hypothesesDischarges) {
94
+ const suppositions = claim.getSuppositions(),
95
+ suppositionsUnify = this.unifySuppositions(suppositions, context);
91
96
 
92
- signatureUnifies = generalSignature.unifySignature(specificSignature, context);
97
+ if (suppositionsUnify) {
98
+ claimUnifies = true;
99
+ }
100
+ }
101
+ }
93
102
 
94
- if (signatureUnifies) {
95
- context.debug(`...unified the '${signatureString}' signature with the '${axiomString}' axiom.`);
103
+ if (claimUnifies) {
104
+ context.debug(`...unified the '${claimString}' claim with the '${axiomString}' axiom.`);
96
105
  }
97
106
 
98
- return signatureUnifies;
107
+ return claimUnifies;
108
+ }
109
+
110
+ unifySignatureAssertion(signatureAssertion, context, continuation) {
111
+ let signatureAssertionUnifies = false;
112
+
113
+ const axiomString = this.getString(), ///
114
+ signatureAssertionString = signatureAssertion.getString();
115
+
116
+ context.trace(`Unifying the '${signatureAssertionString}' signature assertion with the '${axiomString}' axiom...`);
117
+
118
+ const terms = signatureAssertion.getTerms(),
119
+ signature = this.getSignature();
120
+
121
+ return signature.unifyTerms(terms, context, (termsUnify) => {
122
+ if (termsUnify) {
123
+ signatureAssertionUnifies = true;
124
+ }
125
+
126
+ if (signatureAssertionUnifies) {
127
+ context.debug(`...unified the '${signatureAssertionString}' signature assertion with the '${axiomString}' axiom.`);
128
+ }
129
+
130
+ return continuation(signatureAssertionUnifies);
131
+ });
99
132
  }
100
133
 
101
134
  unifyDeduction(deduction, context) {
135
+ debugger
136
+
102
137
  let deductionUnifies;
103
138
 
104
139
  const axiomString = this.getString(), ///
@@ -143,6 +178,8 @@ export default define(class Axiom extends Claim {
143
178
  }
144
179
 
145
180
  unifySupposition(supposition, index, context) {
181
+ debugger
182
+
146
183
  let suppositionUnifies = false;
147
184
 
148
185
  const specificSupposition = supposition; ///
@@ -190,6 +227,8 @@ export default define(class Axiom extends Claim {
190
227
  }
191
228
 
192
229
  unifySuppositions(suppositions, context) {
230
+ debugger
231
+
193
232
  let suppositionsUnify;
194
233
 
195
234
  const specificSuppositions = suppositions; ///
@@ -210,37 +249,6 @@ export default define(class Axiom extends Claim {
210
249
  return suppositionsUnify;
211
250
  }
212
251
 
213
- unifyClaim(claim, context) {
214
- let claimUnifies = false;
215
-
216
- const axiomString = this.getString(), ///
217
- claimString = claim.getString();
218
-
219
- context.trace(`Unifying the '${claimString}' claim with the '${axiomString}' axiom...`);
220
-
221
- const deduction = claim.getDeduction(),
222
- deductionUnifies = this.unifyDeduction(deduction, context);
223
-
224
- if (deductionUnifies) {
225
- const hypothesesDischarges = claim.dischargeHypotheses(context);
226
-
227
- if (hypothesesDischarges) {
228
- const suppositions = claim.getSuppositions(),
229
- suppositionsUnify = this.unifySuppositions(suppositions, context);
230
-
231
- if (suppositionsUnify) {
232
- claimUnifies = true;
233
- }
234
- }
235
- }
236
-
237
- if (claimUnifies) {
238
- context.debug(`...unified the '${claimString}' claim with the '${axiomString}' axiom.`);
239
- }
240
-
241
- return claimUnifies;
242
- }
243
-
244
252
  static name = "Axiom";
245
253
 
246
254
  static fromJSON(json, context) { return Claim.fromJSON(Axiom, json, context); }
@@ -249,10 +249,10 @@ export default define(class Label extends Element {
249
249
 
250
250
  ablate((context) => {
251
251
  instantiate((context) => {
252
- const string = labelString, ///
253
- labelNode = instantiateLabel(string, context);
252
+ const string = labelString, ///
253
+ labelNode = instantiateLabel(string, context);
254
254
 
255
- label = labelFromLabelNode(labelNode, context);
255
+ label = labelFromLabelNode(labelNode, context);
256
256
  }, context);
257
257
  }, context);
258
258