Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Func claims translation to KORE #2733

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private RewriterResult executeKoreCommands(Module rules, String[] koreCommand,
@Override
public RewriterResult prove(Module rules, Rule boundaryPattern, Boolean reuseDef) {
Module kompiledModule = KoreBackend.getKompiledModule(module);
ModuleToKORE converter = new ModuleToKORE(kompiledModule, def.topCellInitializer, kompileOptions);
ModuleToKORE converter = new ModuleToKORE(kompiledModule, def.topCellInitializer, kompileOptions, kem);
String defPath = reuseDef ? files.resolveKompiled("definition.kore").getAbsolutePath() : saveKoreDefinitionToTemp(converter);
String specPath = saveKoreSpecToTemp(converter, rules);
File koreOutputFile = files.resolveTemp("result.kore");
Expand Down
19 changes: 17 additions & 2 deletions kernel/src/main/java/org/kframework/backend/kore/ModuleToKORE.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import org.kframework.unparser.Formatter;
import org.kframework.utils.StringUtil;
import org.kframework.utils.errorsystem.KEMException;
import org.kframework.utils.errorsystem.KException;
import org.kframework.utils.errorsystem.KExceptionManager;
import scala.Option;
import scala.Tuple2;
import scala.collection.JavaConverters;
Expand Down Expand Up @@ -107,7 +109,14 @@ public enum SentenceType {
private final Set<String> mlBinders = new HashSet<>();
private final KompileOptions options;

private final KExceptionManager kem;

public ModuleToKORE(Module module, KLabel topCellInitializer, KompileOptions options) {
this(module, topCellInitializer, options, null);
}

public ModuleToKORE(Module module, KLabel topCellInitializer, KompileOptions options, KExceptionManager kem) {
this.kem = kem;
this.module = module;
this.addSortInjections = new AddSortInjections(module);
this.topCellInitializer = topCellInitializer;
Expand Down Expand Up @@ -941,7 +950,13 @@ private void convertRule(RuleOrClaim rule, int ruleIndex, boolean heatCoolEq, St
.stream().collect(Collectors.toMap(KVariable::name, Function.identity()));
if (ruleInfo.isEquation) {
assertNoExistentials(rule, existentials);
sb.append(" axiom{R");
if (rule instanceof Claim) {
sb.append(" claim{R");
if (kem != null) // TODO: remove once https://github.com/runtimeverification/haskell-backend/issues/3010 is implemented
kem.registerCompilerWarning(KException.ExceptionType.FUTURE_ERROR, "Functional claims not yet supported. https://github.com/runtimeverification/haskell-backend/issues/3010", rule);
} else {
sb.append(" axiom{R");
}
Option<Sort> sortParamsWrapper = rule.att().getOption("sortParams", Sort.class);
Option<Set<String>> sortParams = sortParamsWrapper.map(s -> stream(s.params()).map(sort -> sort.name()).collect(Collectors.toSet()));
if (sortParams.nonEmpty()) {
Expand Down Expand Up @@ -1054,7 +1069,7 @@ private void convertRule(RuleOrClaim rule, int ruleIndex, boolean heatCoolEq, St
sb.append(")))\n ");
convert(consideredAttributes, rule.att(), sb, freeVarsMap, rule);
sb.append("\n\n");
} else if (rule.att().contains(Att.SIMPLIFICATION())) {
} else if (rule.att().contains(Att.SIMPLIFICATION()) || rule instanceof Claim) {
sb.append("\\implies{R} (\n ");
convertSideCondition(requires, sb);
sb.append(",\n \\equals{");
Expand Down