private boolean isPredicate(Rule r) { return getPredicateSort(r).isPresent(); }
public static String getKompiledString(Module mainModule, KLabel topCellInitializer, FileUtil files, boolean heatCoolEquations) { mainModule = new GenerateSortPredicateRules(true).gen(mainModule); mainModule = ModuleTransformer.fromKTransformer(new AddSortInjections(mainModule)::addInjections, "Add sort injections").apply(mainModule); mainModule = ModuleTransformer.fromSentenceTransformer(new MinimizeTermConstruction(mainModule)::resolve, "Minimize term construction").apply(mainModule); ModuleToKORE moduleToKORE = new ModuleToKORE(mainModule, files, topCellInitializer); String kompiledString = moduleToKORE.convert(heatCoolEquations); Properties koreToKLabels = new Properties(); koreToKLabels.putAll(moduleToKORE.getKToKoreLabelMap().inverse()); try { FileOutputStream output = new FileOutputStream(files.resolveKompiled("kore_to_k_labels.properties")); koreToKLabels.store(output, "Properties file containing the mapping from kore to k labels"); } catch (IOException e) { throw KEMException.criticalError("Error while saving kore to K labels map", e); } return kompiledString; }
private Stream<? extends Sentence> gen(Sort sort) { if (kore) { return genKore(sort); MutableBoolean isProtecting = new MutableBoolean(true); stream(mod.definedSorts()).filter(s -> mod.subsorts().lessThanEq(s, subsort)).forEach(candidateSort -> { if (predicateRules.stream().filter(r -> isPredicateFor(r, candidateSort)).findAny().isPresent()) { BooleanUtils.TRUE)); if (nonProtectingSubsorts.contains(s)) { res.addAll(predicateRules.stream().filter(r -> isPredicateFor(r, s)).filter(this::isTruePredicate).map(r -> promotePredicate(r, sort)).collect(Collectors.toList()));
public void initialize(CompiledDefinition def) { Function1<Module, Module> generatePredicates = new GenerateSortPredicateRules(false)::gen; this.convertDataStructure = new ConvertDataStructureToLookup(def.executionModule(), true); ModuleTransformer convertLookups = ModuleTransformer.fromSentenceTransformer(convertDataStructure::convert, "convert data structures to lookups");
private boolean isPredicateFor(Rule r, Sort s) { Optional<Sort> sort = getPredicateSort(r); return sort.isPresent() && sort.get().equals(s); }