eyeprolog 1.5.105 → 1.5.106

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
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.5.105",
6
+ "version": "1.5.106",
7
7
  "description": "EyeProlog turns facts and rules into answers and proofs.",
8
8
  "type": "module",
9
9
  "main": "./index.js",
package/src/iso.js CHANGED
@@ -674,22 +674,25 @@ function* termVariablesBuiltin({ goal, env }) {
674
674
  }
675
675
 
676
676
  function validPredicateIndicator(term) {
677
- // Each position is checked independently, not "could some single
678
- // instantiation satisfy both at once" -- so current_predicate(X/X)
679
- // (issue #115) passes this check exactly like current_predicate(X/Y)
680
- // does, and is then left to the ordinary group search below, which
681
- // unifies goal.args[0] (still X/X, the two positions aliased) against
682
- // each candidate Name/Arity in turn. Name and Arity are never the same
683
- // type, so that unification always fails and the goal simply finds no
684
- // solutions, the same way ISO's own current_op/3 (8.14.4.1) is specified:
685
- // its candidate set is built by unifying a triple's priority (an integer)
686
- // and specifier (an atom) against Priority and Op-specifier, so aliasing
687
- // those two arguments the same way makes every candidate fail to unify
688
- // and the set come up empty -- current_op/3's own Errors subclause
689
- // (8.14.4.3) has no special case for it, only domain errors for an
690
- // argument that is instantiated and outright wrong on its own. A
691
- // predicate_indicator type error remains for a term that cannot look
692
- // like a Name/Arity pair at all (a bare atom, a negative arity, ...).
677
+ // ISO 13211-1 8.8.2.3's sole error condition is "PI is neither a variable
678
+ // nor a predicate indicator -> type_error(predicate_indicator, PI)", and
679
+ // 8.8.2.4's own worked example -- current_predicate(Name/1) succeeds,
680
+ // backtracking through every matching Name -- shows that a compound whose
681
+ // Name is merely a variable already counts as "a predicate indicator" for
682
+ // this check, not just one whose Name and Arity are already bound to an
683
+ // atom and a non-negative integer as 7.1.6.6 defines the type. So each
684
+ // position is checked independently here, not "could some single
685
+ // instantiation satisfy both at once": current_predicate(X/X) (issue #115)
686
+ // passes this check exactly like current_predicate(X/Y) does, and is left
687
+ // to the ordinary group search below (8.8.2.1 a-c), which unifies
688
+ // goal.args[0] (still X/X, the two positions aliased) against each
689
+ // candidate Name/Arity in turn. Name and Arity are never the same type, so
690
+ // that unification always fails for every candidate and the goal simply
691
+ // finds no solutions -- 8.8.2.1's own procedure gives no other outcome for
692
+ // an empty candidate set than "the goal fails" (step c), with no separate
693
+ // provision for an argument that turned out unable to ever unify. A
694
+ // predicate_indicator type error remains for a term that cannot look like
695
+ // a Name/Arity pair at all (a bare atom, a negative arity, ...).
693
696
  return term.type === COMPOUND && term.name === '/' && term.arity === 2 &&
694
697
  (term.args[0].type === VAR || term.args[0].type === ATOM) &&
695
698
  (term.args[1].type === VAR ||
@@ -1592,19 +1592,30 @@ export function runIsoStrict(reporter = new TestReporter()) {
1592
1592
  const current = run('p(a).\nq.\n', { isoStrict: true, goal: 'current_predicate(p/1)' });
1593
1593
  equal(current.stats.completed_goal_lists, 1, 'current_predicate/1 finds a user procedure');
1594
1594
 
1595
- // The same variable filling both Name and Arity (issue #115, stc#79)
1596
- // looks valid position-by-position -- each alone accepts an unbound
1597
- // variable, and current_predicate/1 must support both fully unbound
1598
- // (current_predicate(X/Y), a generator) -- but no instantiation can
1599
- // satisfy both positions of one shared variable at once, since binding
1600
- // it to an atom makes Arity an atom too, not an integer. ISO does not
1601
- // special-case this for the structurally identical current_op/3
1602
- // (8.14.4.1): its candidate set is built by unifying a triple's integer
1603
- // priority and atom specifier against Priority and Op-specifier, so
1604
- // aliasing those two arguments the same way simply makes every
1605
- // candidate fail to unify and the set come up empty, and current_op/3's
1606
- // own Errors subclause (8.14.4.3) has no case for it. current_predicate
1607
- // /1 follows that precedent: it fails rather than raising an error.
1595
+ // ISO 13211-1 8.8.2.4's own worked example: current_predicate(Name/1)
1596
+ // succeeds with an unbound Name, backtracking through every arity-1
1597
+ // predicate. A compound with an unbound component already counts as "a
1598
+ // predicate indicator" for 8.8.2.3's error check, not only one whose
1599
+ // Name and Arity are already bound to an atom and a non-negative
1600
+ // integer as 7.1.6.6 defines the type.
1601
+ equal(
1602
+ run('elk(a).\ninsect(b).\n', { isoStrict: true, goal: 'current_predicate(Name/1)' }).stats.completed_goal_lists,
1603
+ 2,
1604
+ 'current_predicate/1 enumerates every matching Name with Arity fixed and Name unbound',
1605
+ );
1606
+
1607
+ // The same variable filling both Name and Arity (issue #115) looks
1608
+ // valid position-by-position by that same per-component check -- each
1609
+ // position alone accepts an unbound variable, and current_predicate/1
1610
+ // must support both fully unbound (current_predicate(X/Y), a generator,
1611
+ // just demonstrated above) -- but no instantiation can satisfy both
1612
+ // positions of one shared variable at once, since binding it to an atom
1613
+ // makes Arity an atom too, not an integer. 8.8.2.3 has only the one
1614
+ // error condition above, and 8.8.2.1's procedure gives no outcome for an
1615
+ // empty candidate set (step a-c) besides "the goal fails" (step c) --
1616
+ // there is no separate provision for an argument that turned out unable
1617
+ // to ever unify with anything. current_predicate/1 follows that: it
1618
+ // fails rather than raising an error.
1608
1619
  for (const [goal, label] of [
1609
1620
  ['current_predicate(X/X)', 'current_predicate/1 aliased name/arity variable fails'],
1610
1621
  ['X = Y, current_predicate(X/Y)', 'current_predicate/1 previously unified name/arity variables fails'],