public override object Execute(Reasoner ts, Unifier un, ITerm[] args) { CheckArguments(args); Trigger te = null; try { te = Trigger.TryToGetTrigger(args[0]); } catch (ParseException e) {} if (te == null) { throw JasonityException.CreateWrongArgument(this, "first argument '" + args[0] + "' must follow the syntax of a trigger."); } IListTerm labels = new ListTermImpl(); IListTerm lt = new ListTermImpl(); IListTerm last = lt; if (!te.GetLiteral().HasSource()) { // the ts.relevantPlans requires a source to work properly te.SetLiteral(te.GetLiteral().ForceFullLiteralImpl()); te.GetLiteral().AddSource(new UnnamedVar()); } List <Option> rp = ts.RelevantPlans(te); if (rp != null) { foreach (Option opt in rp) { // remove sources (this IA is used for communication) Plan np = (Plan)opt.GetPlan().Clone(); if (np.GetLabel() != null) { np.GetLabel().DelSources(); } np.SetAsPlanTerm(true); np.MakeVarsAnnon(); last = last.Append(np); if (args.Length == 3) { labels.Add(np.GetLabel()); } } } bool ok = un.Unifies(lt, args[1]); // args[1] is a var; if (ok && args.Length == 3) { ok = un.Unifies(labels, args[2]); } return(ok); }