public Rule addImplicitCells(Rule rule) { return new Rule( addImplicitCells(rule.body()), rule.requires(), rule.ensures(), rule.att()); }
private Rule resolve(Rule rule) { return new Rule( transform(rule.body()), transform(rule.requires()), 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; } } }
pattern = new Rule(KORE.KVariable("Result"), BooleanUtils.TRUE, BooleanUtils.TRUE, KORE.Att()); parsedPattern = pattern;
private Rule resolve(Rule rule) { resetVars(); gatherVars(rule.body()); gatherVars(rule.requires()); gatherVars(rule.ensures()); return new Rule( transform(rule.body()), transform(rule.requires()), transform(rule.ensures()), rule.att()); }
private Rule close(Rule rule) { resetVars(); gatherVars(rule.body()); gatherVars(rule.requires()); gatherVars(rule.ensures()); return new Rule( transform(rule.body()), transform(rule.requires()), transform(rule.ensures()), rule.att()); }
public Sentence apply(Sentence s) { if (s.att().contains(Attribute.MACRO_KEY) || s.att().contains(Attribute.ALIAS_KEY) || s.att().contains(Attribute.ANYWHERE_KEY)) { return s; } if (s instanceof Rule) { Rule rule = (Rule) s; return new Rule(apply(rule.body()), rule.requires(), rule.ensures(), rule.att()); } else if (s instanceof Context) { Context context = (Context) s; return new Context(apply(context.body()), context.requires(), context.att()); } else { return s; } }
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()); }
private Rule resolve(Rule rule) { resetVars(); gatherVars(rule.body()); gatherVars(rule.requires()); gatherVars(rule.ensures()); gatherTerms(rule.body(), true); gatherTerms(rule.requires(), false); gatherTerms(rule.ensures(), false); filterTerms(rule.body(), true); filterTerms(rule.requires(), false); filterTerms(rule.ensures(), false); return new Rule( transform(rule.body(), true), transform(rule.requires(), false), transform(rule.ensures(), false), rule.att()); }
/** Ensure that the splitting in {@linkplain #testPredicateExpansion()} does not happen * in a term which applies the sort predicate for a <em>different</em> cell fragment sort * to a cell fragment variable. */ @Test public void testUnrelatedPredicate() { Rule term = new Rule(KRewrite(cell("<t>", cell("<env>"), KVariable("X"), KVariable("Y", Att().add(Sort.class, Sort("OptCell")))), KVariable("X")) , app("isTopCellFragment",KVariable("X")) , BooleanUtils.TRUE , Att()); K replacement = app("<t>-fragment", KVariable("X"), app("noEnvCell"), app(".OptCell")); K expectedBody = KRewrite(cell("<t>", KVariable("X"), cell("<env>"), KVariable("Y", Att().add(Sort.class, Sort("OptCell")))), replacement); Rule expected = new Rule(expectedBody , app("isTopCellFragment", replacement) , BooleanUtils.TRUE, Att()); KExceptionManager kem = new KExceptionManager(new GlobalOptions()); Assert.assertEquals(expected, new SortCells(cfgInfo, labelInfo).sortCells(term)); Assert.assertEquals(0, kem.getExceptions().size()); }
/** When a cell fragment variable occurs as an argument to the appropriate cell fragment sort predict, we * specialize the expansion by splitting it into a conjunction of individual sort predicate tests on * the variables the cell fragment variable splits into, rather than just using the generic replacement term. * This is a very special case of statically simplifying predicate applications. */ @Test public void testPredicateExpansion() { Rule term = new Rule(KRewrite(cell("<t>", cell("<env>"), KVariable("X"), KVariable("Y", Att().add(Sort.class, Sort("OptCell")))), KVariable("X")) , app("isThreadCellFragment",KVariable("X")) , BooleanUtils.TRUE , Att()); K expectedBody = KRewrite(cell("<t>", KVariable("X"), cell("<env>"), KVariable("Y", Att().add(Sort.class, Sort("OptCell")))), cell("<t>-fragment", KVariable("X"), app("noEnvCell"), app(".OptCell"))); Rule expected = new Rule(expectedBody , BooleanUtils.and(BooleanUtils.TRUE, app("isKCell", KVariable("X"))) , BooleanUtils.TRUE, Att()); KExceptionManager kem = new KExceptionManager(new GlobalOptions()); Assert.assertEquals(expected, new SortCells(cfgInfo, labelInfo).sortCells(term)); Assert.assertEquals(0, kem.getExceptions().size()); }