Query instantiatedQuery; for (Substitution lSubst : lSubstSet) { instantiatedQuery = query.applySubst(lSubst); if (!instantiatedQuery.isClosed()) { throw new MSTQueryException("goal query '" + query + "' did not result in a closed formula but returned '" + instantiatedQuery + "'.");
/** * Add a query (a use of predicates). */ public void addQuery(Query query) { addQuery(((PrologQuery) query).getCompound(), query.getSourceInfo()); }
/** * A mental literal is an atomic query on the mental state. Examples: bel(...), * goal(...) or not(bel(...)). * * @param polarity * The polarity of the mental literal. Default is true. If set to * false, the literal is of the form not(...). * @param selector * A {@link Selector} prefix of this mental literal. * @param query * A {@link KRInterface} query. * @param info * Source info about this object. */ public MentalLiteral(boolean polarity, Selector selector, Query query, Set<String> signatures, SourceInfo info) { super(info); this.polarity = polarity; this.query = query; this.selector = selector; this.signatures = (signatures == null) ? new LinkedHashSet<>(0) : signatures; this.free.addAll(this.query.getFreeVar()); this.free.addAll(this.selector.getFreeVar()); }
public ActionPreCondition applySubst(Substitution subst) { return new ActionPreCondition((getPreCondition() == null) ? null : getPreCondition().applySubst(subst), getSignatures(), getSourceInfo()); }
/** * Extracts relevant info for validation. */ private void processInfo() { // Extract relevant info from referenced files. this.knowledge.addAll(this.program.getKnowledge()); this.beliefs.addAll(this.program.getBeliefs()); this.goals.addAll(this.program.getGoals()); // Extract relevant info from macros. for (Macro macro : this.program.getMacros()) { processInfoMacro(macro); } // Extract relevant info from rules. for (Rule rule : this.program.getRules()) { processInfoRule(rule); } // Add goals in referenced files as goal definitions. for (Query query : this.program.getGoals()) { this.goalDbfs.addAll(query.toUpdate().getAddList()); } } }
public boolean isClosed() { return this.query.isClosed(); }
@Override public MentalLiteral applySubst(Substitution substitution) { return new PerceptLiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getUsedSignatures(), getSourceInfo()); }
if (msc != null) { for (MentalLiteral literal : msc.getAllLiterals()) { result.merge(attentionSet.insert(literal.getFormula().toUpdate()));
Query instantiatedQuery; for (Substitution lSubst : lSubstSet) { instantiatedQuery = query.applySubst(lSubst); if (!instantiatedQuery.isClosed()) { // should be closed; see TRAC
@Override public MentalLiteral applySubst(Substitution substitution) { return new GoalLiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getUsedSignatures(), getSourceInfo()); }
this.firstPass.reportError(ModuleError.KR_BELIEF_QUERIED_NEVER_DEFINED, query.getSourceInfo(), query.toString()); this.firstPass.reportError(ModuleError.KR_GOAL_QUERIED_NEVER_DEFINED, query.getSourceInfo(), query.toString()); this.firstPass.reportWarning(ModuleWarning.KR_GOAL_DOES_NOT_MATCH_BELIEF, query.getSourceInfo(), query.toString());
for (DatabaseFormula formula : lit.getFormula().toUpdate().getAddList()) { try { super.getGraph().add(formula, true, false);
postvars.removeAll(precondition.getPreCondition().getFreeVar());
@Override public MentalLiteral applySubst(Substitution substitution) { return new AGoalLiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getUsedSignatures(), getSourceInfo()); }
/** * Returns the precondition of this {@link AdoptAction}. * * <p> * An adopt action can be performed if the agent does not believe that the goal * that is adopted has already been achieved, i.e., believes it already to be * the case, and the goal does not follow from one of the goals that are already * present in the goal base. * </p> * * @return A {@link MentalStateCondition} that represents the action's * precondition. */ @Override public MentalStateCondition getPrecondition() { // Get the goal this action should add Query query = getUpdate().toQuery(); List<MentalFormula> formulalist = new ArrayList<>(2); // Construct the belief part of the query: NOT(BEL(query)). formulalist.add(new BelLiteral(false, getSelector(), query, null, getSourceInfo())); // Construct the goal part of the query: NOT(GOAL(query)). formulalist.add(new GoalLiteral(false, getSelector(), query, null, getSourceInfo())); // Combine both parts. return new MentalStateCondition(formulalist, query.getSourceInfo()); }
@Override public MentalLiteral applySubst(Substitution substitution) { return new BelLiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getUsedSignatures(), getSourceInfo()); }
@Override public MentalLiteral applySubst(Substitution substitution) { return new GoalALiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getUsedSignatures(), getSourceInfo()); }
@Override public MentalLiteral applySubst(Substitution substitution) { return new SentLiteral(isPositive(), (getSelector() == null) ? null : getSelector().applySubst(substitution), (getFormula() == null) ? null : getFormula().applySubst(substitution), getMood(), getUsedSignatures(), getSourceInfo()); } }