private void convertComment(Rule r, StringBuilder sb) { sb.append("(*{| rule "); sb.append(ToKast.apply(r.body()).replace("|}", "| )")); sb.append(" requires "); sb.append(ToKast.apply(r.requires()).replace("|)", "| )")); sb.append(" ensures "); sb.append(ToKast.apply(r.ensures()).replace("|)", "| )")); sb.append(" "); sb.append(r.att().toString().replace("|)", "| )")); sb.append("|}*)\n"); }
public Rule addImplicitCells(Rule rule) { return new Rule( addImplicitCells(rule.body()), rule.requires(), rule.ensures(), rule.att()); }
private Rule lift(Rule rule) { return Rule( lift(rule.body()), lift(rule.requires()), lift(rule.ensures()), rule.att()); }
private Rule preprocess(Rule rule) { return Rule( preprocess(rule.body()), preprocess(rule.requires()), preprocess(rule.ensures()), rule.att()); }
/** * Takes a rule representing a predicate of one sort and promotes it to a rule representing a predicate for one of its supersorts */ private Rule promotePredicate(Rule r, Sort s) { K left = RewriteToTop.toLeft(r.body()); K right = RewriteToTop.toRight(r.body()); if (left instanceof KApply) { // the case where a rewrite applies unconditionally may be dependent on the klabel, so we hoist the rhs into the side condition return Rule(KRewrite(KApply(KLabel("is" + s.toString()), ((KApply) left).klist()), BooleanUtils.TRUE), BooleanUtils.and(r.requires(), right), r.ensures(), r.att()); } else { throw new IllegalArgumentException("not a predicate rule"); } } }
private Rule resolve(Rule rule) { return new Rule( transform(rule.body()), transform(rule.requires()), transform(rule.ensures()), rule.att()); }
private Rule postprocess(Rule rule) { return Rule( postprocess(rule.body()), postprocess(rule.requires()), postprocess(rule.ensures()), rule.att()); }
private Rule expand(Rule rule) { return Rule(expand(rule.body()), expand(rule.requires()), expand(rule.ensures()), rule.att()); }
public Rule applyNormalization(Rule denormal, K... normals) { return Rule( applyNormalization(denormal.body(), normals), applyNormalization(denormal.requires(), normals), applyNormalization(denormal.ensures(), normals), denormal.att()); }
private Rule resolve(Rule rule) { return Rule( transformBody(rule.body(), rule.att()), transform(rule.requires(), rule.att()), rule.ensures(), rule.att()); }
private Rule resolve(Rule rule) { resetCasts(); gatherCasts(rule.body()); gatherCasts(rule.requires()); gatherCasts(rule.ensures()); return new Rule( transform(rule.body()), addSideCondition(transform(rule.requires()), rule.att().contains("macro") || rule.att().contains("alias")), transform(rule.ensures()), rule.att()); }
public Sentence concretize(Sentence m) { if (m instanceof Rule) { Rule r = (Rule) m; return new Rule(concretize(r.body()), r.requires(), r.ensures(), r.att()); } else if (m instanceof Context) { Context c = (Context) m; return new Context(concretize(c.body()), c.requires(), c.att()); } else { return m; } } }
private static Sentence markRegularRules(Definition d, ConfigurationInfoFromModule configInfo, Sentence s, String att) { if (s instanceof org.kframework.definition.Rule) { org.kframework.definition.Rule r = (org.kframework.definition.Rule) s; if (r.body() instanceof KApply) { KLabel klabel = ((KApply) r.body()).klabel(); if (d.mainModule().sortFor().contains(klabel) //is false for rules in specification modules not part of semantics && d.mainModule().sortFor().apply(klabel).equals(configInfo.topCell())) { return Rule.apply(r.body(), r.requires(), r.ensures(), r.att().add(att)); } } } return s; }