Пример #1
0
  @Override
  public KRunProofResult<Set<org.kframework.kil.Term>> prove(Module module)
      throws KRunExecutionException {
    TermContext termContext = TermContext.of(globalContext);
    List<Rule> rules = new ArrayList<Rule>();
    for (org.kframework.kil.ModuleItem moduleItem : module.getItems()) {
      if (!(moduleItem instanceof org.kframework.kil.Rule)) {
        continue;
      }

      Rule rule = transformer.transformAndEval((org.kframework.kil.Rule) moduleItem);
      Rule freshRule = rule.getFreshRule(termContext);
      rules.add(freshRule);
    }

    CounterGetter counterGetter = new CounterGetter(context);
    counterGetter.visitNode(module);
    BigInteger counter = counterGetter.counter.add(BigInteger.ONE);

    SymbolicRewriter symbolicRewriter = executor.getSymbolicRewriter();
    List<ConstrainedTerm> proofResults = new ArrayList<>();
    for (org.kframework.kil.ModuleItem moduleItem : module.getItems()) {
      if (!(moduleItem instanceof org.kframework.kil.Rule)
          || moduleItem.containsAttribute(Attribute.TRUSTED_KEY)) {
        continue;
      }

      termContext.setCounter(counter);
      Rule rule = transformer.transformAndEval((org.kframework.kil.Rule) moduleItem);
      ConstrainedTerm initialTerm =
          new ConstrainedTerm(
              rule.leftHandSide(), ConjunctiveFormula.of(termContext).addAll(rule.requires()));
      ConstrainedTerm targetTerm =
          new ConstrainedTerm(
              rule.rightHandSide(), ConjunctiveFormula.of(termContext).addAll(rule.ensures()));
      proofResults.addAll(symbolicRewriter.proveRule(initialTerm, targetTerm, rules));
    }

    return new KRunProofResult<>(
        proofResults.isEmpty(), Collections.<org.kframework.kil.Term>emptySet());
  }
Пример #2
0
 @Override
 public Module preprocess(Module module, Term cfg) throws KRunExecutionException {
   Map<Term, Term> substitution = null;
   if (cfg != null) {
     cfg = executor.run(cfg, false).getFinalState().getRawResult();
     cfg = (Term) (new DataStructure2Cell(context)).visitNode(cfg);
     ConfigurationSubstitutionVisitor configurationSubstitutionVisitor =
         new ConfigurationSubstitutionVisitor(context);
     configurationSubstitutionVisitor.visitNode(cfg);
     substitution = configurationSubstitutionVisitor.getSubstitution();
     //            System.out.println(substitution);
     Module mod = module;
     mod = (Module) new Substitution(substitution, context).visitNode(module);
     //                System.out.println(mod.toString());
     module = mod;
   }
   try {
     module = new SpecificationCompilerSteps(context, kem).compile(module, null);
   } catch (CompilerStepDone e) {
     assert false : "dead code";
   }
   return module;
 }