/** * This method is invoked when the builtin is called in a rule head. * Such a use is only valid in a forward rule. * @param args the array of argument values for the builtin, this is an array * of Nodes. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { if (context.getGraph() instanceof FBRuleInfGraph) { Triple t = new Triple(args[0], args[1], args[2]); ((FBRuleInfGraph)context.getGraph()).addDeduction(t); } else { throw new BuiltinException(this, context, "Only usable in FBrule graphs"); } } }
/** * This method is invoked when the builtin is called in a rule head. * Such a use is only valid in a forward rule. * @param args the array of argument values for the builtin, this is an array * of Nodes. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { if (context.getGraph() instanceof FBRuleInfGraph) { Triple t = new Triple(args[0], args[1], args[2]); ((FBRuleInfGraph)context.getGraph()).addDeduction(t); } else { throw new BuiltinException(this, context, "Only usable in FBrule graphs"); } } }
/** * Shared implementation applicable to head or body */ private void doHide(Node[] args, int length, RuleContext context ) { InfGraph g = context.getGraph(); if (g instanceof FBRuleInfGraph) { for (int i = 0; i < length; i++) { ((FBRuleInfGraph)g).hideNode(args[i]); } } else { throw new BuiltinException(this, context, "hide only available for FB rule engines"); } } }
/** * Shared implementation applicable to head or body */ private void doHide(Node[] args, int length, RuleContext context ) { InfGraph g = context.getGraph(); if (g instanceof FBRuleInfGraph) { for (int i = 0; i < length; i++) { ((FBRuleInfGraph)g).hideNode(args[i]); } } else { throw new BuiltinException(this, context, "hide only available for FB rule engines"); } } }
/** * This method is invoked when the builtin is called in a rule body. * @param args the array of argument values for the builtin, this is an array * of Nodes, some of which may be Node_RuleVariables. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { InfGraph infgraph = context.getGraph(); if (infgraph instanceof FBRuleInfGraph) { ((FBRuleInfGraph)infgraph).setTabled(Node.ANY); } else if (infgraph instanceof LPBackwardRuleInfGraph) { ((LPBackwardRuleInfGraph)infgraph).setTabled(Node.ANY); } else { // Quietly ignore as an irrelevant directive // Could log or throw exception but currently I want to be able to use // the same rule base from different contexts which do and do not need // to know about this. } } }
/** * This method is invoked when the builtin is called in a rule body. * @param args the array of argument values for the builtin, this is an array * of Nodes, some of which may be Node_RuleVariables. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { InfGraph infgraph = context.getGraph(); if (infgraph instanceof FBRuleInfGraph) { ((FBRuleInfGraph)infgraph).setTabled(Node.ANY); } else if (infgraph instanceof LPBackwardRuleInfGraph) { ((LPBackwardRuleInfGraph)infgraph).setTabled(Node.ANY); } else { // Quietly ignore as an irrelevant directive // Could log or throw exception but currently I want to be able to use // the same rule base from different contexts which do and do not need // to know about this. } } }
/** * This method is invoked when the builtin is called in a rule body. * @param args the array of argument values for the builtin, this is an array * of Nodes, some of which may be Node_RuleVariables. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { InfGraph infgraph = context.getGraph(); if (infgraph instanceof FBRuleInfGraph) { for (int i = 0; i < length; i++) { ((FBRuleInfGraph)infgraph).setTabled(args[i]); } } else if (infgraph instanceof LPBackwardRuleInfGraph) { for (int i = 0; i < length; i++) { ((LPBackwardRuleInfGraph)infgraph).setTabled(args[i]); } } else { // Quietly ignore as an irrelevant directive // Could log or throw exception but currently I want to be able to use // the same rule base from different contexts which do and do not need // to know about this. } }
/** * This method is invoked when the builtin is called in a rule body. * @param args the array of argument values for the builtin, this is an array * of Nodes, some of which may be Node_RuleVariables. * @param length the length of the argument list, may be less than the length of the args array * for some rule engines * @param context an execution context giving access to other relevant data */ @Override public void headAction(Node[] args, int length, RuleContext context) { InfGraph infgraph = context.getGraph(); if (infgraph instanceof FBRuleInfGraph) { for (int i = 0; i < length; i++) { ((FBRuleInfGraph)infgraph).setTabled(args[i]); } } else if (infgraph instanceof LPBackwardRuleInfGraph) { for (int i = 0; i < length; i++) { ((LPBackwardRuleInfGraph)infgraph).setTabled(args[i]); } } else { // Quietly ignore as an irrelevant directive // Could log or throw exception but currently I want to be able to use // the same rule base from different contexts which do and do not need // to know about this. } }
InfGraph inf = context.getGraph(); Graph raw = inf.getRawGraph(); Graph deductions = inf.getDeductionsGraph();
InfGraph inf = context.getGraph(); Graph raw = inf.getRawGraph(); Graph deductions = inf.getDeductionsGraph();