Skip to content

Commit 1df3200

Browse files
committed
fix double Taclet problem
1 parent af811cc commit 1df3200

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

key.core/src/main/java/de/uka/ilkd/key/proof/init/AbstractPO.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,9 @@ public final ProofAggregate getPO() {
423423
}
424424
proofs[i] = createProof(poNames != null ? poNames[i] : name, poTerms[i], ic);
425425
if (taclets != null) {
426-
proofs[i].getOpenGoal(proofs[i].root()).indexOfTaclets().addTaclets(taclets);
426+
var filteredTaclets = proofs[i].getInitConfig().filterTaclets(taclets);
427+
proofs[i].getOpenGoal(proofs[i].root()).indexOfTaclets()
428+
.addTaclets(filteredTaclets);
427429
}
428430
}
429431

key.core/src/main/java/de/uka/ilkd/key/proof/init/InitConfig.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import de.uka.ilkd.key.proof.mgt.RuleJustification;
1818
import de.uka.ilkd.key.proof.mgt.RuleJustificationByAddRules;
1919
import de.uka.ilkd.key.proof.mgt.RuleJustificationInfo;
20-
import de.uka.ilkd.key.rule.*;
20+
import de.uka.ilkd.key.rule.BuiltInRule;
21+
import de.uka.ilkd.key.rule.NoPosTacletApp;
22+
import de.uka.ilkd.key.rule.Rule;
23+
import de.uka.ilkd.key.rule.Taclet;
2124
import de.uka.ilkd.key.rule.tacletbuilder.TacletBuilder;
2225
import de.uka.ilkd.key.settings.ProofSettings;
2326

@@ -75,10 +78,14 @@ public class InitConfig {
7578
*/
7679
private ImmutableSet<Choice> activatedChoices = DefaultImmutableSet.nil();
7780

78-
/** HashMap for quick lookups taclet name->taclet */
81+
/**
82+
* HashMap for quick lookups taclet name->taclet
83+
*/
7984
private Map<Name, Taclet> activatedTacletCache = null;
8085

81-
/** the fileRepo which is responsible for consistency between source code and proof */
86+
/**
87+
* the fileRepo which is responsible for consistency between source code and proof
88+
*/
8289
private FileRepo fileRepo;
8390

8491
// weigl this field is never set
@@ -106,7 +113,6 @@ public InitConfig(Services services) {
106113
// -------------------------------------------------------------------------
107114

108115

109-
110116
// -------------------------------------------------------------------------
111117
// public interface
112118
// -------------------------------------------------------------------------
@@ -255,7 +261,7 @@ private void fillActiveTacletCache() {
255261
if (activatedTacletCache != null) {
256262
return;
257263
}
258-
final LinkedHashMap<Name, Taclet> tacletCache = new LinkedHashMap<>();
264+
final Map<Name, Taclet> tacletCache = new TreeMap<>();
259265
var choices = Collections.unmodifiableSet(activatedChoices.toSet());
260266
for (Taclet t : taclets) {
261267
TacletBuilder<? extends Taclet> b = taclet2Builder.get(t);
@@ -266,6 +272,9 @@ private void fillActiveTacletCache() {
266272
}
267273

268274
if (t != null) {
275+
if (tacletCache.containsKey(t.name())) {
276+
throw new IllegalArgumentException();
277+
}
269278
tacletCache.put(t.name(), t);
270279
}
271280
}
@@ -441,7 +450,6 @@ public InitConfig copyWithServices(Services services) {
441450
}
442451

443452

444-
445453
@Override
446454
public String toString() {
447455
return "Namespaces:" + namespaces() + "\n" + "Services:" + services + "\n" + "Taclets:"
@@ -474,4 +482,19 @@ public void activateChoice(Choice choice) {
474482
public void setHeader(KeyAst.@Nullable Declarations header) {
475483
this.header = header;
476484
}
485+
486+
public Collection<NoPosTacletApp> filterTaclets(ImmutableSet<NoPosTacletApp> taclets) {
487+
var result = new HashMap<Name, NoPosTacletApp>();
488+
var choices = Collections.unmodifiableSet(activatedChoices.toSet());
489+
for (var app : taclets) {
490+
var t = app.taclet();
491+
if (t.getChoices().eval(choices)) {
492+
if (result.containsKey(t.name())) {
493+
throw new IllegalArgumentException("Duplicate choice: " + t.name() + " by PO");
494+
}
495+
result.put(t.name(), app);
496+
}
497+
}
498+
return result.values();
499+
}
477500
}

key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/TacletExecutor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ protected void applyAddrule(ImmutableList<? extends org.key_project.prover.rules
168168
for (var tacletToAdd : rules) {
169169
final Node n = goal.node();
170170
String name = tacletToAdd.name() + AUTO_NAME + n.getUniqueTacletId();
171-
System.out.println(name);
172171
tacletToAdd = tacletToAdd.setName(name);
173172

174173

0 commit comments

Comments
 (0)