Skip to content

Commit aae13fa

Browse files
manually transferred and adapted from #3393 (due to changes in EqualityModuloProofIrrelevancy)
1 parent 7aaf2ce commit aae13fa

3 files changed

Lines changed: 177 additions & 14 deletions

File tree

key.core/src/main/java/de/uka/ilkd/key/proof/replay/AbstractProofReplayer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ private TacletApp constructTacletApp(Node originalStep, Goal currGoal) {
227227
Taclet t = proof.getInitConfig().lookupActiveTaclet(new Name(tacletName));
228228
if (t == null) {
229229
// find the correct taclet
230-
for (var partialApp : currGoal.indexOfTaclets().getPartialInstantiatedApps()) {
230+
for (NoPosTacletApp partialApp : currGoal.indexOfTaclets()
231+
.getPartialInstantiatedApps()) {
232+
System.out.println();
231233
if (EqualityModuloProofIrrelevancy.equalsModProofIrrelevancy(partialApp,
232234
originalTacletApp)) {
233235
ourApp = partialApp;
@@ -239,7 +241,8 @@ private TacletApp constructTacletApp(Node originalStep, Goal currGoal) {
239241
}
240242
if (ourApp == null) {
241243
throw new IllegalStateException(
242-
"proof replayer failed to find dynamically added taclet");
244+
"proof replayer failed to find dynamically added taclet at original node "
245+
+ originalStep.serialNr());
243246
}
244247
} else {
245248
ourApp = NoPosTacletApp.createNoPosTacletApp(t);

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

Lines changed: 168 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
import de.uka.ilkd.key.logic.JavaBlock;
1515
import de.uka.ilkd.key.logic.op.*;
1616
import de.uka.ilkd.key.rule.inst.SVInstantiations;
17+
import de.uka.ilkd.key.rule.tacletbuilder.AntecSuccTacletGoalTemplate;
18+
import de.uka.ilkd.key.rule.tacletbuilder.RewriteTacletGoalTemplate;
1719

1820
import org.key_project.logic.op.Operator;
1921
import org.key_project.logic.sort.Sort;
2022
import org.key_project.prover.rules.RuleApp;
2123
import org.key_project.prover.rules.instantiation.AssumesFormulaInstantiation;
24+
import org.key_project.prover.rules.tacletbuilder.TacletGoalTemplate;
2225
import org.key_project.prover.sequent.PosInOccurrence;
26+
import org.key_project.prover.sequent.Semisequent;
2327
import org.key_project.prover.sequent.Sequent;
2428
import org.key_project.prover.sequent.SequentFormula;
2529
import org.key_project.util.EqualsModProofIrrelevancyUtil;
@@ -286,9 +290,7 @@ public static int hashCodeModProofIrrelevancy(JavaBlock jb) {
286290
* @param that the second SequentFormula
287291
* @return true if both arguments are equal modulo proof irrelevancy
288292
*/
289-
public static boolean equalsModProofIrrelevancy(
290-
SequentFormula _this,
291-
SequentFormula that) {
293+
public static boolean equalsModProofIrrelevancy(SequentFormula _this, SequentFormula that) {
292294
if (_this == that) {
293295
return true;
294296
}
@@ -306,11 +308,70 @@ public static boolean equalsModProofIrrelevancy(
306308
* @param sf the {@link SequentFormula} for which to compute the hash
307309
* @return the hash code modulo proof irrelevancy for the given argument
308310
*/
309-
public static int hashCodeModProofIrrelevancy(
310-
SequentFormula sf) {
311+
public static int hashCodeModProofIrrelevancy(SequentFormula sf) {
311312
return PROOF_IRRELEVANCY_PROPERTY.hashCodeModThisProperty((JTerm) sf.formula());
312313
}
313314

315+
// Sequent
316+
317+
/**
318+
* test for equality modulo proof irrelevancy for the given arguments
319+
*
320+
* @param _this the first Sequent
321+
* @param that the second Sequent
322+
* @return true if both arguments are equal modulo proof irrelevancy
323+
*/
324+
public static boolean equalsModProofIrrelevancy(Sequent _this, Sequent that) {
325+
if (_this == that) {
326+
return true;
327+
} else if (_this == null || that == null) {
328+
return false;
329+
}
330+
return equalsModProofIrrelevancy(_this.antecedent(), that.antecedent())
331+
&& equalsModProofIrrelevancy(_this.succedent(), that.succedent());
332+
}
333+
334+
/**
335+
* computes the hash code modulo proof irrelevancy for the given argument
336+
*
337+
* @param sequent the {@link Sequent} for which to compute the hash
338+
* @return the hash code modulo proof irrelevancy for the given argument
339+
*/
340+
public static int hashCodeModProofIrrelevancy(Sequent sequent) {
341+
return Objects.hash(hashCodeModProofIrrelevancy(sequent.antecedent()),
342+
hashCodeModProofIrrelevancy(sequent.succedent()));
343+
}
344+
345+
// Semisequent
346+
347+
/**
348+
* test for equality modulo proof irrelevancy for the given arguments
349+
*
350+
* @param _this the first Semisequent
351+
* @param that the second Semisequent
352+
* @return true if both arguments are equal modulo proof irrelevancy
353+
*/
354+
public static boolean equalsModProofIrrelevancy(Semisequent _this, Semisequent that) {
355+
if (_this == that) {
356+
return true;
357+
} else if (_this == null || that == null) {
358+
return false;
359+
}
360+
return EqualsModProofIrrelevancyUtil.compareImmutableLists(_this.asList(), that.asList(),
361+
EqualityModuloProofIrrelevancy::equalsModProofIrrelevancy);
362+
}
363+
364+
/**
365+
* computes the hash code modulo proof irrelevancy for the given argument
366+
*
367+
* @param semi the {@link Semisequent} for which to compute the hash
368+
* @return the hash code modulo proof irrelevancy for the given argument
369+
*/
370+
public static int hashCodeModProofIrrelevancy(Semisequent semi) {
371+
return EqualsModProofIrrelevancyUtil.hashCodeIterable(semi.asList(),
372+
EqualityModuloProofIrrelevancy::hashCodeModProofIrrelevancy);
373+
}
374+
314375
// RuleApp
315376

316377
/**
@@ -412,7 +473,8 @@ public static int hashCodeModProofIrrelevancy(IBuiltInRuleApp ruleApp) {
412473
* @param that the second Taclet
413474
* @return true if both arguments are equal modulo proof irrelevancy
414475
*/
415-
public static boolean equalsModProofIrrelevancy(Taclet _this, Taclet that) {
476+
public static boolean equalsModProofIrrelevancy(org.key_project.prover.rules.Taclet _this,
477+
org.key_project.prover.rules.Taclet that) {
416478
if (that == _this)
417479
return true;
418480

@@ -442,16 +504,17 @@ && equalsModProofIrrelevancy(if1.head(), if2.head())) {
442504
return false;
443505
}
444506

445-
return _this.goalTemplates().equals(that.goalTemplates());
507+
return EqualsModProofIrrelevancyUtil.compareImmutableLists(_this.goalTemplates(),
508+
that.goalTemplates(), EqualityModuloProofIrrelevancy::equalsModProofIrrelevancy);
446509
}
447510

448511
/**
449512
* computes the hash code modulo proof irrelevancy for the given argument
450513
*
451-
* @param taclet the {@link Taclet} for which to compute the hash
514+
* @param taclet the Taclet for which to compute the hash
452515
* @return the hash code modulo proof irrelevancy for the given argument
453516
*/
454-
public static int hashCodeModProofIrrelevancy(Taclet taclet) {
517+
public static int hashCodeModProofIrrelevancy(org.key_project.prover.rules.Taclet taclet) {
455518
Sequent sequentFormulas = taclet.assumesSequent();
456519
return hashCodeModProofIrrelevancy(sequentFormulas.getFormulaByNr(1));
457520
}
@@ -508,6 +571,102 @@ public static int hashCodeModProofIrrelevancy(TacletApp app) {
508571
app.rule());
509572
}
510573

574+
// TacletGoalTemplate
575+
576+
/**
577+
* test for equality modulo proof irrelevancy for the given arguments
578+
*
579+
* @param _this the first TacletGoalTemplate
580+
* @param that the second TacletGoalTemplate
581+
* @return true if both arguments are equal modulo proof irrelevancy
582+
*/
583+
public static boolean equalsModProofIrrelevancy(TacletGoalTemplate _this,
584+
TacletGoalTemplate that) {
585+
if (_this == that) {
586+
return true;
587+
} else if (_this == null || that == null) {
588+
return false;
589+
}
590+
return equalsModProofIrrelevancy(_this.sequent(), that.sequent())
591+
&& EqualsModProofIrrelevancyUtil.compareImmutableLists(_this.rules(), that.rules(),
592+
EqualityModuloProofIrrelevancy::equalsModProofIrrelevancy);
593+
}
594+
595+
/**
596+
* computes the hash code modulo proof irrelevancy for the given argument
597+
*
598+
* @param t the {@link TacletGoalTemplate} for which to compute the hash
599+
* @return the hash code modulo proof irrelevancy for the given argument
600+
*/
601+
public static int hashCodeModProofIrrelevancy(TacletGoalTemplate t) {
602+
return Objects.hash(hashCodeModProofIrrelevancy(t.sequent()),
603+
EqualsModProofIrrelevancyUtil.hashCodeImmutableList(t.rules(),
604+
EqualityModuloProofIrrelevancy::hashCodeModProofIrrelevancy));
605+
}
606+
607+
// AntecSuccTacletGoalTemplate
608+
609+
/**
610+
* test for equality modulo proof irrelevancy for the given arguments
611+
*
612+
* @param _this the first AntecSuccTacletGoalTemplate
613+
* @param that the second AntecSuccTacletGoalTemplate
614+
* @return true if both arguments are equal modulo proof irrelevancy
615+
*/
616+
public static boolean equalsModProofIrrelevancy(AntecSuccTacletGoalTemplate _this,
617+
AntecSuccTacletGoalTemplate that) {
618+
if (_this == that) {
619+
return true;
620+
} else if (_this == null || that == null) {
621+
return false;
622+
}
623+
return equalsModProofIrrelevancy((TacletGoalTemplate) _this, (TacletGoalTemplate) that)
624+
&& equalsModProofIrrelevancy(_this.replaceWith(), that.replaceWith());
625+
}
626+
627+
/**
628+
* computes the hash code modulo proof irrelevancy for the given argument
629+
*
630+
* @param t the {@link AntecSuccTacletGoalTemplate} for which to compute the hash
631+
* @return the hash code modulo proof irrelevancy for the given argument
632+
*/
633+
public static int hashCodeModProofIrrelevancy(AntecSuccTacletGoalTemplate t) {
634+
return Objects.hash(hashCodeModProofIrrelevancy((TacletGoalTemplate) t),
635+
hashCodeModProofIrrelevancy(t.replaceWith()));
636+
}
637+
638+
// RewriteTacletGoalTemplate
639+
640+
/**
641+
* test for equality modulo proof irrelevancy for the given arguments
642+
*
643+
* @param _this the first RewriteTacletGoalTemplate
644+
* @param that the second RewriteTacletGoalTemplate
645+
* @return true if both arguments are equal modulo proof irrelevancy
646+
*/
647+
public static boolean equalsModProofIrrelevancy(RewriteTacletGoalTemplate _this,
648+
RewriteTacletGoalTemplate that) {
649+
if (_this == that) {
650+
return true;
651+
} else if (_this == null || that == null) {
652+
return false;
653+
}
654+
return equalsModProofIrrelevancy((TacletGoalTemplate) _this, (TacletGoalTemplate) that)
655+
&& _this.replaceWith().equalsModProperty(that.replaceWith(),
656+
PROOF_IRRELEVANCY_PROPERTY);
657+
}
658+
659+
/**
660+
* computes the hash code modulo proof irrelevancy for the given argument
661+
*
662+
* @param t the {@link RewriteTacletGoalTemplate} for which to compute the hash
663+
* @return the hash code modulo proof irrelevancy for the given argument
664+
*/
665+
public static int hashCodeModProofIrrelevancy(RewriteTacletGoalTemplate t) {
666+
return Objects.hash(hashCodeModProofIrrelevancy((TacletGoalTemplate) t),
667+
t.replaceWith().hashCodeModProperty(PROOF_IRRELEVANCY_PROPERTY));
668+
}
669+
511670
// MatchConditions
512671
/**
513672
* test for equality modulo proof irrelevancy for the given arguments

key.util/src/main/java/org/key_project/util/EqualsModProofIrrelevancyUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ public static <T> int hashCodeIterable(Iterable<T> iter, ToIntFunction<T> hasher
7676
* @param b second list
7777
* @return whether they are equal (same length, equal elements)
7878
*/
79-
public static <T> boolean compareImmutableLists(
80-
ImmutableList<T> a, ImmutableList<T> b, BiPredicate<T, T> cmp) {
79+
public static <T> boolean compareImmutableLists(ImmutableList<? extends T> a,
80+
ImmutableList<? extends T> b,
81+
BiPredicate<? super T, ? super T> cmp) {
8182
if (a == b || (a == null && b.size() == 0) || (b == null && a.size() == 0)) {
8283
return true;
8384
}
8485
if (a == null || b == null || (a.size() != b.size())) {
8586
return false;
8687
}
87-
ImmutableList<T> remainderToCompare = a;
88+
ImmutableList<? extends T> remainderToCompare = a;
8889
while (!remainderToCompare.isEmpty()) {
8990
final T obj1 = remainderToCompare.head();
9091
if (!cmp.test(obj1, b.head())) {

0 commit comments

Comments
 (0)