/** * Check that the object of a triple match corresponds to the given functor pattern. * Side effects the variable bindings. */ public boolean functorMatch(Triple t, LPInterpreter interpreter) { Node o = t.getObject(); if (!Functor.isFunctor(o)) return false; Functor f = (Functor)o.getLiteralValue(); if ( ! f.getName().equals(objectFunctor.getName())) return false; if ( f.getArgLength() != objectFunctor.getArgLength()) return false; Node[] fargs = f.getArgs(); Node[] oFargs = objectFunctor.getArgs(); for (int i = 0; i < fargs.length; i++) { if (!interpreter.unify(oFargs[i], fargs[i])) return false; } return true; }
/** * Check that the object of a triple match corresponds to the given functor pattern. * Side effects the variable bindings. */ public boolean functorMatch(Triple t, LPInterpreter interpreter) { Node o = t.getObject(); if (!Functor.isFunctor(o)) return false; Functor f = (Functor)o.getLiteralValue(); if ( ! f.getName().equals(objectFunctor.getName())) return false; if ( f.getArgLength() != objectFunctor.getArgLength()) return false; Node[] fargs = f.getArgs(); Node[] oFargs = objectFunctor.getArgs(); for (int i = 0; i < fargs.length; i++) { if (!interpreter.unify(oFargs[i], fargs[i])) return false; } return true; }
if (term instanceof Functor) { Functor f = (Functor)term; if (f.getArgLength() != 1) break; int ai = aIndex(f.getArgs()[0]); if (ai >= 0) {
if (term instanceof Functor) { Functor f = (Functor)term; if (f.getArgLength() != 1) break; int ai = aIndex(f.getArgs()[0]); if (ai >= 0) {
/** * Emit code for a call to a built-in predicate (functor). * @param functor the built-in to be invoked. */ void emitBody(Functor functor) { Node[] fargs = functor.getArgs(); Builtin builtin = functor.getImplementor(); if (builtin == null) { throw new LPRuleSyntaxException("Unknown builtin operation " + functor.getName(), rule); } if (builtin.getArgLength() != 0 && builtin.getArgLength() != fargs.length) { throw new LPRuleSyntaxException("Wrong number of arguments to functor " + functor.getName() + " : got " + functor.getArgLength() + " : expected " + builtin.getArgLength(), rule); } for (int i = 0; i < fargs.length; i++) { Node node = fargs[i]; // We optionally force an eager dereference of variables here. // We used to force this but the current builtin implementations // now robust against it (the do a deref themselves anyway). emitBodyPut(node, i, true); } code[p++] = CALL_BUILTIN; code[p++] = (byte)fargs.length; args.add(builtin); }
/** * Emit code for a call to a built-in predicate (functor). * @param functor the built-in to be invoked. */ void emitBody(Functor functor) { Node[] fargs = functor.getArgs(); Builtin builtin = functor.getImplementor(); if (builtin == null) { throw new LPRuleSyntaxException("Unknown builtin operation " + functor.getName(), rule); } if (builtin.getArgLength() != 0 && builtin.getArgLength() != fargs.length) { throw new LPRuleSyntaxException("Wrong number of arguments to functor " + functor.getName() + " : got " + functor.getArgLength() + " : expected " + builtin.getArgLength(), rule); } for (int i = 0; i < fargs.length; i++) { Node node = fargs[i]; // We optionally force an eager dereference of variables here. // We used to force this but the current builtin implementations // now robust against it (the do a deref themselves anyway). emitBodyPut(node, i, true); } code[p++] = CALL_BUILTIN; code[p++] = (byte)fargs.length; args.add(builtin); }
description.append( text + "\n"); description.append( "Culprit = " + PrintUtil.print(t.getSubject()) +"\n"); for (int j = 2; j < rFunc.getArgLength(); j++) { description.append( "Implicated node: " + PrintUtil.print(rFunc.getArgs()[j]) + "\n");
description.append( text + "\n"); description.append( "Culprit = " + PrintUtil.print(t.getSubject()) +"\n"); for (int j = 2; j < rFunc.getArgLength(); j++) { description.append( "Implicated node: " + PrintUtil.print(rFunc.getArgs()[j]) + "\n");
imp.headAction( f.getArgs(), f.getArgLength(), context );
imp.headAction( f.getArgs(), f.getArgLength(), context );
Functor funcArg = (Functor)o.getLiteralValue(); if (funcArg.getName().equals(func.getName())) { if (funcArg.getArgLength() == func.getArgLength()) { Node[] fargs = funcArg.getArgs(); for (int i = 0; i < fargs.length; i++) { Node[] fargs = new Node[func.getArgLength()]; Node[] templateArgs = func.getArgs(); for (int i = 0; i < fargs.length; i++) { Node[] fargs = new Node[f.getArgLength()]; System.arraycopy(argVars, 3, fargs, 0, fargs.length); argVars[2] = Functor.makeFunctorNode(f.getName(), fargs);
Functor funcArg = (Functor)o.getLiteralValue(); if (funcArg.getName().equals(func.getName())) { if (funcArg.getArgLength() == func.getArgLength()) { Node[] fargs = funcArg.getArgs(); for (int i = 0; i < fargs.length; i++) { Node[] fargs = new Node[func.getArgLength()]; Node[] templateArgs = func.getArgs(); for (int i = 0; i < fargs.length; i++) { Node[] fargs = new Node[f.getArgLength()]; System.arraycopy(argVars, 3, fargs, 0, fargs.length); argVars[2] = Functor.makeFunctorNode(f.getName(), fargs);
imp.headAction( f.getArgs(), f.getArgLength(), tempContext );
imp.headAction( f.getArgs(), f.getArgLength(), tempContext );
Builtin imp = f.getImplementor(); if (imp != null) { imp.headAction(f.getBoundArgs(env), f.getArgLength(), context); } else { throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + rule.toShortString());
Builtin imp = f.getImplementor(); if (imp != null) { imp.headAction(f.getBoundArgs(env), f.getArgLength(), context); } else { throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + rule.toShortString());
Builtin imp = f.getImplementor(); if (imp != null) { imp.headAction(f.getBoundArgs(env), f.getArgLength(), context); } else { throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + rule.toShortString());
Builtin imp = f.getImplementor(); if (imp != null) { imp.headAction(f.getBoundArgs(env), f.getArgLength(), context); } else { throw new ReasonerException("Invoking undefined Functor " + f.getName() +" in " + rule.toShortString());