@Override public MentalStateCondition getPrecondition() { return this.actionSpec.getPrecondition(); }
/** * 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()); // Extract relevant info from action specifications. for (UserSpecAction action : this.program.getActionSpecifications()) { for (MentalLiteral literal : getBeliefLiterals(action.getPrecondition())) { this.beliefQueries.add(literal.getFormula()); } if (action.getPositivePostcondition() != null) { this.beliefQueries.add(action.getPositivePostcondition().getPostCondition().toQuery()); } if (action.getNegativePostcondition() != null) { this.beliefQueries.add(action.getNegativePostcondition().getPostCondition().toQuery()); } } } }
protected void reportUnusedVariables() { for (UserSpecAction spec : this.program.getActionSpecifications()) { List<Var> vars = new LinkedList<>(); try { CognitiveKR ckr = getFirstPass().getCognitiveKR(); if (spec.getPrecondition() != null) { for (MentalLiteral literal : spec.getPrecondition().getAllLiterals()) { vars.addAll(ckr.getAllVariables(literal.getFormula())); } } if (spec.getNegativePostcondition() != null) { vars.addAll(ckr.getAllVariables(spec.getNegativePostcondition().getPostCondition())); } if (spec.getPositivePostcondition() != null) { vars.addAll(ckr.getAllVariables(spec.getPositivePostcondition().getPostCondition())); } Set<Var> unique = new LinkedHashSet<>(vars); unique.removeAll(spec.getParameters()); for (Var var : unique) { int occurences = Collections.frequency(vars, var); if (occurences < 2) { getFirstPass().reportWarning(ActionSpecWarning.VARIABLE_UNUSED, var.getSourceInfo(), var.toString()); } } } catch (ParserException e) { getFirstPass().reportParsingException(e); } } }
/** * Add an action specification to this action specification program. * * @param actionSpec * An action specification. */ public void addActionSpecification(UserSpecAction action) { register(action); if (action.getFullPreCondition() != null) { register(action.getPrecondition()); } if (action.getPositivePostcondition() != null) { register(action.getPositivePostcondition()); } if (action.getNegativePostcondition() != null) { register(action.getNegativePostcondition()); } this.actions.add(action); }
protected void doCreateGraph(UserSpecAction subject) { for (MentalLiteral formula : subject.getPrecondition().getAllLiterals()) { try { super.getGraph().add(formula.getFormula());
for (MentalLiteral formula : userspec.getPrecondition().getAllLiterals()) { super.getGraph().add(formula.getFormula());