Skip to content

Commit 52c42c2

Browse files
Only group rule apps on the same pos
1 parent 985de87 commit 52c42c2

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.key_project.util.collection.ImmutableList;
1414
import org.key_project.util.collection.ImmutableSLList;
1515

16-
public abstract class AbstractBuiltInRuleApp implements IBuiltInRuleApp {
16+
public abstract class AbstractBuiltInRuleApp implements IBuiltInRuleApp, PosRuleApp {
1717
public static final AtomicLong PERF_EXECUTE = new AtomicLong();
1818
public static final AtomicLong PERF_SET_SEQUENT = new AtomicLong();
1919

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package de.uka.ilkd.key.rule;
2+
3+
import de.uka.ilkd.key.logic.PosInOccurrence;
4+
5+
/**
6+
* Interface for rule applications with associated position information.
7+
*
8+
* @author Arne Keller
9+
*/
10+
public interface PosRuleApp {
11+
/**
12+
* @return the position the rule was applied on
13+
*/
14+
PosInOccurrence posInOccurrence();
15+
}

key.core/src/main/java/de/uka/ilkd/key/rule/PosTacletApp.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* ({@link de.uka.ilkd.key.rule.NoPosTacletApp}) is used to keep track of the (partial)
2525
* instantiation information.
2626
*/
27-
public class PosTacletApp extends TacletApp {
27+
public class PosTacletApp extends TacletApp implements PosRuleApp {
2828

2929
/**
3030
* stores the information where the Taclet is to be applied. This means where the find section
@@ -68,18 +68,6 @@ public static PosTacletApp createPosTacletApp(FindTaclet taclet, MatchConditions
6868
return createPosTacletApp(taclet, matchCond.getInstantiations(), null, pos, services);
6969
}
7070

71-
72-
/**
73-
* creates a PosTacletApp for the given taclet and a position information
74-
*
75-
* @param taclet the FindTaclet
76-
* @param pos the PosInOccurrence storing the position where to apply the Taclet
77-
*/
78-
private PosTacletApp(FindTaclet taclet, PosInOccurrence pos) {
79-
super(taclet);
80-
this.pos = pos;
81-
}
82-
8371
/**
8472
* creates a PosTacletApp for the given taclet with some known instantiations and a position
8573
* information

keyext.slicing/src/main/java/org/key_project/slicing/ProofRegroup.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@
77

88
import de.uka.ilkd.key.proof.Node;
99
import de.uka.ilkd.key.proof.Proof;
10+
import de.uka.ilkd.key.rule.PosRuleApp;
1011
import de.uka.ilkd.key.rule.Rule;
1112
import de.uka.ilkd.key.rule.RuleApp;
1213
import de.uka.ilkd.key.rule.Taclet;
1314

15+
import org.key_project.slicing.graph.DependencyGraph;
16+
1417
public final class ProofRegroup {
1518
private static final List<List<String>> GROUPS =
1619
List.of(List.of("alpha", "delta"), List.of("negationNormalForm", "conjNormalForm"),
1720
List.of("polySimp_expand", "polySimp_normalise", "polySimp_newSym",
1821
"polySimp_pullOutGcd", "polySimp_applyEq", "polySimp_applyEqRigid",
1922
"simplify_literals"));
2023

21-
public static void regroupProof(Proof proof) {
24+
public static void regroupProof(Proof proof, DependencyGraph graph) {
2225
/*
2326
* alpha, delta
2427
* negationNormalForm, conjNormalForm
@@ -57,8 +60,17 @@ public static void regroupProof(Proof proof) {
5760
break;
5861
}
5962
var n2 = n.child(0);
60-
var rule2 = n2.getAppliedRuleApp().rule();
61-
if (rule2 instanceof Taclet) {
63+
var r2 = n2.getAppliedRuleApp();
64+
var rule2 = r2.rule();
65+
if (r2 instanceof PosRuleApp && rule2 instanceof Taclet) {
66+
var p2 = (PosRuleApp) r2;
67+
var graphNode = graph.getGraphNode(proof, n2.getBranchLocation(),
68+
p2.posInOccurrence());
69+
Node finalN = n;
70+
if (graph.edgesProducing(graphNode)
71+
.noneMatch(a -> a.getProofStep() == finalN)) {
72+
break;
73+
}
6274
var ruleSets2 = ((Taclet) rule2).getRuleSets();
6375
var found = false;
6476
for (var name : ruleSets2) {

keyext.slicing/src/main/java/org/key_project/slicing/SlicingExtension.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ public JToolBar getToolbar(MainWindow mainWindow) {
198198
b2.addActionListener(e -> {
199199
KeYMediator m = MainWindow.getInstance().getMediator();
200200
try {
201-
ProofRegroup.regroupProof(m.getSelectedProof());
201+
ProofRegroup.regroupProof(m.getSelectedProof(),
202+
trackers.get(m.getSelectedProof()).getDependencyGraph());
202203
} catch (Exception exc) {
203204
exc.printStackTrace();
204205
}

0 commit comments

Comments
 (0)