From b41c2b79ffd3b3b068fea3f3a8e3ba22d4d9b6b3 Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 27 Mar 2024 08:53:50 +0100 Subject: [PATCH 01/15] API design --- .../org/key_project/logic/SyntaxElement.java | 3 +++ .../logic/SyntaxElementCursor.java | 23 +++++++++++++++++++ .../logic/SyntaxElementCursorNode.java | 4 ++++ 3 files changed, 30 insertions(+) create mode 100644 key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java create mode 100644 key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java index 244f53bbe4b..347ec52dd1b 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java @@ -8,4 +8,7 @@ * AST nodes. */ public interface SyntaxElement { + SyntaxElement getChild(int child); + + int getChildCount(); } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java new file mode 100644 index 00000000000..ee6ad7d01ee --- /dev/null +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -0,0 +1,23 @@ +package org.key_project.logic; + +public class SyntaxElementCursor { + public SyntaxElement getCurrentNode() { + return null; + } + + public SyntaxElementCursorNode getCurrentTreeCursorNode() { + return null; + } + + public boolean gotoFirstChild() { + return false; + } + + public boolean gotoNextSibling() { + return false; + } + + public boolean gotoParent() { + return false; + } +} diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java new file mode 100644 index 00000000000..f6494c6efd3 --- /dev/null +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java @@ -0,0 +1,4 @@ +package org.key_project.logic; + +public record SyntaxElementCursorNode(String type, String name) { +} From 179d71e8b65e1f357cbb6774fd71703a203b1da7 Mon Sep 17 00:00:00 2001 From: Drodt Date: Thu, 2 May 2024 10:18:09 +0200 Subject: [PATCH 02/15] Increase Java version --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586a54a..48c0a02ca41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From c168bb765ca93673a929ceff446abd852882c990 Mon Sep 17 00:00:00 2001 From: Drodt Date: Thu, 2 May 2024 11:08:10 +0200 Subject: [PATCH 03/15] Implement cursor --- .../org/key_project/logic/SyntaxElement.java | 12 +++++- .../logic/SyntaxElementCursor.java | 37 +++++++++++++++---- .../logic/SyntaxElementCursorNode.java | 4 -- 3 files changed, 41 insertions(+), 12 deletions(-) delete mode 100644 key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java index 347ec52dd1b..a9e2a7e0bd0 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java @@ -8,7 +8,17 @@ * AST nodes. */ public interface SyntaxElement { - SyntaxElement getChild(int child); + /** + * Get the {@code n}-th child of this syntax element. + * @param n index of the child. + * @return the {@code n}-th child of this syntax element. + * @throws IndexOutOfBoundsException if there is no {@code n}-th child. + */ + SyntaxElement getChild(int n); + /** + * + * @return the number of children of this syntax element. + */ int getChildCount(); } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index ee6ad7d01ee..fdc3e6013cd 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -1,23 +1,46 @@ package org.key_project.logic; +import java.util.ArrayDeque; +import java.util.Deque; + public class SyntaxElementCursor { - public SyntaxElement getCurrentNode() { - return null; + record ParentAndPosition(SyntaxElement parent, int index) {} + + private final Deque path = new ArrayDeque<>(); + + private SyntaxElement node; + + SyntaxElementCursor(SyntaxElement node) { + this.node = node; } - public SyntaxElementCursorNode getCurrentTreeCursorNode() { - return null; + public SyntaxElement getCurrentNode() { + return node; } public boolean gotoFirstChild() { - return false; + if (node.getChildCount() <= 0) return false; + path.push(new ParentAndPosition(node, 0)); + node = node.getChild(0); + return true; } public boolean gotoNextSibling() { - return false; + if (path.isEmpty()) return false; + var pnp = path.pop(); + SyntaxElement parent = pnp.parent; + int index =pnp.index+1; + if (index > parent.getChildCount()) { + return false; + } + path.push(new ParentAndPosition(parent, index)); + node = parent.getChild(index); + return true; } public boolean gotoParent() { - return false; + if (path.isEmpty()) return false; + node = path.pop().parent; + return true; } } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java deleted file mode 100644 index f6494c6efd3..00000000000 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursorNode.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.key_project.logic; - -public record SyntaxElementCursorNode(String type, String name) { -} From fe83fc86efccd3fa093e919886202e0718c1fa53 Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 8 May 2024 13:47:00 +0200 Subject: [PATCH 04/15] Start implementation of traversal --- .../MethodCallProofReferencesAnalyst.java | 2 +- .../ProgramVariableReferencesAnalyst.java | 2 +- .../slicing/AbstractBackwardSlicer.java | 2 +- .../slicing/AbstractSlicer.java | 2 +- .../breakpoint/ExceptionBreakpoint.java | 2 +- .../strategy/breakpoint/FieldWatchpoint.java | 4 +- .../SymbolicExecutionExceptionBreakpoint.java | 2 +- .../util/SymbolicExecutionUtil.java | 4 +- .../CcatchBreakLabelParameterDeclaration.java | 2 +- .../java/CcatchBreakParameterDeclaration.java | 2 +- ...atchBreakWildcardParameterDeclaration.java | 2 +- ...atchContinueLabelParameterDeclaration.java | 2 +- .../CcatchContinueParameterDeclaration.java | 2 +- ...hContinueWildcardParameterDeclaration.java | 2 +- .../CcatchReturnParameterDeclaration.java | 2 +- .../CcatchReturnValParameterDeclaration.java | 2 +- .../java/de/uka/ilkd/key/java/Comment.java | 12 ++++++ .../de/uka/ilkd/key/java/CompilationUnit.java | 6 +-- .../ilkd/key/java/ContextStatementBlock.java | 4 +- .../java/de/uka/ilkd/key/java/Import.java | 2 +- .../java/JavaNonTerminalProgramElement.java | 16 +++++--- .../key/java/NonTerminalProgramElement.java | 2 +- .../ilkd/key/java/PackageSpecification.java | 2 +- .../java/de/uka/ilkd/key/java/SourceData.java | 2 +- .../de/uka/ilkd/key/java/SourceElement.java | 4 +- .../de/uka/ilkd/key/java/StatementBlock.java | 2 +- .../ilkd/key/java/TerminalProgramElement.java | 11 +++++ .../java/declaration/ArrayDeclaration.java | 2 +- .../java/declaration/ClassDeclaration.java | 2 +- .../java/declaration/ClassInitializer.java | 2 +- .../java/declaration/FieldDeclaration.java | 2 +- .../declaration/InheritanceSpecification.java | 2 +- .../declaration/InterfaceDeclaration.java | 2 +- .../declaration/LocalVariableDeclaration.java | 2 +- .../java/declaration/MethodDeclaration.java | 4 +- .../declaration/ParameterDeclaration.java | 2 +- .../declaration/SuperArrayDeclaration.java | 2 +- .../uka/ilkd/key/java/declaration/Throws.java | 2 +- .../java/declaration/VariableDeclaration.java | 2 +- .../declaration/VariableSpecification.java | 6 +-- .../modifier/AnnotationUseSpecification.java | 2 +- .../key/java/expression/ArrayInitializer.java | 2 +- .../ilkd/key/java/expression/Operator.java | 2 +- .../expression/operator/ExactInstanceof.java | 2 +- .../java/expression/operator/Instanceof.java | 6 +-- .../key/java/expression/operator/New.java | 4 +- .../java/expression/operator/NewArray.java | 2 +- .../java/expression/operator/TypeCast.java | 2 +- .../java/reference/ArrayLengthReference.java | 2 +- .../key/java/reference/ArrayReference.java | 2 +- .../key/java/reference/ExecutionContext.java | 2 +- .../key/java/reference/FieldReference.java | 2 +- .../java/reference/MetaClassReference.java | 2 +- .../key/java/reference/MethodReference.java | 2 +- .../key/java/reference/PackageReference.java | 2 +- .../reference/SchematicFieldReference.java | 2 +- .../SpecialConstructorReference.java | 2 +- .../key/java/reference/SuperReference.java | 2 +- .../key/java/reference/ThisReference.java | 2 +- .../key/java/reference/TypeReferenceImp.java | 2 +- .../key/java/reference/VariableReference.java | 2 +- .../uka/ilkd/key/java/statement/Assert.java | 2 +- .../de/uka/ilkd/key/java/statement/Case.java | 2 +- .../de/uka/ilkd/key/java/statement/Catch.java | 2 +- .../key/java/statement/CatchAllStatement.java | 2 +- .../uka/ilkd/key/java/statement/Ccatch.java | 2 +- .../uka/ilkd/key/java/statement/Default.java | 2 +- .../de/uka/ilkd/key/java/statement/Else.java | 2 +- .../de/uka/ilkd/key/java/statement/Exec.java | 4 +- .../statement/ExpressionJumpStatement.java | 2 +- .../uka/ilkd/key/java/statement/Finally.java | 2 +- .../ilkd/key/java/statement/ForUpdates.java | 2 +- .../de/uka/ilkd/key/java/statement/Guard.java | 2 +- .../de/uka/ilkd/key/java/statement/If.java | 4 +- .../ilkd/key/java/statement/JmlAssert.java | 2 +- .../java/statement/LabelJumpStatement.java | 2 +- .../key/java/statement/LabeledStatement.java | 2 +- .../uka/ilkd/key/java/statement/LoopInit.java | 2 +- .../key/java/statement/LoopScopeBlock.java | 4 +- .../key/java/statement/LoopStatement.java | 2 +- .../java/statement/MergePointStatement.java | 2 +- .../java/statement/MethodBodyStatement.java | 2 +- .../ilkd/key/java/statement/MethodFrame.java | 8 ++-- .../ilkd/key/java/statement/SetStatement.java | 2 +- .../uka/ilkd/key/java/statement/Switch.java | 2 +- .../key/java/statement/SynchronizedBlock.java | 4 +- .../de/uka/ilkd/key/java/statement/Then.java | 2 +- .../java/statement/TransactionStatement.java | 2 +- .../de/uka/ilkd/key/java/statement/Try.java | 4 +- .../key/java/visitor/CreatingASTVisitor.java | 6 +-- .../key/java/visitor/FreeLabelFinder.java | 2 +- .../InnerBreakAndContinueReplacer.java | 4 +- .../ilkd/key/java/visitor/JavaASTWalker.java | 2 +- .../OuterBreakContinueAndReturnReplacer.java | 4 +- .../key/java/visitor/ProgramContextAdder.java | 6 +-- .../java/de/uka/ilkd/key/logic/JavaBlock.java | 17 +++++++- .../ilkd/key/logic/op/ElementaryUpdate.java | 13 ++++++ .../de/uka/ilkd/key/logic/op/Equality.java | 11 +++++ .../uka/ilkd/key/logic/op/IfExThenElse.java | 11 +++++ .../de/uka/ilkd/key/logic/op/IfThenElse.java | 11 +++++ .../de/uka/ilkd/key/logic/op/Junctor.java | 11 +++++ .../uka/ilkd/key/logic/op/LogicVariable.java | 11 +++++ .../ilkd/key/logic/op/ObserverFunction.java | 18 ++++++-- .../uka/ilkd/key/logic/op/ProgramMethod.java | 2 +- .../de/uka/ilkd/key/logic/op/ProgramSV.java | 2 +- .../ilkd/key/logic/op/ProgramVariable.java | 12 ++++++ .../de/uka/ilkd/key/logic/op/Qualifier.java | 41 +++++++++++++++++++ .../de/uka/ilkd/key/logic/op/Quantifier.java | 11 +++++ .../key/logic/op/SortDependingFunction.java | 21 ++++++++-- .../de/uka/ilkd/key/logic/op/SubstOp.java | 12 ++++++ .../de/uka/ilkd/key/logic/op/TermLabelSV.java | 2 +- .../ilkd/key/logic/op/UpdateApplication.java | 11 +++++ .../uka/ilkd/key/logic/op/UpdateJunctor.java | 11 +++++ .../ilkd/key/logic/sort/ProgramSVSort.java | 2 +- .../de/uka/ilkd/key/pp/PrettyPrinter.java | 2 +- .../de/uka/ilkd/key/proof/TacletIndex.java | 2 +- .../key/rule/LoopInvariantBuiltInRuleApp.java | 2 +- .../rule/conditions/StoreStmtInCondition.java | 2 +- .../metaconstruct/ProgramTransformer.java | 2 +- .../WhileLoopTransformation.java | 4 +- .../key/speclang/jml/JMLSpecExtractor.java | 2 +- .../key/java/TestContextStatementBlock.java | 2 +- .../org/key_project/logic/SyntaxElement.java | 3 +- .../logic/SyntaxElementCursor.java | 16 +++++--- .../main/java/org/key_project/logic/Term.java | 19 +++++++++ .../org/key_project/logic/op/Function.java | 11 +++++ .../org/key_project/logic/op/Modality.java | 28 ++++++++++++- .../org/key_project/logic/op/Operator.java | 3 +- .../ilkd/key/gui/sourceview/SourceView.java | 2 +- 129 files changed, 455 insertions(+), 150 deletions(-) create mode 100644 key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java diff --git a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java index 706723eaeab..07bee533ecd 100644 --- a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java +++ b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java @@ -59,7 +59,7 @@ public LinkedHashSet> computeReferences(Node node, Services s ExecutionContext context = extractContext(node, services); LinkedHashSet> result = new LinkedHashSet<>(); - for (int i = 0; i < assignment.getChildCount(); i++) { + for (int i = 0; i < assignment.getSyntaxChildCount(); i++) { ProgramElement child = assignment.getChildAt(i); if (child instanceof MethodReference) { IProofReference reference = diff --git a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java index e37beeaa55b..49c35b4f0e6 100644 --- a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java +++ b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java @@ -82,7 +82,7 @@ protected void listReferences(Node node, ProgramElement pe, ProgramVariable arra ProofReferenceUtil.merge(toFill, reference); } } else if (includeExpressionContainer && pe instanceof ExpressionContainer ec) { - for (int i = ec.getChildCount() - 1; i >= 0; i--) { + for (int i = ec.getSyntaxChildCount() - 1; i >= 0; i--) { ProgramElement element = ec.getChildAt(i); listReferences(node, element, arrayLength, toFill, includeExpressionContainer); } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java index bfb10ac3e91..20a6a6e091e 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java @@ -120,7 +120,7 @@ protected void updateRelevantLocations(final ProgramElement read, Location normalizedElement = normalizeAlias(services, relevantElement, info); relevantLocations.add(normalizedElement); } else if (read instanceof NonTerminalProgramElement ntpe) { - for (int i = 0; i < ntpe.getChildCount(); i++) { + for (int i = 0; i < ntpe.getSyntaxChildCount(); i++) { updateRelevantLocations(ntpe.getChildAt(i), relevantLocations, info, services); } } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java index 56ead50dddb..3aab95bc564 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java @@ -792,7 +792,7 @@ protected Location computeRepresentativeAlias(Location location, */ protected ReferencePrefix toReferencePrefix(SourceElement sourceElement) { if (sourceElement instanceof PassiveExpression) { - if (((PassiveExpression) sourceElement).getChildCount() != 1) { + if (((PassiveExpression) sourceElement).getSyntaxChildCount() != 1) { throw new IllegalStateException( "PassiveExpression '" + sourceElement + "' has not exactly one child."); } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java index bb81a7f3e64..74c23775aff 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java @@ -104,7 +104,7 @@ public boolean isBreakpointHit(SourceElement activeStatement, RuleApp ruleApp, P Node node) { Node SETParent = SymbolicExecutionUtil.findParentSetNode(node); if (activeStatement instanceof Throw throwStatement && isEnabled()) { - for (int i = 0; i < throwStatement.getChildCount(); i++) { + for (int i = 0; i < throwStatement.getSyntaxChildCount(); i++) { SourceElement childElement = throwStatement.getChildAt(i); if (childElement instanceof LocationVariable locVar) { if (locVar.getKeYJavaType().getSort().toString().equals(exceptionName) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java index d1082bca4c9..a3246cc6949 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java @@ -80,7 +80,7 @@ public boolean isBreakpointHit(SourceElement activeStatement, RuleApp ruleApp, P private boolean checkChildrenOfSourceElement(SourceElement sourceElement) { boolean found = false; if (sourceElement instanceof Assignment assignment) { - for (int i = 1; i < assignment.getChildCount(); i++) { + for (int i = 1; i < assignment.getSyntaxChildCount(); i++) { SourceElement childElement = assignment.getChildAt(i); if (childElement instanceof FieldReference field && ((FieldReference) childElement) .getProgramVariable().name().toString().equals(fullFieldName)) { @@ -93,7 +93,7 @@ private boolean checkChildrenOfSourceElement(SourceElement sourceElement) { } } } else if (sourceElement instanceof NonTerminalProgramElement programElement) { - for (int i = 0; i < programElement.getChildCount(); i++) { + for (int i = 0; i < programElement.getSyntaxChildCount(); i++) { SourceElement childElement = programElement.getChildAt(i); if (childElement instanceof FieldReference field && ((FieldReference) childElement) .getProgramVariable().name().toString().equals(fullFieldName)) { diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java index 18787225830..995917eef20 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java @@ -93,7 +93,7 @@ public void updateState(int maxApplications, long timeout, Proof proof, long sta SourceElement activeStatement = NodeInfo.computeActiveStatement(ruleApp); Node SETParent = SymbolicExecutionUtil.findParentSetNode(node); if (activeStatement instanceof Throw throwStatement && isEnabled()) { - for (int i = 0; i < throwStatement.getChildCount(); i++) { + for (int i = 0; i < throwStatement.getSyntaxChildCount(); i++) { SourceElement childElement = throwStatement.getChildAt(i); if (childElement instanceof LocationVariable locVar) { if (locVar.getKeYJavaType().getSort().toString().equals(exceptionName) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java index 785b03e3d80..fa13eb0fe87 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java @@ -3951,10 +3951,10 @@ public static Pair computeSecondStatement(RuleApp ruleAp } // Compute second statement StatementBlock block = null; - while (!blocks.isEmpty() && (block == null || block.getChildCount() < 2)) { + while (!blocks.isEmpty() && (block == null || block.getSyntaxChildCount() < 2)) { block = blocks.removeFirst(); } - if (block != null && block.getChildCount() >= 2) { + if (block != null && block.getSyntaxChildCount() >= 2) { return new Pair<>(methodFrameCount, block.getChildAt(1)); } else { return new Pair<>(methodFrameCount, null); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java index 792cf39949a..f072563e45c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java @@ -21,7 +21,7 @@ public CcatchBreakLabelParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return (label != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java index 8bd2af73e20..05bb1d123f7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchBreakParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java index 51938d23965..69b416cef06 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchBreakWildcardParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java index 1c5544866f6..a16bf704d2d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java @@ -21,7 +21,7 @@ public CcatchContinueLabelParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return (label != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java index e01e4739c8b..47f2a481df7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchContinueParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java index 984ab585973..bad98ad62f4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java @@ -19,7 +19,7 @@ public CcatchContinueWildcardParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java index 838ca7e192a..6345841c16a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchReturnParameterDeclaration(ExtList children) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java index 88aaee039ce..78a8bdd40b0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java @@ -43,7 +43,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ @Override - public int getChildCount() { + public int getSyntaxChildCount() { return delegate != null ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java b/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java index 0d556acb369..33b0d882c62 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java @@ -5,6 +5,8 @@ import de.uka.ilkd.key.java.visitor.Visitor; +import org.key_project.logic.SyntaxElement; + /** * Comment element of Java source code. */ @@ -71,4 +73,14 @@ public boolean equals(Object o) { } return (getText().equals(cmp.getText())); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("Comment has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java b/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java index 1f4573e5f3f..c8540345aff 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java @@ -72,12 +72,12 @@ public CompilationUnit(ExtList children) { public SourceElement getFirstElement() { - return (getChildCount() > 0) ? getChildAt(0).getFirstElement() : this; + return (getSyntaxChildCount() > 0) ? getChildAt(0).getFirstElement() : this; } @Override public SourceElement getFirstElementIncludingBlocks() { - return (getChildCount() > 0) ? getChildAt(0).getFirstElementIncludingBlocks() : this; + return (getSyntaxChildCount() > 0) ? getChildAt(0).getFirstElementIncludingBlocks() : this; } public SourceElement getLastElement() { @@ -101,7 +101,7 @@ public String getName() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (packageSpec != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java index 408d81bbdb1..b8deb7f0d83 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java @@ -88,12 +88,12 @@ public IExecutionContext getExecutionContext() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int count = 0; if (executionContext != null) { count++; } - count += super.getChildCount(); + count += super.getSyntaxChildCount(); return count; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Import.java b/key.core/src/main/java/de/uka/ilkd/key/java/Import.java index 500d659b836..43bd217e901 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Import.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Import.java @@ -88,7 +88,7 @@ public boolean isMultiImport() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (reference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java index ded5c975478..af7148c5398 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java @@ -5,6 +5,7 @@ import de.uka.ilkd.key.rule.MatchConditions; +import org.key_project.logic.SyntaxElement; import org.key_project.util.ExtList; import org.key_project.util.collection.ImmutableArray; @@ -69,11 +70,11 @@ public boolean equalsModRenaming(SourceElement se, NameAbstractionTable nat) { } final JavaNonTerminalProgramElement jnte = (JavaNonTerminalProgramElement) se; - if (jnte.getChildCount() != getChildCount()) { + if (jnte.getSyntaxChildCount() != getSyntaxChildCount()) { return false; } - for (int i = 0, cc = getChildCount(); i < cc; i++) { + for (int i = 0, cc = getSyntaxChildCount(); i < cc; i++) { if (!getChildAt(i).equalsModRenaming(jnte.getChildAt(i), nat)) { return false; } @@ -89,7 +90,7 @@ public boolean equals(Object o) { @Override protected int computeHashCode() { int localHash = 17 * super.computeHashCode(); - for (int i = 0, sz = getChildCount(); i < sz; i++) { + for (int i = 0, sz = getSyntaxChildCount(); i < sz; i++) { final ProgramElement pe = getChildAt(i); localHash = 17 * localHash + (pe == null ? 0 : pe.hashCode()); } @@ -148,7 +149,7 @@ protected boolean compatibleBlockSize(int pos, int max) { protected MatchConditions matchChildren(SourceData source, MatchConditions matchCond, int offset) { - for (int i = offset, sz = getChildCount(); i < sz; i++) { + for (int i = offset, sz = getSyntaxChildCount(); i < sz; i++) { matchCond = getChildAt(i).match(source, matchCond); if (matchCond == null) { return null; @@ -157,10 +158,15 @@ protected MatchConditions matchChildren(SourceData source, MatchConditions match final NonTerminalProgramElement ntSrc = (NonTerminalProgramElement) source.getElement(); - if (!compatibleBlockSize(source.getChildPos(), ntSrc.getChildCount())) { + if (!compatibleBlockSize(source.getChildPos(), ntSrc.getSyntaxChildCount())) { return null; } return matchCond; } + + @Override + public SyntaxElement getChild(int n) { + return getChildAt(n); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java index ca20a719d4d..97368ebdad2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java @@ -14,7 +14,7 @@ public interface NonTerminalProgramElement extends ProgramElement { * * @return an int giving the number of children of this node */ - int getChildCount(); + int getSyntaxChildCount(); /** * Returns the child at the specified index in this node's "virtual" child array. diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java index 1adeb3a75d5..82a9d5de4fb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java @@ -46,7 +46,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (reference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java b/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java index 0c34b1c15bf..e56178bde54 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java @@ -99,7 +99,7 @@ public ProgramElement getSource() { final NonTerminalProgramElement ntpe = (NonTerminalProgramElement) element; - if (childPos < ntpe.getChildCount()) { + if (childPos < ntpe.getSyntaxChildCount()) { return ntpe.getChildAt(childPos); } else { return null; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java index 046d51538cb..d9709324c9d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java @@ -6,13 +6,15 @@ import de.uka.ilkd.key.java.visitor.Visitor; import de.uka.ilkd.key.logic.op.SVSubstitute; +import org.key_project.logic.SyntaxElement; + /** * A source element is a piece of syntax. It does not necessarily have a semantics, at least none * that is machinable, for instance a {@link recoder.java.Comment}. taken from RECODER and changed * to achieve an immutable structure */ -public interface SourceElement extends SVSubstitute { +public interface SourceElement extends SVSubstitute, SyntaxElement { /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java index 6d0c95695c8..0fe7c811033 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java @@ -121,7 +121,7 @@ public final boolean isEmpty() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return body.size(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java index 902e791ace6..b0cc3d15ece 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java @@ -3,9 +3,20 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java; +import org.key_project.logic.SyntaxElement; + /** * Terminal program element. taken from COMPOST and changed to achieve an immutable structure */ public interface TerminalProgramElement extends ProgramElement { + @Override + default int getSyntaxChildCount() { + return 0; + } + + @Override + default SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("Program element " + this + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java index c432502f14d..a689408a21a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java @@ -71,7 +71,7 @@ public ArrayDeclaration(ExtList children, TypeReference baseType, KeYJavaType su * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java index 269dc7f999a..a9ab43f9e41 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java @@ -117,7 +117,7 @@ public ClassDeclaration(ExtList children, ProgramElementName fullName, boolean i * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java index aebf56f774e..2a35ae21d8f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java @@ -70,7 +70,7 @@ public Statement getStatementAt(int index) { } - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java index 26223d4712b..b3dbd242dd7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java @@ -66,7 +66,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java index df4cebda29f..631c6aecb4d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java @@ -82,7 +82,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (supertypes != null) { result += supertypes.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java index 201ab2f32ea..baf29255751 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java @@ -65,7 +65,7 @@ public InterfaceDeclaration(ProgramElementName name) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java index 710ed417aa5..16a18b6a58c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java @@ -121,7 +121,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java index 04346acf3a7..04a1aa6cf0b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java @@ -163,12 +163,12 @@ public SourceElement getFirstElement() { @Override public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(getSyntaxChildCount() - 1).getLastElement(); } @Override - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java index 75c08a72be7..75685e606d5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java @@ -109,7 +109,7 @@ public ImmutableArray getVariables() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java index 67f52df42bc..55cd9a967b3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java @@ -28,7 +28,7 @@ public SuperArrayDeclaration(FieldDeclaration length) { this(new ProgramElementName("SuperArray"), length); } - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java index 35d0279ec88..80eb623695c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java @@ -77,7 +77,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (exceptions != null) { result += exceptions.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java index 185194af413..a6124472682 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java @@ -95,7 +95,7 @@ public SourceElement getFirstElementIncludingBlocks() { } public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(getSyntaxChildCount() - 1).getLastElement(); } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java index 787cf6b874e..6c28e9a0ad8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java @@ -100,7 +100,7 @@ public VariableSpecification(ExtList children, IProgramVariable var, int dim, Ty * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (var != null) { result++; @@ -280,10 +280,10 @@ public boolean equalsModRenaming(SourceElement se, NameAbstractionTable nat) { } } nat.add(var, vs.getProgramVariable()); - if (vs.getChildCount() != getChildCount()) { + if (vs.getSyntaxChildCount() != getSyntaxChildCount()) { return false; } - for (int i = 0, cc = getChildCount(); i < cc; i++) { + for (int i = 0, cc = getSyntaxChildCount(); i < cc; i++) { if (!getChildAt(i).equalsModRenaming(vs.getChildAt(i), nat)) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java index fa81c6b4a6d..18266529523 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java @@ -39,7 +39,7 @@ public ProgramElement getChildAt(int index) { throw new ArrayIndexOutOfBoundsException(); } - public int getChildCount() { + public int getSyntaxChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java index 5e1a0fe937b..a4f9abffeb8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java @@ -54,7 +54,7 @@ public ArrayInitializer(Expression[] expressions, KeYJavaType kjt) { @Override - public int getChildCount() { + public int getSyntaxChildCount() { return (children != null) ? children.size() : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java index ff1a653287a..952f7e1b5da 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java @@ -143,7 +143,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (children != null) ? children.size() : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java index a76c65a7676..f327fa68264 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java @@ -43,7 +43,7 @@ public ExactInstanceof(Expression unaryChild, TypeReference typeref) { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (children != null) { result += children.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java index 284c254db72..a3ba9852625 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java @@ -31,13 +31,13 @@ public class Instanceof extends TypeOperator { public Instanceof(ExtList children) { super(children); - assert getChildCount() == 2 : "not 2 children but " + getChildCount(); + assert this.getSyntaxChildCount() == 2 : "not 2 children but " + this.getSyntaxChildCount(); } public Instanceof(Expression unaryChild, TypeReference typeref) { super(unaryChild, typeref); - assert getChildCount() == 2 : "not 2 children but " + getChildCount(); + assert this.getSyntaxChildCount() == 2 : "not 2 children but " + this.getSyntaxChildCount(); } /** @@ -46,7 +46,7 @@ public Instanceof(Expression unaryChild, TypeReference typeref) { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (children != null) { result += children.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java index bc7027d5498..51062cc9558 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java @@ -99,7 +99,7 @@ public SourceElement getFirstElementIncludingBlocks() { @Override public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(this.getSyntaxChildCount() - 1).getLastElement(); } @@ -142,7 +142,7 @@ public TypeDeclaration getTypeDeclarationAt(int index) { @Override - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (accessPath != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java index 2496a1a84cd..e88712ff847 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java @@ -148,7 +148,7 @@ public ArrayInitializer getArrayInitializer() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (typeReference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java index 76ac7b3c5a1..f6b3d467215 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java @@ -49,7 +49,7 @@ public TypeCast(ExtList children) { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (typeReference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java index c12d07be94d..d141a83bd81 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java @@ -49,7 +49,7 @@ public ArrayLengthReference(ExtList children) { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (prefix != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java index 667f011688b..abba0a21f91 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java @@ -184,7 +184,7 @@ public ReferencePrefix getReferencePrefix() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java index c9a1ba78a12..3c0aab03cd8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java @@ -63,7 +63,7 @@ public ExecutionContext(ExtList children) { * @return an int giving the number of children of this node */ @Override - public int getChildCount() { + public int getSyntaxChildCount() { int count = 0; if (classContext != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java index 0616f1b3c7e..e6d3b6f61af 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java @@ -56,7 +56,7 @@ public FieldReference(ProgramVariable pv, ReferencePrefix prefix, PositionInfo p * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java index 446d332ff55..2305cf42a18 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java @@ -54,7 +54,7 @@ public MetaClassReference(ExtList children) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (typeReference != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java index e31c8e827b3..7b48aaaab09 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java @@ -117,7 +117,7 @@ public ReferencePrefix getReferencePrefix() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java index fdccddd95cc..fc821d1c24d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java @@ -63,7 +63,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java index 97c27ac7abc..130c07b1c93 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java @@ -43,7 +43,7 @@ public SchematicFieldReference(ExtList children, ReferencePrefix prefix) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java index bb05f76b56c..81e6e2baf4b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java @@ -77,7 +77,7 @@ public SpecialConstructorReference(ExtList children, PositionInfo pi) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java index ad5d2828d63..11d9725c4a7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java @@ -73,7 +73,7 @@ public ReferencePrefix getReferencePrefix() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int count = 0; if (prefix != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java index 6c04bf116a3..573444a7bff 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java @@ -66,7 +66,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int count = 0; if (prefix != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java index f70a47f3e46..a05c177b7ec 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java @@ -80,7 +80,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java index 8b2d4a86702..6d127891693 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java @@ -41,7 +41,7 @@ public ProgramElementName getProgramElementName() { return (ProgramElementName) variable.name(); } - public int getChildCount() { + public int getSyntaxChildCount() { return (variable != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java index 1cffa3aa4e6..065e882b968 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java @@ -41,7 +41,7 @@ public ProgramElement getChildAt(int index) { return getExpressionAt(index); } - public int getChildCount() { + public int getSyntaxChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java index c1c9535b626..6b24a389b40 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java @@ -76,7 +76,7 @@ public Case(ExtList children, Expression expr, PositionInfo pos) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java index 4ab7438bc60..bf1d64d22c7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java @@ -70,7 +70,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (parameter != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java index bb7690aa055..b0387cb822f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java @@ -44,7 +44,7 @@ public LocationVariable getParam() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int i = 0; if (body != null) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java index e3126a5ebe6..3e8558efbf8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java @@ -99,7 +99,7 @@ public boolean hasNonStdParameterDeclaration() { * @return an int giving the number of children of this node */ @Override - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (hasParameterDeclaration()) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java index 6536464ed76..d1d4960d423 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java @@ -54,7 +54,7 @@ public Default(ExtList children) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (body != null) { result += body.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java index 63dc0c92e63..154fffc633e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java @@ -54,7 +54,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (body != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java index 32774cb8f19..5afad68e81b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java @@ -131,7 +131,7 @@ public SourceElement getFirstElement() { @Override public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(getSyntaxChildCount() - 1).getLastElement(); } /** @@ -140,7 +140,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ @Override - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java index 4bddeab80a7..2a1d810627d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java @@ -85,7 +85,7 @@ public Expression getExpression() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (expression != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java index bd4e40b6d8b..24c2db9ea17 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java @@ -52,7 +52,7 @@ public Finally(ExtList children) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java index 3823a2ab3be..3626fccfc96 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java @@ -69,7 +69,7 @@ public void visit(Visitor v) { v.performActionOnForUpdates(this); } - public int getChildCount() { + public int getSyntaxChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java index d1483fed22a..70c883985bd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java @@ -33,7 +33,7 @@ public void visit(Visitor v) { v.performActionOnGuard(this); } - public int getChildCount() { + public int getSyntaxChildCount() { return (expr != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java index e9f451dc038..25a8be2825c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java @@ -88,7 +88,7 @@ public If(Expression e, Then thenBranch, Else elseBranch) { * @return */ public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(getSyntaxChildCount() - 1).getLastElement(); } /** @@ -97,7 +97,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { if (elseBranch != null) { return 3; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java index 732174aa2fd..8254ebcbe92 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java @@ -149,7 +149,7 @@ protected int computeHashCode() { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java index 68d1c45a7b2..755e228811a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java @@ -93,7 +93,7 @@ public ProgramElementName getProgramElementName() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (name != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java index 7a8fffc97ca..6ac702ba7be 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java @@ -211,7 +211,7 @@ public Statement getBody() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (name != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java index f3f6e918d8c..289ab69dd81 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java @@ -74,7 +74,7 @@ public void visit(Visitor v) { v.performActionOnLoopInit(this); } - public int getChildCount() { + public int getSyntaxChildCount() { return getStatementCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java index 90b373e1438..edd36bc8d50 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java @@ -107,7 +107,7 @@ public ImmutableArray getPrefixElements() { @Override public PosInProgram getFirstActiveChildPos() { return getStatementCount() == 0 ? PosInProgram.TOP - : PosInProgram.TOP.down(getChildCount() - 1).down(0); + : PosInProgram.TOP.down(this.getSyntaxChildCount() - 1).down(0); } /** @@ -150,7 +150,7 @@ public IProgramVariable getIndexPV() { * @return an int giving the number of children of this node */ @Override - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (indexPV != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java index af0b8c08b57..d2f68f3de43 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java @@ -217,7 +217,7 @@ static private ExtList add(ExtList e, Object o) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (inits != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java index 1749900d64d..0de156b2627 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java @@ -82,7 +82,7 @@ public Expression getExpression() { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (identifier != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java index 60d8aa4206b..33be238c465 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java @@ -161,7 +161,7 @@ public Statement getBody(Services services) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int i = 0; if (bodySource != null) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java index ede5682ff23..224239aaa71 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java @@ -53,7 +53,8 @@ public MethodFrame(IProgramVariable resultVar, IExecutionContext execContext, this.execContext = execContext; firstActiveChildPos = - body.isEmpty() ? PosInProgram.TOP : PosInProgram.TOP.down(getChildCount() - 1).down(0); + body.isEmpty() ? PosInProgram.TOP + : PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0); Debug.assertTrue(execContext != null, "methodframe: executioncontext missing"); Debug.assertTrue(body != null, "methodframe: body missing"); @@ -78,7 +79,8 @@ public MethodFrame(IProgramVariable resultVar, IExecutionContext execContext, this.execContext = execContext; firstActiveChildPos = - body.isEmpty() ? PosInProgram.TOP : PosInProgram.TOP.down(getChildCount() - 1).down(0); + body.isEmpty() ? PosInProgram.TOP + : PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0); Debug.assertTrue(execContext != null, "methodframe: executioncontext missing"); @@ -185,7 +187,7 @@ public IProgramMethod getProgramMethod() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (resultVar != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java index 0ece40806f5..5bbdd77569e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java @@ -62,7 +62,7 @@ public void visit(Visitor v) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java index 3816e6f9282..f4a2b7ca6eb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java @@ -81,7 +81,7 @@ public Switch(ExtList children) { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java index 492cfc5b683..d0bc46c3c61 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java @@ -135,7 +135,7 @@ private boolean expressionWithoutSideffects() { public PosInProgram getFirstActiveChildPos() { return getStatementCount() == 0 ? PosInProgram.TOP : (expressionWithoutSideffects() - ? PosInProgram.TOP.down(getChildCount() - 1).down(0) + ? PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0) : PosInProgram.ONE); } @@ -183,7 +183,7 @@ public Expression getExpression() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java index a87fd000787..37ed703cd92 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java @@ -65,7 +65,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return (body != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java index 00c17a5e034..6ae42412b2a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java @@ -39,7 +39,7 @@ public ProgramElement getChildAt(int index) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java index 9011234e233..01c2c35e49a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java @@ -137,7 +137,7 @@ public SourceElement getFirstElement() { public SourceElement getLastElement() { - return getChildAt(getChildCount() - 1).getLastElement(); + return getChildAt(this.getSyntaxChildCount() - 1).getLastElement(); } /** @@ -146,7 +146,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java index 31bb841ed14..b8cdb2acdeb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java @@ -543,11 +543,11 @@ public void performActionOnMethodFrame(MethodFrame x) { pi = PositionInfo.UNDEFINED; } - if (x.getChildCount() == 3) { + if (x.getSyntaxChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), pi)); - } else if (x.getChildCount() == 2) { + } else if (x.getSyntaxChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), pi)); } else { @@ -1527,7 +1527,7 @@ ProgramElement createNewElement(ExtList changeList) { * @return pe2's position in pe1 */ protected static int getPosition(NonTerminalProgramElement pe1, ProgramElement pe2) { - int n = pe1.getChildCount(); + int n = pe1.getSyntaxChildCount(); int i = 0; while ((i < n) && (pe1.getChildAt(i) != pe2)) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java index cd4968add8d..55e251fb36b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java @@ -20,7 +20,7 @@ public boolean findLabel(Label label, ProgramElement node) { if (!(node instanceof LabeledStatement && ((LabeledStatement) node).getLabel().equals(label))) { if (node instanceof NonTerminalProgramElement nonTerminalNode) { - for (int i = 0; i < nonTerminalNode.getChildCount(); i++) { + for (int i = 0; i < nonTerminalNode.getSyntaxChildCount(); i++) { if (nonTerminalNode.getChildAt(i) != null) { if (findLabel(label, nonTerminalNode.getChildAt(i))) { return true; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java index bbb9fbfe280..35c3b1e4d1a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java @@ -285,11 +285,11 @@ public void performActionOnMethodFrame(final MethodFrame x) { final ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getChildCount() == 3) { + if (x.getSyntaxChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getChildCount() == 2) { + } else if (x.getSyntaxChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java index 125f6dbdd5c..3dd9391d1fd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java @@ -63,7 +63,7 @@ public int depth() { protected void walk(ProgramElement node) { if (node instanceof NonTerminalProgramElement nonTerminalNode) { depth++; - for (int i = 0; i < nonTerminalNode.getChildCount(); i++) { + for (int i = 0; i < nonTerminalNode.getSyntaxChildCount(); i++) { if (nonTerminalNode.getChildAt(i) != null) { walk(nonTerminalNode.getChildAt(i)); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java index a796487d7d1..c6c560ffb4f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java @@ -303,12 +303,12 @@ public void performActionOnMethodFrame(final MethodFrame x) { final ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getChildCount() == 3) { + if (x.getSyntaxChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getChildCount() == 2) { + } else if (x.getSyntaxChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java index 589b1cb9d4d..49df58e0032 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java @@ -110,12 +110,12 @@ protected JavaNonTerminalProgramElement wrap(JavaNonTerminalProgramElement conte private final StatementBlock createWrapperBody(JavaNonTerminalProgramElement wrapper, StatementBlock putIn, PosInProgram suffix) { - final int putInLength = putIn.getChildCount(); + final int putInLength = putIn.getSyntaxChildCount(); // ATTENTION: may be -1 final int lastChild = suffix.last(); - final int childLeft = wrapper.getChildCount() - lastChild; + final int childLeft = wrapper.getSyntaxChildCount() - lastChild; final int childrenToAdd = putInLength + childLeft; @@ -182,7 +182,7 @@ protected MethodFrame createMethodFrameWrapper(MethodFrame old, StatementBlock b protected LabeledStatement createLabeledStatementWrapper(LabeledStatement old, JavaNonTerminalProgramElement body) { return new LabeledStatement(old.getLabel(), - body instanceof StatementBlock && body.getChildCount() == 1 + body instanceof StatementBlock && body.getSyntaxChildCount() == 1 && !(body.getChildAt(0) instanceof LocalVariableDeclaration) ? (Statement) body.getChildAt(0) : (Statement) body, diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java b/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java index b7d72e26382..2dd935eda54 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java @@ -8,6 +8,7 @@ import de.uka.ilkd.key.pp.PrettyPrinter; import org.key_project.logic.Program; +import org.key_project.logic.SyntaxElement; import org.key_project.util.EqualsModProofIrrelevancy; import org.slf4j.Logger; @@ -64,7 +65,7 @@ public boolean isEmpty() { public int size() { if ((program() instanceof StatementBlock)) { - return ((StatementBlock) program()).getChildCount(); + return ((StatementBlock) program()).getSyntaxChildCount(); } return 0; } @@ -128,4 +129,18 @@ public int hashCodeModProofIrrelevancy() { } return hashCode; } + + @Override + public int getSyntaxChildCount() { + if (prg == null || this == EMPTY_JAVABLOCK) + return 0; + return 1; + } + + @Override + public SyntaxElement getChild(int n) { + if (n == 0) + return prg; + throw new IndexOutOfBoundsException("JavaBlock " + this + " has only one child"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java index 0837fda6089..9ae7934762d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java @@ -9,6 +9,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -58,4 +59,16 @@ public static ElementaryUpdate getInstance(UpdateableOperator lhs) { public UpdateableOperator lhs() { return lhs; } + + @Override + public int getSyntaxChildCount() { + return 1; + } + + @Override + public SyntaxElement getChild(int n) { + if (n == 0) + return lhs; + throw new IndexOutOfBoundsException("Elementary updates only contain 1 child"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java index ecd4c878dfc..d1d58d62d6c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java @@ -6,6 +6,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -34,4 +35,14 @@ public final class Equality extends AbstractSortedOperator { private Equality(Name name, Sort targetSort) { super(name, new Sort[] { targetSort, targetSort }, JavaDLTheory.FORMULA, true); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java index be40110ea40..a9ee0c2371b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java @@ -6,6 +6,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.TermCreationException; import org.key_project.logic.op.AbstractOperator; import org.key_project.logic.sort.Sort; @@ -44,4 +45,14 @@ public void validTopLevelException(T term throw new TermCreationException(this, term); } } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java index a7fe9097055..bf2aabb58d0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java @@ -8,6 +8,7 @@ import de.uka.ilkd.key.logic.sort.ProgramSVSort; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.TermCreationException; import org.key_project.logic.op.AbstractOperator; import org.key_project.logic.sort.Sort; @@ -85,4 +86,14 @@ public void validTopLevelException(T term throw new TermCreationException(this, term); } } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java index e2b1162c6cc..71db0f91e10 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java @@ -6,6 +6,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -62,4 +63,14 @@ private static Sort[] createFormulaSortArray(int arity) { private Junctor(Name name, int arity) { super(name, createFormulaSortArray(arity), JavaDLTheory.FORMULA, true); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("The Junctor operator " + name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java index d4e8aa5def9..c8d0769489a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java @@ -9,6 +9,7 @@ import org.key_project.logic.Name; import org.key_project.logic.ParsableVariable; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.key_project.util.EqualsModProofIrrelevancy; @@ -43,4 +44,14 @@ public boolean equalsModProofIrrelevancy(Object obj) { public int hashCodeModProofIrrelevancy() { return Objects.hash(name(), sort()); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("Logic variable " + name() + " does not have children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java index 95d0597ab6c..adbd5d5736a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java @@ -7,6 +7,7 @@ import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.ProgramElementName; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.key_project.util.collection.ImmutableArray; @@ -22,7 +23,7 @@ */ public class ObserverFunction extends JFunction implements IObserverFunction { - private final KeYJavaType container; + private final Qualifier container; private final boolean isStatic; private final ImmutableArray paramTypes; private final KeYJavaType type; @@ -42,7 +43,7 @@ public ObserverFunction(String baseName, Sort sort, KeYJavaType type, Sort heapS assert type == null || type.getSort() == sort; assert container != null; this.type = type; - this.container = container; + this.container = Qualifier.create(container); this.isStatic = isStatic; this.paramTypes = paramTypes; this.heapCount = heapCount; @@ -107,7 +108,7 @@ public final KeYJavaType getType() { */ @Override public final KeYJavaType getContainerType() { - return container; + return container.getQualifier(); } @@ -169,4 +170,15 @@ public final ImmutableArray getParamTypes() { return paramTypes; } + @Override + public int getSyntaxChildCount() { + return 1; + } + + @Override + public SyntaxElement getChild(int n) { + if (n == 0) + return container; + throw new IndexOutOfBoundsException("ObserverFunction " + name() + " has only one child"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java index a86db464202..07a2e2bc5de 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java @@ -257,7 +257,7 @@ public ImmutableArray getModifiers() { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java index 1ab0db5231b..12db0cb8831 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java @@ -142,7 +142,7 @@ public Expression getExpressionAt(int index) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java index 40cb2da7762..49982fd749d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java @@ -16,6 +16,7 @@ import de.uka.ilkd.key.rule.MatchConditions; import org.key_project.logic.ParsableVariable; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.key_project.util.ExtList; @@ -256,4 +257,15 @@ public MatchConditions match(SourceData source, MatchConditions matchCond) { return null; } } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException( + "Program variable " + name() + " does not have children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java new file mode 100644 index 00000000000..be18e73d0d3 --- /dev/null +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java @@ -0,0 +1,41 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ +package de.uka.ilkd.key.logic.op; + +import java.util.WeakHashMap; + +import org.key_project.logic.SyntaxElement; + +public class Qualifier implements SyntaxElement { + private final T qualifier; + + private static final WeakHashMap> INSTANCES = new WeakHashMap<>(); + + private Qualifier(T qualifier) { + this.qualifier = qualifier; + } + + synchronized static Qualifier create(T qualifier) { + if (INSTANCES.containsKey(qualifier)) { + return (Qualifier) INSTANCES.get(qualifier); + } + var q = new Qualifier<>(qualifier); + INSTANCES.put(qualifier, q); + return q; + } + + public T getQualifier() { + return qualifier; + } + + @Override + public SyntaxElement getChild(int n) { + return null; + } + + @Override + public int getSyntaxChildCount() { + return 0; + } +} diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java index bbf777afbfd..7a94e63f953 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java @@ -6,6 +6,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; /** @@ -36,4 +37,14 @@ private Quantifier(Name name) { super(name, new Sort[] { JavaDLTheory.FORMULA }, JavaDLTheory.FORMULA, new Boolean[] { true }, true); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java index 4d0e486211a..50eee4f7b96 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java @@ -12,6 +12,7 @@ import de.uka.ilkd.key.logic.sort.ProgramSVSort; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.key_project.util.collection.ImmutableArray; @@ -29,7 +30,7 @@ public final class SortDependingFunction extends JFunction { private static final Logger LOGGER = LoggerFactory.getLogger(SortDependingFunction.class); private final SortDependingFunctionTemplate template; - private final Sort sortDependingOn; + private final Qualifier sortDependingOn; // ------------------------------------------------------------------------- @@ -41,7 +42,7 @@ private SortDependingFunction(SortDependingFunctionTemplate template, Sort sortD instantiateResultSort(template, sortDependingOn), instantiateArgSorts(template, sortDependingOn), null, template.unique, false); this.template = template; - this.sortDependingOn = sortDependingOn; + this.sortDependingOn = Qualifier.create(sortDependingOn); } @@ -168,7 +169,7 @@ && instantiateName(getKind(), sort).toString().contains("seqGet") public Sort getSortDependingOn() { - return sortDependingOn; + return sortDependingOn.getQualifier(); } @@ -188,4 +189,18 @@ public Name getKind() { private record SortDependingFunctionTemplate(GenericSort sortDependingOn, Name kind, Sort sort, ImmutableArray argSorts, boolean unique) { } + + @Override + public int getSyntaxChildCount() { + return 1; + } + + @Override + public SyntaxElement getChild(int n) { + if (n == 0) { + return sortDependingOn; + } + throw new IndexOutOfBoundsException( + "SortDependingFunction " + name() + " has only one child"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java index f993389d350..561389444cf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java @@ -7,6 +7,7 @@ import de.uka.ilkd.key.logic.TermBuilder; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.TermCreationException; import org.key_project.logic.op.AbstractOperator; import org.key_project.logic.sort.Sort; @@ -72,4 +73,15 @@ public void validTopLevelException(T term // Term res = cfSubst.apply(term.sub(1)); // return res; // } + + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("SubstOp " + name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java index 4662b1f17ad..6dc0b73105f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java @@ -34,7 +34,7 @@ public Object getChild(int i) { } @Override - public int getChildCount() { + public int getSyntaxChildCount() { return 0; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java index fb6ff4791b6..c51f0452be3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java @@ -7,6 +7,7 @@ import de.uka.ilkd.key.logic.Term; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.TermCreationException; import org.key_project.logic.op.AbstractOperator; import org.key_project.logic.sort.Sort; @@ -77,4 +78,14 @@ public static Term getTarget(Term t) { assert t.op() == UPDATE_APPLICATION; return t.sub(targetPos()); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("UpdateApplication has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java index 38b43150538..5f55b7cfaad 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java @@ -6,6 +6,7 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -34,4 +35,14 @@ private static Sort[] createUpdateSortArray(int arity) { private UpdateJunctor(Name name, int arity) { super(name, createUpdateSortArray(arity), JavaDLTheory.UPDATE, false); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("UpdateJunctor " + name() + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java index 4f344bb86a2..04c17871eea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java @@ -482,7 +482,7 @@ protected boolean canStandFor(ProgramElement pe, Services services) { || pe instanceof SeqLength || pe instanceof SeqGet || pe instanceof SeqIndexOf || pe instanceof SeqSub || pe instanceof SeqReverse || pe instanceof SeqPut) { if (pe instanceof NonTerminalProgramElement npe) { - for (int i = 0, childCount = npe.getChildCount(); i < childCount; i++) { + for (int i = 0, childCount = npe.getSyntaxChildCount(); i < childCount; i++) { if (!canStandFor(npe.getChildAt(i), services)) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java index aa4d5c176c9..fbc296e5837 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java @@ -410,7 +410,7 @@ public void performActionOnDLEmbeddedExpression(DLEmbeddedExpression x) { layouter.print("\\dl_" + x.getFunctionSymbol().name()); layouter.print("("); - for (int i = 0; i < x.getChildCount(); i++) { + for (int i = 0; i < x.getSyntaxChildCount(); i++) { if (i != 0) { layouter.print(",").brk(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java index b8fcfbee6b9..1f0aebea363 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java @@ -314,7 +314,7 @@ private ImmutableList getJavaTacletList( if (pe instanceof ProgramPrefix) { int next = prefixOccurrences.occurred(pe); NonTerminalProgramElement nt = (NonTerminalProgramElement) pe; - if (next < nt.getChildCount()) { + if (next < nt.getSyntaxChildCount()) { return getJavaTacletList(map, nt.getChildAt(next), prefixOccurrences); } } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java index 88f44e40120..bfd4ff80c55 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java @@ -93,7 +93,7 @@ private LoopSpecification instantiateIndexValues(LoopSpecification rawInv, // try to retrieve a loop index variable de.uka.ilkd.key.java.statement.IGuard guard = loop.getGuard(); // the guard is expected to be of the form "i < x" and we want to retrieve "i". - assert guard.getChildCount() == 1 : "child count: " + guard.getChildCount(); + assert guard.getSyntaxChildCount() == 1 : "child count: " + guard.getSyntaxChildCount(); ProgramElement guardStatement = guard.getChildAt(0); skipIndex = !(guardStatement instanceof LessThan); Expression loopIndex = diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java index 74f87909a8f..ca3e68b6a44 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java @@ -55,7 +55,7 @@ public MatchConditions check(SchemaVariable sv, SVSubstitute instCandidate, assert !instantiatedTerm.javaBlock().isEmpty(); assert instantiatedTerm.javaBlock().program() instanceof StatementBlock; - assert ((StatementBlock) instantiatedTerm.javaBlock().program()).getChildCount() == 1; + assert ((StatementBlock) instantiatedTerm.javaBlock().program()).getSyntaxChildCount() == 1; return matchCond.setInstantiations(// svInst.add(storeInSV, diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java index 0b7e5d2716e..fd5edcccdb6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java @@ -134,7 +134,7 @@ public Statement getStatementAt(int index) { * * @return an int giving the number of children of this node */ - public int getChildCount() { + public int getSyntaxChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java index 14bc6a66ec1..a11be238695 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java @@ -718,11 +718,11 @@ public void performActionOnMethodFrame(MethodFrame x) { ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getChildCount() == 3) { + if (x.getSyntaxChildCount() == 3) { addChild(KeYJavaASTFactory.methodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getChildCount() == 2) { + } else if (x.getSyntaxChildCount() == 2) { addChild(KeYJavaASTFactory.methodFrame((IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java index 15fba88cfc9..00be8ef33e4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java @@ -281,7 +281,7 @@ public ImmutableSet extractClassSpecs(KeYJavaType kjt) } // iterate over all children - for (int i = 0, n = td.getChildCount(); i <= n; i++) { + for (int i = 0, n = td.getSyntaxChildCount(); i <= n; i++) { // collect comments // (last position are comments of type declaration itself) Comment[] comments = null; diff --git a/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java b/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java index b7f699eeff2..68cd906b2d0 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java +++ b/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java @@ -43,7 +43,7 @@ public void tearDown() { public void testContextTermInstantiation() { ExtList statementList = new ExtList(); StatementBlock stContainer = (StatementBlock) blockOne.program(); - int size = stContainer.getChildCount(); + int size = stContainer.getSyntaxChildCount(); assertEquals(3, size, "Wrong size. Should have only 3 children"); PosInProgram prefixEnd = PosInProgram.TOP.down(0); assertTrue( diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java index a9e2a7e0bd0..2439237ae9e 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java @@ -10,6 +10,7 @@ public interface SyntaxElement { /** * Get the {@code n}-th child of this syntax element. + * * @param n index of the child. * @return the {@code n}-th child of this syntax element. * @throws IndexOutOfBoundsException if there is no {@code n}-th child. @@ -20,5 +21,5 @@ public interface SyntaxElement { * * @return the number of children of this syntax element. */ - int getChildCount(); + int getSyntaxChildCount(); } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index fdc3e6013cd..b6b20313bbe 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -1,3 +1,6 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.logic; import java.util.ArrayDeque; @@ -19,18 +22,20 @@ public SyntaxElement getCurrentNode() { } public boolean gotoFirstChild() { - if (node.getChildCount() <= 0) return false; + if (node.getSyntaxChildCount() <= 0) + return false; path.push(new ParentAndPosition(node, 0)); node = node.getChild(0); return true; } public boolean gotoNextSibling() { - if (path.isEmpty()) return false; + if (path.isEmpty()) + return false; var pnp = path.pop(); SyntaxElement parent = pnp.parent; - int index =pnp.index+1; - if (index > parent.getChildCount()) { + int index = pnp.index + 1; + if (index > parent.getSyntaxChildCount()) { return false; } path.push(new ParentAndPosition(parent, index)); @@ -39,7 +44,8 @@ public boolean gotoNextSibling() { } public boolean gotoParent() { - if (path.isEmpty()) return false; + if (path.isEmpty()) + return false; node = path.pop().parent; return true; } diff --git a/key.ncore/src/main/java/org/key_project/logic/Term.java b/key.ncore/src/main/java/org/key_project/logic/Term.java index c08c5a866fd..a66d82ecc52 100644 --- a/key.ncore/src/main/java/org/key_project/logic/Term.java +++ b/key.ncore/src/main/java/org/key_project/logic/Term.java @@ -91,4 +91,23 @@ public interface Term extends LogicElement, Sorted { * @param visitor the Visitor */ void execPreOrder(Visitor visitor); + + @Override + default int getSyntaxChildCount() { + return 1 + boundVars().size() + subs().size(); + } + + @Override + default SyntaxElement getChild(int n) { + if (n == 0) + return op(); + n--; + if (n < boundVars().size()) + return boundVars().get(n); + n -= boundVars().size(); + if (n < subs().size()) + return sub(n); + throw new IndexOutOfBoundsException( + "Term " + this + " has only " + getSyntaxChildCount() + " children"); + } } diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Function.java b/key.ncore/src/main/java/org/key_project/logic/op/Function.java index 94b97468c93..1f638f9efd8 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Function.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Function.java @@ -4,6 +4,7 @@ package org.key_project.logic.op; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.key_project.util.collection.ImmutableArray; @@ -51,4 +52,14 @@ public final boolean isSkolemConstant() { public final String toString() { return (name() + (whereToBind() == null ? "" : "{" + whereToBind() + "}")); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("Function " + name() + " has no children"); + } } diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java index 10d40f7a239..4a6c01643e3 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java @@ -8,6 +8,7 @@ import org.key_project.logic.Name; import org.key_project.logic.Named; import org.key_project.logic.Program; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.jspecify.annotations.Nullable; @@ -41,10 +42,25 @@ public final K kind() { */ public abstract Program program(); + @Override + public int getSyntaxChildCount() { + return 2; + } + + @Override + public SyntaxElement getChild(int n) { + return switch (n) { + case 0 -> kind; + case 1 -> program(); + default -> throw new IndexOutOfBoundsException( + "Modality " + name() + " has only two children"); + }; + } + /** * Modality kinds like box and diamond. */ - public abstract static class Kind implements Named { + public abstract static class Kind implements Named, SyntaxElement { private final Name name; public Kind(Name name) { @@ -74,5 +90,15 @@ public boolean equals(@Nullable Object o) { public int hashCode() { return Objects.hash(name()); } + + @Override + public int getSyntaxChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException("Modality kind " + name() + " has no children"); + } } } diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Operator.java b/key.ncore/src/main/java/org/key_project/logic/op/Operator.java index 3a4f900dde8..81fd39f426c 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Operator.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Operator.java @@ -4,11 +4,12 @@ package org.key_project.logic.op; import org.key_project.logic.Named; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.Term; import org.key_project.logic.TermCreationException; import org.key_project.logic.sort.Sort; -public interface Operator extends Named { +public interface Operator extends Named, SyntaxElement { /** * the arity of this operator */ diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java index 1ee7b710b81..0de19c95623 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java @@ -815,7 +815,7 @@ private static PositionInfo joinPositionsRec(SourceElement se) { PositionInfo pos = se.getPositionInfo(); - for (int i = 0; i < ntpe.getChildCount(); i++) { + for (int i = 0; i < ntpe.getSyntaxChildCount(); i++) { ProgramElement pe2 = ntpe.getChildAt(i); pos = PositionInfo.join(pos, joinPositionsRec(pe2)); } From b48ae735c3d3e603b344208eab2b0a91848ca4d9 Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 22 May 2024 10:19:19 +0200 Subject: [PATCH 05/15] Implement missing methods --- .../MethodCallProofReferencesAnalyst.java | 2 +- .../ProgramVariableReferencesAnalyst.java | 2 +- .../slicing/AbstractBackwardSlicer.java | 2 +- .../slicing/AbstractSlicer.java | 2 +- .../breakpoint/ExceptionBreakpoint.java | 2 +- .../strategy/breakpoint/FieldWatchpoint.java | 4 ++-- .../SymbolicExecutionExceptionBreakpoint.java | 2 +- .../util/SymbolicExecutionUtil.java | 4 ++-- .../CcatchBreakLabelParameterDeclaration.java | 2 +- .../java/CcatchBreakParameterDeclaration.java | 2 +- ...CcatchBreakWildcardParameterDeclaration.java | 2 +- ...CcatchContinueLabelParameterDeclaration.java | 2 +- .../CcatchContinueParameterDeclaration.java | 2 +- ...tchContinueWildcardParameterDeclaration.java | 2 +- .../java/CcatchReturnParameterDeclaration.java | 2 +- .../CcatchReturnValParameterDeclaration.java | 2 +- .../main/java/de/uka/ilkd/key/java/Comment.java | 2 +- .../de/uka/ilkd/key/java/CompilationUnit.java | 6 +++--- .../ilkd/key/java/ContextStatementBlock.java | 4 ++-- .../main/java/de/uka/ilkd/key/java/Import.java | 2 +- .../key/java/JavaNonTerminalProgramElement.java | 10 +++++----- .../key/java/NonTerminalProgramElement.java | 2 +- .../uka/ilkd/key/java/PackageSpecification.java | 2 +- .../java/de/uka/ilkd/key/java/SourceData.java | 2 +- .../de/uka/ilkd/key/java/StatementBlock.java | 2 +- .../ilkd/key/java/TerminalProgramElement.java | 2 +- .../key/java/declaration/ArrayDeclaration.java | 2 +- .../key/java/declaration/ClassDeclaration.java | 2 +- .../key/java/declaration/ClassInitializer.java | 2 +- .../key/java/declaration/FieldDeclaration.java | 2 +- .../declaration/InheritanceSpecification.java | 2 +- .../java/declaration/InterfaceDeclaration.java | 2 +- .../declaration/LocalVariableDeclaration.java | 2 +- .../key/java/declaration/MethodDeclaration.java | 4 ++-- .../java/declaration/ParameterDeclaration.java | 2 +- .../java/declaration/SuperArrayDeclaration.java | 2 +- .../uka/ilkd/key/java/declaration/Throws.java | 2 +- .../java/declaration/VariableDeclaration.java | 2 +- .../java/declaration/VariableSpecification.java | 6 +++--- .../modifier/AnnotationUseSpecification.java | 2 +- .../key/java/expression/ArrayInitializer.java | 2 +- .../uka/ilkd/key/java/expression/Operator.java | 2 +- .../expression/operator/ExactInstanceof.java | 2 +- .../java/expression/operator/Instanceof.java | 6 +++--- .../ilkd/key/java/expression/operator/New.java | 4 ++-- .../key/java/expression/operator/NewArray.java | 2 +- .../key/java/expression/operator/TypeCast.java | 2 +- .../java/reference/ArrayLengthReference.java | 2 +- .../ilkd/key/java/reference/ArrayReference.java | 2 +- .../key/java/reference/ExecutionContext.java | 2 +- .../ilkd/key/java/reference/FieldReference.java | 2 +- .../key/java/reference/MetaClassReference.java | 2 +- .../key/java/reference/MethodReference.java | 2 +- .../key/java/reference/PackageReference.java | 2 +- .../java/reference/SchematicFieldReference.java | 2 +- .../reference/SpecialConstructorReference.java | 2 +- .../ilkd/key/java/reference/SuperReference.java | 2 +- .../ilkd/key/java/reference/ThisReference.java | 2 +- .../key/java/reference/TypeReferenceImp.java | 2 +- .../key/java/reference/VariableReference.java | 2 +- .../de/uka/ilkd/key/java/statement/Assert.java | 2 +- .../de/uka/ilkd/key/java/statement/Case.java | 2 +- .../de/uka/ilkd/key/java/statement/Catch.java | 2 +- .../key/java/statement/CatchAllStatement.java | 2 +- .../de/uka/ilkd/key/java/statement/Ccatch.java | 2 +- .../de/uka/ilkd/key/java/statement/Default.java | 2 +- .../de/uka/ilkd/key/java/statement/Else.java | 2 +- .../de/uka/ilkd/key/java/statement/Exec.java | 4 ++-- .../java/statement/ExpressionJumpStatement.java | 2 +- .../de/uka/ilkd/key/java/statement/Finally.java | 2 +- .../uka/ilkd/key/java/statement/ForUpdates.java | 2 +- .../de/uka/ilkd/key/java/statement/Guard.java | 2 +- .../java/de/uka/ilkd/key/java/statement/If.java | 4 ++-- .../uka/ilkd/key/java/statement/JmlAssert.java | 2 +- .../key/java/statement/LabelJumpStatement.java | 2 +- .../key/java/statement/LabeledStatement.java | 2 +- .../uka/ilkd/key/java/statement/LoopInit.java | 2 +- .../ilkd/key/java/statement/LoopScopeBlock.java | 4 ++-- .../ilkd/key/java/statement/LoopStatement.java | 2 +- .../key/java/statement/MergePointStatement.java | 2 +- .../key/java/statement/MethodBodyStatement.java | 2 +- .../ilkd/key/java/statement/MethodFrame.java | 6 +++--- .../ilkd/key/java/statement/SetStatement.java | 2 +- .../de/uka/ilkd/key/java/statement/Switch.java | 2 +- .../key/java/statement/SynchronizedBlock.java | 4 ++-- .../de/uka/ilkd/key/java/statement/Then.java | 2 +- .../java/statement/TransactionStatement.java | 2 +- .../de/uka/ilkd/key/java/statement/Try.java | 4 ++-- .../key/java/visitor/CreatingASTVisitor.java | 6 +++--- .../ilkd/key/java/visitor/FreeLabelFinder.java | 2 +- .../visitor/InnerBreakAndContinueReplacer.java | 4 ++-- .../ilkd/key/java/visitor/JavaASTWalker.java | 2 +- .../OuterBreakContinueAndReturnReplacer.java | 4 ++-- .../key/java/visitor/ProgramContextAdder.java | 6 +++--- .../java/de/uka/ilkd/key/logic/JavaBlock.java | 4 ++-- .../de/uka/ilkd/key/logic/ProgramConstruct.java | 6 ++++++ .../label/BlockContractValidityTermLabel.java | 4 ++-- .../ilkd/key/logic/label/FormulaTermLabel.java | 4 ++-- .../ilkd/key/logic/label/OriginTermLabel.java | 6 +++--- .../key/logic/label/ParameterlessTermLabel.java | 4 ++-- .../logic/label/SymbolicExecutionTermLabel.java | 4 ++-- .../de/uka/ilkd/key/logic/label/TermLabel.java | 14 ++++++++------ .../uka/ilkd/key/logic/op/ElementaryUpdate.java | 2 +- .../java/de/uka/ilkd/key/logic/op/Equality.java | 2 +- .../de/uka/ilkd/key/logic/op/FormulaSV.java | 3 ++- .../de/uka/ilkd/key/logic/op/IfExThenElse.java | 2 +- .../de/uka/ilkd/key/logic/op/IfThenElse.java | 2 +- .../java/de/uka/ilkd/key/logic/op/Junctor.java | 2 +- .../de/uka/ilkd/key/logic/op/LogicVariable.java | 2 +- .../uka/ilkd/key/logic/op/ObserverFunction.java | 2 +- .../de/uka/ilkd/key/logic/op/ProgramMethod.java | 2 +- .../de/uka/ilkd/key/logic/op/ProgramSV.java | 17 ++++++++++++----- .../uka/ilkd/key/logic/op/ProgramVariable.java | 2 +- .../de/uka/ilkd/key/logic/op/Qualifier.java | 2 +- .../de/uka/ilkd/key/logic/op/Quantifier.java | 2 +- .../de/uka/ilkd/key/logic/op/SkolemTermSV.java | 3 ++- .../key/logic/op/SortDependingFunction.java | 2 +- .../java/de/uka/ilkd/key/logic/op/SubstOp.java | 2 +- .../de/uka/ilkd/key/logic/op/TermLabelSV.java | 11 ++++++----- .../java/de/uka/ilkd/key/logic/op/TermSV.java | 3 ++- .../uka/ilkd/key/logic/op/TermTransformer.java | 3 ++- .../ilkd/key/logic/op/UpdateApplication.java | 2 +- .../de/uka/ilkd/key/logic/op/UpdateJunctor.java | 2 +- .../java/de/uka/ilkd/key/logic/op/UpdateSV.java | 3 ++- .../de/uka/ilkd/key/logic/op/VariableSV.java | 5 ++++- .../uka/ilkd/key/logic/sort/ProgramSVSort.java | 2 +- .../java/de/uka/ilkd/key/pp/LogicPrinter.java | 8 ++++---- .../java/de/uka/ilkd/key/pp/PrettyPrinter.java | 2 +- .../java/de/uka/ilkd/key/proof/TacletIndex.java | 2 +- .../key/rule/LoopInvariantBuiltInRuleApp.java | 2 +- .../rule/conditions/StoreStmtInCondition.java | 2 +- .../rule/label/OriginTermLabelRefactoring.java | 4 ++-- .../rule/metaconstruct/ProgramTransformer.java | 2 +- .../metaconstruct/WhileLoopTransformation.java | 4 ++-- .../ilkd/key/speclang/jml/JMLSpecExtractor.java | 2 +- .../quantifierHeuristics/Metavariable.java | 3 ++- .../termgenerator/SuperTermGenerator.java | 3 ++- .../key/java/TestContextStatementBlock.java | 2 +- .../ilkd/key/logic/TestTermLabelManager.java | 12 ++++++------ .../org/key_project/logic/SyntaxElement.java | 2 +- .../key_project/logic/SyntaxElementCursor.java | 4 ++-- .../main/java/org/key_project/logic/Term.java | 4 ++-- .../logic/TerminalSyntaxElement.java | 13 +++++++++++++ .../java/org/key_project/logic/op/Function.java | 2 +- .../java/org/key_project/logic/op/Modality.java | 4 ++-- .../uka/ilkd/key/gui/sourceview/SourceView.java | 2 +- 146 files changed, 244 insertions(+), 205 deletions(-) create mode 100644 key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java diff --git a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java index 07bee533ecd..706723eaeab 100644 --- a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java +++ b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/MethodCallProofReferencesAnalyst.java @@ -59,7 +59,7 @@ public LinkedHashSet> computeReferences(Node node, Services s ExecutionContext context = extractContext(node, services); LinkedHashSet> result = new LinkedHashSet<>(); - for (int i = 0; i < assignment.getSyntaxChildCount(); i++) { + for (int i = 0; i < assignment.getChildCount(); i++) { ProgramElement child = assignment.getChildAt(i); if (child instanceof MethodReference) { IProofReference reference = diff --git a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java index 49c35b4f0e6..e37beeaa55b 100644 --- a/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java +++ b/key.core.proof_references/src/main/java/de/uka/ilkd/key/proof_references/analyst/ProgramVariableReferencesAnalyst.java @@ -82,7 +82,7 @@ protected void listReferences(Node node, ProgramElement pe, ProgramVariable arra ProofReferenceUtil.merge(toFill, reference); } } else if (includeExpressionContainer && pe instanceof ExpressionContainer ec) { - for (int i = ec.getSyntaxChildCount() - 1; i >= 0; i--) { + for (int i = ec.getChildCount() - 1; i >= 0; i--) { ProgramElement element = ec.getChildAt(i); listReferences(node, element, arrayLength, toFill, includeExpressionContainer); } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java index 20a6a6e091e..bfb10ac3e91 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractBackwardSlicer.java @@ -120,7 +120,7 @@ protected void updateRelevantLocations(final ProgramElement read, Location normalizedElement = normalizeAlias(services, relevantElement, info); relevantLocations.add(normalizedElement); } else if (read instanceof NonTerminalProgramElement ntpe) { - for (int i = 0; i < ntpe.getSyntaxChildCount(); i++) { + for (int i = 0; i < ntpe.getChildCount(); i++) { updateRelevantLocations(ntpe.getChildAt(i), relevantLocations, info, services); } } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java index 3aab95bc564..56ead50dddb 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java @@ -792,7 +792,7 @@ protected Location computeRepresentativeAlias(Location location, */ protected ReferencePrefix toReferencePrefix(SourceElement sourceElement) { if (sourceElement instanceof PassiveExpression) { - if (((PassiveExpression) sourceElement).getSyntaxChildCount() != 1) { + if (((PassiveExpression) sourceElement).getChildCount() != 1) { throw new IllegalStateException( "PassiveExpression '" + sourceElement + "' has not exactly one child."); } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java index 74c23775aff..bb81a7f3e64 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/ExceptionBreakpoint.java @@ -104,7 +104,7 @@ public boolean isBreakpointHit(SourceElement activeStatement, RuleApp ruleApp, P Node node) { Node SETParent = SymbolicExecutionUtil.findParentSetNode(node); if (activeStatement instanceof Throw throwStatement && isEnabled()) { - for (int i = 0; i < throwStatement.getSyntaxChildCount(); i++) { + for (int i = 0; i < throwStatement.getChildCount(); i++) { SourceElement childElement = throwStatement.getChildAt(i); if (childElement instanceof LocationVariable locVar) { if (locVar.getKeYJavaType().getSort().toString().equals(exceptionName) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java index a3246cc6949..d1082bca4c9 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/FieldWatchpoint.java @@ -80,7 +80,7 @@ public boolean isBreakpointHit(SourceElement activeStatement, RuleApp ruleApp, P private boolean checkChildrenOfSourceElement(SourceElement sourceElement) { boolean found = false; if (sourceElement instanceof Assignment assignment) { - for (int i = 1; i < assignment.getSyntaxChildCount(); i++) { + for (int i = 1; i < assignment.getChildCount(); i++) { SourceElement childElement = assignment.getChildAt(i); if (childElement instanceof FieldReference field && ((FieldReference) childElement) .getProgramVariable().name().toString().equals(fullFieldName)) { @@ -93,7 +93,7 @@ private boolean checkChildrenOfSourceElement(SourceElement sourceElement) { } } } else if (sourceElement instanceof NonTerminalProgramElement programElement) { - for (int i = 0; i < programElement.getSyntaxChildCount(); i++) { + for (int i = 0; i < programElement.getChildCount(); i++) { SourceElement childElement = programElement.getChildAt(i); if (childElement instanceof FieldReference field && ((FieldReference) childElement) .getProgramVariable().name().toString().equals(fullFieldName)) { diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java index 995917eef20..18787225830 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/SymbolicExecutionExceptionBreakpoint.java @@ -93,7 +93,7 @@ public void updateState(int maxApplications, long timeout, Proof proof, long sta SourceElement activeStatement = NodeInfo.computeActiveStatement(ruleApp); Node SETParent = SymbolicExecutionUtil.findParentSetNode(node); if (activeStatement instanceof Throw throwStatement && isEnabled()) { - for (int i = 0; i < throwStatement.getSyntaxChildCount(); i++) { + for (int i = 0; i < throwStatement.getChildCount(); i++) { SourceElement childElement = throwStatement.getChildAt(i); if (childElement instanceof LocationVariable locVar) { if (locVar.getKeYJavaType().getSort().toString().equals(exceptionName) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java index fa13eb0fe87..785b03e3d80 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java @@ -3951,10 +3951,10 @@ public static Pair computeSecondStatement(RuleApp ruleAp } // Compute second statement StatementBlock block = null; - while (!blocks.isEmpty() && (block == null || block.getSyntaxChildCount() < 2)) { + while (!blocks.isEmpty() && (block == null || block.getChildCount() < 2)) { block = blocks.removeFirst(); } - if (block != null && block.getSyntaxChildCount() >= 2) { + if (block != null && block.getChildCount() >= 2) { return new Pair<>(methodFrameCount, block.getChildAt(1)); } else { return new Pair<>(methodFrameCount, null); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java index f072563e45c..792cf39949a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakLabelParameterDeclaration.java @@ -21,7 +21,7 @@ public CcatchBreakLabelParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return (label != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java index 05bb1d123f7..8bd2af73e20 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchBreakParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java index 69b416cef06..51938d23965 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchBreakWildcardParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchBreakWildcardParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java index a16bf704d2d..1c5544866f6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueLabelParameterDeclaration.java @@ -21,7 +21,7 @@ public CcatchContinueLabelParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return (label != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java index 47f2a481df7..e01e4739c8b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchContinueParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java index bad98ad62f4..984ab585973 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchContinueWildcardParameterDeclaration.java @@ -19,7 +19,7 @@ public CcatchContinueWildcardParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java index 6345841c16a..838ca7e192a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnParameterDeclaration.java @@ -18,7 +18,7 @@ public CcatchReturnParameterDeclaration(ExtList children) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java index 78a8bdd40b0..88aaee039ce 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CcatchReturnValParameterDeclaration.java @@ -43,7 +43,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ @Override - public int getSyntaxChildCount() { + public int getChildCount() { return delegate != null ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java b/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java index 33b0d882c62..60221fca8fe 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Comment.java @@ -75,7 +75,7 @@ public boolean equals(Object o) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java b/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java index c8540345aff..1f4573e5f3f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/CompilationUnit.java @@ -72,12 +72,12 @@ public CompilationUnit(ExtList children) { public SourceElement getFirstElement() { - return (getSyntaxChildCount() > 0) ? getChildAt(0).getFirstElement() : this; + return (getChildCount() > 0) ? getChildAt(0).getFirstElement() : this; } @Override public SourceElement getFirstElementIncludingBlocks() { - return (getSyntaxChildCount() > 0) ? getChildAt(0).getFirstElementIncludingBlocks() : this; + return (getChildCount() > 0) ? getChildAt(0).getFirstElementIncludingBlocks() : this; } public SourceElement getLastElement() { @@ -101,7 +101,7 @@ public String getName() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (packageSpec != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java index b8deb7f0d83..408d81bbdb1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/ContextStatementBlock.java @@ -88,12 +88,12 @@ public IExecutionContext getExecutionContext() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int count = 0; if (executionContext != null) { count++; } - count += super.getSyntaxChildCount(); + count += super.getChildCount(); return count; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/Import.java b/key.core/src/main/java/de/uka/ilkd/key/java/Import.java index 43bd217e901..500d659b836 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/Import.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/Import.java @@ -88,7 +88,7 @@ public boolean isMultiImport() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (reference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java index af7148c5398..8a1b4c0cf82 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java @@ -70,11 +70,11 @@ public boolean equalsModRenaming(SourceElement se, NameAbstractionTable nat) { } final JavaNonTerminalProgramElement jnte = (JavaNonTerminalProgramElement) se; - if (jnte.getSyntaxChildCount() != getSyntaxChildCount()) { + if (jnte.getChildCount() != getChildCount()) { return false; } - for (int i = 0, cc = getSyntaxChildCount(); i < cc; i++) { + for (int i = 0, cc = getChildCount(); i < cc; i++) { if (!getChildAt(i).equalsModRenaming(jnte.getChildAt(i), nat)) { return false; } @@ -90,7 +90,7 @@ public boolean equals(Object o) { @Override protected int computeHashCode() { int localHash = 17 * super.computeHashCode(); - for (int i = 0, sz = getSyntaxChildCount(); i < sz; i++) { + for (int i = 0, sz = getChildCount(); i < sz; i++) { final ProgramElement pe = getChildAt(i); localHash = 17 * localHash + (pe == null ? 0 : pe.hashCode()); } @@ -149,7 +149,7 @@ protected boolean compatibleBlockSize(int pos, int max) { protected MatchConditions matchChildren(SourceData source, MatchConditions matchCond, int offset) { - for (int i = offset, sz = getSyntaxChildCount(); i < sz; i++) { + for (int i = offset, sz = getChildCount(); i < sz; i++) { matchCond = getChildAt(i).match(source, matchCond); if (matchCond == null) { return null; @@ -158,7 +158,7 @@ protected MatchConditions matchChildren(SourceData source, MatchConditions match final NonTerminalProgramElement ntSrc = (NonTerminalProgramElement) source.getElement(); - if (!compatibleBlockSize(source.getChildPos(), ntSrc.getSyntaxChildCount())) { + if (!compatibleBlockSize(source.getChildPos(), ntSrc.getChildCount())) { return null; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java index 97368ebdad2..ca20a719d4d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java @@ -14,7 +14,7 @@ public interface NonTerminalProgramElement extends ProgramElement { * * @return an int giving the number of children of this node */ - int getSyntaxChildCount(); + int getChildCount(); /** * Returns the child at the specified index in this node's "virtual" child array. diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java index 82a9d5de4fb..1adeb3a75d5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/PackageSpecification.java @@ -46,7 +46,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (reference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java b/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java index e56178bde54..0c34b1c15bf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SourceData.java @@ -99,7 +99,7 @@ public ProgramElement getSource() { final NonTerminalProgramElement ntpe = (NonTerminalProgramElement) element; - if (childPos < ntpe.getSyntaxChildCount()) { + if (childPos < ntpe.getChildCount()) { return ntpe.getChildAt(childPos); } else { return null; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java index 0fe7c811033..6d0c95695c8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/StatementBlock.java @@ -121,7 +121,7 @@ public final boolean isEmpty() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return body.size(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java index b0cc3d15ece..653187dc473 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java @@ -11,7 +11,7 @@ public interface TerminalProgramElement extends ProgramElement { @Override - default int getSyntaxChildCount() { + default int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java index a689408a21a..c432502f14d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ArrayDeclaration.java @@ -71,7 +71,7 @@ public ArrayDeclaration(ExtList children, TypeReference baseType, KeYJavaType su * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java index a9ab43f9e41..269dc7f999a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassDeclaration.java @@ -117,7 +117,7 @@ public ClassDeclaration(ExtList children, ProgramElementName fullName, boolean i * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java index 2a35ae21d8f..aebf56f774e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ClassInitializer.java @@ -70,7 +70,7 @@ public Statement getStatementAt(int index) { } - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java index b3dbd242dd7..26223d4712b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/FieldDeclaration.java @@ -66,7 +66,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java index 631c6aecb4d..df4cebda29f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InheritanceSpecification.java @@ -82,7 +82,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (supertypes != null) { result += supertypes.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java index baf29255751..201ab2f32ea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/InterfaceDeclaration.java @@ -65,7 +65,7 @@ public InterfaceDeclaration(ProgramElementName name) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java index 16a18b6a58c..710ed417aa5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/LocalVariableDeclaration.java @@ -121,7 +121,7 @@ public ImmutableArray getVariables() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java index 04a1aa6cf0b..fc59c65e880 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/MethodDeclaration.java @@ -163,12 +163,12 @@ public SourceElement getFirstElement() { @Override public SourceElement getLastElement() { - return getChildAt(getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(this.getChildCount() - 1).getLastElement(); } @Override - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java index 75685e606d5..75c08a72be7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/ParameterDeclaration.java @@ -109,7 +109,7 @@ public ImmutableArray getVariables() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (modArray != null) { result += modArray.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java index 55cd9a967b3..67f52df42bc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/SuperArrayDeclaration.java @@ -28,7 +28,7 @@ public SuperArrayDeclaration(FieldDeclaration length) { this(new ProgramElementName("SuperArray"), length); } - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java index 80eb623695c..35d0279ec88 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Throws.java @@ -77,7 +77,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (exceptions != null) { result += exceptions.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java index a6124472682..185194af413 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableDeclaration.java @@ -95,7 +95,7 @@ public SourceElement getFirstElementIncludingBlocks() { } public SourceElement getLastElement() { - return getChildAt(getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(getChildCount() - 1).getLastElement(); } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java index 6c28e9a0ad8..787cf6b874e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/VariableSpecification.java @@ -100,7 +100,7 @@ public VariableSpecification(ExtList children, IProgramVariable var, int dim, Ty * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (var != null) { result++; @@ -280,10 +280,10 @@ public boolean equalsModRenaming(SourceElement se, NameAbstractionTable nat) { } } nat.add(var, vs.getProgramVariable()); - if (vs.getSyntaxChildCount() != getSyntaxChildCount()) { + if (vs.getChildCount() != getChildCount()) { return false; } - for (int i = 0, cc = getSyntaxChildCount(); i < cc; i++) { + for (int i = 0, cc = getChildCount(); i < cc; i++) { if (!getChildAt(i).equalsModRenaming(vs.getChildAt(i), nat)) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java index 18266529523..fa81c6b4a6d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/AnnotationUseSpecification.java @@ -39,7 +39,7 @@ public ProgramElement getChildAt(int index) { throw new ArrayIndexOutOfBoundsException(); } - public int getSyntaxChildCount() { + public int getChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java index a4f9abffeb8..5e1a0fe937b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/ArrayInitializer.java @@ -54,7 +54,7 @@ public ArrayInitializer(Expression[] expressions, KeYJavaType kjt) { @Override - public int getSyntaxChildCount() { + public int getChildCount() { return (children != null) ? children.size() : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java index 952f7e1b5da..ff1a653287a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/Operator.java @@ -143,7 +143,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (children != null) ? children.size() : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java index f327fa68264..a76c65a7676 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/ExactInstanceof.java @@ -43,7 +43,7 @@ public ExactInstanceof(Expression unaryChild, TypeReference typeref) { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (children != null) { result += children.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java index a3ba9852625..d53c134154e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/Instanceof.java @@ -31,13 +31,13 @@ public class Instanceof extends TypeOperator { public Instanceof(ExtList children) { super(children); - assert this.getSyntaxChildCount() == 2 : "not 2 children but " + this.getSyntaxChildCount(); + assert this.getChildCount() == 2 : "not 2 children but " + this.getChildCount(); } public Instanceof(Expression unaryChild, TypeReference typeref) { super(unaryChild, typeref); - assert this.getSyntaxChildCount() == 2 : "not 2 children but " + this.getSyntaxChildCount(); + assert this.getChildCount() == 2 : "not 2 children but " + this.getChildCount(); } /** @@ -46,7 +46,7 @@ public Instanceof(Expression unaryChild, TypeReference typeref) { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (children != null) { result += children.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java index 51062cc9558..6d041245c71 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/New.java @@ -99,7 +99,7 @@ public SourceElement getFirstElementIncludingBlocks() { @Override public SourceElement getLastElement() { - return getChildAt(this.getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(this.getChildCount() - 1).getLastElement(); } @@ -142,7 +142,7 @@ public TypeDeclaration getTypeDeclarationAt(int index) { @Override - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (accessPath != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java index e88712ff847..2496a1a84cd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/NewArray.java @@ -148,7 +148,7 @@ public ArrayInitializer getArrayInitializer() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (typeReference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java index f6b3d467215..76ac7b3c5a1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/expression/operator/TypeCast.java @@ -49,7 +49,7 @@ public TypeCast(ExtList children) { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (typeReference != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java index d141a83bd81..c12d07be94d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayLengthReference.java @@ -49,7 +49,7 @@ public ArrayLengthReference(ExtList children) { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (prefix != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java index abba0a21f91..667f011688b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ArrayReference.java @@ -184,7 +184,7 @@ public ReferencePrefix getReferencePrefix() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java index 3c0aab03cd8..c9a1ba78a12 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ExecutionContext.java @@ -63,7 +63,7 @@ public ExecutionContext(ExtList children) { * @return an int giving the number of children of this node */ @Override - public int getSyntaxChildCount() { + public int getChildCount() { int count = 0; if (classContext != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java index e6d3b6f61af..0616f1b3c7e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/FieldReference.java @@ -56,7 +56,7 @@ public FieldReference(ProgramVariable pv, ReferencePrefix prefix, PositionInfo p * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java index 2305cf42a18..446d332ff55 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MetaClassReference.java @@ -54,7 +54,7 @@ public MetaClassReference(ExtList children) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (typeReference != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java index 7b48aaaab09..e31c8e827b3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/MethodReference.java @@ -117,7 +117,7 @@ public ReferencePrefix getReferencePrefix() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java index fc821d1c24d..fdccddd95cc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/PackageReference.java @@ -63,7 +63,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java index 130c07b1c93..97c27ac7abc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SchematicFieldReference.java @@ -43,7 +43,7 @@ public SchematicFieldReference(ExtList children, ReferencePrefix prefix) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java index 81e6e2baf4b..bb05f76b56c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SpecialConstructorReference.java @@ -77,7 +77,7 @@ public SpecialConstructorReference(ExtList children, PositionInfo pi) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java index 11d9725c4a7..ad5d2828d63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/SuperReference.java @@ -73,7 +73,7 @@ public ReferencePrefix getReferencePrefix() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int count = 0; if (prefix != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java index 573444a7bff..6c04bf116a3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/ThisReference.java @@ -66,7 +66,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int count = 0; if (prefix != null) { count++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java index a05c177b7ec..f70a47f3e46 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/TypeReferenceImp.java @@ -80,7 +80,7 @@ public SourceElement getFirstElementIncludingBlocks() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (prefix != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java b/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java index 6d127891693..8b2d4a86702 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/reference/VariableReference.java @@ -41,7 +41,7 @@ public ProgramElementName getProgramElementName() { return (ProgramElementName) variable.name(); } - public int getSyntaxChildCount() { + public int getChildCount() { return (variable != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java index 065e882b968..1cffa3aa4e6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Assert.java @@ -41,7 +41,7 @@ public ProgramElement getChildAt(int index) { return getExpressionAt(index); } - public int getSyntaxChildCount() { + public int getChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java index 6b24a389b40..c1c9535b626 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Case.java @@ -76,7 +76,7 @@ public Case(ExtList children, Expression expr, PositionInfo pos) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java index bf1d64d22c7..4ab7438bc60 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Catch.java @@ -70,7 +70,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (parameter != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java index b0387cb822f..bb7690aa055 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/CatchAllStatement.java @@ -44,7 +44,7 @@ public LocationVariable getParam() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int i = 0; if (body != null) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java index 3e8558efbf8..e3126a5ebe6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Ccatch.java @@ -99,7 +99,7 @@ public boolean hasNonStdParameterDeclaration() { * @return an int giving the number of children of this node */ @Override - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (hasParameterDeclaration()) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java index d1d4960d423..6536464ed76 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Default.java @@ -54,7 +54,7 @@ public Default(ExtList children) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (body != null) { result += body.size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java index 154fffc633e..63dc0c92e63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Else.java @@ -54,7 +54,7 @@ public SourceElement getLastElement() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (body != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java index 5afad68e81b..32774cb8f19 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Exec.java @@ -131,7 +131,7 @@ public SourceElement getFirstElement() { @Override public SourceElement getLastElement() { - return getChildAt(getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(getChildCount() - 1).getLastElement(); } /** @@ -140,7 +140,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ @Override - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java index 2a1d810627d..4bddeab80a7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ExpressionJumpStatement.java @@ -85,7 +85,7 @@ public Expression getExpression() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (expression != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java index 24c2db9ea17..bd4e40b6d8b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Finally.java @@ -52,7 +52,7 @@ public Finally(ExtList children) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java index 3626fccfc96..3823a2ab3be 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ForUpdates.java @@ -69,7 +69,7 @@ public void visit(Visitor v) { v.performActionOnForUpdates(this); } - public int getSyntaxChildCount() { + public int getChildCount() { return getExpressionCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java index 70c883985bd..d1483fed22a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Guard.java @@ -33,7 +33,7 @@ public void visit(Visitor v) { v.performActionOnGuard(this); } - public int getSyntaxChildCount() { + public int getChildCount() { return (expr != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java index 25a8be2825c..e9f451dc038 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/If.java @@ -88,7 +88,7 @@ public If(Expression e, Then thenBranch, Else elseBranch) { * @return */ public SourceElement getLastElement() { - return getChildAt(getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(getChildCount() - 1).getLastElement(); } /** @@ -97,7 +97,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { if (elseBranch != null) { return 3; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java index 8254ebcbe92..732174aa2fd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/JmlAssert.java @@ -149,7 +149,7 @@ protected int computeHashCode() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java index 755e228811a..68d1c45a7b2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabelJumpStatement.java @@ -93,7 +93,7 @@ public ProgramElementName getProgramElementName() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (name != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java index 6ac702ba7be..7a8fffc97ca 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LabeledStatement.java @@ -211,7 +211,7 @@ public Statement getBody() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (name != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java index 289ab69dd81..f3f6e918d8c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopInit.java @@ -74,7 +74,7 @@ public void visit(Visitor v) { v.performActionOnLoopInit(this); } - public int getSyntaxChildCount() { + public int getChildCount() { return getStatementCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java index edd36bc8d50..60d71b65f31 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopScopeBlock.java @@ -107,7 +107,7 @@ public ImmutableArray getPrefixElements() { @Override public PosInProgram getFirstActiveChildPos() { return getStatementCount() == 0 ? PosInProgram.TOP - : PosInProgram.TOP.down(this.getSyntaxChildCount() - 1).down(0); + : PosInProgram.TOP.down(this.getChildCount() - 1).down(0); } /** @@ -150,7 +150,7 @@ public IProgramVariable getIndexPV() { * @return an int giving the number of children of this node */ @Override - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (indexPV != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java index d2f68f3de43..af0b8c08b57 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/LoopStatement.java @@ -217,7 +217,7 @@ static private ExtList add(ExtList e, Object o) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (inits != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java index 0de156b2627..1749900d64d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MergePointStatement.java @@ -82,7 +82,7 @@ public Expression getExpression() { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (identifier != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java index 33be238c465..60d8aa4206b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodBodyStatement.java @@ -161,7 +161,7 @@ public Statement getBody(Services services) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int i = 0; if (bodySource != null) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java index 224239aaa71..105e3ab446a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/MethodFrame.java @@ -54,7 +54,7 @@ public MethodFrame(IProgramVariable resultVar, IExecutionContext execContext, firstActiveChildPos = body.isEmpty() ? PosInProgram.TOP - : PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0); + : PosInProgram.TOP.down(getChildCount() - 1).down(0); Debug.assertTrue(execContext != null, "methodframe: executioncontext missing"); Debug.assertTrue(body != null, "methodframe: body missing"); @@ -80,7 +80,7 @@ public MethodFrame(IProgramVariable resultVar, IExecutionContext execContext, firstActiveChildPos = body.isEmpty() ? PosInProgram.TOP - : PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0); + : PosInProgram.TOP.down(getChildCount() - 1).down(0); Debug.assertTrue(execContext != null, "methodframe: executioncontext missing"); @@ -187,7 +187,7 @@ public IProgramMethod getProgramMethod() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (resultVar != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java index 5bbdd77569e..0ece40806f5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SetStatement.java @@ -62,7 +62,7 @@ public void visit(Visitor v) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java index f4a2b7ca6eb..3816e6f9282 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Switch.java @@ -81,7 +81,7 @@ public Switch(ExtList children) { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java index d0bc46c3c61..492cfc5b683 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/SynchronizedBlock.java @@ -135,7 +135,7 @@ private boolean expressionWithoutSideffects() { public PosInProgram getFirstActiveChildPos() { return getStatementCount() == 0 ? PosInProgram.TOP : (expressionWithoutSideffects() - ? PosInProgram.TOP.down(getSyntaxChildCount() - 1).down(0) + ? PosInProgram.TOP.down(getChildCount() - 1).down(0) : PosInProgram.ONE); } @@ -183,7 +183,7 @@ public Expression getExpression() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (expression != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java index 37ed703cd92..a87fd000787 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Then.java @@ -65,7 +65,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return (body != null) ? 1 : 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java index 6ae42412b2a..00c17a5e034 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/TransactionStatement.java @@ -39,7 +39,7 @@ public ProgramElement getChildAt(int index) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java index 01c2c35e49a..02386a7c6e9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/Try.java @@ -137,7 +137,7 @@ public SourceElement getFirstElement() { public SourceElement getLastElement() { - return getChildAt(this.getSyntaxChildCount() - 1).getLastElement(); + return getChildAt(this.getChildCount() - 1).getLastElement(); } /** @@ -146,7 +146,7 @@ public SourceElement getLastElement() { * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { int result = 0; if (body != null) { result++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java index b8cdb2acdeb..31bb841ed14 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/CreatingASTVisitor.java @@ -543,11 +543,11 @@ public void performActionOnMethodFrame(MethodFrame x) { pi = PositionInfo.UNDEFINED; } - if (x.getSyntaxChildCount() == 3) { + if (x.getChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), pi)); - } else if (x.getSyntaxChildCount() == 2) { + } else if (x.getChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), pi)); } else { @@ -1527,7 +1527,7 @@ ProgramElement createNewElement(ExtList changeList) { * @return pe2's position in pe1 */ protected static int getPosition(NonTerminalProgramElement pe1, ProgramElement pe2) { - int n = pe1.getSyntaxChildCount(); + int n = pe1.getChildCount(); int i = 0; while ((i < n) && (pe1.getChildAt(i) != pe2)) { i++; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java index 55e251fb36b..cd4968add8d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/FreeLabelFinder.java @@ -20,7 +20,7 @@ public boolean findLabel(Label label, ProgramElement node) { if (!(node instanceof LabeledStatement && ((LabeledStatement) node).getLabel().equals(label))) { if (node instanceof NonTerminalProgramElement nonTerminalNode) { - for (int i = 0; i < nonTerminalNode.getSyntaxChildCount(); i++) { + for (int i = 0; i < nonTerminalNode.getChildCount(); i++) { if (nonTerminalNode.getChildAt(i) != null) { if (findLabel(label, nonTerminalNode.getChildAt(i))) { return true; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java index 35c3b1e4d1a..bbb9fbfe280 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/InnerBreakAndContinueReplacer.java @@ -285,11 +285,11 @@ public void performActionOnMethodFrame(final MethodFrame x) { final ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getSyntaxChildCount() == 3) { + if (x.getChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getSyntaxChildCount() == 2) { + } else if (x.getChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java index 3dd9391d1fd..125f6dbdd5c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/JavaASTWalker.java @@ -63,7 +63,7 @@ public int depth() { protected void walk(ProgramElement node) { if (node instanceof NonTerminalProgramElement nonTerminalNode) { depth++; - for (int i = 0; i < nonTerminalNode.getSyntaxChildCount(); i++) { + for (int i = 0; i < nonTerminalNode.getChildCount(); i++) { if (nonTerminalNode.getChildAt(i) != null) { walk(nonTerminalNode.getChildAt(i)); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java index c6c560ffb4f..a796487d7d1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/OuterBreakContinueAndReturnReplacer.java @@ -303,12 +303,12 @@ public void performActionOnMethodFrame(final MethodFrame x) { final ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getSyntaxChildCount() == 3) { + if (x.getChildCount() == 3) { addChild(new MethodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getSyntaxChildCount() == 2) { + } else if (x.getChildCount() == 2) { addChild(new MethodFrame(null, (IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java index 49df58e0032..589b1cb9d4d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/visitor/ProgramContextAdder.java @@ -110,12 +110,12 @@ protected JavaNonTerminalProgramElement wrap(JavaNonTerminalProgramElement conte private final StatementBlock createWrapperBody(JavaNonTerminalProgramElement wrapper, StatementBlock putIn, PosInProgram suffix) { - final int putInLength = putIn.getSyntaxChildCount(); + final int putInLength = putIn.getChildCount(); // ATTENTION: may be -1 final int lastChild = suffix.last(); - final int childLeft = wrapper.getSyntaxChildCount() - lastChild; + final int childLeft = wrapper.getChildCount() - lastChild; final int childrenToAdd = putInLength + childLeft; @@ -182,7 +182,7 @@ protected MethodFrame createMethodFrameWrapper(MethodFrame old, StatementBlock b protected LabeledStatement createLabeledStatementWrapper(LabeledStatement old, JavaNonTerminalProgramElement body) { return new LabeledStatement(old.getLabel(), - body instanceof StatementBlock && body.getSyntaxChildCount() == 1 + body instanceof StatementBlock && body.getChildCount() == 1 && !(body.getChildAt(0) instanceof LocalVariableDeclaration) ? (Statement) body.getChildAt(0) : (Statement) body, diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java b/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java index 2dd935eda54..9f18163e5e7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/JavaBlock.java @@ -65,7 +65,7 @@ public boolean isEmpty() { public int size() { if ((program() instanceof StatementBlock)) { - return ((StatementBlock) program()).getSyntaxChildCount(); + return ((StatementBlock) program()).getChildCount(); } return 0; } @@ -131,7 +131,7 @@ public int hashCodeModProofIrrelevancy() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { if (prg == null || this == EMPTY_JAVABLOCK) return 0; return 1; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java b/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java index 70bd980e18b..6457646b443 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java @@ -17,6 +17,7 @@ import de.uka.ilkd.key.java.statement.ILoopInit; import de.uka.ilkd.key.logic.op.IProgramMethod; import de.uka.ilkd.key.logic.op.IProgramVariable; +import org.key_project.logic.SyntaxElement; /** * A type that implement this interface can be used in all java programs instead of an expression or @@ -26,4 +27,9 @@ public interface ProgramConstruct extends Expression, Statement, ILoopInit, IForUpdates, IGuard, Label, TerminalProgramElement, ExpressionStatement, TypeReference, IProgramVariable, IProgramMethod, Branch, IExecutionContext, MethodName { + @Override + SyntaxElement getChild(int n); + + @Override + int getChildCount() ; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/BlockContractValidityTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/BlockContractValidityTermLabel.java index c4181e3c988..f4cb02f511f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/BlockContractValidityTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/BlockContractValidityTermLabel.java @@ -40,7 +40,7 @@ public ProgramVariable exceptionVariable() { * {@inheritDoc} */ @Override - public ProgramVariable getChild(int i) { + public ProgramVariable getTLChild(int i) { if (i == 0) { return exceptionVariable(); } @@ -51,7 +51,7 @@ public ProgramVariable getChild(int i) { * {@inheritDoc} */ @Override - public int getChildCount() { + public int getTLChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/FormulaTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/FormulaTermLabel.java index cde4271a90d..def77a6dd50 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/FormulaTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/FormulaTermLabel.java @@ -134,7 +134,7 @@ public String toString() { * {@inheritDoc} */ @Override - public Object getChild(int i) { + public Object getTLChild(int i) { return switch (i) { case 0 -> getId(); case 1 -> beforeIds; @@ -146,7 +146,7 @@ public Object getChild(int i) { * {@inheritDoc} */ @Override - public int getChildCount() { + public int getTLChildCount() { if (beforeIds != null) { return 2; } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java index 36136ad11f8..522fd209611 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java @@ -57,7 +57,7 @@ public class OriginTermLabel implements TermLabel { public final static Name NAME = new Name("origin"); /** - * @see #getChildCount() + * @see #getTLChildCount() */ public final static int CHILD_COUNT = 2; public static final Sort[] EMPTY_SORTS = new Sort[0]; @@ -450,7 +450,7 @@ public Name name() { } @Override - public Object getChild(int i) { + public Object getTLChild(int i) { if (i == 0) { return origin; } else if (i == 1) { @@ -461,7 +461,7 @@ public Object getChild(int i) { } @Override - public int getChildCount() { + public int getTLChildCount() { return CHILD_COUNT; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/ParameterlessTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/ParameterlessTermLabel.java index 850c5c1b3d5..596410ce3e8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/ParameterlessTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/ParameterlessTermLabel.java @@ -139,7 +139,7 @@ public Name name() { * {@link IndexOutOfBoundsException}. */ @Override - public Object getChild(int i) { + public Object getTLChild(int i) { throw new IndexOutOfBoundsException(); } @@ -150,7 +150,7 @@ public Object getChild(int i) { * Simple term labels have no parameters. This always returns 0. */ @Override - public int getChildCount() { + public int getTLChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/SymbolicExecutionTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/SymbolicExecutionTermLabel.java index 03659186d6a..6596ce2ba89 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/SymbolicExecutionTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/SymbolicExecutionTermLabel.java @@ -50,7 +50,7 @@ public String toString() { * {@inheritDoc} */ @Override - public Object getChild(int i) { + public Object getTLChild(int i) { if (i == 0) { return id(); } @@ -61,7 +61,7 @@ public Object getChild(int i) { * {@inheritDoc} */ @Override - public int getChildCount() { + public int getTLChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java index b514fbd04d5..a1ffadb28ea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java @@ -20,6 +20,8 @@ import org.key_project.logic.Name; import org.key_project.logic.Named; +import org.key_project.logic.SyntaxElement; +import org.key_project.logic.TerminalSyntaxElement; // spotless:off // this protects the JavaDoc from automatic reformatting /** @@ -34,8 +36,8 @@ * without parameters class {@link ParameterlessTermLabel} can be used. *

*

- * A term label can have parameters accessible via {@link #getChild(int)} and - * {@link #getChildCount()}. Such parameters can be any {@link Object}. But keep in mind that it is + * A term label can have parameters accessible via {@link #getTLChild(int)} and + * {@link #getTLChildCount()}. Such parameters can be any {@link Object}. But keep in mind that it is * required to parse {@link String}s into {@link Term}s, e.g. if it is used in a Taclet definition * or if a cut rule is applied. For convenience parameters are always printed as {@link String}s * and have to be parsed individually into the required {@link Object} instances via a @@ -150,7 +152,7 @@ * @see TermLabelManager */ // spotless:on -public interface TermLabel extends Named { +public interface TermLabel extends Named, SyntaxElement, /* TODO: Remove*/ TerminalSyntaxElement { /** * Retrieves the i-th parameter object of this term label. @@ -161,16 +163,16 @@ public interface TermLabel extends Named { * @param i the number of the parameter to retrieve ( {@code 0 <= i < getChildCount()}) * @return the selected parameter * @throws IndexOutOfBoundsException if the given parameter number i is negative or - * greater-or-equal the number of parameters returned by {@link #getChildCount()} + * greater-or-equal the number of parameters returned by {@link #getTLChildCount()} */ - Object getChild(int i); + Object getTLChild(int i); /** * Gets the number of parameters of this term label. * * @return the number of parameters (a non-negative number) */ - int getChildCount(); + int getTLChildCount(); /** * Returns {@code true} iff this label is used in any way during the proof. E.g., diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java index 9ae7934762d..c4ae30a8789 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ElementaryUpdate.java @@ -61,7 +61,7 @@ public UpdateableOperator lhs() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java index d1d58d62d6c..09fa71a855e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Equality.java @@ -37,7 +37,7 @@ private Equality(Name name, Sort targetSort) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/FormulaSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/FormulaSV.java index f93b960860e..270c2a92c89 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/FormulaSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/FormulaSV.java @@ -7,12 +7,13 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; /** * A schema variable that is used as placeholder for formulas. */ -public final class FormulaSV extends OperatorSV { +public final class FormulaSV extends OperatorSV implements TerminalSyntaxElement { /** * @param name the name of the SchemaVariable diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java index a9ee0c2371b..c7f05ada203 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfExThenElse.java @@ -47,7 +47,7 @@ public void validTopLevelException(T term } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java index bf2aabb58d0..a77b49ec111 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/IfThenElse.java @@ -88,7 +88,7 @@ public void validTopLevelException(T term } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java index 71db0f91e10..42b78108d67 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Junctor.java @@ -65,7 +65,7 @@ private Junctor(Name name, int arity) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java index c8d0769489a..fe94c1c3b01 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/LogicVariable.java @@ -46,7 +46,7 @@ public int hashCodeModProofIrrelevancy() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java index adbd5d5736a..3edd92a4333 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ObserverFunction.java @@ -171,7 +171,7 @@ public final ImmutableArray getParamTypes() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java index 07a2e2bc5de..a86db464202 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramMethod.java @@ -257,7 +257,7 @@ public ImmutableArray getModifiers() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java index 12db0cb8831..8a0406ee4b6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java @@ -22,6 +22,8 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableList; @@ -32,7 +34,7 @@ * Objects of this class are schema variables matching program constructs within modal operators. * The particular construct being matched is determined by the ProgramSVSort of the schema variable. */ -public final class ProgramSV extends OperatorSV implements ProgramConstruct, UpdateableOperator { +public final class ProgramSV extends OperatorSV implements ProgramConstruct, UpdateableOperator , TerminalSyntaxElement { public static final Logger LOGGER = LoggerFactory.getLogger(ProgramSV.class); private static final ProgramList EMPTY_LIST_INSTANTIATION = @@ -142,13 +144,18 @@ public Expression getExpressionAt(int index) { } @Override - public int getSyntaxChildCount() { - return 0; + public ProgramElement getChildAt(int index) { + return this; } @Override - public ProgramElement getChildAt(int index) { - return this; + public SyntaxElement getChild(int n) { + return TerminalSyntaxElement.super.getChild(n); + } + + @Override + public int getChildCount() { + return TerminalSyntaxElement.super.getChildCount(); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java index 49982fd749d..67210bebe7f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramVariable.java @@ -259,7 +259,7 @@ public MatchConditions match(SourceData source, MatchConditions matchCond) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java index be18e73d0d3..ad978c0b346 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java @@ -35,7 +35,7 @@ public SyntaxElement getChild(int n) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java index 7a94e63f953..e73cb2e17c6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Quantifier.java @@ -39,7 +39,7 @@ private Quantifier(Name name) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SkolemTermSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SkolemTermSV.java index 19bce65bc98..1cd550fa69d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SkolemTermSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SkolemTermSV.java @@ -7,6 +7,7 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.logic.sort.Sort; /** @@ -14,7 +15,7 @@ * variables have to be accompanied by a "NewDependingOn" varcond, although with the removal of the * meta variable mechanism, this would no longer really be necessary. */ -public final class SkolemTermSV extends OperatorSV { +public final class SkolemTermSV extends OperatorSV implements TerminalSyntaxElement { /** * Creates a new schema variable that is used as placeholder for skolem terms. diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java index 50eee4f7b96..bd675d35d89 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SortDependingFunction.java @@ -191,7 +191,7 @@ private record SortDependingFunctionTemplate(GenericSort sortDependingOn, Name k } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java index 561389444cf..193fcc78e60 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SubstOp.java @@ -76,7 +76,7 @@ public void validTopLevelException(T term @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java index 6dc0b73105f..fc1fb8526e3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermLabelSV.java @@ -8,11 +8,12 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; /** * A schema variable which matches term labels */ -public final class TermLabelSV extends OperatorSV implements SchemaVariable, TermLabel { +public final class TermLabelSV extends OperatorSV implements TermLabel, TerminalSyntaxElement { TermLabelSV(Name name) { super(name, JavaDLTheory.TERMLABEL, true, false); @@ -29,12 +30,12 @@ public String toString() { } @Override - public Object getChild(int i) { - throw new IndexOutOfBoundsException(); + public int getTLChildCount() { + return 0; } @Override - public int getSyntaxChildCount() { - return 0; + public Object getTLChild(int i) { + throw new IndexOutOfBoundsException(); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermSV.java index b057d045105..15353a7aaea 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermSV.java @@ -7,13 +7,14 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.logic.sort.Sort; /** * A schema variable that is used as placeholder for terms. */ -public final class TermSV extends OperatorSV { +public final class TermSV extends OperatorSV implements TerminalSyntaxElement { /** * @param name the name of the schema variable diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java index b722678fd3d..bb21080c5a3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java @@ -6,12 +6,13 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.TerminalSyntaxElement; /** * TermTransformer perform complex term transformation which cannot be (efficiently or at all) * described by taclets. */ -public interface TermTransformer extends org.key_project.logic.op.SortedOperator, Operator { +public interface TermTransformer extends org.key_project.logic.op.SortedOperator, Operator, /*TODO: check*/ TerminalSyntaxElement { /** * initiates term transformation of term. Note the top level operator of of parameter diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java index c51f0452be3..19c503cff67 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateApplication.java @@ -80,7 +80,7 @@ public static Term getTarget(Term t) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java index 5f55b7cfaad..ca3586e9aa8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateJunctor.java @@ -37,7 +37,7 @@ private UpdateJunctor(Name name, int arity) { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateSV.java index 44b86cbd2c3..089f3b003e4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/UpdateSV.java @@ -7,12 +7,13 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; /** * A schema variable that is used as placeholder for updates. */ -public final class UpdateSV extends OperatorSV { +public final class UpdateSV extends OperatorSV implements TerminalSyntaxElement { UpdateSV(Name name) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java index 1024cf7b45d..732769c23b4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java @@ -6,12 +6,13 @@ import de.uka.ilkd.key.util.pp.Layouter; import org.key_project.logic.Name; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.logic.sort.Sort; /** * Schema variable that is instantiated with logical variables. */ -public final class VariableSV extends OperatorSV implements QuantifiableVariable { +public final class VariableSV extends OperatorSV implements QuantifiableVariable, TerminalSyntaxElement { /** * Creates a new SchemaVariable that is used as placeholder for bound(quantified) variables. @@ -34,4 +35,6 @@ public void layout(Layouter l) { l.print("\\schemaVar \\variables ").print(sort().name().toString()).print(" ") .print(name().toString()); } + + } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java index 04c17871eea..4f344bb86a2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/sort/ProgramSVSort.java @@ -482,7 +482,7 @@ protected boolean canStandFor(ProgramElement pe, Services services) { || pe instanceof SeqLength || pe instanceof SeqGet || pe instanceof SeqIndexOf || pe instanceof SeqSub || pe instanceof SeqReverse || pe instanceof SeqPut) { if (pe instanceof NonTerminalProgramElement npe) { - for (int i = 0, childCount = npe.getSyntaxChildCount(); i < childCount; i++) { + for (int i = 0, childCount = npe.getChildCount(); i < childCount; i++) { if (!canStandFor(npe.getChildAt(i), services)) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java index 409c6dd32cd..11deca874c7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java @@ -816,11 +816,11 @@ void printLabels(Term t, String left, String right) { afterFirst = true; } layouter.print(l.name().toString()); - if (l.getChildCount() > 0) { + if (l.getTLChildCount() > 0) { layouter.print("(").beginC(); - for (int i = 0; i < l.getChildCount(); i++) { - layouter.print("\"" + l.getChild(i).toString() + "\""); - if (i < l.getChildCount() - 1) { + for (int i = 0; i < l.getTLChildCount(); i++) { + layouter.print("\"" + l.getTLChild(i).toString() + "\""); + if (i < l.getTLChildCount() - 1) { layouter.print(",").ind(1, 2); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java index fbc296e5837..aa4d5c176c9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/PrettyPrinter.java @@ -410,7 +410,7 @@ public void performActionOnDLEmbeddedExpression(DLEmbeddedExpression x) { layouter.print("\\dl_" + x.getFunctionSymbol().name()); layouter.print("("); - for (int i = 0; i < x.getSyntaxChildCount(); i++) { + for (int i = 0; i < x.getChildCount(); i++) { if (i != 0) { layouter.print(",").brk(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java index 1f0aebea363..b8fcfbee6b9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java @@ -314,7 +314,7 @@ private ImmutableList getJavaTacletList( if (pe instanceof ProgramPrefix) { int next = prefixOccurrences.occurred(pe); NonTerminalProgramElement nt = (NonTerminalProgramElement) pe; - if (next < nt.getSyntaxChildCount()) { + if (next < nt.getChildCount()) { return getJavaTacletList(map, nt.getChildAt(next), prefixOccurrences); } } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java index bfd4ff80c55..88f44e40120 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopInvariantBuiltInRuleApp.java @@ -93,7 +93,7 @@ private LoopSpecification instantiateIndexValues(LoopSpecification rawInv, // try to retrieve a loop index variable de.uka.ilkd.key.java.statement.IGuard guard = loop.getGuard(); // the guard is expected to be of the form "i < x" and we want to retrieve "i". - assert guard.getSyntaxChildCount() == 1 : "child count: " + guard.getSyntaxChildCount(); + assert guard.getChildCount() == 1 : "child count: " + guard.getChildCount(); ProgramElement guardStatement = guard.getChildAt(0); skipIndex = !(guardStatement instanceof LessThan); Expression loopIndex = diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java index ca3e68b6a44..74f87909a8f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java @@ -55,7 +55,7 @@ public MatchConditions check(SchemaVariable sv, SVSubstitute instCandidate, assert !instantiatedTerm.javaBlock().isEmpty(); assert instantiatedTerm.javaBlock().program() instanceof StatementBlock; - assert ((StatementBlock) instantiatedTerm.javaBlock().program()).getSyntaxChildCount() == 1; + assert ((StatementBlock) instantiatedTerm.javaBlock().program()).getChildCount() == 1; return matchCond.setInstantiations(// svInst.add(storeInSV, diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/label/OriginTermLabelRefactoring.java b/key.core/src/main/java/de/uka/ilkd/key/rule/label/OriginTermLabelRefactoring.java index 3fc16ba6428..9b964549cfb 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/label/OriginTermLabelRefactoring.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/label/OriginTermLabelRefactoring.java @@ -129,8 +129,8 @@ private Set collectSubtermOrigins(Term term, Set result) { TermLabel label = term.getLabel(OriginTermLabel.NAME); if (label != null) { - result.add((Origin) label.getChild(0)); - result.addAll((Set) label.getChild(1)); + result.add((Origin) label.getTLChild(0)); + result.addAll((Set) label.getTLChild(1)); } ImmutableArray subterms = term.subs(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java index fd5edcccdb6..0b7e5d2716e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/ProgramTransformer.java @@ -134,7 +134,7 @@ public Statement getStatementAt(int index) { * * @return an int giving the number of children of this node */ - public int getSyntaxChildCount() { + public int getChildCount() { return 1; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java index a11be238695..14bc6a66ec1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/metaconstruct/WhileLoopTransformation.java @@ -718,11 +718,11 @@ public void performActionOnMethodFrame(MethodFrame x) { ExtList changeList = stack.peek(); if (!changeList.isEmpty() && changeList.getFirst() == CHANGED) { changeList.removeFirst(); - if (x.getSyntaxChildCount() == 3) { + if (x.getChildCount() == 3) { addChild(KeYJavaASTFactory.methodFrame((IProgramVariable) changeList.get(0), (IExecutionContext) changeList.get(1), (StatementBlock) changeList.get(2), PositionInfo.UNDEFINED)); - } else if (x.getSyntaxChildCount() == 2) { + } else if (x.getChildCount() == 2) { addChild(KeYJavaASTFactory.methodFrame((IExecutionContext) changeList.get(0), (StatementBlock) changeList.get(1), PositionInfo.UNDEFINED)); } else { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java index 00be8ef33e4..15fba88cfc9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/jml/JMLSpecExtractor.java @@ -281,7 +281,7 @@ public ImmutableSet extractClassSpecs(KeYJavaType kjt) } // iterate over all children - for (int i = 0, n = td.getSyntaxChildCount(); i <= n; i++) { + for (int i = 0, n = td.getChildCount(); i <= n; i++) { // collect comments // (last position are comments of type declaration itself) Comment[] comments = null; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Metavariable.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Metavariable.java index 76edd2ab297..44fb3a27177 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Metavariable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Metavariable.java @@ -8,11 +8,12 @@ import org.key_project.logic.Name; import org.key_project.logic.ParsableVariable; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.logic.sort.Sort; @Deprecated public final class Metavariable extends AbstractSortedOperator - implements ParsableVariable, Comparable { + implements ParsableVariable, Comparable, TerminalSyntaxElement { // Used to define an alternative order of all existing // metavariables diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java index c3a3b2599d0..201090e5703 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java @@ -19,6 +19,7 @@ import org.key_project.logic.Name; import org.key_project.logic.TermCreationException; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.logic.op.Modifier; import org.key_project.logic.op.SortedOperator; import org.key_project.logic.sort.Sort; @@ -95,7 +96,7 @@ protected Term generateOneTerm(Term superterm, int child) { return services.getTermBuilder().tf().createTerm(binFunc, superterm, index); } - private static class SuperTermGeneratedOp implements SortedOperator, Operator { + private static class SuperTermGeneratedOp implements SortedOperator, Operator, TerminalSyntaxElement { private final Name NAME; private final IntegerLDT numbers; diff --git a/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java b/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java index 68cd906b2d0..b7f699eeff2 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java +++ b/key.core/src/test/java/de/uka/ilkd/key/java/TestContextStatementBlock.java @@ -43,7 +43,7 @@ public void tearDown() { public void testContextTermInstantiation() { ExtList statementList = new ExtList(); StatementBlock stContainer = (StatementBlock) blockOne.program(); - int size = stContainer.getSyntaxChildCount(); + int size = stContainer.getChildCount(); assertEquals(3, size, "Wrong size. Should have only 3 children"); PosInProgram prefixEnd = PosInProgram.TOP.down(0); assertTrue( diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java index 517a5a78a8c..8599f8d81d3 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java @@ -557,18 +557,18 @@ public void testParseLabel() throws TermLabelException { TermLabel label = manager.parseLabel("ONE", null, services); assertTrue(label instanceof LoggingTermLabel); assertEquals("ONE", label.name().toString()); - assertEquals(0, label.getChildCount()); + assertEquals(0, label.getTLChildCount()); // Test empty parameter label = manager.parseLabel("TWO", null, services); assertTrue(label instanceof LoggingTermLabel); assertEquals("TWO", label.name().toString()); - assertEquals(0, label.getChildCount()); + assertEquals(0, label.getTLChildCount()); // Test with parameter label = manager.parseLabel("THREE", Collections.singletonList("Param"), services); assertTrue(label instanceof LoggingTermLabel); assertEquals("THREE", label.name().toString()); - assertEquals(1, label.getChildCount()); - assertEquals("Param", label.getChild(0)); + assertEquals(1, label.getTLChildCount()); + assertEquals("Param", label.getTLChild(0)); // Test unsupported try { manager.parseLabel("UNKNOWN", null, services); @@ -850,12 +850,12 @@ public Name name() { } @Override - public Object getChild(int i) { + public Object getTLChild(int i) { return arguments.get(i); } @Override - public int getChildCount() { + public int getTLChildCount() { return arguments != null ? arguments.size() : 0; } } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java index 2439237ae9e..a0e61d60102 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java @@ -21,5 +21,5 @@ public interface SyntaxElement { * * @return the number of children of this syntax element. */ - int getSyntaxChildCount(); + int getChildCount(); } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index b6b20313bbe..cc4892122b3 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -22,7 +22,7 @@ public SyntaxElement getCurrentNode() { } public boolean gotoFirstChild() { - if (node.getSyntaxChildCount() <= 0) + if (node.getChildCount() <= 0) return false; path.push(new ParentAndPosition(node, 0)); node = node.getChild(0); @@ -35,7 +35,7 @@ public boolean gotoNextSibling() { var pnp = path.pop(); SyntaxElement parent = pnp.parent; int index = pnp.index + 1; - if (index > parent.getSyntaxChildCount()) { + if (index > parent.getChildCount()) { return false; } path.push(new ParentAndPosition(parent, index)); diff --git a/key.ncore/src/main/java/org/key_project/logic/Term.java b/key.ncore/src/main/java/org/key_project/logic/Term.java index a66d82ecc52..5dc16e0ea29 100644 --- a/key.ncore/src/main/java/org/key_project/logic/Term.java +++ b/key.ncore/src/main/java/org/key_project/logic/Term.java @@ -93,7 +93,7 @@ public interface Term extends LogicElement, Sorted { void execPreOrder(Visitor visitor); @Override - default int getSyntaxChildCount() { + default int getChildCount() { return 1 + boundVars().size() + subs().size(); } @@ -108,6 +108,6 @@ default SyntaxElement getChild(int n) { if (n < subs().size()) return sub(n); throw new IndexOutOfBoundsException( - "Term " + this + " has only " + getSyntaxChildCount() + " children"); + "Term " + this + " has only " + getChildCount() + " children"); } } diff --git a/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java new file mode 100644 index 00000000000..e6d25f7ae00 --- /dev/null +++ b/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java @@ -0,0 +1,13 @@ +package org.key_project.logic; + +public interface TerminalSyntaxElement extends SyntaxElement{ + @Override + default SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(this.getClass() + " " + this + " has no children"); + } + + @Override + default int getChildCount() { + return 0; + } +} diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Function.java b/key.ncore/src/main/java/org/key_project/logic/op/Function.java index 1f638f9efd8..ec55b5dcd44 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Function.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Function.java @@ -54,7 +54,7 @@ public final String toString() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java index 4a6c01643e3..9df6dccc9bd 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java @@ -43,7 +43,7 @@ public final K kind() { public abstract Program program(); @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 2; } @@ -92,7 +92,7 @@ public int hashCode() { } @Override - public int getSyntaxChildCount() { + public int getChildCount() { return 0; } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java index 0de19c95623..1ee7b710b81 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java @@ -815,7 +815,7 @@ private static PositionInfo joinPositionsRec(SourceElement se) { PositionInfo pos = se.getPositionInfo(); - for (int i = 0; i < ntpe.getSyntaxChildCount(); i++) { + for (int i = 0; i < ntpe.getChildCount(); i++) { ProgramElement pe2 = ntpe.getChildAt(i); pos = PositionInfo.join(pos, joinPositionsRec(pe2)); } From 1bb54fc29654174f1d0e4d80621ac9b403b634f0 Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 22 May 2024 10:47:36 +0200 Subject: [PATCH 06/15] Clean up inheritance --- .../key/java/JavaNonTerminalProgramElement.java | 5 ----- .../key/java/NonTerminalProgramElement.java | 6 ++++++ .../ilkd/key/java/TerminalProgramElement.java | 11 ++--------- .../uka/ilkd/key/java/declaration/Modifier.java | 13 ++++++++++++- .../key/java/declaration/modifier/Static.java | 1 + .../ilkd/key/java/statement/IForUpdates.java | 2 +- .../uka/ilkd/key/java/statement/ILoopInit.java | 3 ++- .../de/uka/ilkd/key/logic/op/ProgramSV.java | 6 +++--- .../de/uka/ilkd/key/logic/op/Qualifier.java | 13 ++----------- .../java/org/key_project/logic/op/Modality.java | 17 ++--------------- 10 files changed, 31 insertions(+), 46 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java index 8a1b4c0cf82..4f1dfdb2ff2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java @@ -164,9 +164,4 @@ protected MatchConditions matchChildren(SourceData source, MatchConditions match return matchCond; } - - @Override - public SyntaxElement getChild(int n) { - return getChildAt(n); - } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java index ca20a719d4d..1865f6e964c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/NonTerminalProgramElement.java @@ -3,6 +3,8 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java; +import org.key_project.logic.SyntaxElement; + /** * Non terminal program element. taken from COMPOST and changed to achieve an immutable structure */ @@ -25,4 +27,8 @@ public interface NonTerminalProgramElement extends ProgramElement { */ ProgramElement getChildAt(int index); + @Override + default SyntaxElement getChild(int n) { + return getChildAt(n); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java index 653187dc473..d240ddafb2e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java @@ -4,19 +4,12 @@ package de.uka.ilkd.key.java; import org.key_project.logic.SyntaxElement; +import org.key_project.logic.TerminalSyntaxElement; /** * Terminal program element. taken from COMPOST and changed to achieve an immutable structure */ -public interface TerminalProgramElement extends ProgramElement { - @Override - default int getChildCount() { - return 0; - } +public interface TerminalProgramElement extends ProgramElement, TerminalSyntaxElement { - @Override - default SyntaxElement getChild(int n) { - throw new IndexOutOfBoundsException("Program element " + this + " has no children"); - } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java index 357d417d3ca..c6533ebfe38 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java @@ -7,13 +7,14 @@ import de.uka.ilkd.key.java.TerminalProgramElement; import de.uka.ilkd.key.java.visitor.Visitor; +import org.key_project.logic.SyntaxElement; import org.key_project.util.ExtList; /** * Modifier. taken from COMPOST and changed to achieve an immutable structure */ -public abstract class Modifier extends JavaProgramElement implements TerminalProgramElement { +public abstract class Modifier extends JavaProgramElement { /** * Modifier. @@ -56,4 +57,14 @@ public String getText() { public void visit(Visitor v) { v.performActionOnModifier(this); } + + @Override + public int getChildCount() { + return 0; + } + + @Override + public SyntaxElement getChild(int n) { + throw new IndexOutOfBoundsException(getClass() + " " + this + " has no children"); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java index 6efc4cf1f20..f99f1494181 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java @@ -5,6 +5,7 @@ import de.uka.ilkd.key.java.declaration.Modifier; +import org.key_project.logic.TerminalSyntaxElement; import org.key_project.util.ExtList; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/IForUpdates.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/IForUpdates.java index a532522aa5e..75d499d1cdf 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/IForUpdates.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/IForUpdates.java @@ -7,7 +7,7 @@ import org.key_project.util.collection.ImmutableArray; -public interface IForUpdates extends de.uka.ilkd.key.java.TerminalProgramElement { +public interface IForUpdates extends de.uka.ilkd.key.java.NonTerminalProgramElement { int size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java index c8528112d4d..362b5b85e4a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java @@ -4,11 +4,12 @@ package de.uka.ilkd.key.java.statement; import de.uka.ilkd.key.java.LoopInitializer; +import de.uka.ilkd.key.java.NonTerminalProgramElement; import de.uka.ilkd.key.java.TerminalProgramElement; import org.key_project.util.collection.ImmutableArray; -public interface ILoopInit extends TerminalProgramElement { +public interface ILoopInit extends NonTerminalProgramElement { int size(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java index 8a0406ee4b6..efd705956fc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java @@ -34,7 +34,7 @@ * Objects of this class are schema variables matching program constructs within modal operators. * The particular construct being matched is determined by the ProgramSVSort of the schema variable. */ -public final class ProgramSV extends OperatorSV implements ProgramConstruct, UpdateableOperator , TerminalSyntaxElement { +public final class ProgramSV extends OperatorSV implements ProgramConstruct, UpdateableOperator , SyntaxElement { public static final Logger LOGGER = LoggerFactory.getLogger(ProgramSV.class); private static final ProgramList EMPTY_LIST_INSTANTIATION = @@ -150,12 +150,12 @@ public ProgramElement getChildAt(int index) { @Override public SyntaxElement getChild(int n) { - return TerminalSyntaxElement.super.getChild(n); + throw new IndexOutOfBoundsException("ProgramSV " + this + " has no children"); } @Override public int getChildCount() { - return TerminalSyntaxElement.super.getChildCount(); + return 0; } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java index ad978c0b346..ed06827732d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java @@ -6,8 +6,9 @@ import java.util.WeakHashMap; import org.key_project.logic.SyntaxElement; +import org.key_project.logic.TerminalSyntaxElement; -public class Qualifier implements SyntaxElement { +public class Qualifier implements TerminalSyntaxElement { private final T qualifier; private static final WeakHashMap> INSTANCES = new WeakHashMap<>(); @@ -28,14 +29,4 @@ synchronized static Qualifier create(T qualifier) { public T getQualifier() { return qualifier; } - - @Override - public SyntaxElement getChild(int n) { - return null; - } - - @Override - public int getChildCount() { - return 0; - } } diff --git a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java index 9df6dccc9bd..9c93156a847 100644 --- a/key.ncore/src/main/java/org/key_project/logic/op/Modality.java +++ b/key.ncore/src/main/java/org/key_project/logic/op/Modality.java @@ -5,10 +5,7 @@ import java.util.Objects; -import org.key_project.logic.Name; -import org.key_project.logic.Named; -import org.key_project.logic.Program; -import org.key_project.logic.SyntaxElement; +import org.key_project.logic.*; import org.key_project.logic.sort.Sort; import org.jspecify.annotations.Nullable; @@ -60,7 +57,7 @@ public SyntaxElement getChild(int n) { /** * Modality kinds like box and diamond. */ - public abstract static class Kind implements Named, SyntaxElement { + public abstract static class Kind implements Named, TerminalSyntaxElement { private final Name name; public Kind(Name name) { @@ -90,15 +87,5 @@ public boolean equals(@Nullable Object o) { public int hashCode() { return Objects.hash(name()); } - - @Override - public int getChildCount() { - return 0; - } - - @Override - public SyntaxElement getChild(int n) { - throw new IndexOutOfBoundsException("Modality kind " + name() + " has no children"); - } } } From 92e0ae9f0e0ee805ea30e2eea035253f3bce359e Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 22 May 2024 10:59:03 +0200 Subject: [PATCH 07/15] Remove SVSubstitute --- .../AbstractConditionalBreakpoint.java | 29 ++++++++++--------- .../java/JavaNonTerminalProgramElement.java | 1 - .../de/uka/ilkd/key/java/SourceElement.java | 3 +- .../ilkd/key/java/TerminalProgramElement.java | 1 - .../ilkd/key/java/declaration/Modifier.java | 1 - .../key/java/declaration/modifier/Static.java | 1 - .../ilkd/key/java/statement/ILoopInit.java | 1 - .../uka/ilkd/key/logic/ProgramConstruct.java | 3 +- .../main/java/de/uka/ilkd/key/logic/Term.java | 3 +- .../uka/ilkd/key/logic/label/TermLabel.java | 2 +- .../de/uka/ilkd/key/logic/op/Modality.java | 2 +- .../de/uka/ilkd/key/logic/op/Operator.java | 2 +- .../de/uka/ilkd/key/logic/op/ProgramSV.java | 4 +-- .../de/uka/ilkd/key/logic/op/Qualifier.java | 1 - .../uka/ilkd/key/logic/op/SVSubstitute.java | 12 -------- .../ilkd/key/logic/op/TermTransformer.java | 4 ++- .../de/uka/ilkd/key/logic/op/VariableSV.java | 3 +- .../de/uka/ilkd/key/proof/OpReplacer.java | 12 ++++---- .../de/uka/ilkd/key/proof/ReplacementMap.java | 13 +++++---- .../de/uka/ilkd/key/rule/TacletMatcher.java | 5 ++-- .../uka/ilkd/key/rule/VariableCondition.java | 6 ++-- .../key/rule/VariableConditionAdapter.java | 7 +++-- .../conditions/AbstractOrInterfaceType.java | 4 +-- .../AlternativeVariableCondition.java | 5 ++-- .../ApplyUpdateOnRigidCondition.java | 4 ++- .../ArrayComponentTypeCondition.java | 4 +-- .../rule/conditions/ArrayLengthCondition.java | 5 ++-- .../rule/conditions/ArrayTypeCondition.java | 4 +-- .../rule/conditions/ConstantCondition.java | 5 ++-- .../ContainsAssignmentCondition.java | 5 ++-- .../key/rule/conditions/DifferentFields.java | 4 +-- .../DifferentInstantiationCondition.java | 4 +-- .../DropEffectlessElementariesCondition.java | 6 ++-- .../DropEffectlessStoresCondition.java | 5 ++-- .../conditions/EnumConstantCondition.java | 5 ++-- .../rule/conditions/EnumTypeCondition.java | 4 +-- .../rule/conditions/EqualUniqueCondition.java | 4 ++- .../conditions/FieldTypeToSortCondition.java | 3 +- .../conditions/FinalReferenceCondition.java | 5 ++-- .../FreeLabelInVariableCondition.java | 5 ++-- .../conditions/HasLoopInvariantCondition.java | 5 ++-- .../ilkd/key/rule/conditions/InStrictFp.java | 5 ++-- .../rule/conditions/IsLabeledCondition.java | 5 ++-- .../key/rule/conditions/IsThisReference.java | 4 +-- .../conditions/JavaTypeToSortCondition.java | 4 +-- .../conditions/LocalVariableCondition.java | 5 ++-- .../LoopFreeInvariantCondition.java | 5 ++-- .../conditions/LoopInvariantCondition.java | 5 ++-- .../rule/conditions/LoopVariantCondition.java | 5 ++-- .../conditions/MayExpandMethodCondition.java | 4 +-- .../conditions/MetaDisjointCondition.java | 3 +- .../rule/conditions/ModelFieldCondition.java | 5 ++-- .../conditions/NewJumpLabelCondition.java | 6 ++-- .../rule/conditions/ObserverCondition.java | 6 ++-- .../conditions/SameObserverCondition.java | 5 ++-- .../SimplifyIfThenElseUpdateCondition.java | 4 ++- .../rule/conditions/StaticFieldCondition.java | 4 ++- .../conditions/StaticMethodCondition.java | 4 +-- .../conditions/StaticReferenceCondition.java | 5 ++-- .../rule/conditions/StoreStmtInCondition.java | 5 ++-- .../rule/conditions/StoreTermInCondition.java | 5 ++-- .../rule/conditions/SubFormulaCondition.java | 5 ++-- .../rule/conditions/TermLabelCondition.java | 4 +-- .../conditions/TypeComparisonCondition.java | 4 +-- .../key/rule/conditions/TypeCondition.java | 4 +-- .../key/rule/conditions/TypeResolver.java | 26 ++++++++--------- .../uka/ilkd/key/rule/inst/ProgramList.java | 14 +++++++-- .../key/rule/match/vm/VMTacletMatcher.java | 8 ++--- .../key/speclang/DependencyContractImpl.java | 14 ++++----- .../FunctionalOperationContractImpl.java | 11 +++---- .../ilkd/key/speclang/LoopContractImpl.java | 4 +-- .../uka/ilkd/key/speclang/ReplacementMap.java | 5 ++-- .../termgenerator/SuperTermGenerator.java | 3 +- .../TestApplyUpdateOnRigidCondition.java | 3 +- .../logic/TerminalSyntaxElement.java | 5 +++- 75 files changed, 224 insertions(+), 182 deletions(-) delete mode 100644 key.core/src/main/java/de/uka/ilkd/key/logic/op/SVSubstitute.java diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/AbstractConditionalBreakpoint.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/AbstractConditionalBreakpoint.java index c6084f2b8fb..d997436ad8e 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/AbstractConditionalBreakpoint.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/breakpoint/AbstractConditionalBreakpoint.java @@ -32,6 +32,7 @@ import de.uka.ilkd.key.symbolic_execution.util.SymbolicExecutionSideProofUtil; import de.uka.ilkd.key.symbolic_execution.util.SymbolicExecutionUtil; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -76,7 +77,7 @@ public abstract class AbstractConditionalBreakpoint extends AbstractHitCountBrea * A {@link Map} mapping from relevant variables for the condition to their runtime equivalent * in KeY */ - private Map variableNamingMap; + private Map variableNamingMap; /** * The list of parameter variables of the method that contains the associated breakpoint @@ -162,14 +163,14 @@ private void putValuesFromGlobalVars(ProgramVariable varForCondition, Node node, * * @return the cloned map */ - private Map getOldMap() { - Map oldMap = new HashMap<>(); - for (Entry svSubstituteSVSubstituteEntry : getVariableNamingMap() + private Map getOldMap() { + Map oldMap = new HashMap<>(); + for (Entry svSubstituteSVSubstituteEntry : getVariableNamingMap() .entrySet()) { Entry oldEntry = svSubstituteSVSubstituteEntry; - if (oldEntry.getKey() instanceof SVSubstitute - && oldEntry.getValue() instanceof SVSubstitute) { - oldMap.put((SVSubstitute) oldEntry.getKey(), (SVSubstitute) oldEntry.getValue()); + if (oldEntry.getKey() instanceof SyntaxElement + && oldEntry.getValue() instanceof SyntaxElement) { + oldMap.put((SyntaxElement) oldEntry.getKey(), (SyntaxElement) oldEntry.getValue()); } } return oldMap; @@ -200,7 +201,7 @@ private void freeVariablesAfterReturn(Node node, RuleApp ruleApp, boolean inScop * @param oldMap the oldMap variableNamings */ private void putValuesFromRenamings(ProgramVariable varForCondition, Node node, boolean inScope, - Map oldMap, RuleApp ruleApp) { + Map oldMap, RuleApp ruleApp) { // look for renamings KeY did boolean found = false; // get current renaming tables @@ -215,7 +216,7 @@ private void putValuesFromRenamings(ProgramVariable varForCondition, Node node, .getHashMap().entrySet()) { Entry entry = value; if (entry.getKey() instanceof LocationVariable - && entry.getValue() instanceof SVSubstitute) { + && entry.getValue() instanceof SyntaxElement) { if ((VariableNamer.getBasename(((LocationVariable) entry.getKey()).name())) .equals(varForCondition.name()) && ((LocationVariable) entry.getKey()).name().toString() @@ -229,7 +230,7 @@ private void putValuesFromRenamings(ProgramVariable varForCondition, Node node, // add new value toKeep.add((LocationVariable) entry.getValue()); getVariableNamingMap().put(varForCondition, - (SVSubstitute) entry.getValue()); + (SyntaxElement) entry.getValue()); found = true; break; } else if (inScope && ((LocationVariable) entry.getKey()).name() @@ -242,7 +243,7 @@ private void putValuesFromRenamings(ProgramVariable varForCondition, Node node, // add new value toKeep.add((LocationVariable) entry.getValue()); getVariableNamingMap().put(varForCondition, - (SVSubstitute) entry.getValue()); + (SyntaxElement) entry.getValue()); found = true; break; } @@ -263,7 +264,7 @@ private void putValuesFromRenamings(ProgramVariable varForCondition, Node node, protected void refreshVarMaps(RuleApp ruleApp, Node node) { boolean inScope = isInScope(node); // collect old values - Map oldMap = getOldMap(); + Map oldMap = getOldMap(); // put values into map which have to be replaced for (ProgramVariable varForCondition : getVarsForCondition()) { // put global variables only done when a variable is instantiated by @@ -498,14 +499,14 @@ public Set getToKeep() { /** * @return the variableNamingMap */ - public Map getVariableNamingMap() { + public Map getVariableNamingMap() { return variableNamingMap; } /** * @param variableNamingMap the variableNamingMap to set */ - public void setVariableNamingMap(Map variableNamingMap) { + public void setVariableNamingMap(Map variableNamingMap) { this.variableNamingMap = variableNamingMap; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java index 4f1dfdb2ff2..ded5c975478 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/JavaNonTerminalProgramElement.java @@ -5,7 +5,6 @@ import de.uka.ilkd.key.rule.MatchConditions; -import org.key_project.logic.SyntaxElement; import org.key_project.util.ExtList; import org.key_project.util.collection.ImmutableArray; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java index d9709324c9d..206efd7fb8e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/SourceElement.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.java; import de.uka.ilkd.key.java.visitor.Visitor; -import de.uka.ilkd.key.logic.op.SVSubstitute; import org.key_project.logic.SyntaxElement; @@ -14,7 +13,7 @@ * to achieve an immutable structure */ -public interface SourceElement extends SVSubstitute, SyntaxElement { +public interface SourceElement extends SyntaxElement { /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java index d240ddafb2e..e6fdc309f71 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/TerminalProgramElement.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.java; -import org.key_project.logic.SyntaxElement; import org.key_project.logic.TerminalSyntaxElement; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java index c6533ebfe38..b8fd1e2d410 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/Modifier.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.java.declaration; import de.uka.ilkd.key.java.JavaProgramElement; -import de.uka.ilkd.key.java.TerminalProgramElement; import de.uka.ilkd.key.java.visitor.Visitor; import org.key_project.logic.SyntaxElement; diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java index f99f1494181..6efc4cf1f20 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/declaration/modifier/Static.java @@ -5,7 +5,6 @@ import de.uka.ilkd.key.java.declaration.Modifier; -import org.key_project.logic.TerminalSyntaxElement; import org.key_project.util.ExtList; /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java index 362b5b85e4a..ee0bc657b95 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java +++ b/key.core/src/main/java/de/uka/ilkd/key/java/statement/ILoopInit.java @@ -5,7 +5,6 @@ import de.uka.ilkd.key.java.LoopInitializer; import de.uka.ilkd.key.java.NonTerminalProgramElement; -import de.uka.ilkd.key.java.TerminalProgramElement; import org.key_project.util.collection.ImmutableArray; diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java b/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java index 6457646b443..8b68b44f4dc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/ProgramConstruct.java @@ -17,6 +17,7 @@ import de.uka.ilkd.key.java.statement.ILoopInit; import de.uka.ilkd.key.logic.op.IProgramMethod; import de.uka.ilkd.key.logic.op.IProgramVariable; + import org.key_project.logic.SyntaxElement; /** @@ -31,5 +32,5 @@ public interface ProgramConstruct extends Expression, Statement, ILoopInit, IFor SyntaxElement getChild(int n); @Override - int getChildCount() ; + int getChildCount(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java index 60c03e6fdae..73e99f387e2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import org.key_project.logic.Name; import org.key_project.logic.Visitor; @@ -43,7 +42,7 @@ * supported: {@link Term#execPostOrder(Visitor)} and {@link Term#execPreOrder(Visitor)}. */ public interface Term - extends SVSubstitute, Sorted, TermEqualsModProperty, org.key_project.logic.Term { + extends Sorted, TermEqualsModProperty, org.key_project.logic.Term { @Override Operator op(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java index a1ffadb28ea..a5287c1f2d1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java @@ -152,7 +152,7 @@ * @see TermLabelManager */ // spotless:on -public interface TermLabel extends Named, SyntaxElement, /* TODO: Remove*/ TerminalSyntaxElement { +public interface TermLabel extends Named, SyntaxElement, /* TODO: Remove */ TerminalSyntaxElement { /** * Retrieves the i-th parameter object of this term label. diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Modality.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Modality.java index 0510d66fc73..c9d4557970b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Modality.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Modality.java @@ -125,7 +125,7 @@ public String toString() { return super.toString(); } - public static class JavaModalityKind extends Kind implements SVSubstitute { + public static class JavaModalityKind extends Kind { private static final Map kinds = new HashMap<>(); /** * The diamond operator of dynamic logic. A formula Phi can be read as after diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Operator.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Operator.java index e12cfc522c6..3647725e850 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Operator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Operator.java @@ -13,7 +13,7 @@ * etc. have to implement this interface. */ public interface Operator - extends org.key_project.logic.op.Operator, SVSubstitute, EqualsModProofIrrelevancy { + extends org.key_project.logic.op.Operator, EqualsModProofIrrelevancy { /** * comparator to compare operators; for modalities only their kind is compared diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java index efd705956fc..394c0f736a1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/ProgramSV.java @@ -23,7 +23,6 @@ import org.key_project.logic.Name; import org.key_project.logic.SyntaxElement; -import org.key_project.logic.TerminalSyntaxElement; import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableList; @@ -34,7 +33,8 @@ * Objects of this class are schema variables matching program constructs within modal operators. * The particular construct being matched is determined by the ProgramSVSort of the schema variable. */ -public final class ProgramSV extends OperatorSV implements ProgramConstruct, UpdateableOperator , SyntaxElement { +public final class ProgramSV extends OperatorSV + implements ProgramConstruct, UpdateableOperator, SyntaxElement { public static final Logger LOGGER = LoggerFactory.getLogger(ProgramSV.class); private static final ProgramList EMPTY_LIST_INSTANTIATION = diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java index ed06827732d..2450b036d2e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/Qualifier.java @@ -5,7 +5,6 @@ import java.util.WeakHashMap; -import org.key_project.logic.SyntaxElement; import org.key_project.logic.TerminalSyntaxElement; public class Qualifier implements TerminalSyntaxElement { diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SVSubstitute.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/SVSubstitute.java deleted file mode 100644 index b7f183d6ed5..00000000000 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/SVSubstitute.java +++ /dev/null @@ -1,12 +0,0 @@ -/* This file is part of KeY - https://key-project.org - * KeY is licensed under the GNU General Public License Version 2 - * SPDX-License-Identifier: GPL-2.0-only */ -package de.uka.ilkd.key.logic.op; - -/** - * JavaCardDL syntactical elements implement this interface if they can occur as instantiations of - * schema variables. - */ -public interface SVSubstitute { - -} diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java index bb21080c5a3..4ca7e30a52f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/TermTransformer.java @@ -6,13 +6,15 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.rule.inst.SVInstantiations; + import org.key_project.logic.TerminalSyntaxElement; /** * TermTransformer perform complex term transformation which cannot be (efficiently or at all) * described by taclets. */ -public interface TermTransformer extends org.key_project.logic.op.SortedOperator, Operator, /*TODO: check*/ TerminalSyntaxElement { +public interface TermTransformer extends org.key_project.logic.op.SortedOperator, Operator, + /* TODO: check */ TerminalSyntaxElement { /** * initiates term transformation of term. Note the top level operator of of parameter diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java b/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java index 732769c23b4..fcbec1e7937 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/op/VariableSV.java @@ -12,7 +12,8 @@ /** * Schema variable that is instantiated with logical variables. */ -public final class VariableSV extends OperatorSV implements QuantifiableVariable, TerminalSyntaxElement { +public final class VariableSV extends OperatorSV + implements QuantifiableVariable, TerminalSyntaxElement { /** * Creates a new SchemaVariable that is used as placeholder for bound(quantified) variables. diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/OpReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/OpReplacer.java index 55a54a489f3..a50e7a424b1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/OpReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/OpReplacer.java @@ -10,9 +10,9 @@ import de.uka.ilkd.key.logic.TermFactory; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.util.InfFlowSpec; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableList; @@ -36,7 +36,7 @@ public class OpReplacer { /** * The replacement map. */ - private final ReplacementMap map; + private final ReplacementMap map; /** *

@@ -53,7 +53,7 @@ public class OpReplacer { * with * @param tf a term factory. */ - public OpReplacer(Map map, TermFactory tf) { + public OpReplacer(Map map, TermFactory tf) { this(map, tf, null); } @@ -65,12 +65,12 @@ public OpReplacer(Map map, TermF * @param tf a term factory. * @param proof the currently loaded proof */ - public OpReplacer(Map map, TermFactory tf, + public OpReplacer(Map map, TermFactory tf, Proof proof) { assert map != null; this.map = map instanceof ReplacementMap - ? (ReplacementMap) map + ? (ReplacementMap) map : ReplacementMap.create(tf, proof, map); this.tf = tf; @@ -234,7 +234,7 @@ public Term replace(Term term) { return newTerm; } - for (SVSubstitute svs : map.keySet()) { + for (SyntaxElement svs : map.keySet()) { if (term.equalsModProperty(svs, TERM_LABELS_PROPERTY)) { return (Term) map.get(svs); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/ReplacementMap.java b/key.core/src/main/java/de/uka/ilkd/key/proof/ReplacementMap.java index 88fe0af0499..a6df47649fb 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/ReplacementMap.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/ReplacementMap.java @@ -11,11 +11,12 @@ import de.uka.ilkd.key.logic.TermFactory; import de.uka.ilkd.key.logic.label.OriginTermLabel; import de.uka.ilkd.key.logic.label.TermLabelManager; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.settings.ProofSettings; import de.uka.ilkd.key.settings.TermLabelSettings; import de.uka.ilkd.key.util.LinkedHashMap; +import org.key_project.logic.SyntaxElement; + /** * A map to be used in an {@link OpReplacer}. It maps operators that should be replaced to their * replacements. @@ -25,7 +26,7 @@ * @param the type of the elements to replace. * @param the type of the replacements. */ -public interface ReplacementMap extends Map { +public interface ReplacementMap extends Map { /** * Creates a new replacement map. @@ -36,7 +37,7 @@ public interface ReplacementMap extends Map { * @param proof the currently loaded proof, or {@code null} if no proof is loaded. * @return a new replacement map. */ - static ReplacementMap create(TermFactory tf, + static ReplacementMap create(TermFactory tf, Proof proof) { var noIrrelevantTermLabelsMap = proof == null ? ProofSettings.DEFAULT_SETTINGS.getTermLabelSettings().getUseOriginLabels() @@ -58,7 +59,7 @@ static ReplacementMap create(TermFactory tf, * @param initialMappings a map whose mapping should be added to the new replacement map. * @return a new replacement map. */ - static ReplacementMap create(TermFactory tf, + static ReplacementMap create(TermFactory tf, Proof proof, Map initialMappings) { ReplacementMap result = create(tf, proof); result.putAll(initialMappings); @@ -77,7 +78,7 @@ static ReplacementMap create(TermFactory tf, * @param the type of the operators to replace. * @param the type of the replacements. */ - class DefaultReplacementMap extends LinkedHashMap + class DefaultReplacementMap extends LinkedHashMap implements ReplacementMap { private static final long serialVersionUID = 6223486569442129676L; } @@ -98,7 +99,7 @@ class DefaultReplacementMap extends LinkedHashMap + class NoIrrelevantLabelsReplacementMap implements ReplacementMap { /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletMatcher.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletMatcher.java index 567b38b68f1..9ca5be95b01 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletMatcher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletMatcher.java @@ -6,9 +6,10 @@ import de.uka.ilkd.key.java.ProgramElement; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; +import org.key_project.logic.SyntaxElement; + public interface TacletMatcher { /** @@ -69,7 +70,7 @@ MatchConditions checkConditions(MatchConditions p_matchconditions, * instantiationCandidate or null if a match was not possible */ MatchConditions checkVariableConditions(SchemaVariable var, - SVSubstitute instantiationCandidate, MatchConditions matchCond, Services services); + SyntaxElement instantiationCandidate, MatchConditions matchCond, Services services); /** * matches the given term against the taclet's find term if the taclet has no find term or the diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/VariableCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/VariableCondition.java index aa9cc4495e5..1907547ddc7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/VariableCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/VariableCondition.java @@ -4,9 +4,10 @@ package de.uka.ilkd.key.rule; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; +import org.key_project.logic.SyntaxElement; + /** * The instantiations of a schemavariable can be restricted on rule scope by attaching conditions on @@ -30,7 +31,8 @@ public interface VariableCondition { * @return modified match results if the condition can be satisfied, or null * otherwise */ - MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, MatchConditions matchCond, + MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, + MatchConditions matchCond, Services services); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/VariableConditionAdapter.java b/key.core/src/main/java/de/uka/ilkd/key/rule/VariableConditionAdapter.java index cb29e713636..d2c19ec07fb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/VariableConditionAdapter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/VariableConditionAdapter.java @@ -4,10 +4,11 @@ package de.uka.ilkd.key.rule; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * The variable condition adapter can be used by variable conditions which can either fail or be @@ -24,13 +25,13 @@ public abstract class VariableConditionAdapter implements VariableCondition { * @param services the program information object * @return true iff condition is fulfilled */ - public abstract boolean check(SchemaVariable var, SVSubstitute instCandidate, + public abstract boolean check(SchemaVariable var, SyntaxElement instCandidate, SVInstantiations instMap, Services services); @Override - public final MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, + public final MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, MatchConditions mc, Services services) { return check(var, instCandidate, mc.getInstantiations(), services) ? mc : null; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AbstractOrInterfaceType.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AbstractOrInterfaceType.java index 396d872b368..8ff2d7edcb0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AbstractOrInterfaceType.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AbstractOrInterfaceType.java @@ -4,11 +4,11 @@ package de.uka.ilkd.key.rule.conditions; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -34,7 +34,7 @@ public TypeResolver getTypeResolver() { } @Override - public boolean check(SchemaVariable var, SVSubstitute instCandidate, SVInstantiations instMap, + public boolean check(SchemaVariable var, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { final Sort sort = resolver.resolveSort(var, instCandidate, instMap, services); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AlternativeVariableCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AlternativeVariableCondition.java index 5ac5d19f8b3..8b1455e32bb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AlternativeVariableCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/AlternativeVariableCondition.java @@ -5,11 +5,12 @@ import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * disjoin two variable conditions @@ -30,7 +31,7 @@ public AlternativeVariableCondition(VariableConditionAdapter delegate0, * check whether any of the two delegates apply */ @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { return delegate0.check(var, subst, svInst, services) || delegate1.check(var, subst, svInst, services); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ApplyUpdateOnRigidCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ApplyUpdateOnRigidCondition.java index 78f40a82ba6..511ce913b22 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ApplyUpdateOnRigidCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ApplyUpdateOnRigidCondition.java @@ -13,6 +13,7 @@ import de.uka.ilkd.key.rule.inst.SVInstantiations; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableSet; @@ -198,7 +199,8 @@ private static boolean nameIsAlreadyUsed(Name name, ImmutableSet toExpArray( @SuppressWarnings("unchecked") @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { Map tacletOptions = services.getProof().getSettings().getChoiceSettings().getDefaultChoices(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/MetaDisjointCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/MetaDisjointCondition.java index 58f2f5e8ef4..a657c581069 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/MetaDisjointCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/MetaDisjointCondition.java @@ -10,6 +10,7 @@ import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.op.Function; import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableSet; @@ -66,7 +67,7 @@ private static boolean clearlyDisjoint(Term t1, Term t2, Services services) { @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { final Term s1Inst = (Term) svInst.getInstantiation(var1); final Term s2Inst = (Term) svInst.getInstantiation(var2); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ModelFieldCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ModelFieldCondition.java index 84b479a3a64..cfcc8aa1240 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ModelFieldCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ModelFieldCondition.java @@ -20,11 +20,12 @@ import de.uka.ilkd.key.java.reference.FieldReference; import de.uka.ilkd.key.logic.op.ProgramConstant; import de.uka.ilkd.key.logic.op.ProgramVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * This variable condition checks if the instantiation of a schemavariable (of * type Field) refers to a Java field declared as "model". @@ -47,7 +48,7 @@ public ModelFieldCondition(SchemaVariable field, boolean negated) { } @Override - public boolean check(SchemaVariable var, SVSubstitute subst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations instMap, Services services) { if (var == field) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/NewJumpLabelCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/NewJumpLabelCondition.java index 063b580d813..4823f007a09 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/NewJumpLabelCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/NewJumpLabelCondition.java @@ -12,7 +12,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.visitor.LabelCollector; import de.uka.ilkd.key.logic.op.ProgramSV; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.sort.ProgramSVSort; import de.uka.ilkd.key.rule.MatchConditions; @@ -20,6 +19,7 @@ import de.uka.ilkd.key.rule.inst.InstantiationEntry; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableMapEntry; /** @@ -41,11 +41,11 @@ public NewJumpLabelCondition(SchemaVariable sv) { } @Override - public MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, + public MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, MatchConditions matchCond, Services services) { if (var != labelSV && matchCond.getInstantiations().isInstantiated(labelSV)) { var = labelSV; - instCandidate = (SVSubstitute) matchCond.getInstantiations().getInstantiation(labelSV); + instCandidate = (SyntaxElement) matchCond.getInstantiations().getInstantiation(labelSV); } if (var == labelSV) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ObserverCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ObserverCondition.java index 88695c74bd0..8c877c2cc6c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ObserverCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/ObserverCondition.java @@ -7,13 +7,14 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.IObserverFunction; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.op.TermSV; import de.uka.ilkd.key.rule.MatchConditions; import de.uka.ilkd.key.rule.VariableCondition; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + public final class ObserverCondition implements VariableCondition { @@ -28,7 +29,8 @@ public ObserverCondition(TermSV obs, TermSV heap) { @Override - public MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, MatchConditions mc, + public MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, + MatchConditions mc, Services services) { SVInstantiations svInst = mc.getInstantiations(); final Term obsInst = (Term) svInst.getInstantiation(obs); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SameObserverCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SameObserverCondition.java index 52287cf0a6f..2249534b53e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SameObserverCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SameObserverCondition.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.IObserverFunction; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.MatchConditions; import de.uka.ilkd.key.rule.UseDependencyContractRule; @@ -17,6 +16,7 @@ import de.uka.ilkd.key.speclang.Contract; import org.key_project.logic.ParsableVariable; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableSet; /** @@ -70,7 +70,8 @@ public SameObserverCondition(ParsableVariable schema1, ParsableVariable schema2) // explanation see class javadoc. @Override - public MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, MatchConditions mc, + public MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, + MatchConditions mc, Services services) { SVInstantiations svInst = mc.getInstantiations(); final Term term1 = (Term) svInst.getInstantiation(schema1); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SimplifyIfThenElseUpdateCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SimplifyIfThenElseUpdateCondition.java index 980911205ec..7b64f04a5c5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SimplifyIfThenElseUpdateCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SimplifyIfThenElseUpdateCondition.java @@ -17,6 +17,7 @@ import de.uka.ilkd.key.rule.inst.SVInstantiations; import org.key_project.logic.Named; +import org.key_project.logic.SyntaxElement; public class SimplifyIfThenElseUpdateCondition implements VariableCondition { @@ -151,7 +152,8 @@ private Term simplify(Term phi, Term u1, Term u2, Term t, TermServices services) @Override - public MatchConditions check(SchemaVariable var, SVSubstitute instCandidate, MatchConditions mc, + public MatchConditions check(SchemaVariable var, SyntaxElement instCandidate, + MatchConditions mc, Services services) { SVInstantiations svInst = mc.getInstantiations(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticFieldCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticFieldCondition.java index 2d942802bf8..f850a1d42be 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticFieldCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticFieldCondition.java @@ -10,6 +10,8 @@ import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * This variable condition checks if the instantiation of a schemavariable (of type Field) refers to * a Java field declared as "static". @@ -31,7 +33,7 @@ public StaticFieldCondition(SchemaVariable field, boolean negated) { } @Override - public boolean check(SchemaVariable var, SVSubstitute instCandidate, SVInstantiations instMap, + public boolean check(SchemaVariable var, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { final Object o = instMap.getInstantiation(field); if (!(o instanceof Term f)) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticMethodCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticMethodCondition.java index 2ce44dab8b6..10524eba651 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticMethodCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticMethodCondition.java @@ -13,12 +13,12 @@ import de.uka.ilkd.key.java.reference.ReferencePrefix; import de.uka.ilkd.key.logic.op.IProgramMethod; import de.uka.ilkd.key.logic.op.LocationVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.sort.NullSort; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableArray; @@ -58,7 +58,7 @@ private static ImmutableArray toExpArray( @SuppressWarnings("unchecked") @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { ReferencePrefix rp = (ReferencePrefix) svInst.getInstantiation(caller); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticReferenceCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticReferenceCondition.java index c3ce83b2aa2..332bba35df2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticReferenceCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StaticReferenceCondition.java @@ -8,11 +8,12 @@ import de.uka.ilkd.key.java.reference.FieldReference; import de.uka.ilkd.key.logic.op.ProgramConstant; import de.uka.ilkd.key.logic.op.ProgramVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * ensures that the given instantiation for the schemavariable denotes a static field @@ -34,7 +35,7 @@ public StaticReferenceCondition(SchemaVariable reference, boolean negation) { @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { if (var == reference) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java index 74f87909a8f..a92a20bdb21 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreStmtInCondition.java @@ -9,13 +9,14 @@ import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.ProgramSV; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.LightweightSyntacticalReplaceVisitor; import de.uka.ilkd.key.rule.MatchConditions; import de.uka.ilkd.key.rule.VariableCondition; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * Stores the given {@link Statement}, after substitution of {@link SchemaVariable}s, into the given * {@link ProgramSV} for later use in other conditions and transformers. The arguments are a @@ -37,7 +38,7 @@ public StoreStmtInCondition(ProgramSV resultVarSV, Term term) { } @Override - public MatchConditions check(SchemaVariable sv, SVSubstitute instCandidate, + public MatchConditions check(SchemaVariable sv, SyntaxElement instCandidate, MatchConditions matchCond, Services services) { final SVInstantiations svInst = matchCond.getInstantiations(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreTermInCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreTermInCondition.java index a155d62dc1c..6b6e31e5b4e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreTermInCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/StoreTermInCondition.java @@ -5,13 +5,14 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Term; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.LightweightSyntacticalReplaceVisitor; import de.uka.ilkd.key.rule.MatchConditions; import de.uka.ilkd.key.rule.VariableCondition; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * Stores the given {@link Term}, after substitution of {@link SchemaVariable}s, into the given * {@link SchemaVariable} for later use in other conditions and transformers. @@ -28,7 +29,7 @@ public StoreTermInCondition(SchemaVariable resultVarSV, Term term) { } @Override - public MatchConditions check(SchemaVariable sv, SVSubstitute instCandidate, + public MatchConditions check(SchemaVariable sv, SyntaxElement instCandidate, MatchConditions matchCond, Services services) { final SVInstantiations svInst = matchCond.getInstantiations(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SubFormulaCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SubFormulaCondition.java index 7787df797dd..2ac0c4428a2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SubFormulaCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/SubFormulaCondition.java @@ -7,11 +7,12 @@ import de.uka.ilkd.key.ldt.JavaDLTheory; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.FormulaSV; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; + /** * This variable condition checks if an instantiation for a formula has sub formulas which are * formulas. It returns false for an arity equal to zero or no sub formulas. This is needed to @@ -32,7 +33,7 @@ public SubFormulaCondition(FormulaSV a, boolean negated) { } @Override - public boolean check(SchemaVariable var, SVSubstitute instCandidate, SVInstantiations instMap, + public boolean check(SchemaVariable var, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { if (!(var instanceof FormulaSV) || var != this.a) { return false; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TermLabelCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TermLabelCondition.java index 1f29050176e..6bccef558d5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TermLabelCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TermLabelCondition.java @@ -5,13 +5,13 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.label.TermLabel; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.op.TermLabelSV; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableArray; /** @@ -33,7 +33,7 @@ public TermLabelCondition(TermLabelSV l, String t, boolean negated) { } @Override - public boolean check(SchemaVariable var, SVSubstitute instCandidate, SVInstantiations instMap, + public boolean check(SchemaVariable var, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { assert instMap.getInstantiation(l) instanceof ImmutableArray; ImmutableArray tInsts = (ImmutableArray) instMap.getInstantiation(l); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeComparisonCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeComparisonCondition.java index 6d49717e70d..3c28d087433 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeComparisonCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeComparisonCondition.java @@ -12,7 +12,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.declaration.InterfaceDeclaration; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.sort.ArraySort; import de.uka.ilkd.key.logic.sort.NullSort; @@ -20,6 +19,7 @@ import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -72,7 +72,7 @@ public Mode getMode() { } @Override - public boolean check(SchemaVariable var, SVSubstitute subst, SVInstantiations svInst, + public boolean check(SchemaVariable var, SyntaxElement subst, SVInstantiations svInst, Services services) { if (!fst.isComplete(var, subst, svInst, services) diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeCondition.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeCondition.java index febb37096b7..7f041a3731a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeCondition.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeCondition.java @@ -5,13 +5,13 @@ import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.sort.NullSort; import de.uka.ilkd.key.logic.sort.ProxySort; import de.uka.ilkd.key.rule.VariableConditionAdapter; import de.uka.ilkd.key.rule.inst.SVInstantiations; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; @@ -55,7 +55,7 @@ public boolean getNonNull() { @Override - public boolean check(SchemaVariable p_var, SVSubstitute candidate, SVInstantiations svInst, + public boolean check(SchemaVariable p_var, SyntaxElement candidate, SVInstantiations svInst, Services services) { if (!resolver.isComplete(p_var, candidate, svInst, services)) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeResolver.java b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeResolver.java index f7dd7617ab8..f313becfd78 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeResolver.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/conditions/TypeResolver.java @@ -11,13 +11,13 @@ import de.uka.ilkd.key.logic.op.IObserverFunction; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.ProgramVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.sort.GenericSort; import de.uka.ilkd.key.rule.inst.SVInstantiations; import de.uka.ilkd.key.util.Debug; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.op.Function; import org.key_project.logic.sort.Sort; @@ -50,10 +50,10 @@ public static TypeResolver createNonGenericSortResolver(Sort s) { } - public abstract boolean isComplete(SchemaVariable sv, SVSubstitute instCandidate, + public abstract boolean isComplete(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, TermServices services); - public abstract Sort resolveSort(SchemaVariable sv, SVSubstitute instCandidate, + public abstract Sort resolveSort(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, Services services); @@ -74,13 +74,13 @@ public GenericSort getGenericSort() { } @Override - public boolean isComplete(SchemaVariable sv, SVSubstitute instCandidate, + public boolean isComplete(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, TermServices services) { return instMap.getGenericSortInstantiations().getInstantiation(gs) != null; } @Override - public Sort resolveSort(SchemaVariable sv, SVSubstitute instCandidate, + public Sort resolveSort(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { return instMap.getGenericSortInstantiations().getInstantiation(gs); } @@ -100,13 +100,13 @@ public NonGenericSortResolver(Sort s) { } @Override - public boolean isComplete(SchemaVariable sv, SVSubstitute instCandidate, + public boolean isComplete(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, TermServices services) { return true; } @Override - public Sort resolveSort(SchemaVariable sv, SVSubstitute instCandidate, + public Sort resolveSort(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { return s; } @@ -130,18 +130,18 @@ public ElementTypeResolverForSV(SchemaVariable sv) { } @Override - public boolean isComplete(SchemaVariable sv, SVSubstitute instCandidate, + public boolean isComplete(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, TermServices services) { return resolveSV == sv || instMap.getInstantiation(resolveSV) != null; } @Override - public Sort resolveSort(SchemaVariable sv, SVSubstitute instCandidate, + public Sort resolveSort(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { final Sort s; - final SVSubstitute inst = (SVSubstitute) (resolveSV == sv ? instCandidate + final SyntaxElement inst = (SyntaxElement) (resolveSV == sv ? instCandidate : instMap.getInstantiation(resolveSV)); if (inst instanceof ProgramVariable) { @@ -178,18 +178,18 @@ public ContainerTypeResolver(SchemaVariable sv) { } @Override - public boolean isComplete(SchemaVariable sv, SVSubstitute instCandidate, + public boolean isComplete(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, TermServices services) { return sv == memberSV || instMap.getInstantiation(memberSV) != null; } @Override - public Sort resolveSort(SchemaVariable sv, SVSubstitute instCandidate, + public Sort resolveSort(SchemaVariable sv, SyntaxElement instCandidate, SVInstantiations instMap, Services services) { final Sort result; - final SVSubstitute inst = (SVSubstitute) (memberSV == sv ? instCandidate + final SyntaxElement inst = (SyntaxElement) (memberSV == sv ? instCandidate : instMap.getInstantiation(memberSV)); if (inst instanceof Operator) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/inst/ProgramList.java b/key.core/src/main/java/de/uka/ilkd/key/rule/inst/ProgramList.java index 408e0b82b92..e5f38ccbc06 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/inst/ProgramList.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/inst/ProgramList.java @@ -4,11 +4,11 @@ package de.uka.ilkd.key.rule.inst; import de.uka.ilkd.key.java.ProgramElement; -import de.uka.ilkd.key.logic.op.SVSubstitute; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableArray; -public class ProgramList implements SVSubstitute { +public class ProgramList implements SyntaxElement { private final ImmutableArray list; @@ -34,4 +34,14 @@ public int hashCode() { return list.hashCode(); } + + @Override + public SyntaxElement getChild(int n) { + return list.get(n); + } + + @Override + public int getChildCount() { + return list.size(); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java b/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java index ef2d5270d82..7832eae3b67 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java @@ -13,7 +13,6 @@ import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.op.UpdateApplication; import de.uka.ilkd.key.rule.FindTaclet; @@ -30,6 +29,7 @@ import de.uka.ilkd.key.rule.match.TacletMatcherKit; import de.uka.ilkd.key.rule.match.vm.instructions.MatchSchemaVariableInstruction; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; import org.key_project.util.collection.ImmutableSet; @@ -239,8 +239,8 @@ public final MatchConditions checkConditions(MatchConditions cond, Services serv while (result != null && svIterator.hasNext()) { final SchemaVariable sv = svIterator.next(); final Object o = result.getInstantiations().getInstantiation(sv); - if (o instanceof SVSubstitute) { - result = checkVariableConditions(sv, (SVSubstitute) o, result, services); + if (o instanceof SyntaxElement) { + result = checkVariableConditions(sv, (SyntaxElement) o, result, services); } } } @@ -279,7 +279,7 @@ private boolean varIsBound(SchemaVariable v) { */ @Override public final MatchConditions checkVariableConditions(SchemaVariable var, - SVSubstitute instantiationCandidate, MatchConditions matchCond, Services services) { + SyntaxElement instantiationCandidate, MatchConditions matchCond, Services services) { if (matchCond != null) { if (instantiationCandidate instanceof Term term) { if (!(term.op() instanceof QuantifiableVariable)) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/DependencyContractImpl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/DependencyContractImpl.java index 2ddd6dbc086..ccca2629fd4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/DependencyContractImpl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/DependencyContractImpl.java @@ -14,7 +14,6 @@ import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.IObserverFunction; import de.uka.ilkd.key.logic.op.LocationVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.pp.LogicPrinter; import de.uka.ilkd.key.proof.OpReplacer; import de.uka.ilkd.key.proof.init.ContractPO; @@ -22,6 +21,7 @@ import de.uka.ilkd.key.proof.init.InitConfig; import de.uka.ilkd.key.proof.init.ProofOblInput; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableList; import org.key_project.util.java.MapUtil; @@ -145,7 +145,7 @@ public Term getPre(LocationVariable heap, LocationVariable selfVar, assert paramVars != null; assert paramVars.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); if (originalSelfVar != null) { map.put(originalSelfVar, selfVar); } @@ -192,7 +192,7 @@ public Term getPre(LocationVariable heap, Term heapTerm, Term selfTerm, assert paramTerms != null; assert paramTerms.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put(services.getTermBuilder().var(heap), heapTerm); if (originalSelfVar != null) { map.put(services.getTermBuilder().var(originalSelfVar), selfTerm); @@ -259,7 +259,7 @@ public Term getMby(LocationVariable selfVar, ImmutableList par assert paramVars != null; assert paramVars.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); if (originalSelfVar != null) { map.put(originalSelfVar, selfVar); } @@ -281,7 +281,7 @@ public Term getMby(Map heapTerms, Term selfTerm, assert paramTerms != null; assert paramTerms.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); for (LocationVariable heap : heapTerms.keySet()) { map.put(services.getTermBuilder().var(heap), heapTerms.get(heap)); } @@ -370,7 +370,7 @@ public Term getDep(LocationVariable heap, boolean atPre, LocationVariable selfVa assert paramVars != null; assert paramVars.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); if (originalSelfVar != null) { map.put(originalSelfVar, selfVar); } @@ -400,7 +400,7 @@ public Term getDep(LocationVariable heap, boolean atPre, Term heapTerm, Term sel assert paramTerms != null; assert paramTerms.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put(services.getTermBuilder().var(heap), heapTerm); if (originalSelfVar != null) { map.put(services.getTermBuilder().var(originalSelfVar), selfTerm); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/FunctionalOperationContractImpl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/FunctionalOperationContractImpl.java index 6023d0880c5..48125b113a3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/FunctionalOperationContractImpl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/FunctionalOperationContractImpl.java @@ -29,6 +29,7 @@ import de.uka.ilkd.key.proof.init.ProofOblInput; import org.key_project.logic.Named; +import org.key_project.logic.SyntaxElement; import org.key_project.util.collection.ImmutableArray; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -741,7 +742,7 @@ public static String getText(FunctionalOperationContract contract, private static String getSignatureText(IProgramMethod pm, Operator originalResultVar, - Operator originalSelfVar, ImmutableList originalParamVars, + Operator originalSelfVar, ImmutableList originalParamVars, LocationVariable originalExcVar, Services services, boolean usePrettyPrinting, boolean useUnicodeSymbols) { final StringBuilder sig = new StringBuilder(); @@ -758,7 +759,7 @@ private static String getSignatureText(IProgramMethod pm, Operator originalResul } sig.append(pm.getName()); sig.append("("); - for (SVSubstitute subst : originalParamVars) { + for (SyntaxElement subst : originalParamVars) { if (subst instanceof Named named) { sig.append(named.name()).append(", "); } else if (subst instanceof Term) { @@ -863,7 +864,7 @@ private static String getPostText(Map originalPosts, } private static String getText(IProgramMethod pm, Operator originalResultVar, - Operator originalSelfVar, ImmutableList originalParamVars, + Operator originalSelfVar, ImmutableList originalParamVars, LocationVariable originalExcVar, boolean hasMby, Term originalMby, Map originalMods, Map hasRealModifiesClause, Term globalDefs, @@ -1288,7 +1289,7 @@ public Term getDep(LocationVariable heap, boolean atPre, LocationVariable selfVa assert paramVars != null; assert paramVars.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); if (originalSelfVar != null) { map.put(originalSelfVar, selfVar); } @@ -1316,7 +1317,7 @@ public Term getDep(LocationVariable heap, boolean atPre, Term heapTerm, Term sel assert paramTerms != null; assert paramTerms.size() == originalParamVars.size(); assert services != null; - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put(tb.var(heap), heapTerm); if (originalSelfVar != null) { map.put(tb.var(originalSelfVar), selfTerm); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopContractImpl.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopContractImpl.java index a4cee8a6683..13c702544ae 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopContractImpl.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopContractImpl.java @@ -41,13 +41,13 @@ import de.uka.ilkd.key.logic.op.LocationVariable; import de.uka.ilkd.key.logic.op.Modality; import de.uka.ilkd.key.logic.op.ProgramVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; import de.uka.ilkd.key.proof.OpReplacer; import de.uka.ilkd.key.proof.mgt.SpecificationRepository; import de.uka.ilkd.key.rule.metaconstruct.EnhancedForElimination; import de.uka.ilkd.key.speclang.jml.pretranslation.Behavior; import de.uka.ilkd.key.util.InfFlowSpec; +import org.key_project.logic.SyntaxElement; import org.key_project.util.ExtList; import org.key_project.util.collection.DefaultImmutableSet; import org.key_project.util.collection.ImmutableList; @@ -329,7 +329,7 @@ public static LoopContract combine(ImmutableSet contracts, Service */ private static OpReplacer createOpReplacer(final ProgramVariable index, final ProgramVariable values, Services services) { - final Map replacementMap = new HashMap<>(); + final Map replacementMap = new HashMap<>(); if (index != null) { replacementMap.put(services.getTermBuilder().index(), services.getTermBuilder().var(index)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/ReplacementMap.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/ReplacementMap.java index 0e1617da870..3bfcaf07435 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/ReplacementMap.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/ReplacementMap.java @@ -13,7 +13,8 @@ import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.logic.op.LocationVariable; import de.uka.ilkd.key.logic.op.ProgramVariable; -import de.uka.ilkd.key.logic.op.SVSubstitute; + +import org.key_project.logic.SyntaxElement; /** * A map from some type to the same type. @@ -22,7 +23,7 @@ * * @author lanzinger */ -public abstract class ReplacementMap +public abstract class ReplacementMap extends de.uka.ilkd.key.proof.ReplacementMap.NoIrrelevantLabelsReplacementMap { /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java index 201090e5703..49368cb1602 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SuperTermGenerator.java @@ -96,7 +96,8 @@ protected Term generateOneTerm(Term superterm, int child) { return services.getTermBuilder().tf().createTerm(binFunc, superterm, index); } - private static class SuperTermGeneratedOp implements SortedOperator, Operator, TerminalSyntaxElement { + private static class SuperTermGeneratedOp + implements SortedOperator, Operator, TerminalSyntaxElement { private final Name NAME; private final IntegerLDT numbers; diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/conditions/TestApplyUpdateOnRigidCondition.java b/key.core/src/test/java/de/uka/ilkd/key/rule/conditions/TestApplyUpdateOnRigidCondition.java index 91ff2692110..fae51cc5a3e 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/conditions/TestApplyUpdateOnRigidCondition.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/conditions/TestApplyUpdateOnRigidCondition.java @@ -12,6 +12,7 @@ import de.uka.ilkd.key.rule.inst.SVInstantiations; import org.key_project.logic.Name; +import org.key_project.logic.SyntaxElement; import org.key_project.logic.sort.Sort; import org.junit.jupiter.api.Test; @@ -229,7 +230,7 @@ private Term applyUpdateOnTerm(Term term) { * @param tOrPhi the {@link SchemaVariable} that is instantiated with the term or formula in * term * @param result the {@link SchemaVariable} that is instantiated with the result of a - * {@link ApplyUpdateOnRigidCondition#check(SchemaVariable, SVSubstitute, MatchConditions, Services)} + * {@link ApplyUpdateOnRigidCondition#check(SchemaVariable, SyntaxElement, MatchConditions, Services)} * call * * @return the original formula or term if the update cannot be applied; else, the updated diff --git a/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java index e6d25f7ae00..860f1e62a65 100644 --- a/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/TerminalSyntaxElement.java @@ -1,6 +1,9 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ package org.key_project.logic; -public interface TerminalSyntaxElement extends SyntaxElement{ +public interface TerminalSyntaxElement extends SyntaxElement { @Override default SyntaxElement getChild(int n) { throw new IndexOutOfBoundsException(this.getClass() + " " + this + " has no children"); From 38f16c27874e16d58b2bf75574d78f6714f5600f Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 5 Jun 2024 14:41:38 +0200 Subject: [PATCH 08/15] Add comments and next() method --- .../logic/SyntaxElementCursor.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index cc4892122b3..44f396c2120 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -6,8 +6,11 @@ import java.util.ArrayDeque; import java.util.Deque; +/** + * A cursor (or walker) for navigating {@link SyntaxElement}s in pre-order. * + */ public class SyntaxElementCursor { - record ParentAndPosition(SyntaxElement parent, int index) {} + private record ParentAndPosition(SyntaxElement parent, int index) {} private final Deque path = new ArrayDeque<>(); @@ -21,6 +24,11 @@ public SyntaxElement getCurrentNode() { return node; } + /** + * Advance the cursor to the current node's first child if possible. + * Otherwise, no changes to the state occur. + * @return true iff the current node has at least one child. + */ public boolean gotoFirstChild() { if (node.getChildCount() <= 0) return false; @@ -29,6 +37,11 @@ public boolean gotoFirstChild() { return true; } + /** + * Advance the cursor to the current node's next sibling if possible. + * Otherwise, no changes to the state occur. + * @return true iff the current node has at least one sibling not yet visited. + */ public boolean gotoNextSibling() { if (path.isEmpty()) return false; @@ -36,6 +49,7 @@ public boolean gotoNextSibling() { SyntaxElement parent = pnp.parent; int index = pnp.index + 1; if (index > parent.getChildCount()) { + path.push(pnp); return false; } path.push(new ParentAndPosition(parent, index)); @@ -43,10 +57,26 @@ public boolean gotoNextSibling() { return true; } + /** + * Advance the cursor to the current node's parent if possible. + * Otherwise, no changes to the state occur. + * @return true iff the current node is not the root. + */ public boolean gotoParent() { if (path.isEmpty()) return false; node = path.pop().parent; return true; } + + /** + * Advance cursor to the next node. + * If the node has children, the cursor advances to the first child. + * Otherwise, if the node has unvisited siblings, the cursor advances to the next unvisited sibling. + * Otherwise, no changes to the state. + * @return true iff the node has children or an unvisited sibling. + */ + public boolean goToNext() { + return gotoFirstChild() || gotoNextSibling(); + } } From 7fd9e473f291b8872c2ed1b5b2cc5f57f2349d9e Mon Sep 17 00:00:00 2001 From: Drodt Date: Wed, 5 Jun 2024 14:51:09 +0200 Subject: [PATCH 09/15] Format --- .../java/org/key_project/logic/SyntaxElementCursor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index 44f396c2120..0376c811a37 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -27,6 +27,7 @@ public SyntaxElement getCurrentNode() { /** * Advance the cursor to the current node's first child if possible. * Otherwise, no changes to the state occur. + * * @return true iff the current node has at least one child. */ public boolean gotoFirstChild() { @@ -40,6 +41,7 @@ public boolean gotoFirstChild() { /** * Advance the cursor to the current node's next sibling if possible. * Otherwise, no changes to the state occur. + * * @return true iff the current node has at least one sibling not yet visited. */ public boolean gotoNextSibling() { @@ -60,6 +62,7 @@ public boolean gotoNextSibling() { /** * Advance the cursor to the current node's parent if possible. * Otherwise, no changes to the state occur. + * * @return true iff the current node is not the root. */ public boolean gotoParent() { @@ -72,8 +75,10 @@ public boolean gotoParent() { /** * Advance cursor to the next node. * If the node has children, the cursor advances to the first child. - * Otherwise, if the node has unvisited siblings, the cursor advances to the next unvisited sibling. + * Otherwise, if the node has unvisited siblings, the cursor advances to the next unvisited + * sibling. * Otherwise, no changes to the state. + * * @return true iff the node has children or an unvisited sibling. */ public boolean goToNext() { From 4af2a6c2a5400632d22c814188196679e8b925b4 Mon Sep 17 00:00:00 2001 From: Drodt Date: Fri, 7 Jun 2024 12:56:43 +0200 Subject: [PATCH 10/15] Fix goToNextSibling() (thx Tobias) --- .../main/java/org/key_project/logic/SyntaxElementCursor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index 0376c811a37..cbcab9ef737 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -50,7 +50,7 @@ public boolean gotoNextSibling() { var pnp = path.pop(); SyntaxElement parent = pnp.parent; int index = pnp.index + 1; - if (index > parent.getChildCount()) { + if (index >= parent.getChildCount()) { path.push(pnp); return false; } From a8f975dec18c98100366662137ba99cf93d46cec Mon Sep 17 00:00:00 2001 From: Drodt Date: Fri, 7 Jun 2024 15:29:32 +0200 Subject: [PATCH 11/15] Fix and test goToNext() --- .../org/key_project/logic/SyntaxElement.java | 4 ++ .../logic/SyntaxElementCursor.java | 16 ++++- .../logic/SyntaxElementCursorTest.java | 62 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 key.ncore/src/test/java/org/key_project/logic/SyntaxElementCursorTest.java diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java index a0e61d60102..12f2c5be7e5 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElement.java @@ -22,4 +22,8 @@ public interface SyntaxElement { * @return the number of children of this syntax element. */ int getChildCount(); + + default SyntaxElementCursor getCursor() { + return new SyntaxElementCursor(this); + } } diff --git a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java index cbcab9ef737..52a040d7819 100644 --- a/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java +++ b/key.ncore/src/main/java/org/key_project/logic/SyntaxElementCursor.java @@ -82,6 +82,20 @@ public boolean gotoParent() { * @return true iff the node has children or an unvisited sibling. */ public boolean goToNext() { - return gotoFirstChild() || gotoNextSibling(); + var ancestors = new ArrayDeque(); + if (gotoFirstChild()) + return true; + if (gotoNextSibling()) + return true; + while (!path.isEmpty()) { + ancestors.add(path.pop()); + if (gotoNextSibling()) + return true; + } + // Nothing found; re-build stack + for (var ancestor : ancestors) { + path.push(ancestor); + } + return false; } } diff --git a/key.ncore/src/test/java/org/key_project/logic/SyntaxElementCursorTest.java b/key.ncore/src/test/java/org/key_project/logic/SyntaxElementCursorTest.java new file mode 100644 index 00000000000..86aafe4dba2 --- /dev/null +++ b/key.ncore/src/test/java/org/key_project/logic/SyntaxElementCursorTest.java @@ -0,0 +1,62 @@ +/* This file is part of KeY - https://key-project.org + * KeY is licensed under the GNU General Public License Version 2 + * SPDX-License-Identifier: GPL-2.0-only */ +package org.key_project.logic; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class SyntaxElementCursorTest { + class Node implements SyntaxElement { + private final int value; + private final Node[] children; + + public Node(int value, Node... children) { + this.value = value; + this.children = children; + } + + public int getValue() { + return value; + } + + @Override + public int getChildCount() { + return children.length; + } + + @Override + public SyntaxElement getChild(int n) { + return children[n]; + } + } + + private Node example1() { + return new Node(0, + new Node(1, new Node(2), new Node(3)), + new Node(4, new Node(5), new Node(6))); + } + + private List traverse(Node n) { + var lst = new ArrayList(); + var cursor = n.getCursor(); + do { + lst.add(((Node) cursor.getCurrentNode()).getValue()); + } while (cursor.goToNext()); + return lst; + } + + @Test + void testOrder() { + var tree = example1(); + + assertEquals( + Arrays.asList(0, 1, 2, 3, 4, 5, 6), + traverse(tree)); + } +} From 7b806ce7988e577fd8faa7534a7cf781162f01c9 Mon Sep 17 00:00:00 2001 From: Richard Bubel Date: Wed, 12 Jun 2024 08:54:16 +0200 Subject: [PATCH 12/15] Removes class SequentFormula The class is a left-over from previous times when a formula in the sequent could have a constraint attached. This commit works towards generalizing proof structures --- .../rule/label/FormulaTermLabelMerger.java | 5 +- .../label/FormulaTermLabelRefactoring.java | 52 ++-- .../rule/label/FormulaTermLabelUpdate.java | 9 +- .../label/StayOnFormulaTermLabelPolicy.java | 10 +- .../AbstractUpdateExtractor.java | 8 +- .../SymbolicExecutionTreeBuilder.java | 4 +- .../SymbolicLayoutExtractor.java | 6 +- .../TruthValueTracingUtil.java | 41 +-- .../impl/AbstractExecutionMethodReturn.java | 7 +- .../impl/ExecutionAuxiliaryContract.java | 2 +- .../rule/AbstractSideProofRule.java | 9 +- .../rule/ModalitySideProofRule.java | 15 +- .../rule/QuerySideProofRule.java | 26 +- .../slicing/AbstractSlicer.java | 12 +- .../strategy/CutHeapObjectsFeature.java | 7 +- .../strategy/CutHeapObjectsTermGenerator.java | 15 +- .../strategy/SimplifyTermStrategy.java | 2 +- .../util/SymbolicExecutionSideProofUtil.java | 114 ++++---- .../util/SymbolicExecutionUtil.java | 153 ++++++----- .../AbstractSymbolicExecutionTestCase.java | 2 +- .../smt/testgen/AbstractTestGenerator.java | 11 +- .../uka/ilkd/key/testgen/ModelGenerator.java | 11 +- .../de/uka/ilkd/key/testgen/ProofInfo.java | 2 +- .../ilkd/key/testgen/TestCaseGenerator.java | 9 +- .../java/de/uka/ilkd/key/api/Matcher.java | 6 +- .../java/de/uka/ilkd/key/api/SearchNode.java | 7 +- .../TacletAssumesModel.java | 5 +- .../TacletInstantiationModel.java | 4 +- ...stractFinishAuxiliaryComputationMacro.java | 9 +- .../SelfcompositionStateExpansionMacro.java | 5 +- .../informationflow/proof/InfFlowProof.java | 9 +- .../InfFlowContractAppTacletExecutor.java | 5 +- ...stractInfFlowContractAppTacletBuilder.java | 4 +- .../uka/ilkd/key/logic/BoundVarsVisitor.java | 4 +- .../uka/ilkd/key/logic/FormulaChangeInfo.java | 6 +- .../uka/ilkd/key/logic/PosInOccurrence.java | 49 ++-- .../de/uka/ilkd/key/logic/Semisequent.java | 257 +++++++++--------- .../ilkd/key/logic/SemisequentChangeInfo.java | 42 +-- .../java/de/uka/ilkd/key/logic/Sequent.java | 93 +++---- .../uka/ilkd/key/logic/SequentChangeInfo.java | 24 +- .../de/uka/ilkd/key/logic/SequentFormula.java | 90 ------ .../main/java/de/uka/ilkd/key/logic/Term.java | 1 + .../ilkd/key/logic/label/OriginTermLabel.java | 6 +- .../uka/ilkd/key/logic/label/TermLabel.java | 11 +- .../key/logic/label/TermLabelManager.java | 74 ++--- .../de/uka/ilkd/key/logic/package-info.java | 2 +- .../key/macros/AbstractBlastingMacro.java | 31 +-- ...SymbolicExecutionUntilMergePointMacro.java | 4 +- .../de/uka/ilkd/key/macros/ModalityCache.java | 5 +- .../ilkd/key/macros/scripts/FocusCommand.java | 24 +- .../ilkd/key/macros/scripts/HideCommand.java | 24 +- .../macros/scripts/InstantiateCommand.java | 26 +- .../ilkd/key/macros/scripts/MacroCommand.java | 7 +- .../key/macros/scripts/RewriteCommand.java | 30 +- .../ilkd/key/macros/scripts/RuleCommand.java | 18 +- .../key/macros/scripts/SelectCommand.java | 5 +- .../key/macros/scripts/UnhideCommand.java | 8 +- .../nparser/builder/ExpressionBuilder.java | 6 +- .../key/nparser/builder/ProblemFinder.java | 2 +- .../key/nparser/builder/TacletPBuilder.java | 18 +- .../ilkd/key/pp/HideSequentPrintFilter.java | 8 +- .../key/pp/IdentitySequentPrintFilter.java | 16 +- .../uka/ilkd/key/pp/InitialPositionTable.java | 10 +- .../java/de/uka/ilkd/key/pp/LogicPrinter.java | 4 +- .../java/de/uka/ilkd/key/pp/PosInSequent.java | 8 +- .../de/uka/ilkd/key/pp/PositionTable.java | 6 +- .../key/pp/RegroupSequentPrintFilter.java | 8 +- .../uka/ilkd/key/pp/SequentPrintFilter.java | 4 +- .../ilkd/key/pp/SequentPrintFilterEntry.java | 6 +- .../pp/ShowSelectedSequentPrintFilter.java | 15 +- .../ilkd/key/proof/BuiltInRuleAppIndex.java | 10 +- .../uka/ilkd/key/proof/FormulaTagManager.java | 6 +- .../main/java/de/uka/ilkd/key/proof/Goal.java | 24 +- .../uka/ilkd/key/proof/ProgVarReplacer.java | 28 +- .../java/de/uka/ilkd/key/proof/Proof.java | 25 +- .../key/proof/SemisequentTacletAppIndex.java | 28 +- .../ilkd/key/proof/TermTacletAppIndex.java | 8 +- .../proof/delayedcut/DelayedCutProcessor.java | 12 +- .../key/proof/init/ProblemInitializer.java | 5 +- .../proof/io/IntermediateProofReplayer.java | 2 +- .../key/proof/io/OutputStreamProofSaver.java | 12 +- .../ilkd/key/proof/join/JoinIsApplicable.java | 8 +- .../ilkd/key/proof/join/JoinProcessor.java | 36 +-- .../key/proof/join/LateApplicationCheck.java | 6 +- .../key/proof/join/ProspectivePartner.java | 17 +- .../proof/mgt/SpecificationRepository.java | 3 +- .../key/proof/proofevent/NodeReplacement.java | 18 +- .../proof/replay/AbstractProofReplayer.java | 13 +- .../ilkd/key/prover/impl/ApplyStrategy.java | 4 +- .../key/rule/AbstractBlockContractRule.java | 9 +- .../ilkd/key/rule/AbstractBuiltInRuleApp.java | 6 +- .../key/rule/AuxiliaryContractBuilders.java | 18 +- .../key/rule/BlockContractInternalRule.java | 4 +- .../ilkd/key/rule/BoundUniquenessChecker.java | 5 +- .../ilkd/key/rule/IfFormulaInstDirect.java | 10 +- .../uka/ilkd/key/rule/IfFormulaInstSeq.java | 14 +- .../ilkd/key/rule/IfFormulaInstantiation.java | 11 +- .../de/uka/ilkd/key/rule/JmlAssertRule.java | 5 +- .../uka/ilkd/key/rule/LoopApplyHeadRule.java | 5 +- .../ilkd/key/rule/LoopScopeInvariantRule.java | 15 +- .../de/uka/ilkd/key/rule/NoPosTacletApp.java | 2 +- .../ilkd/key/rule/ObserverToUpdateRule.java | 13 +- .../uka/ilkd/key/rule/OneStepSimplifier.java | 90 +++--- .../de/uka/ilkd/key/rule/PosTacletApp.java | 6 +- .../de/uka/ilkd/key/rule/QueryExpand.java | 2 +- .../de/uka/ilkd/key/rule/RewriteTaclet.java | 2 +- .../main/java/de/uka/ilkd/key/rule/Rule.java | 4 +- .../uka/ilkd/key/rule/RuleAbortException.java | 4 +- .../java/de/uka/ilkd/key/rule/RuleApp.java | 18 +- .../rule/SVNameCorrespondenceCollector.java | 5 +- .../uka/ilkd/key/rule/SetStatementRule.java | 2 +- .../java/de/uka/ilkd/key/rule/Taclet.java | 71 ++--- .../java/de/uka/ilkd/key/rule/TacletApp.java | 16 +- .../rule/TacletSchemaVariableCollector.java | 5 +- .../key/rule/UseDependencyContractRule.java | 18 +- .../key/rule/UseOperationContractRule.java | 24 +- .../uka/ilkd/key/rule/WhileInvariantRule.java | 25 +- .../executor/javadl/AntecTacletExecutor.java | 4 +- .../executor/javadl/FindTacletExecutor.java | 2 +- .../javadl/RewriteTacletExecutor.java | 21 +- .../rule/executor/javadl/TacletExecutor.java | 37 ++- .../ilkd/key/rule/label/TermLabelMerger.java | 15 +- .../key/rule/label/TermLabelRefactoring.java | 3 +- .../key/rule/match/vm/VMTacletMatcher.java | 15 +- .../ilkd/key/rule/merge/CloseAfterMerge.java | 5 +- .../de/uka/ilkd/key/rule/merge/MergeRule.java | 9 +- ...ewriteTacletBuilderSchemaVarCollector.java | 5 +- .../key/rule/tacletbuilder/TacletBuilder.java | 4 +- .../rule/tacletbuilder/TacletGenerator.java | 24 +- .../tacletbuilder/TacletPrefixBuilder.java | 5 +- .../de/uka/ilkd/key/smt/SMTFocusResults.java | 12 +- .../java/de/uka/ilkd/key/smt/SMTProblem.java | 17 +- .../java/de/uka/ilkd/key/smt/SMTRuleApp.java | 4 +- .../smt/newsmt2/ModularSMTLib2Translator.java | 9 +- .../key/speclang/BlockWellDefinedness.java | 5 +- .../key/speclang/LoopWellDefinedness.java | 5 +- .../de/uka/ilkd/key/speclang/QueryAxiom.java | 5 +- .../speclang/StatementWellDefinedness.java | 7 +- .../key/strategy/BuiltInRuleAppContainer.java | 5 +- .../key/strategy/FindTacletAppContainer.java | 9 +- .../FocussedRuleApplicationManager.java | 4 +- .../uka/ilkd/key/strategy/IfInstantiator.java | 39 ++- .../strategy/feature/AbstractBetaFeature.java | 2 +- .../strategy/feature/CheckApplyEqFeature.java | 2 +- .../feature/DiffFindAndIfFeature.java | 6 +- ...SubFormulaOfInfFlowContractAppFeature.java | 2 +- .../feature/FormulaAddedByRuleFeature.java | 4 +- .../feature/InfFlowContractAppFeature.java | 25 +- .../feature/NoSelfApplicationFeature.java | 2 +- .../SeqContainsExecutableCodeFeature.java | 6 +- ...ExistentiallyConnectedFormulasFeature.java | 2 +- .../HeuristicInstantiation.java | 2 +- .../quantifierHeuristics/Instantiation.java | 13 +- .../InstantiationCost.java | 2 +- .../SplittableQuantifiedFormulaFeature.java | 2 +- .../termProjection/AssumptionProjection.java | 2 +- .../FocusFormulaProjection.java | 2 +- .../AllowedCutPositionsGenerator.java | 2 +- .../strategy/termgenerator/HeapGenerator.java | 5 +- .../MultiplesModEquationsGenerator.java | 5 +- .../SequentFormulasGenerator.java | 34 +-- .../TriggeredInstantiations.java | 11 +- .../taclettranslation/SkeletonGenerator.java | 5 +- .../key/taclettranslation/TacletVisitor.java | 9 +- .../ilkd/key/util/HelperClassForTests.java | 2 +- .../de/uka/ilkd/key/util/ProofStarter.java | 3 +- .../key/util/mergerule/MergeRuleUtils.java | 31 ++- .../proof/LocationVariableTracker.java | 4 +- .../de/uka/ilkd/key/logic/TestPosInOcc.java | 6 +- .../uka/ilkd/key/logic/TestSemisequent.java | 40 +-- .../ilkd/key/logic/TestTermLabelManager.java | 22 +- .../uka/ilkd/key/logic/TestVariableNamer.java | 16 +- .../uka/ilkd/key/parser/TestTacletParser.java | 4 +- .../java/de/uka/ilkd/key/proof/TestGoal.java | 8 +- .../de/uka/ilkd/key/proof/TestProofTree.java | 14 +- .../uka/ilkd/key/proof/TestTacletIndex.java | 14 +- .../key/proof/TestTermTacletAppIndex.java | 5 +- .../runallproofs/performance/NodeData.java | 9 +- .../ilkd/key/rule/CreateTacletForTests.java | 10 +- .../de/uka/ilkd/key/rule/TestApplyTaclet.java | 108 ++++---- .../ilkd/key/rule/TestCollisionResolving.java | 16 +- .../de/uka/ilkd/key/rule/TestMatchTaclet.java | 18 +- .../key/rule/TestSchemaModalOperators.java | 12 +- .../rule/tacletbuilder/TestTacletBuild.java | 6 +- .../key/smt/newsmt2/ProveSMTLemmasTest.java | 2 +- .../util/TestEqualsModProofIrrelevancy.java | 10 +- .../gui/InspectorForDecisionPredicates.java | 5 +- .../key/gui/LoopInvariantRuleCompletion.java | 1 + .../MergePartnerSelectionDialog.java | 9 +- .../gui/nodeviews/DragNDropInstantiator.java | 2 +- .../ilkd/key/gui/nodeviews/SequentView.java | 22 +- .../OriginTermLabelVisualizer.java | 11 +- .../key/gui/proofdiff/ProofDifference.java | 4 +- .../ilkd/key/gui/prooftree/ProofTreeView.java | 3 +- .../ilkd/key/gui/sourceview/SourceView.java | 111 ++++---- .../util/collection/ImmutableList.java | 2 +- .../proof/reference/ReferenceSearcher.java | 12 +- .../exploration/ProofExplorationService.java | 9 +- .../actions/EditFormulaAction.java | 7 +- .../ProofExplorationServiceTest.java | 4 +- .../slicing/DependencyTracker.java | 13 +- .../slicing/analysis/AnalysisResults.java | 6 +- .../slicing/graph/DependencyGraph.java | 2 +- .../slicing/graph/TrackedFormula.java | 16 +- settings.gradle | 2 +- 205 files changed, 1543 insertions(+), 1685 deletions(-) delete mode 100644 key.core/src/main/java/de/uka/ilkd/key/logic/SequentFormula.java diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelMerger.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelMerger.java index da7e85f8a9e..313b188cb4f 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelMerger.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelMerger.java @@ -7,7 +7,6 @@ import java.util.Arrays; import java.util.List; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.FormulaTermLabel; import de.uka.ilkd.key.logic.label.TermLabel; @@ -22,8 +21,8 @@ public class FormulaTermLabelMerger implements TermLabelMerger { * {@inheritDoc} */ @Override - public boolean mergeLabels(SequentFormula existingSF, Term existingTerm, - TermLabel existingLabel, SequentFormula rejectedSF, Term rejectedTerm, + public boolean mergeLabels(Term existingSF, Term existingTerm, + TermLabel existingLabel, Term rejectedSF, Term rejectedTerm, TermLabel rejectedLabel, List mergedLabels) { if (existingLabel != null) { FormulaTermLabel fExisting = (FormulaTermLabel) existingLabel; diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java index f55f6111dcc..ed1005355a9 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelRefactoring.java @@ -84,9 +84,9 @@ public class FormulaTermLabelRefactoring implements TermLabelRefactoring { /** * Key used in {@link TermLabelState} by the {@link FormulaTermLabelUpdate} to indicate that a - * refactoring of specified {@link SequentFormula}s ({@link RefactoringScope#SEQUENT}) is + * refactoring of specified {@link Term}s ({@link RefactoringScope#SEQUENT}) is * required, which will be performed by - * {@link #refactorSequentFormulas(TermLabelState, Services, Term, LabelCollection)}. + * {@link #refactorTerms(TermLabelState, Services, Term, LabelCollection)}. *

* This is for instance required if the assumes clause of a rule has a {@link FormulaTermLabel} * but the application does not have it. Example rules are: @@ -95,7 +95,7 @@ public class FormulaTermLabelRefactoring implements TermLabelRefactoring { * */ private static final String SEQUENT_FORMULA_REFACTORING_REQUIRED = - "sequentFormulaRefactoringRequired"; + "TermRefactoringRequired"; /** * {@inheritDoc} @@ -118,7 +118,7 @@ public RefactoringScope defineRefactoringScope(TermLabelState state, Services se return RefactoringScope.APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE_AND_PARENTS; } else if (isUpdateRefactoringRequired(state)) { return RefactoringScope.APPLICATION_BELOW_UPDATES; - } else if (containsSequentFormulasToRefactor(state)) { + } else if (containsTermsToRefactor(state)) { return RefactoringScope.SEQUENT; } else if (SyntacticalReplaceVisitor.SUBSTITUTION_WITH_LABELS_HINT.equals(hint)) { return RefactoringScope.APPLICATION_BELOW_UPDATES; @@ -152,8 +152,8 @@ public void refactorLabels(TermLabelState state, Services services, refactorInCaseOfNewIdRequired(state, goal, term, services, labels); } else if (isUpdateRefactoringRequired(state)) { refactorBelowUpdates(applicationPosInOccurrence, term, labels); - } else if (containsSequentFormulasToRefactor(state)) { - refactorSequentFormulas(state, services, term, labels); + } else if (containsTermsToRefactor(state)) { + refactorTerms(state, services, term, labels); } else if (SyntacticalReplaceVisitor.SUBSTITUTION_WITH_LABELS_HINT.equals(hint)) { refactorSubstitution(term, tacletTerm, labels); } @@ -238,7 +238,7 @@ private void refactorBelowUpdates(PosInOccurrence applicationPosInOccurrence, Te } /** - * Refactors the specified {@link SequentFormula}s. + * Refactors the specified {@link Term}s. * * @param state The {@link TermLabelState} of the current rule application. * @param services The {@link Services} used by the {@link Proof} on which a {@link Rule} is @@ -246,10 +246,12 @@ private void refactorBelowUpdates(PosInOccurrence applicationPosInOccurrence, Te * @param term The {@link Term} which is now refactored. * @param labels The new labels the {@link Term} will have after the refactoring. */ - private void refactorSequentFormulas(TermLabelState state, Services services, final Term term, + private void refactorTerms(TermLabelState state, Services services, final Term term, LabelCollection labels) { - Set sequentFormulas = getSequentFormulasToRefactor(state); - if (CollectionUtil.search(sequentFormulas, element -> element.formula() == term) != null) { + Set Terms = getTermsToRefactor(state); + if (CollectionUtil.search(Terms, element -> { + return element == term; + }) != null) { FormulaTermLabel termLabel = (FormulaTermLabel) term.getLabel(FormulaTermLabel.NAME); if (termLabel != null) { labels.remove(termLabel); @@ -373,45 +375,45 @@ public static void setParentRefactoringRequired(TermLabelState state, boolean re } /** - * Checks if {@link SequentFormula}s to refactor are specified. + * Checks if {@link Term}s to refactor are specified. * * @param state The {@link TermLabelState} to read from. - * @return {@code true} at least one {@link SequentFormula} needs to be refactored, + * @return {@code true} at least one {@link Term} needs to be refactored, * {@code false} refactoring is not required. */ - public static boolean containsSequentFormulasToRefactor(TermLabelState state) { + public static boolean containsTermsToRefactor(TermLabelState state) { Map labelState = state.getLabelState(FormulaTermLabel.NAME); @SuppressWarnings("unchecked") - Set sfSet = - (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); + Set sfSet = + (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); return sfSet != null && !sfSet.isEmpty(); } /** - * Returns the {@link SequentFormula}s to refactor. + * Returns the {@link Term}s to refactor. * * @param state The {@link TermLabelState} to read from. - * @return The {@link SequentFormula}s to refactor. + * @return The {@link Term}s to refactor. */ - public static Set getSequentFormulasToRefactor(TermLabelState state) { + public static Set getTermsToRefactor(TermLabelState state) { Map labelState = state.getLabelState(FormulaTermLabel.NAME); @SuppressWarnings("unchecked") - Set sfSet = - (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); + Set sfSet = + (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); return sfSet; } /** - * Adds the given {@link SequentFormula} for refactoring purpose. + * Adds the given {@link Term} for refactoring purpose. * * @param state The {@link TermLabelState} to modify. - * @param sf The {@link SequentFormula} to add. + * @param sf The {@link Term} to add. */ - public static void addSequentFormulaToRefactor(TermLabelState state, SequentFormula sf) { + public static void addTermToRefactor(TermLabelState state, Term sf) { Map labelState = state.getLabelState(FormulaTermLabel.NAME); @SuppressWarnings("unchecked") - Set sfSet = - (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); + Set sfSet = + (Set) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED); if (sfSet == null) { sfSet = new LinkedHashSet<>(); labelState.put(SEQUENT_FORMULA_REFACTORING_REQUIRED, sfSet); diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelUpdate.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelUpdate.java index 2ae4dbc912d..ac55939d736 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelUpdate.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/FormulaTermLabelUpdate.java @@ -72,11 +72,12 @@ public void updateLabels(TermLabelState state, Services services, } if (ruleApp instanceof TacletApp ta) { if (ta.ifInstsComplete() && ta.ifFormulaInstantiations() != null) { - Map ifLabels = + Map ifLabels = new LinkedHashMap<>(); for (IfFormulaInstantiation ifInst : ta.ifFormulaInstantiations()) { + final Term assumesFml = ifInst.getConstrainedFormula(); FormulaTermLabel ifLabel = StayOnFormulaTermLabelPolicy.searchFormulaTermLabel( - ifInst.getConstrainedFormula().formula().getLabels()); + assumesFml.getLabels()); if (ifLabel != null) { ifLabels.put(ifInst.getConstrainedFormula(), ifLabel); } @@ -85,14 +86,14 @@ public void updateLabels(TermLabelState state, Services services, if (TruthValueTracingUtil.isLogicOperator(newTerm.op(), newTerm.subs()) // || TruthValueEvaluationUtil.isPredicate(newTermOp) ) { - for (Entry ifEntry : ifLabels + for (Entry ifEntry : ifLabels .entrySet()) { FormulaTermLabel ifLabel = ifEntry.getValue(); int labelSubID = FormulaTermLabel.newLabelSubID(services, ifLabel); FormulaTermLabel newLabel = new FormulaTermLabel(ifLabel.getMajorId(), labelSubID, Collections.singletonList(ifLabel.getId())); labels.add(newLabel); - FormulaTermLabelRefactoring.addSequentFormulaToRefactor(state, + FormulaTermLabelRefactoring.addTermToRefactor(state, ifEntry.getKey()); } } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/StayOnFormulaTermLabelPolicy.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/StayOnFormulaTermLabelPolicy.java index 7d2ea52c692..98360e9fe59 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/StayOnFormulaTermLabelPolicy.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/rule/label/StayOnFormulaTermLabelPolicy.java @@ -69,8 +69,8 @@ public TermLabel keepLabel(TermLabelState state, Services services, originalLabelIds.add(mostImportantLabel.getId()); } } - if (tacletHint.getSequentFormula() != null) { - if (!TruthValueTracingUtil.isPredicate(tacletHint.getSequentFormula())) { + if (tacletHint.getTerm() != null) { + if (!TruthValueTracingUtil.isPredicate(tacletHint.getTerm())) { newLabelIdRequired = true; } } else if (tacletHint.getTerm() != null) { @@ -164,10 +164,6 @@ public static FormulaTermLabel searchFormulaTermLabel(ImmutableArray * @return {@code true} is top level, {@code false} is not top level. */ protected boolean isTopLevel(TacletLabelHint tacletHint, Term tacletTerm) { - if (TacletOperation.REPLACE_TERM.equals(tacletHint.getTacletOperation())) { - return tacletHint.getTerm() == tacletTerm; - } else { - return tacletHint.getSequentFormula().formula() == tacletTerm; - } + return tacletHint.getTerm() == tacletTerm; } } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/AbstractUpdateExtractor.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/AbstractUpdateExtractor.java index e04c2be2a75..830214147aa 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/AbstractUpdateExtractor.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/AbstractUpdateExtractor.java @@ -152,8 +152,8 @@ protected Set computeInitialObjectsToIgnore(boolean ignoreExceptionVariabl // Add initial updates which are used as backup of the heap and method arguments. They // are not part of the source code and should be ignored. Sequent sequent = getRoot().sequent(); - for (SequentFormula sf : sequent.succedent()) { - Term term = sf.formula(); + for (Term sf : sequent.succedent()) { + Term term = sf; if (Junctor.IMP.equals(term.op())) { fillInitialObjectsToIgnoreRecursively(term.sub(1), result); } @@ -434,9 +434,9 @@ protected boolean hasFreeVariables(Term term) { protected Set extractLocationsFromSequent(Sequent sequent, Set objectsToIgnore) throws ProofInputException { Set result = new LinkedHashSet<>(); - for (SequentFormula sf : sequent) { + for (Term sf : sequent) { result.addAll(extractLocationsFromTerm( - OriginTermLabel.removeOriginLabels(sf.formula(), getServices()), objectsToIgnore)); + OriginTermLabel.removeOriginLabels(sf, getServices()), objectsToIgnore)); } return result; } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicExecutionTreeBuilder.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicExecutionTreeBuilder.java index 35e6ea1b81d..2f96a4927a4 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicExecutionTreeBuilder.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicExecutionTreeBuilder.java @@ -249,8 +249,8 @@ public SymbolicExecutionTreeBuilder(Proof proof, boolean mergeBranchConditions, protected void initMethodCallStack(final Node root, Services services) { // Find all modalities in the succedent final List modalityTerms = new LinkedList<>(); - for (SequentFormula sequentFormula : root.sequent().succedent()) { - sequentFormula.formula().execPreOrder(new DefaultVisitor() { + for (Term succFml : root.sequent().succedent()) { + succFml.execPreOrder(new DefaultVisitor() { @Override public void visit(Term visited) { if (visited.op() instanceof Modality diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicLayoutExtractor.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicLayoutExtractor.java index 7d849a0530f..8cd7cd1c19b 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicLayoutExtractor.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/SymbolicLayoutExtractor.java @@ -309,7 +309,7 @@ protected ImmutableList extractInitialUpdates() { Sequent sequent = getRoot().sequent(); assert sequent.antecedent().isEmpty(); assert sequent.succedent().size() == 1; - Term sf = sequent.succedent().get(0).formula(); + final Term sf = sequent.succedent().get(0); assert sf.op() == Junctor.IMP; Term modality = sf.sub(1); return TermBuilder.goBelowUpdates2(modality).first; @@ -680,9 +680,9 @@ protected Set updateLocationsAccordingtoEquivalentClas protected Set collectObjectsFromSequent(Sequent sequent, Set objectsToIgnore) throws ProofInputException { Set result = new LinkedHashSet<>(); - for (SequentFormula sf : sequent) { + for (Term sf : sequent) { if (SymbolicExecutionUtil.checkSkolemEquality(sf) == 0) { - result.addAll(collectSymbolicObjectsFromTerm(sf.formula(), objectsToIgnore)); + result.addAll(collectSymbolicObjectsFromTerm(sf, objectsToIgnore)); } } return result; diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/TruthValueTracingUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/TruthValueTracingUtil.java index d4a12b894c9..bafe6a9a052 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/TruthValueTracingUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/TruthValueTracingUtil.java @@ -16,7 +16,6 @@ import de.uka.ilkd.key.logic.DefaultVisitor; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.label.FormulaTermLabel; @@ -59,16 +58,6 @@ public final class TruthValueTracingUtil { private TruthValueTracingUtil() { } - /** - * Checks if the given {@link SequentFormula} is a predicate. - * - * @param sequentFormula The {@link SequentFormula} to check. - * @return {@code true} is predicate, {@code false} is something else. - */ - public static boolean isPredicate(SequentFormula sequentFormula) { - return sequentFormula != null && isPredicate(sequentFormula.formula()); - } - /** * Checks if the given {@link Term} is a predicate. * @@ -342,8 +331,8 @@ private static List findInvolvedLabels( if (tacletApp.ifInstsComplete() && tacletApp.ifFormulaInstantiations() != null) { for (IfFormulaInstantiation ifInst : tacletApp.ifFormulaInstantiations()) { assert ifInst instanceof IfFormulaInstSeq; - Term term = ifInst.getConstrainedFormula().formula(); - TermLabel label = term.getLabel(termLabelName); + final Term assumesFml = ifInst.getConstrainedFormula(); + TermLabel label = assumesFml.getLabel(termLabelName); if (label instanceof FormulaTermLabel) { result.add(new LabelOccurrence((FormulaTermLabel) label, ((IfFormulaInstSeq) ifInst).inAntec())); @@ -451,7 +440,7 @@ private static void updatePredicateResultBasedOnNewMinorIdsOSS( parentPio.subTerm().execPreOrder(new DefaultVisitor() { @Override public void visit(Term visited) { - checkForNewMinorIdsOSS(childPio.sequentFormula(), visited, termLabelName, + checkForNewMinorIdsOSS(childPio.sequentLevelFormula(), visited, termLabelName, parentPio, tb, results); } }); @@ -459,7 +448,7 @@ public void visit(Term visited) { PosInOccurrence currentPio = parentPio; while (!currentPio.isTopLevel()) { currentPio = currentPio.up(); - checkForNewMinorIdsOSS(childPio.sequentFormula(), currentPio.subTerm(), + checkForNewMinorIdsOSS(childPio.sequentLevelFormula(), currentPio.subTerm(), termLabelName, parentPio, tb, results); } } @@ -468,7 +457,7 @@ public void visit(Term visited) { /** * Checks if new minor IDs are available in case of {@link OneStepSimplifier} usage. * - * @param onlyChangedChildSF The only changed {@link SequentFormula} in the child {@link Node}. + * @param onlyChangedChildSF The only changed {@link Term} in the child {@link Node}. * @param term The {@link Term} contained in the child {@link Node} to check. * @param termLabelName The name of the {@link TermLabel} which is added to predicates. * @param parentPio The {@link PosInOccurrence} of the applied rule of the parent {@link Node}. @@ -476,7 +465,7 @@ public void visit(Term visited) { * @param results The {@link Map} with all available {@link MultiEvaluationResult}s. */ private static void checkForNewMinorIdsOSS( - SequentFormula onlyChangedChildSF, Term term, + Term onlyChangedChildSF, Term term, Name termLabelName, PosInOccurrence parentPio, TermBuilder tb, Map results) { TermLabel label = term.getLabel(termLabelName); @@ -492,7 +481,7 @@ private static void checkForNewMinorIdsOSS( /** * Checks if new minor IDs are available in case of {@link OneStepSimplifier} usage. * - * @param onlyChangedChildSF The only changed {@link SequentFormula} in the child {@link Node}. + * @param onlyChangedChildSF The only changed {@link Term} in the child {@link Node}. * @param label The {@link FormulaTermLabel} of interest. * @param antecedentRuleApplication {@code true} rule applied on antecedent, {@code false} rule * applied on succedent. @@ -500,7 +489,7 @@ private static void checkForNewMinorIdsOSS( * @return The computed instruction {@link Term} or {@code null} if not available. */ private static Term checkForNewMinorIdsOSS( - SequentFormula onlyChangedChildSF, + Term onlyChangedChildSF, FormulaTermLabel label, boolean antecedentRuleApplication, TermBuilder tb) { // Search replacements List antecedentReplacements = new LinkedList<>(); @@ -553,7 +542,7 @@ public void visit(Term visited) { if (parentRuleApp instanceof TacletApp ta) { if (ta.ifInstsComplete() && ta.ifFormulaInstantiations() != null) { for (IfFormulaInstantiation ifInst : ta.ifFormulaInstantiations()) { - checkForNewMinorIds(childNode, ifInst.getConstrainedFormula().formula(), + checkForNewMinorIds(childNode, ifInst.getConstrainedFormula(), termLabelName, parentPio, tb, results); } } @@ -601,10 +590,10 @@ private static Term checkForNewMinorIds( // Search replacements List antecedentReplacements = new LinkedList<>(); List succedentReplacements = new LinkedList<>(); - for (SequentFormula sf : childNode.sequent().antecedent()) { + for (Term sf : childNode.sequent().antecedent()) { listLabelReplacements(sf, label.name(), label.getId(), antecedentReplacements); } - for (SequentFormula sf : childNode.sequent().succedent()) { + for (Term sf : childNode.sequent().succedent()) { listLabelReplacements(sf, label.name(), label.getId(), succedentReplacements); } // Compute term @@ -613,17 +602,17 @@ private static Term checkForNewMinorIds( } /** - * Lists all label replacements in the given {@link SequentFormula}. + * Lists all label replacements in the given {@link Term}. * - * @param sf The {@link SequentFormula} to analyze. + * @param sf The {@link Term} to analyze. * @param labelName The name of the {@link TermLabel} which is added to predicates. * @param labelId The label ID of interest. * @param resultToFill The result {@link List} to fill. */ private static void listLabelReplacements( - final SequentFormula sf, final Name labelName, + final Term sf, final Name labelName, final String labelId, final List resultToFill) { - sf.formula().execPreOrder(new DefaultVisitor() { + sf.execPreOrder(new DefaultVisitor() { @Override public boolean visitSubtree(Term visited) { return !hasLabelOfInterest(visited); diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/AbstractExecutionMethodReturn.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/AbstractExecutionMethodReturn.java index d74bfb41cd4..b757d6c6f08 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/AbstractExecutionMethodReturn.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/AbstractExecutionMethodReturn.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.SourceElement; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.UpdateApplication; import de.uka.ilkd.key.proof.Node; @@ -180,11 +179,11 @@ protected IExecutionVariable[] lazyComputeCallStateVariables() throws ProofInput assert proofNode.childrenCount() == 1; PosInOccurrence originalPIO = methodCall.getModalityPIO(); int index = originalPIO.isInAntec() - ? proofNode.sequent().antecedent().indexOf(originalPIO.sequentFormula()) - : proofNode.sequent().succedent().indexOf(originalPIO.sequentFormula()); + ? proofNode.sequent().antecedent().indexOf(originalPIO.sequentLevelFormula()) + : proofNode.sequent().succedent().indexOf(originalPIO.sequentLevelFormula()); // Search relevant position in child node Node childNode = proofNode.child(0); - SequentFormula nodeSF = + Term nodeSF = originalPIO.isInAntec() ? childNode.sequent().antecedent().get(index) : childNode.sequent().succedent().get(index); PosInOccurrence modalityPIO = diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/ExecutionAuxiliaryContract.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/ExecutionAuxiliaryContract.java index 293a231f50f..2e06327f513 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/ExecutionAuxiliaryContract.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/model/impl/ExecutionAuxiliaryContract.java @@ -88,7 +88,7 @@ protected String lazyComputeName() throws ProofInputException { assert "Usage".equals(usageNode.getNodeInfo().getBranchLabel()) : "Block Contract Rule has changed."; Term usagePrecondition = usageNode.sequent().antecedent() - .get(usageNode.sequent().antecedent().size() - 1).formula(); + .get(usageNode.sequent().antecedent().size() - 1); // Find remembrance heaps and local variables while (applicationTerm.op() == UpdateApplication.UPDATE_APPLICATION) { assert applicationTerm.sub(0) == usagePrecondition.sub(0) diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/AbstractSideProofRule.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/AbstractSideProofRule.java index b4f25f305e1..b3f5c71b399 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/AbstractSideProofRule.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/AbstractSideProofRule.java @@ -14,7 +14,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.PosInTerm; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.JFunction; import de.uka.ilkd.key.proof.Goal; @@ -103,12 +102,12 @@ protected List, Node>> computeResultsAndConditions(Servic * * @param pio The {@link PosInOccurrence} which defines the {@link Term} to replace. * @param newTerm The new {@link Term}. - * @return The created {@link SequentFormula} in which the {@link Term} is replaced. + * @return The created {@link Term} in which the {@link Term} is replaced. */ - protected static SequentFormula replace(PosInOccurrence pio, Term newTerm, Services services) { + protected static Term replace(PosInOccurrence pio, Term newTerm, Services services) { // Iterate along the PosInOccurrence and collect the parents and indices Deque> indexAndParents = new LinkedList<>(); - Term root = pio.sequentFormula().formula(); + Term root = pio.sequentLevelFormula(); final PosInTerm pit = pio.posInTerm(); for (int i = 0, sz = pit.depth(); i < sz; i++) { int next = pit.getIndexAt(i); @@ -124,7 +123,7 @@ protected static SequentFormula replace(PosInOccurrence pio, Term newTerm, Servi root = services.getTermFactory().createTerm(parent.op(), newSubs, parent.boundVars(), parent.getLabels()); } - return new SequentFormula(root); + return root; } /** diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java index 6c1fc13fb94..cef7f53abd2 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/ModalitySideProofRule.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -39,7 +38,7 @@ * A {@link BuiltInRule} which evaluates a modality in a side proof. *

*

- * This rule is applicable on top level terms ({@link SequentFormula}) of the form. + * This rule is applicable on top level terms ({@link Term}) of the form. *

    *
  • {@code {...}\[...\]( = )} or
  • *
  • {@code {...}\<...\>( = )} or
  • @@ -49,8 +48,8 @@ * The leading updates are optional and any {@link Modality} is supported. *

    *

    - * The original {@link SequentFormula} which contains the equality is always removed in the - * following {@link Goal}. For each possible result value is a {@link SequentFormula} added to the + * The original {@link Term} which contains the equality is always removed in the + * following {@link Goal}. For each possible result value is a {@link Term} added to the * {@link Sequent} of the form: *

      *
    • Antecedent: {@code -> = } or
    • @@ -169,7 +168,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { .cloneProofEnvironmentWithOwnOneStepSimplifier(goal.proof(), true); final Services sideProofServices = sideProofEnv.getServicesForEnvironment(); Sequent sequentToProve = SymbolicExecutionSideProofUtil - .computeGeneralSequentToProve(goal.sequent(), pio.sequentFormula()); + .computeGeneralSequentToProve(goal.sequent(), pio.sequentLevelFormula()); JFunction newPredicate = createResultFunction(sideProofServices, varTerm.sort()); final TermBuilder tb = sideProofServices.getTermBuilder(); Term newTerm = tb.func(newPredicate, varTerm); @@ -178,7 +177,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { modalityTerm.getLabels()); Term newModalityWithUpdatesTerm = tb.applySequential(updates, newModalityTerm); sequentToProve = sequentToProve - .addFormula(new SequentFormula(newModalityWithUpdatesTerm), false, false) + .addFormula(newModalityWithUpdatesTerm, false, false) .sequent(); // Compute results and their conditions List, Node>> conditionsAndResultsMap = @@ -207,12 +206,12 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { } Term newImplication = tb.imp(newCondition, modalityTerm.sub(0).sub(1)); Term newImplicationWithUpdates = tb.applySequential(updates, newImplication); - resultGoal.addFormula(new SequentFormula(newImplicationWithUpdates), + resultGoal.addFormula(newImplicationWithUpdates, pio.isInAntec(), false); } else { // Add result directly as new top level formula for (Term result : resultTerms) { - resultGoal.addFormula(new SequentFormula(result), pio.isInAntec(), false); + resultGoal.addFormula(result, pio.isInAntec(), false); } } return goals; diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/QuerySideProofRule.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/QuerySideProofRule.java index 2f00a4a8941..1ec20e96789 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/QuerySideProofRule.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/rule/QuerySideProofRule.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.logic.PIOPathIterator; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -45,12 +44,12 @@ *
    *

    *

    - * The original {@link SequentFormula} which contains the equality is always removed in the + * The original {@link Term} which contains the equality is always removed in the * following {@link Goal}. How the result of the query computed in the side proof is represented * depends on the occurrence of the equality: *

      *
    1. top level {@code = } or {@code = }
      - * For each possible result value is a {@link SequentFormula} added to the {@link Sequent} of the + * For each possible result value is a {@link Term} added to the {@link Sequent} of the * form: *
        *
      • Antecedent: {@code -> = } or
      • @@ -62,7 +61,7 @@ *
      • right side of an implication on top level * {@code -> = } or * {@code -> = }
        - * For each possible result value is a {@link SequentFormula} added to the {@link Sequent} of the + * For each possible result value is a {@link Term} added to the {@link Sequent} of the * form: *
          *
        • Antecedent: {@code @@ -93,9 +92,9 @@ *
        • *
        • everywhere else {@code ...( = )...} or * {@code ...( = )...}
          - * In the original {@link SequentFormula} is the {@code } replaced by a new constant function + * In the original {@link Term} is the {@code } replaced by a new constant function * named {@code QueryResult} and added to the antecedent/succedent in which it was contained before. - * For each possible result value is an additional {@link SequentFormula} added to the + * For each possible result value is an additional {@link Term} added to the * antecedent of the form: *
            *
          • {@code -> QueryResult = } or
          • @@ -196,7 +195,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { // Extract required Terms from goal PosInOccurrence pio = ruleApp.posInOccurrence(); Sequent goalSequent = goal.sequent(); - SequentFormula equalitySF = pio.sequentFormula(); + Term equalitySF = pio.sequentLevelFormula(); Term equalityTerm = pio.subTerm(); Term queryTerm; Term varTerm; @@ -211,9 +210,10 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { varFirst = false; } Term queryConditionTerm = null; - if (equalitySF.formula().op() == Junctor.IMP - && equalitySF.formula().sub(1) == equalityTerm) { - queryConditionTerm = equalitySF.formula().sub(0); + if (equalitySF.op() == Junctor.IMP) { + if (equalitySF.sub(1) == equalityTerm) { + queryConditionTerm = equalitySF.sub(0); + } } // Compute sequent for side proof to compute query in. // New OneStepSimplifier is required because it has an internal state and the default @@ -226,7 +226,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { JFunction newPredicate = createResultFunction(sideProofServices, queryTerm.sort()); Term newTerm = sideProofServices.getTermBuilder().func(newPredicate, queryTerm); sequentToProve = - sequentToProve.addFormula(new SequentFormula(newTerm), false, false).sequent(); + sequentToProve.addFormula(newTerm, false, false).sequent(); // Compute results and their conditions List, Node>> conditionsAndResultsMap = computeResultsAndConditions(services, goal, sideProofEnv, sequentToProve, @@ -246,7 +246,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { if (queryConditionTerm != null) { resultTerm = tb.imp(queryConditionTerm, resultTerm); } - resultGoal.addFormula(new SequentFormula(resultTerm), pio.isInAntec(), false); + resultGoal.addFormula(resultTerm, pio.isInAntec(), false); } } else { JFunction resultFunction = createResultConstant(services, varTerm.sort()); @@ -261,7 +261,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence pos, TermServices services) { Term resultTerm = tb.imp(conditionTerm, varFirst ? tb.equals(resultFunctionTerm, conditionsAndResult.first) : tb.equals(conditionsAndResult.first, resultFunctionTerm)); - resultGoal.addFormula(new SequentFormula(resultTerm), true, false); + resultGoal.addFormula(resultTerm, true, false); } } return goals; diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java index 56ead50dddb..d875fafffd6 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/slicing/AbstractSlicer.java @@ -69,7 +69,7 @@ public ImmutableArray slice(Node seedNode, ReferencePrefix seedLocation, ImmutableList sec) throws ProofInputException { // Solve this reference PosInOccurrence pio = seedNode.getAppliedRuleApp().posInOccurrence(); - Term topLevel = pio.sequentFormula().formula(); + Term topLevel = pio.sequentLevelFormula(); Term modalityTerm = TermBuilder.goBelowUpdates(topLevel); Services services = seedNode.proof().getServices(); ExecutionContext ec = @@ -209,7 +209,7 @@ public ReferencePrefix getThisReference() { */ protected SequentInfo analyzeSequent(Node node, ImmutableList sec) { PosInOccurrence pio = node.getAppliedRuleApp().posInOccurrence(); - Term topLevel = pio.sequentFormula().formula(); + Term topLevel = pio.sequentLevelFormula(); Pair, Term> pair = TermBuilder.goBelowUpdates2(topLevel); Term modalityTerm = pair.second; SymbolicExecutionTermLabel label = @@ -283,14 +283,14 @@ protected void analyzeEquivalenceClasses(Services services, */ protected void analyzeSequent(Services services, Sequent sequent, Map> aliases, ReferencePrefix thisReference) { - for (SequentFormula sf : sequent.antecedent()) { - Term term = sf.formula(); + for (Term sf : sequent.antecedent()) { + Term term = sf; if (Equality.EQUALS == term.op()) { analyzeEquality(services, term, aliases, thisReference); } } - for (SequentFormula sf : sequent.succedent()) { - Term term = sf.formula(); + for (Term sf : sequent.succedent()) { + Term term = sf; if (Junctor.NOT == term.op()) { Term negatedTerm = term.sub(0); if (Equality.EQUALS == negatedTerm.op()) { diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsFeature.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsFeature.java index b82c837cd0c..20904e34173 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsFeature.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsFeature.java @@ -7,7 +7,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Equality; import de.uka.ilkd.key.logic.op.Junctor; @@ -27,7 +26,7 @@ *

            * This means the cut is only applied if the cut formula is not an equality or if it is not a * negated formula or if the (negated) equality is not contained as top term - * ({@link SequentFormula}) in the {@link Sequent} ignoring the order of the equality children. + * ({@link Term}) in the {@link Sequent} ignoring the order of the equality children. *

            * * @author Martin Hentschel @@ -49,9 +48,9 @@ protected boolean filter(RuleApp app, PosInOccurrence pos, Goal goal, MutableSta Term cutFormulaC0 = cutFormula.sub(0); Term cutFormulaC1 = cutFormula.sub(1); boolean contains = false; - Iterator iter = goal.sequent().iterator(); + Iterator iter = goal.sequent().iterator(); while (!contains && iter.hasNext()) { - Term formula = iter.next().formula(); + Term formula = iter.next(); if (formula.op() == Junctor.NOT) { formula = formula.sub(0); } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsTermGenerator.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsTermGenerator.java index db00d1469bf..b06a9f7f4a8 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsTermGenerator.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/CutHeapObjectsTermGenerator.java @@ -12,7 +12,6 @@ import de.uka.ilkd.key.logic.DefaultVisitor; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.JFunction; import de.uka.ilkd.key.proof.Goal; @@ -38,13 +37,13 @@ public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, // Compute collect terms of sequent formulas Sequent sequent = goal.sequent(); Set topTerms = new LinkedHashSet<>(); - for (SequentFormula sf : sequent) { - topTerms.add(sf.formula()); + for (Term sf : sequent) { + topTerms.add(sf); } // Compute equality terms HeapLDT heapLDT = goal.node().proof().getServices().getTypeConverter().getHeapLDT(); Set equalityTerms = new LinkedHashSet<>(); - for (SequentFormula sf : sequent) { + for (Term sf : sequent) { collectEqualityTerms(sf, equalityTerms, topTerms, heapLDT, goal.node().proof().getServices()); } @@ -52,19 +51,19 @@ public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, } /** - * Computes all possible equality terms between objects in the given {@link SequentFormula}. + * Computes all possible equality terms between objects in the given {@link Term}. * - * @param sf The {@link SequentFormula} to work with. + * @param sf The {@link Term} to work with. * @param equalityTerms The result {@link Set} with the equality {@link Term}s to fill. * @param topTerms The terms of all sequent formulas * @param heapLDT The {@link HeapLDT} to use. * @param services TODO */ - protected void collectEqualityTerms(SequentFormula sf, Set equalityTerms, + protected void collectEqualityTerms(Term sf, Set equalityTerms, Set topTerms, HeapLDT heapLDT, Services services) { // Collect objects (target of store operations on heap) Set storeLocations = new LinkedHashSet<>(); - collectStoreLocations(sf.formula(), storeLocations, heapLDT); + collectStoreLocations(sf, storeLocations, heapLDT); // Check if equality checks are possible if (storeLocations.size() >= 2) { // Generate all possible equality checks diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/SimplifyTermStrategy.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/SimplifyTermStrategy.java index a6594e4e05b..ceeb80aa40f 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/SimplifyTermStrategy.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/strategy/SimplifyTermStrategy.java @@ -60,7 +60,7 @@ protected Feature setupApprovalF() { TacletApp ta = (TacletApp) app; if (ta.ifFormulaInstantiations() != null) { for (IfFormulaInstantiation ifi : ta.ifFormulaInstantiations()) { - if (ifi.getConstrainedFormula().formula() + if (ifi.getConstrainedFormula() .containsLabel(SymbolicExecutionUtil.RESULT_LABEL)) { hasLabel = true; } diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionSideProofUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionSideProofUtil.java index 766547c958c..bafc9353346 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionSideProofUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionSideProofUtil.java @@ -57,24 +57,24 @@ private SymbolicExecutionSideProofUtil() { /** * Computes a general {@link Sequent} to prove in a side proof which contains all - * {@link SequentFormula} of the original {@link Sequent} except the given current - * {@link SequentFormula} and those which contains modalities and queries. + * {@link Term} of the original {@link Sequent} except the given current + * {@link Term} and those which contains modalities and queries. * * @param goalSequent The original {@link Sequent} of the current {@link Goal}. - * @param currentSF The {@link SequentFormula} to ignore. + * @param currentSF The {@link Term} to ignore. * @return The general initial {@link Sequent}. */ public static Sequent computeGeneralSequentToProve(Sequent goalSequent, - SequentFormula currentSF) { + Term currentSF) { Sequent sequentToProve = Sequent.EMPTY_SEQUENT; - for (SequentFormula sf : goalSequent.antecedent()) { + for (Term sf : goalSequent.antecedent()) { if (sf != currentSF) { if (!containsModalityOrQuery(sf)) { sequentToProve = sequentToProve.addFormula(sf, true, false).sequent(); } } } - for (SequentFormula sf : goalSequent.succedent()) { + for (Term sf : goalSequent.succedent()) { if (sf != currentSF) { if (!containsModalityOrQuery(sf)) { sequentToProve = sequentToProve.addFormula(sf, false, false).sequent(); @@ -121,16 +121,16 @@ public static List> computeResults(Services services, Proof pro } Sequent sequent = resultGoal.sequent(); List results = new LinkedList<>(); - for (SequentFormula sf : sequent.antecedent()) { - if (sf.formula().containsLabel(label)) { - Term result = sf.formula(); + for (Term sf : sequent.antecedent()) { + if (sf.containsLabel(label)) { + Term result = sf; result = services.getTermBuilder().not(result); results.add(result); } } - for (SequentFormula sf : sequent.succedent()) { - if (sf.formula().containsLabel(label)) { - Term result = sf.formula(); + for (Term sf : sequent.succedent()) { + if (sf.containsLabel(label)) { + Term result = sf; results.add(result); } } @@ -189,12 +189,12 @@ public static List, Node>> computeResultsAndConditions(Se throw new IllegalStateException("Not all applicable rules are applied."); } Sequent sequent = resultGoal.sequent(); - boolean newPredicateIsSequentFormula = isOperatorASequentFormula(sequent, operator); + boolean newPredicateIsTerm = isOperatorATerm(sequent, operator); Set resultConditions = new LinkedHashSet<>(); Term result = null; - for (SequentFormula sf : sequent.antecedent()) { - if (newPredicateIsSequentFormula) { - if (Operator.opEquals(sf.formula().op(), operator)) { + for (Term sf : sequent.antecedent()) { + if (newPredicateIsTerm) { + if (Operator.opEquals(sf.op(), operator)) { throw new IllegalStateException( "Result predicate found in antecedent."); } else { @@ -208,19 +208,19 @@ public static List, Node>> computeResultsAndConditions(Se } if (!isIrrelevantCondition(services, sequentToProve, relevantThingsInSequentToProve, sf)) { - if (resultConditions.add(sf.formula()) && addNamesToServices) { - addNewNamesToNamespace(services, sf.formula()); + if (resultConditions.add(sf) && addNamesToServices) { + addNewNamesToNamespace(services, sf); } } } - for (SequentFormula sf : sequent.succedent()) { - if (newPredicateIsSequentFormula) { - if (Operator.opEquals(sf.formula().op(), operator)) { + for (Term sf : sequent.succedent()) { + if (newPredicateIsTerm) { + if (Operator.opEquals(sf.op(), operator)) { if (result != null) { throw new IllegalStateException( "Result predicate found multiple times in succedent."); } - result = sf.formula().sub(0); + result = sf.sub(0); } } else { Term constructedResult = constructResultIfContained(services, sf, operator); @@ -235,9 +235,9 @@ public static List, Node>> computeResultsAndConditions(Se if (result == null) { if (!isIrrelevantCondition(services, sequentToProve, relevantThingsInSequentToProve, sf)) { - if (resultConditions.add(services.getTermBuilder().not(sf.formula())) + if (resultConditions.add(services.getTermBuilder().not(sf)) && addNamesToServices) { - addNewNamesToNamespace(services, sf.formula()); + addNewNamesToNamespace(services, sf); } } } @@ -254,11 +254,6 @@ public static List, Node>> computeResultsAndConditions(Se } } - private static Term constructResultIfContained(Services services, SequentFormula sf, - Operator operator) { - return constructResultIfContained(services, sf.formula(), operator); - } - private static Term constructResultIfContained(Services services, Term term, Operator operator) { if (Operator.opEquals(term.op(), operator)) { @@ -287,9 +282,11 @@ private static Term constructResultIfContained(Services services, Term term, } } - private static boolean isOperatorASequentFormula(Sequent sequent, final Operator operator) { + private static boolean isOperatorATerm(Sequent sequent, final Operator operator) { return CollectionUtil.search(sequent, - element -> Operator.opEquals(element.formula().op(), operator)) != null; + element -> { + return Operator.opEquals(element.op(), operator); + }) != null; } /** @@ -315,17 +312,6 @@ public void visit(Term visited) { }); } - /** - * Checks if the given {@link SequentFormula} contains a modality or query. - * - * @param sf The {@link SequentFormula} to check. - * @return {@code true} contains at least one modality or query, {@code false} contains no - * modalities and no queries. - */ - public static boolean containsModalityOrQuery(SequentFormula sf) { - return containsModalityOrQuery(sf.formula()); - } - /** * Checks if the given {@link Term} contains a modality or query. * @@ -384,8 +370,8 @@ public boolean isContainsModalityOrQuery() { public static Set extractRelevantThings(final Services services, Sequent sequentToProve) { final Set result = new HashSet<>(); - for (SequentFormula sf : sequentToProve) { - sf.formula().execPreOrder(new DefaultVisitor() { + for (Term sf : sequentToProve) { + sf.execPreOrder(new DefaultVisitor() { @Override public void visit(Term visited) { if (isRelevantThing(services, visited)) { @@ -426,29 +412,29 @@ private static boolean isRelevantThing(Services services, Term term) { } /** - * Checks if the given {@link SequentFormula} is a relevant condition. + * Checks if the given {@link Term} is a relevant condition. * * @param services The {@link Services} to use. * @param initialSequent The initial {@link Sequent} of the side proof. * @param relevantThingsInSequentToProve The relevant things found in the initial * {@link Sequent}. - * @param sf The {@link SequentFormula} to check. - * @return {@code true} {@link SequentFormula} is relevant condition, {@code false} - * {@link SequentFormula} is not a relevant condition. + * @param sf The {@link Term} to check. + * @return {@code true} {@link Term} is relevant condition, {@code false} + * {@link Term} is not a relevant condition. */ public static boolean isIrrelevantCondition(Services services, Sequent initialSequent, - Set relevantThingsInSequentToProve, SequentFormula sf) { + Set relevantThingsInSequentToProve, Term sf) { return initialSequent.antecedent().contains(sf) || initialSequent.succedent().contains(sf) || containsModalityOrQuery(sf) // isInOrOfAntecedent(initialSequent, sf) || || containsIrrelevantThings(services, sf, relevantThingsInSequentToProve); } - // public static boolean isInOrOfAntecedent(Sequent initialSequent, SequentFormula sf) { + // public static boolean isInOrOfAntecedent(Sequent initialSequent, Term sf) { // Term term = sf.formula(); // boolean result = false; - // Iterator iter = initialSequent.antecedent().iterator(); + // Iterator iter = initialSequent.antecedent().iterator(); // while (!result && iter.hasNext()) { - // SequentFormula next = iter.next(); + // Term next = iter.next(); // if (isInOr(next.formula(), term)) { // result = true; // } @@ -471,26 +457,26 @@ public static boolean isIrrelevantCondition(Services services, Sequent initialSe // } /** - * Checks if the given {@link SequentFormula} contains irrelevant things (things which are not + * Checks if the given {@link Term} contains irrelevant things (things which are not * contained in the relevantThingsToProve and are no Java types) * * @param services The {@link Services} to use. - * @param sf The {@link SequentFormula} to check. + * @param sf The {@link Term} to check. * @param relevantThings The relevant things. - * @return {@code true} The {@link SequentFormula} contains irrelevant things, {@code false} the - * {@link SequentFormula} contains no irrelevant things. + * @return {@code true} The {@link Term} contains irrelevant things, {@code false} the + * {@link Term} contains no irrelevant things. */ - public static boolean containsIrrelevantThings(Services services, SequentFormula sf, + public static boolean containsIrrelevantThings(Services services, Term sf, Set relevantThings) { ContainsIrrelevantThingsVisitor visitor = new ContainsIrrelevantThingsVisitor(services, relevantThings); - sf.formula().execPostOrder(visitor); + sf.execPostOrder(visitor); return visitor.isContainsIrrelevantThings(); } /** * Utility class used by - * {@link #containsIrrelevantThings(Services, SequentFormula, Set)}. + * {@link #containsIrrelevantThings(Services, Term, Set)}. * * @author Martin Hentschel */ @@ -540,8 +526,8 @@ public void visit(Term visited) { /** * Returns the result. * - * @return The {@link SequentFormula} contains irrelevant things, {@code false} the - * {@link SequentFormula} contains no irrelevant things. + * @return The {@link Term} contains irrelevant things, {@code false} the + * {@link Term} contains no irrelevant things. */ public boolean isContainsIrrelevantThings() { return containsIrrelevantThings; @@ -699,13 +685,13 @@ public static Term extractOperatorTerm(Goal goal, final Operator operator) { public static Term extractOperatorTerm(Node node, final Operator operator) { assert node != null; // Search formula with the given operator in sequent (or in some cases below the updates) - SequentFormula sf = CollectionUtil.search(node.sequent(), element -> { - Term term = element.formula(); + Term sf = CollectionUtil.search(node.sequent(), element -> { + Term term = element; term = TermBuilder.goBelowUpdates(term); return Objects.equals(term.op(), operator); }); if (sf != null) { - Term term = sf.formula(); + Term term = sf; term = TermBuilder.goBelowUpdates(term); return term; } else { diff --git a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java index 785b03e3d80..55e8831a48c 100644 --- a/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java +++ b/key.core.symbolic_execution/src/main/java/de/uka/ilkd/key/symbolic_execution/util/SymbolicExecutionUtil.java @@ -189,7 +189,7 @@ public static Term simplify(InitConfig initConfig, Proof parentProof, Term term) .cloneProofEnvironmentWithOwnOneStepSimplifier(initConfig, true); // Create Sequent to prove Sequent sequentToProve = - Sequent.EMPTY_SEQUENT.addFormula(new SequentFormula(term), false, true).sequent(); + Sequent.EMPTY_SEQUENT.addFormula(term, false, true).sequent(); // Return created Sequent and the used predicate to identify the value interested in. ApplyStrategyInfo info = SymbolicExecutionSideProofUtil.startSideProof(parentProof, sideProofEnv, sequentToProve); @@ -245,8 +245,8 @@ public static Term sequentToImplication(Sequent sequent, Services services) { public static ImmutableList listSemisequentTerms(Semisequent semisequent) { ImmutableList terms = ImmutableSLList.nil(); if (semisequent != null) { - for (SequentFormula sf : semisequent) { - terms = terms.append(sf.formula()); + for (Term sf : semisequent) { + terms = terms.append(sf); } } return terms; @@ -487,7 +487,7 @@ public static SiteProofVariableValueInput createExtractReturnVariableValueSequen Term modalityTerm = services.getTermBuilder().dia(newJavaBlock, newTerm); // Get the updates from the return node which includes the value interested in. Term originalModifiedFormula = - methodReturnNode.getAppliedRuleApp().posInOccurrence().sequentFormula().formula(); + methodReturnNode.getAppliedRuleApp().posInOccurrence().sequentLevelFormula(); ImmutableList originalUpdates = TermBuilder.goBelowUpdates2(originalModifiedFormula).first; // Create Sequent to prove with new succedent. @@ -668,16 +668,16 @@ public static IExecutionConstraint[] createExecutionConstraints(IExecutionNode constraints = new LinkedList<>(); Node proofNode = node.getProofNode(); Sequent sequent = proofNode.sequent(); - for (SequentFormula sf : sequent.antecedent()) { - if (!containsSymbolicExecutionLabel(sf.formula())) { + for (Term sf : sequent.antecedent()) { + if (!containsSymbolicExecutionLabel(sf)) { constraints.add(new ExecutionConstraint(node.getSettings(), proofNode, - node.getModalityPIO(), sf.formula())); + node.getModalityPIO(), sf)); } } - for (SequentFormula sf : sequent.succedent()) { - if (!containsSymbolicExecutionLabel(sf.formula())) { + for (Term sf : sequent.succedent()) { + if (!containsSymbolicExecutionLabel(sf)) { constraints.add(new ExecutionConstraint(node.getSettings(), proofNode, - node.getModalityPIO(), tb.not(sf.formula()))); + node.getModalityPIO(), tb.not(sf))); } } return constraints.toArray(new IExecutionConstraint[0]); @@ -820,11 +820,11 @@ public static List collectAllElementaryUpdateTerms(Node node) if (node != null) { Services services = node.proof().getServices(); List result = new LinkedList<>(); - for (SequentFormula sf : node.sequent().antecedent()) { - internalCollectAllElementaryUpdateTerms(services, result, sf.formula()); + for (Term sf : node.sequent().antecedent()) { + internalCollectAllElementaryUpdateTerms(services, result, sf); } - for (SequentFormula sf : node.sequent().succedent()) { - internalCollectAllElementaryUpdateTerms(services, result, sf.formula()); + for (Term sf : node.sequent().succedent()) { + internalCollectAllElementaryUpdateTerms(services, result, sf); } return result; } else { @@ -1339,8 +1339,8 @@ public static PosInOccurrence findModalityWithMaxSymbolicExecutionLabelId( if (semisequent != null) { int maxId = Integer.MIN_VALUE; PosInOccurrence maxPio = null; - for (SequentFormula sf : semisequent) { - PosInTerm current = findModalityWithMaxSymbolicExecutionLabelId(sf.formula()); + for (Term sf : semisequent) { + PosInTerm current = findModalityWithMaxSymbolicExecutionLabelId(sf); if (current != null) { PosInOccurrence pio = new PosInOccurrence(sf, current, inAntec); SymbolicExecutionTermLabel label = getSymbolicExecutionLabel(pio.subTerm()); @@ -1424,8 +1424,8 @@ public static PosInOccurrence findModalityWithMinSymbolicExecutionLabelId( if (semisequent != null) { int maxId = Integer.MIN_VALUE; PosInOccurrence minPio = null; - for (SequentFormula sf : semisequent) { - PosInTerm current = findModalityWithMinSymbolicExecutionLabelId(sf.formula()); + for (Term sf : semisequent) { + PosInTerm current = findModalityWithMinSymbolicExecutionLabelId(sf); if (current != null) { PosInOccurrence pio = new PosInOccurrence(sf, current, inAntec); SymbolicExecutionTermLabel label = getSymbolicExecutionLabel(pio.subTerm()); @@ -2085,8 +2085,8 @@ else if (rightTerm.op() == Junctor.IMP public static ContractPostOrExcPostExceptionVariableResult searchContractPostOrExcPostExceptionVariable( Node node, Services services) throws ProofInputException { Semisequent antecedent = node.sequent().antecedent(); - SequentFormula sf = antecedent.get(antecedent.size() - 1); - Term workingTerm = sf.formula(); + Term sf = antecedent.get(antecedent.size() - 1); + Term workingTerm = sf; Pair, Term> updatesAndTerm = TermBuilder.goBelowUpdates2(workingTerm); workingTerm = updatesAndTerm.second; if (workingTerm.op() != Junctor.AND) { @@ -2257,7 +2257,7 @@ private static Term computeLoopInvariantBuiltInRuleAppBranchCondition(Node paren Services services = parent.proof().getServices(); Node useNode = parent.child(2); Semisequent antecedent = useNode.sequent().antecedent(); - Term invTerm = antecedent.get(antecedent.size() - 1).formula(); + Term invTerm = antecedent.get(antecedent.size() - 1); // Extract loop condition from child Term loopConditionModalityTerm = posInOccurrenceInOtherNode(parent, app.posInOccurrence(), node); @@ -2371,7 +2371,7 @@ private static Term computeBlockContractBuiltInRuleAppBranchCondition(Node paren // Compute invariant (last antecedent formula of the use branch) Services services = parent.proof().getServices(); Semisequent antecedent = node.sequent().antecedent(); - Term condition = antecedent.get(antecedent.size() - 1).formula(); + Term condition = antecedent.get(antecedent.size() - 1); if (simplify) { // New OneStepSimplifier is required because it has an internal state and the // default instance can't be used parallel. @@ -2469,7 +2469,7 @@ public static PosInOccurrence posInOccurrenceToOtherSequent(Sequent original, PosInOccurrence pio, Sequent toApplyTo) { if (original != null && pio != null && toApplyTo != null) { // Search index of formula in original sequent - SequentFormula originalSF = pio.sequentFormula(); + Term originalSF = pio.sequentLevelFormula(); boolean antecendet = pio.isInAntec(); int index; if (antecendet) { @@ -2478,7 +2478,7 @@ public static PosInOccurrence posInOccurrenceToOtherSequent(Sequent original, index = original.succedent().indexOf(originalSF); } if (index >= 0) { - final SequentFormula toApplyToSF = + final Term toApplyToSF = (antecendet ? toApplyTo.antecedent() : toApplyTo.succedent()).get(index); return new PosInOccurrence(toApplyToSF, pio.posInTerm(), antecendet); } else { @@ -2535,8 +2535,8 @@ private static Term computeTacletAppBranchCondition(Node parent, Node node, bool // Remove replace part of symbolic execution rules if (NodeInfo.isSymbolicExecution(app.taclet())) { Sequent sequent = (Sequent) goalTemplate.replaceWithExpressionAsObject(); - for (SequentFormula sf : sequent.antecedent()) { - Term replaceTerm = instantiateTerm(node, sf.formula(), app, services); + for (Term sf : sequent.antecedent()) { + Term replaceTerm = instantiateTerm(node, sf, app, services); replaceTerm = services.getTermBuilder().applyUpdatePairsSequential( app.instantiations().getUpdateContext(), replaceTerm); Term originalTerm = findReplacement(node.sequent().antecedent(), @@ -2544,8 +2544,8 @@ private static Term computeTacletAppBranchCondition(Node parent, Node node, bool assert originalTerm != null; newAntecedents = newAntecedents.removeFirst(originalTerm); } - for (SequentFormula sf : sequent.succedent()) { - Term replaceTerm = instantiateTerm(node, sf.formula(), app, services); + for (Term sf : sequent.succedent()) { + Term replaceTerm = instantiateTerm(node, sf, app, services); replaceTerm = services.getTermBuilder().applyUpdatePairsSequential( app.instantiations().getUpdateContext(), replaceTerm); Term originalTerm = findReplacement(node.sequent().succedent(), @@ -2637,7 +2637,7 @@ private static Term computeTacletAppBranchCondition(Node parent, Node node, bool } /** - * Lists the {@link Term}s of all new {@link SequentFormula} in the child {@link Semisequent}. + * Lists the {@link Term}s of all new {@link Term} in the child {@link Semisequent}. * * @param parent The parent {@link Semisequent}. * @param child The child {@link Semisequent}. @@ -2645,14 +2645,14 @@ private static Term computeTacletAppBranchCondition(Node parent, Node node, bool */ private static ImmutableList listNewSemisequentTerms(Semisequent parent, Semisequent child) { - Set parentSFs = new HashSet<>(); - for (SequentFormula sf : parent) { + Set parentSFs = new HashSet<>(); + for (Term sf : parent) { parentSFs.add(sf); } ImmutableList result = ImmutableSLList.nil(); - for (SequentFormula sf : child) { + for (Term sf : child) { if (!parentSFs.contains(sf)) { - result = result.append(sf.formula()); + result = result.append(sf); } } return result; @@ -2669,9 +2669,15 @@ private static ImmutableList listNewSemisequentTerms(Semisequent parent, */ private static Term findReplacement(Semisequent semisequent, final PosInOccurrence posInOccurrence, final Term replaceTerm) { - SequentFormula sf = CollectionUtil.search(semisequent, - element -> checkReplaceTerm(element.formula(), posInOccurrence, replaceTerm)); - return sf != null ? sf.formula() : null; + Term sf = CollectionUtil.search(semisequent, + element -> { + return checkReplaceTerm(element, posInOccurrence, replaceTerm); + }); + if (sf != null) { + return sf; + } else { + return null; + } } /** @@ -2931,7 +2937,7 @@ public static Sequent createSequentToProveWithNewSuccedent(Node node, PosInOccur if (node.proof().root() == node) { originalUpdates = computeRootElementaryUpdates(node); } else { - Term originalModifiedFormula = pio.sequentFormula().formula(); + Term originalModifiedFormula = pio.sequentLevelFormula(); originalUpdates = TermBuilder.goBelowUpdates2(originalModifiedFormula).first; } // Create new sequent @@ -2952,8 +2958,8 @@ public static Sequent createSequentToProveWithNewSuccedent(Node node, PosInOccur public static ImmutableList computeRootElementaryUpdates(Node root) { ImmutableList result = ImmutableSLList.nil(); Sequent sequent = root.sequent(); - for (SequentFormula sf : sequent.succedent()) { - Term term = sf.formula(); + for (Term sf : sequent.succedent()) { + Term term = sf; if (Junctor.IMP.equals(term.op())) { result = result.prepend(collectElementaryUpdates(term.sub(1))); } @@ -3031,7 +3037,7 @@ public static Sequent createSequentToProveWithNewSuccedent(Node node, PosInOccur // were not modified by the applied rule Sequent originalSequentWithoutMethodFrame = SymbolicExecutionSideProofUtil.computeGeneralSequentToProve(node.sequent(), - pio != null ? pio.sequentFormula() : null); + pio != null ? pio.sequentLevelFormula() : null); Set skolemTerms = newSuccedentToProve != null ? collectSkolemConstants(originalSequentWithoutMethodFrame, newSuccedentToProve) : collectSkolemConstants(originalSequentWithoutMethodFrame, tb.parallel(updates)); @@ -3045,13 +3051,13 @@ public static Sequent createSequentToProveWithNewSuccedent(Node node, PosInOccur newSuccedentToProve = addLabelRecursiveToNonSkolem(factory, newSuccedentToProve, RESULT_LABEL); } - Sequent sequentToProve = newSuccedentToProve != null - ? originalSequentWithoutMethodFrame - .addFormula(new SequentFormula(newSuccedentToProve), false, true).sequent() + Sequent sequentToProve; + sequentToProve = newSuccedentToProve != null ? originalSequentWithoutMethodFrame + .addFormula(newSuccedentToProve, false, true).sequent() : originalSequentWithoutMethodFrame; if (additionalAntecedent != null) { sequentToProve = sequentToProve - .addFormula(new SequentFormula(additionalAntecedent), true, false).sequent(); + .addFormula(additionalAntecedent, true, false).sequent(); } return sequentToProve; } @@ -3067,10 +3073,10 @@ public static Sequent createSequentToProveWithNewSuccedent(Node node, PosInOccur private static Sequent labelSkolemConstants( Sequent sequent, Set constantsToLabel, TermFactory factory) { - for (SequentFormula sf : sequent.antecedent()) { + for (Term sf : sequent.antecedent()) { int skolemEquality = checkSkolemEquality(sf); if (skolemEquality == -1) { - Term equality = sf.formula(); + Term equality = sf; if (constantsToLabel.contains(equality.sub(0))) { Term definition = addLabelRecursiveToNonSkolem(factory, equality.sub(1), RESULT_LABEL); @@ -3082,11 +3088,11 @@ private static Sequent labelSkolemConstants( Term newEquality = factory.createTerm(equality.op(), new ImmutableArray<>(newSubs), equality.boundVars(), equality.getLabels()); - sequent = sequent.changeFormula(new SequentFormula(newEquality), + sequent = sequent.changeFormula(newEquality, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true)).sequent(); } } else if (skolemEquality == 1) { - Term equality = sf.formula(); + Term equality = sf; if (constantsToLabel.contains(equality.sub(1))) { Term definition = addLabelRecursiveToNonSkolem(factory, equality.sub(0), RESULT_LABEL); @@ -3098,7 +3104,7 @@ private static Sequent labelSkolemConstants( Term newEquality = factory.createTerm(equality.op(), new ImmutableArray<>(newSubs), equality.boundVars(), equality.getLabels()); - sequent = sequent.changeFormula(new SequentFormula(newEquality), + sequent = sequent.changeFormula(newEquality, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true)).sequent(); } } @@ -3225,7 +3231,7 @@ public static boolean isSkolemConstant(Term term) { } /** - * Removes all {@link SequentFormula}s with a skolem equality from the given {@link Sequent} if + * Removes all {@link Term}s with a skolem equality from the given {@link Sequent} if * the skolem {@link Term} is not contained in the given {@link Collection}. * * @param sequent The {@link Sequent} to modify. @@ -3236,10 +3242,10 @@ public static boolean isSkolemConstant(Term term) { private static Sequent removeAllUnusedSkolemEqualities(Sequent sequent, Collection skolemConstants) { Sequent result = sequent; - for (SequentFormula sf : sequent.antecedent()) { + for (Term sf : sequent.antecedent()) { result = removeAllUnusedSkolemEqualities(result, sf, true, skolemConstants); } - for (SequentFormula sf : sequent.succedent()) { + for (Term sf : sequent.succedent()) { result = removeAllUnusedSkolemEqualities(result, sf, false, skolemConstants); } return result; @@ -3247,17 +3253,17 @@ private static Sequent removeAllUnusedSkolemEqualities(Sequent sequent, /** * Helper method of {@link #removeAllUnusedSkolemEqualities(Sequent, Collection)} which removes - * the given {@link SequentFormula} if required. + * the given {@link Term} if required. * * @param sequent The {@link Sequent} to modify. - * @param sf The {@link SequentFormula} to remove if its skolem {@link Term} is not listed. + * @param sf The {@link Term} to remove if its skolem {@link Term} is not listed. * @param antecedent {@code true} antecedent, {@code false} succedent. * @param skolemConstants The allowed skolem {@link Term}s. - * @return The modified {@link Sequent} in which the {@link SequentFormula} might be removed. + * @return The modified {@link Sequent} in which the {@link Term} might be removed. */ - private static Sequent removeAllUnusedSkolemEqualities(Sequent sequent, SequentFormula sf, + private static Sequent removeAllUnusedSkolemEqualities(Sequent sequent, Term sf, boolean antecedent, Collection skolemConstants) { - Term term = sf.formula(); + Term term = sf; boolean remove = false; if (term.op() == Equality.EQUALS) { if (isSkolemConstant(term.sub(0))) { @@ -3276,17 +3282,6 @@ private static Sequent removeAllUnusedSkolemEqualities(Sequent sequent, SequentF } } - /** - * Checks if the given {@link SequentFormula} is a skolem equality. - * - * @param sf The {@link SequentFormula} to check. - * @return {@code -1} left side of skolem equality, {@code 0} no skolem equality, {@code 1} - * right side of skolem equality. - */ - public static int checkSkolemEquality(SequentFormula sf) { - return checkSkolemEquality(sf.formula()); - } - /** * Checks if the given {@link Term} is a skolem equality. * @@ -3427,8 +3422,8 @@ public static Term replaceSkolemConstants(Sequent sequent, Term term, Services s private static List findSkolemReplacements(Sequent sequent, Term skolemConstant, Term skolemEquality) { List result = new LinkedList<>(); - for (SequentFormula sf : sequent) { - Term term = sf.formula(); + for (Term sf : sequent) { + Term term = sf; if (term != skolemEquality) { int skolemCheck = checkSkolemEquality(term); if (skolemCheck == -1) { @@ -4111,10 +4106,12 @@ public static boolean lazyComputeIsMainBranchVerified(Node node) { Node leaf = leafsIter.next(); if (!leaf.isClosed()) { final Term toSearch = predicate; - SequentFormula topLevelPredicate = CollectionUtil + Term topLevelPredicate = CollectionUtil .search(leaf.sequent().succedent(), - element -> Operator.opEquals(toSearch.op(), - element.formula().op())); + element -> { + return Operator.opEquals(toSearch.op(), + element.op()); + }); if (topLevelPredicate == null) { verified = false; } @@ -4151,9 +4148,11 @@ public static boolean lazyComputeIsAdditionalBranchVerified(Node node) { for (Term term : additinalPredicates) { additinalOperatos.add(term.op()); } - SequentFormula topLevelPredicate = + Term topLevelPredicate = CollectionUtil.search(leaf.sequent().succedent(), - element -> additinalOperatos.contains(element.formula().op())); + element -> { + return additinalOperatos.contains(element.op()); + }); if (topLevelPredicate == null) { verified = false; } @@ -4199,8 +4198,8 @@ public static Sort lazyComputeExceptionSort(Node node, IProgramVariable exceptio // Search final value of the exceptional variable which is used to check if the verified // program terminates normally ImmutableArray value = null; - for (SequentFormula f : node.sequent().succedent()) { - Pair, Term> updates = TermBuilder.goBelowUpdates2(f.formula()); + for (Term f : node.sequent().succedent()) { + Pair, Term> updates = TermBuilder.goBelowUpdates2(f); Iterator iter = updates.first.iterator(); while (value == null && iter.hasNext()) { value = extractValueFromUpdate(iter.next(), exceptionVariable); diff --git a/key.core.symbolic_execution/src/test/java/de/uka/ilkd/key/symbolic_execution/testcase/AbstractSymbolicExecutionTestCase.java b/key.core.symbolic_execution/src/test/java/de/uka/ilkd/key/symbolic_execution/testcase/AbstractSymbolicExecutionTestCase.java index 95c6da8fe33..2b0a9703bd7 100644 --- a/key.core.symbolic_execution/src/test/java/de/uka/ilkd/key/symbolic_execution/testcase/AbstractSymbolicExecutionTestCase.java +++ b/key.core.symbolic_execution/src/test/java/de/uka/ilkd/key/symbolic_execution/testcase/AbstractSymbolicExecutionTestCase.java @@ -1638,7 +1638,7 @@ protected String getTryContent(Proof proof) { Node node = proof.root(); Sequent sequent = node.sequent(); assertEquals(1, sequent.succedent().size()); - Term succedent = sequent.succedent().get(0).formula(); + Term succedent = sequent.succedent().get(0); assertEquals(2, succedent.arity()); Term updateApplication = succedent.subs().get(1); assertEquals(2, updateApplication.arity()); diff --git a/key.core.testgen/src/main/java/de/uka/ilkd/key/smt/testgen/AbstractTestGenerator.java b/key.core.testgen/src/main/java/de/uka/ilkd/key/smt/testgen/AbstractTestGenerator.java index 2fbfc7b1ce4..7ee2a1cf76a 100644 --- a/key.core.testgen/src/main/java/de/uka/ilkd/key/smt/testgen/AbstractTestGenerator.java +++ b/key.core.testgen/src/main/java/de/uka/ilkd/key/smt/testgen/AbstractTestGenerator.java @@ -11,7 +11,6 @@ import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.UpdateApplication; import de.uka.ilkd.key.macros.ProofMacroFinishedInfo; @@ -283,19 +282,19 @@ private Proof createProofForTestingNoDuplicate(Node node, List otherProof final Sequent oldSequent = node.sequent(); Sequent newSequent = Sequent.createSequent(Semisequent.EMPTY_SEMISEQUENT, Semisequent.EMPTY_SEMISEQUENT); - Iterator it = oldSequent.antecedent().iterator(); + Iterator it = oldSequent.antecedent().iterator(); while (it.hasNext()) { - final SequentFormula sf = it.next(); + final Term sf = it.next(); // Allow updates modailities in the antecedent - if (hasModalities(sf.formula(), false)) { + if (hasModalities(sf, false)) { continue; } newSequent = newSequent.addFormula(sf, true, false).sequent(); } it = oldSequent.succedent().iterator(); while (it.hasNext()) { - final SequentFormula sf = it.next(); - if (hasModalities(sf.formula(), removePostCondition)) { + final Term sf = it.next(); + if (hasModalities(sf, removePostCondition)) { continue; } newSequent = newSequent.addFormula(sf, false, false).sequent(); diff --git a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ModelGenerator.java b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ModelGenerator.java index 0b66418b71b..1d1d4deaf7d 100644 --- a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ModelGenerator.java +++ b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ModelGenerator.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.op.IProgramVariable; @@ -149,7 +148,7 @@ private boolean addModelToTerm(Model m) { if (!tmodel.equals(tb.tt())) { Term notTerm = tb.not(tmodel); - SequentFormula sf = new SequentFormula(notTerm); + Term sf = notTerm; goal.addFormula(sf, true, true); return true; } @@ -175,14 +174,14 @@ public Term sequentToTerm(Sequent s) { final TermBuilder tb = services.getTermBuilder(); ante = ante.append(tb.tt()); - for (SequentFormula f : s.antecedent()) { - ante = ante.append(f.formula()); + for (Term f : s.antecedent()) { + ante = ante.append(f); } ImmutableList succ = ImmutableSLList.nil(); succ = succ.append(tb.ff()); - for (SequentFormula f : s.succedent()) { - succ = succ.append(f.formula()); + for (Term f : s.succedent()) { + succ = succ.append(f); } return tb.imp(tb.and(ante), tb.or(succ)); diff --git a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ProofInfo.java b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ProofInfo.java index 9ea2b64c61c..7abfd7b8a68 100644 --- a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ProofInfo.java +++ b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/ProofInfo.java @@ -146,7 +146,7 @@ private boolean isFalseConstant(Operator o) { } public Term getPO() { - return proof.root().sequent().succedent().get(0).formula(); + return proof.root().sequent().succedent().get(0); } diff --git a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/TestCaseGenerator.java b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/TestCaseGenerator.java index c652b73a373..6cfc7b14f21 100644 --- a/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/TestCaseGenerator.java +++ b/key.core.testgen/src/main/java/de/uka/ilkd/key/testgen/TestCaseGenerator.java @@ -14,7 +14,6 @@ import de.uka.ilkd.key.java.declaration.ParameterDeclaration; import de.uka.ilkd.key.java.declaration.VariableSpecification; import de.uka.ilkd.key.ldt.HeapLDT; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.*; import de.uka.ilkd.key.proof.Node; @@ -602,17 +601,15 @@ protected String inferSort(Map typeInfMap, String progVar) { protected Map generateTypeInferenceMap(Node n) { HashMap typeInfMap = new HashMap<>(); - for (SequentFormula sequentFormula : n.sequent()) { - Term t = sequentFormula.formula(); - generateTypeInferenceMapHelper(t, typeInfMap); + for (Term seqFml : n.sequent()) { + generateTypeInferenceMapHelper(seqFml, typeInfMap); } return typeInfMap; } private void generateTypeInferenceMapHelper(Term t, Map map) { Operator op = t.op(); - if (op instanceof ProgramVariable) { - ProgramVariable pv = (ProgramVariable) t.op(); + if (op instanceof ProgramVariable pv) { final String name = pv.name().toString(); if (map.containsKey(name)) { if (map.get(name) != pv.sort()) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/api/Matcher.java b/key.core/src/main/java/de/uka/ilkd/key/api/Matcher.java index 9105d67b4f4..196733d7d10 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/api/Matcher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/api/Matcher.java @@ -7,7 +7,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.nparser.KeyAst; import de.uka.ilkd.key.nparser.KeyIO; @@ -85,9 +85,9 @@ public List matchPattern(String pattern, Sequent currentSeq ImmutableArray succCand = IfFormulaInstSeq.createList(currentSeq, false, copyServices); - SequentFormula[] patternArray = new SequentFormula[patternSeq.size()]; + Term[] patternArray = new Term[patternSeq.size()]; int i = 0; - for (SequentFormula fm : patternSeq) { + for (Term fm : patternSeq) { patternArray[i++] = fm; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/api/SearchNode.java b/key.core/src/main/java/de/uka/ilkd/key/api/SearchNode.java index bf08e9862ac..973f983a845 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/api/SearchNode.java +++ b/key.core/src/main/java/de/uka/ilkd/key/api/SearchNode.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.api; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.rule.MatchConditions; import de.uka.ilkd.key.rule.inst.SVInstantiations; @@ -12,13 +11,13 @@ * Created by sarah on 5/2/17. */ public final class SearchNode { - private final SequentFormula[] pattern; + private final Term[] pattern; private final int pos; private final int succAntPos; private final MatchConditions mc; - public SearchNode(SequentFormula[] pattern, int succAntPos) { + public SearchNode(Term[] pattern, int succAntPos) { this.pattern = pattern; this.pos = 0; this.succAntPos = succAntPos; @@ -38,7 +37,7 @@ public boolean isAntecedent() { } public Term getPatternTerm() { - return pattern[pos].formula(); + return pattern[pos]; } public boolean isFinished() { diff --git a/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletAssumesModel.java b/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletAssumesModel.java index f4d6ba8618a..e7216887766 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletAssumesModel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletAssumesModel.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.Position; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.NamespaceSet; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.OriginTermLabel.NodeOrigin; import de.uka.ilkd.key.logic.label.OriginTermLabel.SpecType; @@ -41,7 +40,7 @@ public String toString(Services services) { } @Override - public SequentFormula getConstrainedFormula() { + public Term getConstrainedFormula() { return null; } }; @@ -127,7 +126,7 @@ public IfFormulaInstantiation getSelection(int pos) new NodeOrigin(SpecType.USER_INTERACTION, app.rule().displayName(), goal.node().serialNr())); - return new IfFormulaInstDirect(new SequentFormula(term)); + return new IfFormulaInstDirect(term); } catch (RecognitionException e) { throw new SVInstantiationParserException(manualInput, Position.fromOneZeroBased(pos, e.charPositionInLine), diff --git a/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletInstantiationModel.java b/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletInstantiationModel.java index 9948b481af2..756cfe4bcfc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletInstantiationModel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/control/instantiation_model/TacletInstantiationModel.java @@ -125,14 +125,14 @@ private void initIfChoiceModels() { ImmutableArray succCand = IfFormulaInstSeq.createList(seq, false, services); - Iterator it = ifseq.iterator(); + Iterator it = ifseq.iterator(); Term ifFma; MatchConditions matchCond = app.matchConditions(); ifChoiceModel = new TacletAssumesModel[size]; for (int i = 0; i < size; i++) { - ifFma = it.next().formula(); + ifFma = it.next(); ifChoiceModel[i] = new TacletAssumesModel( ifFma, taclet().getMatcher().matchIf((i < asize ? antecCand : succCand), diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/AbstractFinishAuxiliaryComputationMacro.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/AbstractFinishAuxiliaryComputationMacro.java index f0afb84aea8..648f9a76e3e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/AbstractFinishAuxiliaryComputationMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/AbstractFinishAuxiliaryComputationMacro.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Namespace; import de.uka.ilkd.key.logic.NamespaceSet; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermFactory; @@ -120,11 +119,11 @@ private static Term buildFormulaFromGoal(Goal symbExecGoal) { final TermBuilder tb = symbExecGoal.proof().getServices().getTermBuilder(); final TermFactory tf = symbExecGoal.proof().getServices().getTermFactory(); Term result = tb.tt(); - for (final SequentFormula f : symbExecGoal.sequent().antecedent()) { - result = tb.and(result, f.formula()); + for (final Term f : symbExecGoal.sequent().antecedent()) { + result = tb.and(result, f); } - for (final SequentFormula f : symbExecGoal.sequent().succedent()) { - result = tb.and(result, tb.not(f.formula())); + for (final Term f : symbExecGoal.sequent().succedent()) { + result = tb.and(result, tb.not(f)); } result = TermLabelManager.removeIrrelevantLabels(result, tf); return result; diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/SelfcompositionStateExpansionMacro.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/SelfcompositionStateExpansionMacro.java index 18daf7aa846..c514cba0579 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/SelfcompositionStateExpansionMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/macros/SelfcompositionStateExpansionMacro.java @@ -70,8 +70,9 @@ protected Strategy createStrategy(Proof proof, PosInOccurrence posInOcc) { protected boolean ruleApplicationInContextAllowed(RuleApp ruleApp, PosInOccurrence pio, Goal goal) { String ruleName = ruleApp.rule().name().toString(); - return !"andLeft".equals(ruleName) - || !(pio.sequentFormula().formula().op() instanceof UpdateApplication); + if (!"andLeft".equals(ruleName)) + return true; + return !(pio.sequentLevelFormula().op() instanceof UpdateApplication); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/proof/InfFlowProof.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/proof/InfFlowProof.java index cf2f9226bbe..f2827c91b52 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/proof/InfFlowProof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/proof/InfFlowProof.java @@ -5,7 +5,6 @@ import de.uka.ilkd.key.informationflow.po.InfFlowProofSymbols; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.BuiltInRuleIndex; import de.uka.ilkd.key.proof.Proof; @@ -98,11 +97,11 @@ public void addGoalTemplates(Taclet t) { ImmutableList temps = t.goalTemplates(); assert temps != null; for (TacletGoalTemplate tgt : temps) { - for (SequentFormula sf : tgt.sequent().antecedent().asList()) { - addLabeledTotalTerm(sf.formula()); + for (Term sf : tgt.sequent().antecedent().asList()) { + addLabeledTotalTerm(sf); } - for (SequentFormula sf : tgt.sequent().succedent().asList()) { - addLabeledTotalTerm(sf.formula()); + for (Term sf : tgt.sequent().succedent().asList()) { + addLabeledTotalTerm(sf); } } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/executor/InfFlowContractAppTacletExecutor.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/executor/InfFlowContractAppTacletExecutor.java index a3a7fa718f6..a32bab1b947 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/executor/InfFlowContractAppTacletExecutor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/executor/InfFlowContractAppTacletExecutor.java @@ -43,12 +43,13 @@ protected void addToAntec(Semisequent semi, TermLabelState termLabelState, TacletLabelHint labelHint, SequentChangeInfo currentSequent, PosInOccurrence pos, PosInOccurrence applicationPosInOccurrence, MatchConditions matchCond, Goal goal, RuleApp tacletApp, Services services) { - final ImmutableList replacements = instantiateSemisequent(semi, + final ImmutableList replacements = instantiateSemisequent(semi, termLabelState, labelHint, pos, matchCond, goal, tacletApp, services); assert replacements.size() == 1 : "information flow taclets must have " + "exactly one add!"; + final Term replacement = replacements.iterator().next(); updateStrategyInfo(services.getProof().openEnabledGoals().head(), - replacements.iterator().next().formula()); + replacement); super.addToAntec(semi, termLabelState, labelHint, currentSequent, pos, applicationPosInOccurrence, matchCond, goal, tacletApp, services); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/tacletbuilder/AbstractInfFlowContractAppTacletBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/tacletbuilder/AbstractInfFlowContractAppTacletBuilder.java index 474082a360b..82694a57efd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/tacletbuilder/AbstractInfFlowContractAppTacletBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/informationflow/rule/tacletbuilder/AbstractInfFlowContractAppTacletBuilder.java @@ -247,9 +247,9 @@ private Taclet genInfFlowContractApplTaclet(Goal goal, ProofObligationVars appDa // create sequents Sequent assumesSeq = - Sequent.createAnteSequent(new Semisequent(new SequentFormula(schemaAssumes))); + Sequent.createAnteSequent(new Semisequent(schemaAssumes)); Sequent replaceWithSeq = - Sequent.createAnteSequent(new Semisequent(new SequentFormula(replaceWithTerm))); + Sequent.createAnteSequent(new Semisequent(replaceWithTerm)); // create taclet InfFlowContractAppRewriteTacletBuilder tacletBuilder = diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/BoundVarsVisitor.java b/key.core/src/main/java/de/uka/ilkd/key/logic/BoundVarsVisitor.java index da51f6c54f6..76f5407d600 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/BoundVarsVisitor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/BoundVarsVisitor.java @@ -40,8 +40,8 @@ public void visit(Term visited) { * visits a sequent */ public void visit(Sequent visited) { - for (SequentFormula cf : visited) { - visit(cf.formula()); + for (Term cf : visited) { + visit(cf); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/FormulaChangeInfo.java b/key.core/src/main/java/de/uka/ilkd/key/logic/FormulaChangeInfo.java index a01138a9dfb..e7c72d25703 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/FormulaChangeInfo.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/FormulaChangeInfo.java @@ -10,10 +10,10 @@ * @param newFormula modified formula * @see SequentChangeInfo */ -public record FormulaChangeInfo(PosInOccurrence positionOfModification, SequentFormula newFormula) { +public record FormulaChangeInfo(PosInOccurrence positionOfModification, Term newFormula) { - public SequentFormula getOriginalFormula() { - return positionOfModification().sequentFormula(); + public Term getOriginalFormula() { + return positionOfModification().sequentLevelFormula(); } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java b/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java index 0674d8b557b..aef1c55a869 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java @@ -4,7 +4,7 @@ package de.uka.ilkd.key.logic; /** - * This class describes a position in an occurrence of a term. A SequentFormula and a PosInTerm + * This class describes a position in an occurrence of a term. A Term and a PosInTerm * determine an object of this class exactly. */ public final class PosInOccurrence { @@ -17,7 +17,7 @@ public static PosInOccurrence findInSequent(Sequent seq, int formulaNumber, PosI /** * the constrained formula the pos in occurrence describes */ - private final SequentFormula sequentFormula; + private final Term sequentLevelFormula; // saves 8 bytes (due to alignment issues) per instance if we use a // short here instead of an int @@ -28,7 +28,7 @@ public static PosInOccurrence findInSequent(Sequent seq, int formulaNumber, PosI */ private final boolean inAntec; - /** the position in sequentFormula.formula() */ + /** the position in Term.formula() */ private final PosInTerm posInTerm; /** @@ -36,20 +36,20 @@ public static PosInOccurrence findInSequent(Sequent seq, int formulaNumber, PosI */ private volatile Term subTermCache = null; - public PosInOccurrence(SequentFormula sequentFormula, PosInTerm posInTerm, boolean inAntec) { + public PosInOccurrence(Term sequentLevelFormula, PosInTerm posInTerm, boolean inAntec) { assert posInTerm != null; - assert sequentFormula != null; + assert sequentLevelFormula != null; this.inAntec = inAntec; - this.sequentFormula = sequentFormula; + this.sequentLevelFormula = sequentLevelFormula; this.posInTerm = posInTerm; - this.hashCode = (short) (sequentFormula.hashCode() * 13 + posInTerm.hashCode()); + this.hashCode = (short) (sequentLevelFormula.hashCode() * 13 + posInTerm.hashCode()); } /** - * returns the SequentFormula that determines the occurrence of this PosInOccurrence + * returns the Term that determines the occurrence of this PosInOccurrence */ - public SequentFormula sequentFormula() { - return sequentFormula; + public Term sequentLevelFormula() { + return sequentLevelFormula; } /** @@ -66,7 +66,7 @@ public int depth() { * {@link de.uka.ilkd.key.logic.PosInTerm}. */ public PosInOccurrence down(int i) { - return new PosInOccurrence(sequentFormula, posInTerm.down(i), inAntec); + return new PosInOccurrence(sequentLevelFormula, posInTerm.down(i), inAntec); } /** @@ -78,7 +78,7 @@ public boolean eqEquals(Object obj) { return false; } - if (!sequentFormula.equals(cmp.sequentFormula)) { + if (!sequentLevelFormula.equals(cmp.sequentLevelFormula)) { return false; } @@ -100,7 +100,7 @@ public boolean equals(Object obj) { // NB: the class NonDuplicateAppFeature depends on the usage // of != in this condition - if (sequentFormula() != cmp.sequentFormula()) { + if (sequentLevelFormula() != cmp.sequentLevelFormula()) { return false; } @@ -139,7 +139,7 @@ public boolean isTopLevel() { /** * List all subterms between the root and the position this objects points to; the first term is - * the whole term constrainedFormula().formula(), the last one + * the whole sequent level formula, the last one * subTerm() * * @return an iterator that walks from the root of the term to the position this @@ -151,10 +151,9 @@ public PIOPathIterator iterator() { /** * The usage of this method is strongly discouraged, use {@link PosInOccurrence#iterator} - * instead. describes the exact occurrence of the referred term inside - * {@link SequentFormula#formula()} + * instead. describes the exact occurrence of the referred term * - * @return the position in the formula of the SequentFormula of this PosInOccurrence. + * @return the position in the formula of the Term of this PosInOccurrence. */ public PosInTerm posInTerm() { return posInTerm; @@ -169,9 +168,9 @@ public PosInTerm posInTerm() { * constrainedFormula(). It is not tested whether this position exists * within p_newFormula */ - public PosInOccurrence replaceConstrainedFormula(SequentFormula p_newFormula) { + public PosInOccurrence replaceConstrainedFormula(Term p_newFormula) { assert p_newFormula != null; - if (p_newFormula == sequentFormula) { + if (p_newFormula == sequentLevelFormula) { return this; } return new PosInOccurrence(p_newFormula, posInTerm, inAntec); @@ -182,7 +181,7 @@ public PosInOccurrence replaceConstrainedFormula(SequentFormula p_newFormula) { */ public Term subTerm() { if (subTermCache == null) { - subTermCache = posInTerm.getSubTerm(sequentFormula.formula()); + subTermCache = posInTerm.getSubTerm(sequentLevelFormula); } return subTermCache; } @@ -194,13 +193,13 @@ public PosInOccurrence topLevel() { if (isTopLevel()) { return this; } - return new PosInOccurrence(sequentFormula, PosInTerm.getTopLevel(), inAntec); + return new PosInOccurrence(sequentLevelFormula, PosInTerm.getTopLevel(), inAntec); } /** toString */ public String toString() { - return "Term " + posInTerm() + " of " + sequentFormula(); + return "Term " + posInTerm() + " of " + sequentLevelFormula(); } @@ -211,7 +210,7 @@ public String toString() { public PosInOccurrence up() { assert !isTopLevel() : "not possible to go up from top level position"; - return new PosInOccurrence(sequentFormula, posInTerm.up(), inAntec); + return new PosInOccurrence(sequentLevelFormula, posInTerm.up(), inAntec); } @@ -244,7 +243,7 @@ public PosInOccurrence getPosInOccurrence() { // next() faster final PosInOccurrence pio; - pio = new PosInOccurrence(sequentFormula, posInTerm.firstN(count - 1), inAntec); + pio = new PosInOccurrence(sequentLevelFormula, posInTerm.firstN(count - 1), inAntec); return pio; @@ -271,7 +270,7 @@ public int next() { int res; if (currentSubTerm == null) { - currentSubTerm = sequentFormula.formula(); + currentSubTerm = sequentLevelFormula; } else { currentSubTerm = currentSubTerm.sub(child); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java index a8ce511c4fb..7e494a4e5c5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java @@ -18,12 +18,12 @@ * future versions it can be enhanced to do other simplifications. A sequent and so a semisequent * has to be immutable. */ -public class Semisequent implements Iterable { +public class Semisequent implements Iterable { /** the empty semisequent (using singleton pattern) */ public static final Semisequent EMPTY_SEMISEQUENT = new Empty(); - /** list with the {@link SequentFormula}s of the Semisequent */ - private final ImmutableList seqList; + /** list with the {@link Term}s of the Semisequent */ + private final ImmutableList seqList; /** used by inner class Empty */ private Semisequent() { @@ -37,7 +37,7 @@ private Semisequent() { * * @param seqList list of sequent formulas */ - public Semisequent(ImmutableList seqList) { + public Semisequent(ImmutableList seqList) { assert !seqList.isEmpty(); this.seqList = seqList; } @@ -49,7 +49,7 @@ public Semisequent(ImmutableList seqList) { * * @param seqList list of sequent formulas */ - public Semisequent(Collection seqList) { + public Semisequent(Collection seqList) { assert !seqList.isEmpty(); this.seqList = ImmutableList.fromList(seqList); } @@ -62,7 +62,7 @@ public Semisequent(Collection seqList) { * * @param seqList list of sequent formulas */ - public static Semisequent create(Collection seqList) { + public static Semisequent create(Collection seqList) { if (seqList.isEmpty()) { return EMPTY_SEMISEQUENT; } @@ -73,9 +73,9 @@ public static Semisequent create(Collection seqList) { /** * creates a new Semisequent with the Semisequent elements in seqList */ - public Semisequent(SequentFormula seqFormula) { + public Semisequent(Term seqFormula) { assert seqFormula != null; - this.seqList = ImmutableSLList.nil().append(seqFormula); + this.seqList = ImmutableSLList.nil().append(seqFormula); } @@ -84,23 +84,23 @@ public Semisequent(SequentFormula seqFormula) { * returning same semisequent if inserting would create redundancies * * @param idx int encoding the place the element has to be put - * @param sequentFormula {@link SequentFormula} to be inserted + * @param fml {@link Term} to be inserted * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insert(int idx, SequentFormula sequentFormula) { - return removeRedundance(idx, sequentFormula); + public SemisequentChangeInfo insert(int idx, Term fml) { + return removeRedundance(idx, fml); } /** * inserts the elements of the list at the specified index performing redundancy checks * * @param idx int encoding the place where the insertion starts - * @param insertionList IList to be inserted starting at idx + * @param insertionList IList to be inserted starting at idx * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insert(int idx, ImmutableList insertionList) { + public SemisequentChangeInfo insert(int idx, ImmutableList insertionList) { return removeRedundance(idx, insertionList); } @@ -108,23 +108,23 @@ public SemisequentChangeInfo insert(int idx, ImmutableList inser * inserts element at index 0 performing redundancy checks, this may result in returning same * semisequent if inserting would create redundancies * - * @param sequentFormula SequentFormula to be inserted + * @param fml the Term to be inserted * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insertFirst(SequentFormula sequentFormula) { - return insert(0, sequentFormula); + public SemisequentChangeInfo insertFirst(Term fml) { + return insert(0, fml); } /** * inserts element at index 0 performing redundancy checks, this may result in returning same * semisequent if inserting would create redundancies * - * @param insertions IList to be inserted + * @param insertions IList to be inserted * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insertFirst(ImmutableList insertions) { + public SemisequentChangeInfo insertFirst(ImmutableList insertions) { return insert(0, insertions); } @@ -132,23 +132,23 @@ public SemisequentChangeInfo insertFirst(ImmutableList insertion * inserts element at the end of the semisequent performing redundancy checks, this may result * in returning same semisequent if inserting would create redundancies * - * @param sequentFormula {@link SequentFormula} to be inserted + * @param fml {@link Term} to be inserted * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insertLast(SequentFormula sequentFormula) { - return insert(size(), sequentFormula); + public SemisequentChangeInfo insertLast(Term fml) { + return insert(size(), fml); } /** * inserts the formulas of the list at the end of the semisequent performing redundancy checks, * this may result in returning same semisequent if inserting would create redundancies * - * @param insertions the IList to be inserted + * @param insertions the IList to be inserted * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo insertLast(ImmutableList insertions) { + public SemisequentChangeInfo insertLast(ImmutableList insertions) { return insert(size(), insertions); } @@ -163,21 +163,21 @@ public boolean isEmpty() { /** - * inserts new SequentFormula at index idx and removes duplicates, perform simplifications etc. + * inserts new fml at index idx and removes duplicates, perform simplifications etc. * * @param fci null if the formula to be added is new, otherwise an object telling which formula - * is replaced with the new formula sequentFormula, and what are the + * is replaced with the new formula fml, and what are the * differences between the two formulas * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ private SemisequentChangeInfo insertAndRemoveRedundancyHelper(int idx, - SequentFormula sequentFormula, SemisequentChangeInfo semiCI, FormulaChangeInfo fci) { + Term fml, SemisequentChangeInfo semiCI, FormulaChangeInfo fci) { // Search for equivalent formulas and weakest constraint - ImmutableList searchList = semiCI.getFormulaList(); - final SequentFormula[] newSeqList = new SequentFormula[searchList.size()]; - SequentFormula cf; + ImmutableList searchList = semiCI.getFormulaList(); + final Term[] newSeqList = new Term[searchList.size()]; + Term cf; int pos = -1; while (!searchList.isEmpty()) { @@ -185,12 +185,13 @@ private SemisequentChangeInfo insertAndRemoveRedundancyHelper(int idx, cf = searchList.head(); searchList = searchList.tail(); - if (sequentFormula != null - && cf.formula().equalsModProperty(sequentFormula.formula(), - RENAMING_PROPERTY)) { - semiCI.rejectedFormula(sequentFormula); - return semiCI; // semisequent already contains formula + if (fml != null) { + if (cf.equalsModProperty(fml, + RENAMING_PROPERTY)) { + semiCI.rejectedFormula(fml); + return semiCI; // semisequent already contains formula + } } newSeqList[pos] = cf; } @@ -198,15 +199,15 @@ private SemisequentChangeInfo insertAndRemoveRedundancyHelper(int idx, // compose resulting formula list if (fci == null) { - semiCI.addedFormula(idx, sequentFormula); + semiCI.addedFormula(idx, fml); } else { semiCI.modifiedFormula(idx, fci); } - final ImmutableList orig = semiCI.getFormulaList(); + final ImmutableList orig = semiCI.getFormulaList(); pos = Math.min(idx, orig.size()); - searchList = semiCI.getFormulaList().take(pos).prepend(sequentFormula); + searchList = semiCI.getFormulaList().take(pos).prepend(fml); while (pos > 0) { --pos; @@ -223,23 +224,23 @@ private SemisequentChangeInfo insertAndRemoveRedundancyHelper(int idx, * . inserts new ConstrainedFormulas starting at index idx and removes duplicates, perform * simplifications etc. * - * @param sequentFormulasToBeInserted the {@link ImmutableList} to be inserted + * @param TermsToBeInserted the {@link ImmutableList} to be inserted * at position idx - * @param idx an int that means insert sequentFormula at the idx-th position in the semisequent + * @param idx an int that means insert Term at the idx-th position in the semisequent * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ private SemisequentChangeInfo insertAndRemoveRedundancy(int idx, - ImmutableList sequentFormulasToBeInserted, SemisequentChangeInfo sci) { + ImmutableList TermsToBeInserted, SemisequentChangeInfo sci) { int pos = idx; - ImmutableList oldFormulas = sci.getFormulaList(); + ImmutableList oldFormulas = sci.getFormulaList(); - while (!sequentFormulasToBeInserted.isEmpty()) { - final SequentFormula aSequentFormula = sequentFormulasToBeInserted.head(); - sequentFormulasToBeInserted = sequentFormulasToBeInserted.tail(); + while (!TermsToBeInserted.isEmpty()) { + final Term aTerm = TermsToBeInserted.head(); + TermsToBeInserted = TermsToBeInserted.tail(); - sci = insertAndRemoveRedundancyHelper(pos, aSequentFormula, sci, null); + sci = insertAndRemoveRedundancyHelper(pos, aTerm, sci, null); if (sci.getFormulaList() != oldFormulas) { pos = sci.getIndex() + 1; @@ -253,55 +254,55 @@ private SemisequentChangeInfo insertAndRemoveRedundancy(int idx, * . inserts new ConstrainedFormulas starting at index idx and removes duplicates, perform * simplifications etc. * - * @param sequentFormula the IList to be inserted at position idx - * @param idx an int that means insert sequentFormula at the idx-th position in the semisequent + * @param Term the IList to be inserted at position idx + * @param idx an int that means insert Term at the idx-th position in the semisequent * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ private SemisequentChangeInfo removeRedundance(int idx, - ImmutableList sequentFormula) { - return insertAndRemoveRedundancy(idx, sequentFormula, new SemisequentChangeInfo(seqList)); + ImmutableList Term) { + return insertAndRemoveRedundancy(idx, Term, new SemisequentChangeInfo(seqList)); } /** - * . inserts new SequentFormula at index {@code idx} and removes duplicates, perform + * . inserts new fml at index {@code idx} and removes duplicates, perform * simplifications etc. * - * @param sequentFormula the SequentFormula to be inserted at position idx - * @param idx an int that means insert sequentFormula at the idx-th position in the semisequent - * @return new Semisequent with sequentFormula at index idx and removed redundancies + * @param fml the fml to be inserted at position idx + * @param idx an int that means insert fml at the idx-th position in the semisequent + * @return new Semisequent with fml at index idx and removed redundancies */ - private SemisequentChangeInfo removeRedundance(int idx, SequentFormula sequentFormula) { - return insertAndRemoveRedundancyHelper(idx, sequentFormula, + private SemisequentChangeInfo removeRedundance(int idx, Term fml) { + return insertAndRemoveRedundancyHelper(idx, fml, new SemisequentChangeInfo(seqList), null); } /** - * replaces the element at place idx with sequentFormula + * replaces the element at place idx with fml * * @param pos the PosInOccurrence describing the position of and within the formula below which - * the formula differs from the new formula sequentFormula - * @param sequentFormula the SequentFormula replacing the old element at index idx + * the formula differs from the new formula fml + * @param fml the fml replacing the old element at index idx * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ - public SemisequentChangeInfo replace(PosInOccurrence pos, SequentFormula sequentFormula) { - final int idx = indexOf(pos.sequentFormula()); - final FormulaChangeInfo fci = new FormulaChangeInfo(pos, sequentFormula); - return insertAndRemoveRedundancyHelper(idx, sequentFormula, remove(idx), fci); + public SemisequentChangeInfo replace(PosInOccurrence pos, Term fml) { + final int idx = indexOf(pos.sequentLevelFormula()); + final FormulaChangeInfo fci = new FormulaChangeInfo(pos, fml); + return insertAndRemoveRedundancyHelper(idx, fml, remove(idx), fci); } /** - * replaces the idx-th formula by sequentFormula + * replaces the idx-th formula by fml * * @param idx the int with the position of the formula to be replaced - * @param sequentFormula the SequentFormula replacing the formula at the given position + * @param fml the fml replacing the formula at the given position * @return a SemisequentChangeInfo containing the new sequent and a diff to the old one */ - public SemisequentChangeInfo replace(int idx, SequentFormula sequentFormula) { - return insertAndRemoveRedundancyHelper(idx, sequentFormula, remove(idx), null); + public SemisequentChangeInfo replace(int idx, Term fml) { + return insertAndRemoveRedundancyHelper(idx, fml, remove(idx), null); } /** @@ -309,14 +310,14 @@ public SemisequentChangeInfo replace(int idx, SequentFormula sequentFormula) { * of the list to the semisequent behind the replaced formula * * @param pos the formula to be replaced - * @param replacements the IList whose head replaces the element at index idx + * @param replacements the IList whose head replaces the element at index idx * and the tail is added to the semisequent * @return a semi sequent change information object with the new semisequent and information * which formulas have been added or removed */ public SemisequentChangeInfo replace(PosInOccurrence pos, - ImmutableList replacements) { - final int idx = indexOf(pos.sequentFormula()); + ImmutableList replacements) { + final int idx = indexOf(pos.sequentLevelFormula()); return insertAndRemoveRedundancy(idx, replacements, remove(idx)); } @@ -327,7 +328,7 @@ public SemisequentChangeInfo replace(PosInOccurrence pos, * @param replacements the new formulas * @return change information including the resulting semisequent after the replacement */ - public SemisequentChangeInfo replace(int idx, ImmutableList replacements) { + public SemisequentChangeInfo replace(int idx, ImmutableList replacements) { return insertAndRemoveRedundancy(idx, replacements, remove(idx)); } @@ -346,14 +347,14 @@ public int size() { */ public SemisequentChangeInfo remove(int idx) { - ImmutableList newList = seqList; + ImmutableList newList = seqList; int index = 0; if (idx < 0 || idx >= size()) { return new SemisequentChangeInfo(seqList); } - final SequentFormula[] temp = new SequentFormula[idx]; + final Term[] temp = new Term[idx]; while (index < idx) {// go to idx temp[index] = newList.head(); @@ -362,7 +363,7 @@ public SemisequentChangeInfo remove(int idx) { } // remove the element that is at head of newList - final SequentFormula removedFormula = newList.head(); + final Term removedFormula = newList.head(); newList = newList.tail(); for (int k = index - 1; k >= 0; k--) { @@ -377,18 +378,18 @@ public SemisequentChangeInfo remove(int idx) { } /** - * returns the index of the given {@link SequentFormula} or {@code -1} if the sequent formula is + * returns the index of the given {@link Term} or {@code -1} if the sequent formula is * not found. Equality of sequent formulas is checked sing the identy check (i.e., * ==) * - * @param sequentFormula the {@link SequentFormula} to look for - * @return index of sequentFormula (-1 if not found) + * @param fml the {@link Term} to look for + * @return index of fml (-1 if not found) */ - public int indexOf(SequentFormula sequentFormula) { - ImmutableList searchList = seqList; + public int indexOf(Term fml) { + ImmutableList searchList = seqList; int index = 0; while (!searchList.isEmpty()) { - if (searchList.head() == sequentFormula) { + if (searchList.head() == fml) { return index; } searchList = searchList.tail(); @@ -401,53 +402,53 @@ public int indexOf(SequentFormula sequentFormula) { * gets the element at a specific index * * @param idx int representing the index of the element we want to have - * @return {@link SequentFormula} found at index idx + * @return {@link Term} found at index idx * @throws IndexOutOfBoundsException if idx is negative or greater or equal to * {@link Sequent#size()} */ - public SequentFormula get(int idx) { + public Term get(int idx) { if (idx < 0 || idx >= seqList.size()) { throw new IndexOutOfBoundsException(); } return seqList.take(idx).head(); } - /** @return the first {@link SequentFormula} of this Semisequent */ - public SequentFormula getFirst() { + /** @return the first {@link Term} of this Semisequent */ + public Term getFirst() { return seqList.head(); } /** - * checks if the {@link SequentFormula} occurs in this Semisequent (identity check) + * checks if the {@link Term} occurs in this Semisequent (identity check) * - * @param sequentFormula the {@link SequentFormula} to look for - * @return true iff. sequentFormula has been found in this Semisequent + * @param fml the {@link Term} to look for + * @return true iff. fml has been found in this Semisequent */ - public boolean contains(SequentFormula sequentFormula) { - return indexOf(sequentFormula) != -1; + public boolean contains(Term fml) { + return indexOf(fml) != -1; } /** - * checks if a {@link SequentFormula} is in this Semisequent (equality check) + * checks if a {@link Term} is in this Semisequent (equality check) * - * @param sequentFormula the {@link SequentFormula} to look for - * @return true iff. sequentFormula has been found in this Semisequent + * @param fml the {@link Term} to look for + * @return true iff. fml has been found in this Semisequent */ - public boolean containsEqual(SequentFormula sequentFormula) { - return seqList.contains(sequentFormula); + public boolean containsEqual(Term fml) { + return seqList.contains(fml); } /** * returns iterator about the elements of the sequent * - * @return Iterator + * @return Iterator */ @Override - public Iterator iterator() { + public Iterator iterator() { return seqList.iterator(); } - public ImmutableList asList() { + public ImmutableList asList() { return seqList; } @@ -459,21 +460,17 @@ public boolean equals(Object o) { return seqList.equals(((Semisequent) o).seqList); } - @Override public int hashCode() { return seqList.hashCode(); } - /** @return String representation of this Semisequent */ @Override public String toString() { return seqList.toString(); } - - // inner class used to represent an empty semisequent private static class Empty extends Semisequent { @@ -485,40 +482,40 @@ private Empty() { * inserts the element always at index 0 ignores the first argument * * @param idx int encoding the place the element has to be put - * @param sequentFormula {@link SequentFormula} to be inserted - * @return semisequent change information object with new semisequent with sequentFormula at + * @param fml {@link Term} to be inserted + * @return semisequent change information object with new semisequent with fml at * place idx */ @Override - public SemisequentChangeInfo insert(int idx, SequentFormula sequentFormula) { - return insertFirst(sequentFormula); + public SemisequentChangeInfo insert(int idx, Term fml) { + return insertFirst(fml); } /** * inserts the element at index 0 * - * @param sequentFormula {@link SequentFormula} to be inserted - * @return semisequent change information object with new semisequent with sequentFormula at + * @param fml {@link Term} to be inserted + * @return semisequent change information object with new semisequent with Term at * place idx */ @Override - public SemisequentChangeInfo insertFirst(SequentFormula sequentFormula) { + public SemisequentChangeInfo insertFirst(Term fml) { final SemisequentChangeInfo sci = new SemisequentChangeInfo( - ImmutableSLList.nil().prepend(sequentFormula)); - sci.addedFormula(0, sequentFormula); + ImmutableSLList.nil().prepend(fml)); + sci.addedFormula(0, fml); return sci; } /** * inserts the element at the end of the semisequent * - * @param sequentFormula {@link SequentFormula} to be inserted - * @return semisequent change information object with new semisequent with sequentFormula at + * @param fml {@link Term} to be inserted + * @return semisequent change information object with new semisequent with fml at * place idx */ @Override - public SemisequentChangeInfo insertLast(SequentFormula sequentFormula) { - return insertFirst(sequentFormula); + public SemisequentChangeInfo insertLast(Term fml) { + return insertFirst(fml); } @@ -533,16 +530,16 @@ public boolean isEmpty() { } /** - * replaces the element at place idx with sequentFormula + * replaces the element at place idx with Term * * @param idx an int specifying the index of the element that has to be replaced - * @param sequentFormula the {@link SequentFormula} replacing the old element at index idx - * @return semisequent change information object with new semisequent with sequentFormula at + * @param fml the {@link Term} replacing the old element at index idx + * @return semisequent change information object with new semisequent with Term at * place idx */ @Override - public SemisequentChangeInfo replace(int idx, SequentFormula sequentFormula) { - return insertFirst(sequentFormula); + public SemisequentChangeInfo replace(int idx, Term fml) { + return insertFirst(fml); } /** @return int counting the elements of this semisequent */ @@ -563,13 +560,13 @@ public SemisequentChangeInfo remove(int idx) { } /** - * returns index of a {@link SequentFormula} + * returns index of a {@link Term} * - * @param sequentFormula the {@link SequentFormula} the index want to be determined - * @return index of sequentFormula + * @param fml the {@link Term} the index want to be determined + * @return index of Term */ @Override - public int indexOf(SequentFormula sequentFormula) { + public int indexOf(Term fml) { return -1; } @@ -577,29 +574,29 @@ public int indexOf(SequentFormula sequentFormula) { * gets the element at a specific index * * @param idx int representing the index of the element we want to have - * @return {@link SequentFormula} found at index idx + * @return {@link Term} found at index idx */ @Override - public SequentFormula get(int idx) { + public Term get(int idx) { return null; } /** - * @return the first SequentFormula of this Semisequent + * @return the first Term of this Semisequent */ @Override - public SequentFormula getFirst() { + public Term getFirst() { return null; } /** - * checks if a {@link SequentFormula} is in this Semisequent + * checks if a {@link Term} is in this Semisequent * - * @param sequentFormula the {@link SequentFormula} to look for - * @return true iff. sequentFormula has been found in this Semisequent + * @param fml the {@link Term} to look for + * @return true iff. Term has been found in this Semisequent */ @Override - public boolean contains(SequentFormula sequentFormula) { + public boolean contains(Term fml) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/SemisequentChangeInfo.java b/key.core/src/main/java/de/uka/ilkd/key/logic/SemisequentChangeInfo.java index fdb9d8e3aa5..cd9a937f74c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/SemisequentChangeInfo.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/SemisequentChangeInfo.java @@ -13,18 +13,18 @@ public class SemisequentChangeInfo { /** contains the added formulas to the semisequent */ - private ImmutableList added = ImmutableSLList.nil(); + private ImmutableList added = ImmutableSLList.nil(); /** contains the removed formulas from the semisequent */ - private ImmutableList removed = ImmutableSLList.nil(); + private ImmutableList removed = ImmutableSLList.nil(); /** contains the modified formulas from the semisequent */ private ImmutableList modified = ImmutableSLList.nil(); /** stores the redundance free formula list of the semisequent */ - private ImmutableList modifiedSemisequent = ImmutableSLList.nil(); + private ImmutableList modifiedSemisequent = ImmutableSLList.nil(); /** * contains formulas that have been tried to add, but which have been rejected due to already * existing formulas in the sequent subsuming these formulas */ - private ImmutableList rejected = ImmutableSLList.nil(); + private ImmutableList rejected = ImmutableSLList.nil(); /** */ private int lastFormulaIndex = -1; @@ -32,7 +32,7 @@ public class SemisequentChangeInfo { public SemisequentChangeInfo() { } - public SemisequentChangeInfo(ImmutableList formulas) { + public SemisequentChangeInfo(ImmutableList formulas) { this.modifiedSemisequent = formulas; } @@ -60,21 +60,21 @@ public boolean hasChanged() { * sets the list of constrained formula containing all formulas of the semisequent after the * operation */ - public void setFormulaList(ImmutableList list) { + public void setFormulaList(ImmutableList list) { modifiedSemisequent = list; } /** * returns the list of constrained formula of the new semisequent */ - public ImmutableList getFormulaList() { + public ImmutableList getFormulaList() { return modifiedSemisequent; } /** * logs an added formula at position idx */ - public void addedFormula(int idx, SequentFormula cf) { + public void addedFormula(int idx, Term cf) { added = added.prepend(cf); lastFormulaIndex = idx; } @@ -85,7 +85,7 @@ public void addedFormula(int idx, SequentFormula cf) { public void modifiedFormula(int idx, FormulaChangeInfo fci) { // This information can overwrite older records about removed // formulas - removed = removed.removeAll(fci.positionOfModification().sequentFormula()); + removed = removed.removeAll(fci.positionOfModification().sequentLevelFormula()); modified = modified.prepend(fci); lastFormulaIndex = idx; } @@ -93,18 +93,18 @@ public void modifiedFormula(int idx, FormulaChangeInfo fci) { /** * returns the list of all added constrained formulas * - * @return IList added to the semisequent + * @return IList added to the semisequent */ - public ImmutableList addedFormulas() { + public ImmutableList addedFormulas() { return added; } /** * returns the list of all removed constrained formulas * - * @return IList removed from the semisequent + * @return IList removed from the semisequent */ - public ImmutableList removedFormulas() { + public ImmutableList removedFormulas() { return removed; } @@ -114,7 +114,7 @@ public ImmutableList removedFormulas() { * * @return list of formulas rejected due to redundancy */ - public ImmutableList rejectedFormulas() { + public ImmutableList rejectedFormulas() { return this.rejected; } @@ -123,16 +123,16 @@ public ImmutableList rejectedFormulas() { * adding formula f to the semisequent failed due to a redundance check. This means an * equal or stronger formula is already present in the semisequent * - * @param f the SequentFormula + * @param f the Term */ - public void rejectedFormula(SequentFormula f) { + public void rejectedFormula(Term f) { this.rejected = this.rejected.append(f); } /** * returns the list of all modification positions * - * @return IList modified within the semisequent + * @return IList modified within the semisequent */ public ImmutableList modifiedFormulas() { return modified; @@ -141,7 +141,7 @@ public ImmutableList modifiedFormulas() { /** * logs an added formula at position idx */ - public void removedFormula(int idx, SequentFormula cf) { + public void removedFormula(int idx, Term cf) { removed = removed.prepend(cf); lastFormulaIndex = (lastFormulaIndex == idx) ? -1 @@ -166,7 +166,7 @@ public void combine(SemisequentChangeInfo succ) { return; } - for (SequentFormula sf : succ.removed) { + for (Term sf : succ.removed) { predecessor.added = predecessor.added.removeAll(sf); boolean skip = false; @@ -194,14 +194,14 @@ public void combine(SemisequentChangeInfo succ) { } } - for (SequentFormula sf : succ.added) { + for (Term sf : succ.added) { predecessor.removed = predecessor.removed.removeAll(sf); if (!predecessor.added.contains(sf)) { predecessor.addedFormula(succ.lastFormulaIndex, sf); } } - for (SequentFormula sf : succ.rejected) { + for (Term sf : succ.rejected) { if (!predecessor.rejected.contains(sf)) { predecessor.rejectedFormula(sf); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Sequent.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Sequent.java index a3b8424f2de..a931457f419 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Sequent.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Sequent.java @@ -8,7 +8,6 @@ import java.util.Set; import de.uka.ilkd.key.logic.label.TermLabel; -import de.uka.ilkd.key.logic.op.QuantifiableVariable; import org.key_project.logic.Name; import org.key_project.util.collection.ImmutableList; @@ -23,7 +22,7 @@ * {@link Sequent#createSuccSequent} or by inserting formulas directly into * {@link Sequent#EMPTY_SEQUENT}. */ -public class Sequent implements Iterable { +public class Sequent implements Iterable { public static final Sequent EMPTY_SEQUENT = NILSequent.INSTANCE; @@ -95,7 +94,7 @@ private Sequent(Semisequent antecedent, Semisequent succedent) { * first the formulas are inserted at the beginning or end of the ante-/succedent. * (NOTICE:Sequent determines index using identy (==) not equality.) * - * @param cf the SequentFormula to be added + * @param cf the Term to be added * @param antec boolean selecting the correct semisequent where to insert the formulas. If set * to true, the antecedent is taken otherwise the succedent. * @param first boolean if true the formula is added at the beginning of the ante-/succedent, @@ -103,7 +102,7 @@ private Sequent(Semisequent antecedent, Semisequent succedent) { * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo addFormula(SequentFormula cf, boolean antec, boolean first) { + public SequentChangeInfo addFormula(Term cf, boolean antec, boolean first) { final Semisequent seq = antec ? antecedent : succedent; @@ -117,15 +116,15 @@ public SequentChangeInfo addFormula(SequentFormula cf, boolean antec, boolean fi * adds a formula to the sequent at the given position. (NOTICE:Sequent determines index using * identy (==) not equality.) * - * @param cf a SequentFormula to be added + * @param cf a Term to be added * @param p a PosInOccurrence describes position in the sequent * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo addFormula(SequentFormula cf, PosInOccurrence p) { + public SequentChangeInfo addFormula(Term cf, PosInOccurrence p) { final Semisequent seq = getSemisequent(p); - final SemisequentChangeInfo semiCI = seq.insert(seq.indexOf(p.sequentFormula()), cf); + final SemisequentChangeInfo semiCI = seq.insert(seq.indexOf(p.sequentLevelFormula()), cf); return SequentChangeInfo.createSequentChangeInfo(p.isInAntec(), semiCI, composeSequent(p.isInAntec(), semiCI.semisequent()), this); @@ -136,7 +135,7 @@ public SequentChangeInfo addFormula(SequentFormula cf, PosInOccurrence p) { * of first the formulas are inserted at the beginning or end of the ante-/succedent. * (NOTICE:Sequent determines index using identity (==) not equality.) * - * @param insertions the IList to be added + * @param insertions the IList to be added * @param antec boolean selecting the correct semisequent where to insert the formulas. If set * to true, the antecedent is taken otherwise the succedent. * @param first boolean if true the formulas are added at the beginning of the ante-/succedent, @@ -144,7 +143,7 @@ public SequentChangeInfo addFormula(SequentFormula cf, PosInOccurrence p) { * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo addFormula(ImmutableList insertions, boolean antec, + public SequentChangeInfo addFormula(ImmutableList insertions, boolean antec, boolean first) { final Semisequent seq = antec ? antecedent : succedent; @@ -160,17 +159,17 @@ public SequentChangeInfo addFormula(ImmutableList insertions, bo * adds the formulas of list insertions to the sequent starting at position p. (NOTICE:Sequent * determines index using identy (==) not equality.) * - * @param insertions a IList with the formulas to be added + * @param insertions a IList with the formulas to be added * @param p the PosInOccurrence describing the position where to insert the formulas * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo addFormula(ImmutableList insertions, + public SequentChangeInfo addFormula(ImmutableList insertions, PosInOccurrence p) { final Semisequent seq = getSemisequent(p); final SemisequentChangeInfo semiCI = - seq.insert(seq.indexOf(p.sequentFormula()), insertions); + seq.insert(seq.indexOf(p.sequentLevelFormula()), insertions); return SequentChangeInfo.createSequentChangeInfo(p.isInAntec(), semiCI, composeSequent(p.isInAntec(), semiCI.semisequent()), this); @@ -184,7 +183,7 @@ public SequentChangeInfo addFormula(ImmutableList insertions, * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo replaceFormula(int formulaNr, SequentFormula replacement) { + public SequentChangeInfo replaceFormula(int formulaNr, Term replacement) { checkFormulaIndex(formulaNr); formulaNr--; boolean inAntec = formulaNr < antecedent.size(); @@ -207,12 +206,12 @@ public Semisequent antecedent() { * replaces the formula at the given position with another one (NOTICE:Sequent determines index * using identity (==) not equality.) * - * @param newCF the SequentFormula replacing the old one + * @param newCF the Term replacing the old one * @param p a PosInOccurrence describes position in the sequent * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo changeFormula(SequentFormula newCF, PosInOccurrence p) { + public SequentChangeInfo changeFormula(Term newCF, PosInOccurrence p) { final SemisequentChangeInfo semiCI = getSemisequent(p).replace(p, newCF); return SequentChangeInfo.createSequentChangeInfo(p.isInAntec(), semiCI, @@ -224,13 +223,13 @@ public SequentChangeInfo changeFormula(SequentFormula newCF, PosInOccurrence p) * list elements to the sequent (NOTICE:Sequent determines index using identity (==) not * equality.) * - * @param replacements the IList whose head replaces the formula at position p + * @param replacements the IList whose head replaces the formula at position p * and adds the rest of the list behind the changed formula * @param p a PosInOccurrence describing the position of the formula to be replaced * @return a SequentChangeInfo which contains the new sequent and information which formulas * have been added or removed */ - public SequentChangeInfo changeFormula(ImmutableList replacements, + public SequentChangeInfo changeFormula(ImmutableList replacements, PosInOccurrence p) { final SemisequentChangeInfo semiCI = getSemisequent(p).replace(p, replacements); @@ -292,9 +291,9 @@ public boolean equals(Object o) { * @return an integer strictly greater than zero for the position of the given sequent formula * on the proof sequent. */ - public int formulaNumberInSequent(boolean inAntec, SequentFormula cfma) { + public int formulaNumberInSequent(boolean inAntec, Term cfma) { int n = inAntec ? 0 : antecedent.size(); - final Iterator formIter = + final Iterator formIter = inAntec ? antecedent.iterator() : succedent.iterator(); while (formIter.hasNext()) { n++; @@ -315,7 +314,7 @@ public int formulaNumberInSequent(boolean inAntec, SequentFormula cfma) { */ public int formulaNumberInSequent(PosInOccurrence pio) { var inAntec = pio.isInAntec(); - var formula = pio.sequentFormula(); + var formula = pio.sequentLevelFormula(); return formulaNumberInSequent(inAntec, formula); } @@ -326,7 +325,7 @@ public int formulaNumberInSequent(PosInOccurrence pio) { * @param formulaNumber formula number * @return the sequent formula at that position */ - public SequentFormula getFormulabyNr(int formulaNumber) { + public Term getFormulabyNr(int formulaNumber) { checkFormulaIndex(formulaNumber); if (formulaNumber <= antecedent.size()) { return antecedent.get(formulaNumber - 1); @@ -335,7 +334,7 @@ public SequentFormula getFormulabyNr(int formulaNumber) { } /** - * returns the semisequent in which the SequentFormula described by PosInOccurrence p lies + * returns the semisequent in which the Term described by PosInOccurrence p lies */ private Semisequent getSemisequent(PosInOccurrence p) { return p.isInAntec() ? antecedent() : succedent(); @@ -352,7 +351,7 @@ public int hashCode() { * @return iterator about all ConstrainedFormulae of the sequent */ @Override - public Iterator iterator() { + public Iterator iterator() { return new SequentIterator(antecedent(), succedent()); } @@ -376,7 +375,7 @@ public boolean numberInAntec(int formulaNumber) { public SequentChangeInfo removeFormula(PosInOccurrence p) { final Semisequent seq = getSemisequent(p); - final SemisequentChangeInfo semiCI = seq.remove(seq.indexOf(p.sequentFormula())); + final SemisequentChangeInfo semiCI = seq.remove(seq.indexOf(p.sequentLevelFormula())); return SequentChangeInfo.createSequentChangeInfo(p.isInAntec(), semiCI, composeSequent(p.isInAntec(), semiCI.semisequent()), this); @@ -406,23 +405,6 @@ public String toString() { return antecedent().toString() + "==>" + succedent().toString(); } - /** - * returns true iff the given variable is bound in a formula of a SequentFormula in this - * sequent. - * - * @param v the bound variable to search for - */ - public boolean varIsBound(QuantifiableVariable v) { - for (SequentFormula sequentFormula : this) { - final BoundVarsVisitor bvv = new BoundVarsVisitor(); - sequentFormula.formula().execPostOrder(bvv); - if (bvv.getBoundVariables().contains(v)) { - return true; - } - } - return false; - } - private static final class NILSequent extends Sequent { private static final NILSequent INSTANCE = new NILSequent(); @@ -435,27 +417,22 @@ public boolean isEmpty() { } @Override - public Iterator iterator() { - return ImmutableSLList.nil().iterator(); - } - - @Override - public boolean varIsBound(QuantifiableVariable v) { - return false; + public Iterator iterator() { + return ImmutableSLList.nil().iterator(); } } - static class SequentIterator implements Iterator { + static class SequentIterator implements Iterator { /** * The iterator over the ancedent of the proof sequent. */ - private final Iterator anteIt; + private final Iterator anteIt; /** * The iterator over the succedent of the proof sequent. */ - private final Iterator succIt; + private final Iterator succIt; /** * Constructs a new iterator over a proof sequent. @@ -474,7 +451,7 @@ public boolean hasNext() { } @Override - public SequentFormula next() { + public Term next() { if (anteIt.hasNext()) { return anteIt.next(); } @@ -514,8 +491,8 @@ private static Set getLabelsForTermRecursively(Term term) { */ public Set getOccuringTermLabels() { final Set result = new HashSet<>(); - for (final SequentFormula sf : this) { - result.addAll(getLabelsForTermRecursively(sf.formula())); + for (final Term sf : this) { + result.addAll(getLabelsForTermRecursively(sf)); } return result; } @@ -526,16 +503,16 @@ public Set getOccuringTermLabels() { * @param form the given formula * @return true if this sequent contains the given formula */ - public boolean contains(SequentFormula form) { + public boolean contains(Term form) { return antecedent.contains(form) || succedent.contains(form); } /** - * Returns a list containing every {@link SequentFormula} in this sequent. + * Returns a list containing every {@link Term} in this sequent. * - * @return a list containing every {@link SequentFormula} in this sequent. + * @return a list containing every {@link Term} in this sequent. */ - public ImmutableList asList() { + public ImmutableList asList() { return antecedent.asList().append(succedent.asList()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/SequentChangeInfo.java b/key.core/src/main/java/de/uka/ilkd/key/logic/SequentChangeInfo.java index 9253b647ada..c1f9bcf163e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/SequentChangeInfo.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/SequentChangeInfo.java @@ -148,7 +148,7 @@ public SemisequentChangeInfo getSemisequentChangeInfo(boolean antec) { * antecedent; false means succedent) * @return list of formulas added to the selected semisequent */ - public ImmutableList addedFormulas(boolean antec) { + public ImmutableList addedFormulas(boolean antec) { return antec ? (antecedent != null ? antecedent.addedFormulas() : ImmutableSLList.nil()) : (succedent != null ? succedent.addedFormulas() : ImmutableSLList.nil()); @@ -160,9 +160,9 @@ public ImmutableList addedFormulas(boolean antec) { * * @return list of formulas added to sequent */ - public ImmutableList addedFormulas() { - final ImmutableList addedFormulasAntec = addedFormulas(true); - final ImmutableList addedFormulasSucc = addedFormulas(false); + public ImmutableList addedFormulas() { + final ImmutableList addedFormulasAntec = addedFormulas(true); + final ImmutableList addedFormulasSucc = addedFormulas(false); return concatenateHelper(addedFormulasAntec, addedFormulasSucc); @@ -177,7 +177,7 @@ public ImmutableList addedFormulas() { * antecedent; false means succedent) * @return list of formulas removed from the selected semisequent */ - public ImmutableList removedFormulas(boolean antec) { + public ImmutableList removedFormulas(boolean antec) { return antec ? (antecedent != null ? antecedent.removedFormulas() : ImmutableSLList.nil()) : (succedent != null ? succedent.removedFormulas() : ImmutableSLList.nil()); @@ -189,9 +189,9 @@ public ImmutableList removedFormulas(boolean antec) { * * @return list of formulas removed from the sequent */ - public ImmutableList removedFormulas() { - final ImmutableList removedFormulasAntec = removedFormulas(true); - final ImmutableList removedFormulasSucc = removedFormulas(false); + public ImmutableList removedFormulas() { + final ImmutableList removedFormulasAntec = removedFormulas(true); + final ImmutableList removedFormulasSucc = removedFormulas(false); return concatenateHelper(removedFormulasAntec, removedFormulasSucc); } @@ -231,7 +231,7 @@ public ImmutableList modifiedFormulas() { * antecedent; false means succedent) * @return list of formulas rejected when trying to add to the selected semisequent */ - public ImmutableList rejectedFormulas(boolean antec) { + public ImmutableList rejectedFormulas(boolean antec) { return antec ? (antecedent != null ? antecedent.rejectedFormulas() : ImmutableSLList.nil()) : (succedent != null ? succedent.rejectedFormulas() : ImmutableSLList.nil()); @@ -242,9 +242,9 @@ public ImmutableList rejectedFormulas(boolean antec) { * * @return list of rejected formulas */ - public ImmutableList rejectedFormulas() { - final ImmutableList rejectedFormulasAntec = rejectedFormulas(true); - final ImmutableList rejectedFormulasSucc = rejectedFormulas(false); + public ImmutableList rejectedFormulas() { + final ImmutableList rejectedFormulasAntec = rejectedFormulas(true); + final ImmutableList rejectedFormulasSucc = rejectedFormulas(false); return concatenateHelper(rejectedFormulasAntec, rejectedFormulasSucc); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/SequentFormula.java b/key.core/src/main/java/de/uka/ilkd/key/logic/SequentFormula.java deleted file mode 100644 index 38325df369f..00000000000 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/SequentFormula.java +++ /dev/null @@ -1,90 +0,0 @@ -/* This file is part of KeY - https://key-project.org - * KeY is licensed under the GNU General Public License Version 2 - * SPDX-License-Identifier: GPL-2.0-only */ -package de.uka.ilkd.key.logic; - -import de.uka.ilkd.key.ldt.JavaDLTheory; -import de.uka.ilkd.key.logic.op.AbstractTermTransformer; - -import org.key_project.util.EqualsModProofIrrelevancy; - -import static de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY; - - -/** - * A sequent formula is a wrapper around a formula that occurs as top level formula in a sequent. - * SequentFormula instances have to be unique in the sequent as they are used by PosInOccurrence to - * determine the exact position. In earlier KeY versions this class was called ConstrainedFormula as - * it was equipped with an additional constraints. It would be interesting to add more value to this - * class by providing a way to add additional annotations or to cache local information about the - * formula. - */ -public class SequentFormula implements EqualsModProofIrrelevancy { - - private final Term term; - - /** - * Cached value for {@link #hashCode()}. - */ - private final int hashCode; - /** - * Cached value for {@link #hashCodeModProofIrrelevancy()}. - */ - private final int hashCode2; - - /** - * creates a new SequentFormula - * - * @param term a Term of sort {@link JavaDLTheory#FORMULA} - */ - public SequentFormula(Term term) { - if (term.sort() != JavaDLTheory.FORMULA - && term.sort() != AbstractTermTransformer.METASORT) { - throw new RuntimeException("A Term instead of a formula: " + term); - } - this.term = term; - this.hashCode = term.hashCode() * 13; - this.hashCode2 = term.hashCodeModProperty(PROOF_IRRELEVANCY_PROPERTY); - } - - /** @return the stored Term */ - public Term formula() { - return term; - } - - /** equal if terms and constraints are equal */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof SequentFormula cmp) { - return term.equals(cmp.formula()); - } - return false; - } - - /** String representation */ - public String toString() { - return term.toString(); - } - - public int hashCode() { - return hashCode; - } - - @Override - public boolean equalsModProofIrrelevancy(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof SequentFormula cmp) { - return term.equalsModProperty(cmp.formula(), PROOF_IRRELEVANCY_PROPERTY); - } - return false; - } - - @Override - public int hashCodeModProofIrrelevancy() { - return hashCode2; - } -} diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java index 73e99f387e2..95c7cd3e1df 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Term.java @@ -43,6 +43,7 @@ */ public interface Term extends Sorted, TermEqualsModProperty, org.key_project.logic.Term { + @Override Operator op(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java index 522fd209611..a46da8949e5 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/OriginTermLabel.java @@ -251,9 +251,9 @@ public static SequentChangeInfo removeOriginLabels(Sequent seq, Services service SequentChangeInfo changes = null; for (int i = 1; i <= seq.size(); ++i) { - SequentFormula oldFormula = seq.getFormulabyNr(i); - SequentFormula newFormula = new SequentFormula( - OriginTermLabel.removeOriginLabels(oldFormula.formula(), services)); + Term oldFormula = seq.getFormulabyNr(i); + Term uAssumptions = OriginTermLabel.removeOriginLabels(oldFormula, services); + Term newFormula = uAssumptions; SequentChangeInfo change = seq.changeFormula(newFormula, PosInOccurrence.findInSequent(seq, i, PosInTerm.getTopLevel())); diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java index a5287c1f2d1..160615c9f3c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabel.java @@ -5,7 +5,6 @@ import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabelManager.TermLabelConfiguration; import de.uka.ilkd.key.logic.op.Modality; @@ -57,14 +56,14 @@ *

            *

            * Antecedent and succedent of a {@link Sequent} are sets. The equality check if a - * {@link SequentFormula} is already contained ignores {@link TermLabel}s. To ensure that + * {@link Term} is already contained ignores {@link TermLabel}s. To ensure that * {@link TermLabel}s are not lost, * {@link TermLabelManager#mergeLabels(de.uka.ilkd.key.java.Services, * de.uka.ilkd.key.logic.SequentChangeInfo)} - * merges the labels of the existing {@link SequentFormula} with those of the rejected - * {@link SequentFormula}. How this is done in detail is implemented by a {@link TermLabelMerger}. + * merges the labels of the existing {@link Term} with those of the rejected + * {@link Term}. How this is done in detail is implemented by a {@link TermLabelMerger}. * If no {@link TermLabelMerger} is available, the {@link TermLabel} of the rejected - * {@link SequentFormula} are lost. + * {@link Term} are lost. *

            *

            * To implement a new {@link TermLabel} follow the following steps: @@ -126,7 +125,7 @@ * which works on {@link RefactoringScope#SEQUENT} to freely add or remove * {@link TermLabel}s on any {@link Term} of the {@link Sequent}. *

          • Implement a {@link TermLabelMerger} to ensure that {@link TermLabel}s are maintained - * in case of rejected {@link SequentFormula}s.
          • + * in case of rejected {@link Term}s. *
          *
        • *
        • diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabelManager.java b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabelManager.java index 6ac56f95a64..4dc798830b8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabelManager.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/label/TermLabelManager.java @@ -50,7 +50,7 @@ *
            *
          • {@link #refactorGoal(TermLabelState, Services, PosInOccurrence, Rule, Goal, Object, Term)}: * The full sequent
          • - *
          • {@link #refactorSequentFormula(TermLabelState, Services, Term, PosInOccurrence, Rule, Goal, Object, Term)} + *
          • {@link #refactorTerm(TermLabelState, Services, Term, PosInOccurrence, Rule, Goal, Object, Term)} * : The sequent formula which contains the application term on which the rule is applied
          • *
          • {@link #refactorTerm(TermLabelState, Services, PosInOccurrence, Term, Rule, Goal, Object, Term)} * : The current term.
          • @@ -955,8 +955,8 @@ protected void performUpdater(TermLabelState state, Services services, } /** - * Refactors all labels on the {@link PosInOccurrence} in the given {@link Term} of a - * {@link SequentFormula}. + * Refactors all labels on the {@link PosInOccurrence} in the given {@link Term} representing a + * sequent level formula * * @param state The {@link TermLabelState} of the current rule application. * @param services The {@link Services} used by the {@link Proof} on which a {@link Rule} is @@ -970,21 +970,21 @@ protected void performUpdater(TermLabelState state, Services services, * @param tacletTerm The optional taclet {@link Term}. * @return The updated application {@link Term}. */ - public static Term refactorSequentFormula(TermLabelState state, Services services, - Term sequentFormula, PosInOccurrence applicationPosInOccurrence, Rule rule, Goal goal, + public static Term refactorTerm(TermLabelState state, Services services, + Term seqLevelFml, PosInOccurrence applicationPosInOccurrence, Rule rule, Goal goal, Object hint, Term tacletTerm) { TermLabelManager manager = getTermLabelManager(services); if (manager != null) { - return manager.refactorSequentFormula(state, services, sequentFormula, + return manager.refactorTerm(state, services, seqLevelFml, applicationPosInOccurrence, goal, hint, rule, tacletTerm); } else { - return sequentFormula; + return seqLevelFml; } } /** - * Refactors all labels on the {@link PosInOccurrence} in the given {@link Term} of a - * {@link SequentFormula}. + * Refactors all labels on the {@link PosInOccurrence} in the given {@link Term} representing + * a sequent level formula. * * @param state The {@link TermLabelState} of the current rule application. * @param services The {@link Services} used by the {@link Proof} on which a {@link Rule} is @@ -998,11 +998,11 @@ public static Term refactorSequentFormula(TermLabelState state, Services service * @param tacletTerm The optional taclet {@link Term}. * @return The updated application {@link Term}. */ - public Term refactorSequentFormula(TermLabelState state, Services services, Term sequentFormula, + public Term refactorTerm(TermLabelState state, Services services, Term seqLevelFml, PosInOccurrence applicationPosInOccurrence, Goal goal, Object hint, Rule rule, Term tacletTerm) { final PosInTerm pos = applicationPosInOccurrence.posInTerm(); - final Term oldTerm = pos.getSubTerm(sequentFormula); + final Term oldTerm = pos.getSubTerm(seqLevelFml); // Compute active refactorings RefactoringsContainer refactorings = computeRefactorings(state, services, applicationPosInOccurrence, oldTerm, rule, goal, hint, tacletTerm); @@ -1020,7 +1020,7 @@ public Term refactorSequentFormula(TermLabelState state, Services services, Term refactorings.childAndGrandchildRefactoringsAndParents(), services, applicationPosInOccurrence, oldTerm, rule, goal, hint, tacletTerm); } else { - return sequentFormula; + return seqLevelFml; } } @@ -1159,12 +1159,12 @@ public void refactorGoal(TermLabelState state, Services services, Term root = replaceTerm(state, applicationPosInOccurrence, newApplicationTerm, tf, refactorings.childAndGrandchildRefactoringsAndParents(), services, applicationPosInOccurrence, newApplicationTerm, rule, goal, hint, tacletTerm); - goal.changeFormula(new SequentFormula(root), applicationPosInOccurrence.topLevel()); + goal.changeFormula(root, applicationPosInOccurrence.topLevel()); } else if (!refactorings.childAndGrandchildRefactoringsAndParents().isEmpty()) { Term root = replaceTerm(state, applicationPosInOccurrence, applicationTerm, tf, refactorings.childAndGrandchildRefactoringsAndParents(), services, applicationPosInOccurrence, newApplicationTerm, rule, goal, hint, tacletTerm); - goal.changeFormula(new SequentFormula(root), applicationPosInOccurrence.topLevel()); + goal.changeFormula(root, applicationPosInOccurrence.topLevel()); } // Do sequent refactoring if required if (!refactorings.sequentRefactorings().isEmpty() && goal != null) { @@ -1669,13 +1669,13 @@ protected void refactorSemisequent(TermLabelState state, Services services, Object hint, Term tacletTerm, Semisequent semisequent, boolean inAntec, Set activeRefactorings) { if (!activeRefactorings.isEmpty()) { - for (SequentFormula sfa : semisequent) { + for (Term sfa : semisequent) { Term updatedTerm = refactorLabelsRecursive(state, services, applicationPosInOccurrence, - applicationTerm, rule, goal, hint, tacletTerm, sfa.formula(), + applicationTerm, rule, goal, hint, tacletTerm, sfa, activeRefactorings); - if (!sfa.formula().equals(updatedTerm)) { - goal.changeFormula(new SequentFormula(updatedTerm), + if (!sfa.equals(updatedTerm)) { + goal.changeFormula(updatedTerm, new PosInOccurrence(sfa, PosInTerm.getTopLevel(), inAntec)); } } @@ -1962,11 +1962,11 @@ public static TermLabel findInnerMostParentLabel(PosInOccurrence pio, Name termL } /** - * Merges the {@link TermLabel}s of the rejected {@link SequentFormula}s into the resulting + * Merges the {@link TermLabel}s of the rejected {@link Term}s into the resulting * {@link Sequent}. * * @param currentSequent The {@link SequentChangeInfo} which lists the rejected - * {@link SequentFormula}s. + * {@link Term}s. * @param services The {@link Services} to use. */ public static void mergeLabels(SequentChangeInfo currentSequent, Services services) { @@ -1977,47 +1977,49 @@ public static void mergeLabels(SequentChangeInfo currentSequent, Services servic } /** - * Merges the {@link TermLabel}s of the rejected {@link SequentFormula}s into the resulting + * Merges the {@link TermLabel}s of the rejected {@link Term}s into the resulting * {@link Sequent}. * * @param services The {@link Services} to use. * @param currentSequent The {@link SequentChangeInfo} which lists the rejected - * {@link SequentFormula}s. + * {@link Term}s. */ public void mergeLabels(Services services, SequentChangeInfo currentSequent) { - for (SequentFormula rejectedSF : currentSequent.getSemisequentChangeInfo(true) + for (Term rejectedSF : currentSequent.getSemisequentChangeInfo(true) .rejectedFormulas()) { mergeLabels(currentSequent, services, rejectedSF, true); } - for (final SequentFormula rejectedSF : currentSequent.getSemisequentChangeInfo(false) + for (final Term rejectedSF : currentSequent.getSemisequentChangeInfo(false) .rejectedFormulas()) { mergeLabels(currentSequent, services, rejectedSF, false); } } /** - * Merges the {@link TermLabel}s of the given {@link SequentFormula} into the resulting + * Merges the {@link TermLabel}s of the given {@link Term} into the resulting * {@link Sequent}. * * @param currentSequent The {@link SequentChangeInfo} which lists the rejected - * {@link SequentFormula}s. + * {@link Term}s. * @param services The {@link Services} to use. - * @param rejectedSF The rejected {@link SequentFormula} to work with. - * @param inAntecedent {@code true} rejected {@link SequentFormula} is in antecedent, + * @param rejectedSF The rejected {@link Term} to work with. + * @param inAntecedent {@code true} rejected {@link Term} is in antecedent, * {@code false} it is in succedent. */ protected void mergeLabels(SequentChangeInfo currentSequent, Services services, - SequentFormula rejectedSF, boolean inAntecedent) { - final Term rejectedTerm = rejectedSF.formula(); + Term rejectedSF, boolean inAntecedent) { + final Term rejectedTerm = rejectedSF; if (rejectedTerm.hasLabels()) { - // Search existing SequentFormula + // Search existing Term Semisequent s = currentSequent.getSemisequentChangeInfo(inAntecedent).semisequent(); - SequentFormula existingSF = CollectionUtil.search(s, - element -> element.formula().equalsModProperty(rejectedTerm, - RENAMING_PROPERTY)); + Term existingSF = CollectionUtil.search(s, + element -> { + return element.equalsModProperty(rejectedTerm, + RENAMING_PROPERTY); + }); if (existingSF != null) { // Create list of new labels - Term existingTerm = existingSF.formula(); + Term existingTerm = existingSF; List mergedLabels = new LinkedList<>(); CollectionUtil.addAll(mergedLabels, existingTerm.getLabels()); boolean labelsChanged = false; @@ -2039,7 +2041,7 @@ protected void mergeLabels(SequentChangeInfo currentSequent, Services services, existingTerm.subs(), existingTerm.boundVars(), new ImmutableArray<>(mergedLabels)); SequentChangeInfo sci = - currentSequent.sequent().changeFormula(new SequentFormula(newTerm), + currentSequent.sequent().changeFormula(newTerm, new PosInOccurrence(existingSF, PosInTerm.getTopLevel(), inAntecedent)); currentSequent.combine(sci); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/package-info.java b/key.core/src/main/java/de/uka/ilkd/key/logic/package-info.java index 6b837c99a90..a30dfb3f8b4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/package-info.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/package-info.java @@ -24,7 +24,7 @@ * {@link de.uka.ilkd.key.logic.Sequent}s consist of two {@link * de.uka.ilkd.key.logic.Semisequent}s which represent a * duplicate-free list of a {@link - * de.uka.ilkd.key.logic.SequentFormula}s. The latter consist of + * de.uka.ilkd.key.logic.Term}s. The latter consist of * a {@link de.uka.ilkd.key.logic.Constraint} and a {@link * de.uka.ilkd.key.logic.Term} of a special sort {@link * de.uka.ilkd.key.logic.sort.Sort#FORMULA}. diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/AbstractBlastingMacro.java b/key.core/src/main/java/de/uka/ilkd/key/macros/AbstractBlastingMacro.java index e225fca54bc..18c841493e0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/AbstractBlastingMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/AbstractBlastingMacro.java @@ -17,7 +17,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.SortCollector; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; @@ -68,14 +67,14 @@ protected void addInvariantFormula(Goal goal) { SortCollector sortCollector = new SortCollector(); - for (SequentFormula sf : goal.sequent()) { - sf.formula().execPreOrder(sortCollector); + for (Term sf : goal.sequent()) { + sf.execPreOrder(sortCollector); } Set sorts = sortCollector.getSorts(); sorts.remove(nullSort); - List formulae = createFormulae(goal.proof().getServices(), sorts); - for (SequentFormula sf : formulae) { + List formulae = createFormulae(goal.proof().getServices(), sorts); + for (Term sf : formulae) { Sequent s = goal.sequent(); Semisequent antecedent = s.antecedent(); if (!antecedent.containsEqual(sf)) { @@ -98,8 +97,8 @@ private boolean containsSubTypes(Sort s, Set sorts) { return false; } - private List createFormulae(Services services, Set sorts) { - List result = new LinkedList<>(); + private List createFormulae(Services services, Set sorts) { + List result = new LinkedList<>(); JavaInfo info = services.getJavaInfo(); SpecificationRepository spec = services.getSpecificationRepository(); @@ -132,7 +131,7 @@ private List createFormulae(Services services, Set sorts) return result; } - private static void addFormulas(List result, KeYJavaType kjt, ClassAxiom c, + private static void addFormulas(List result, KeYJavaType kjt, ClassAxiom c, LogicVariable o, LogicVariable h, Services services) { TermBuilder tb = new TermBuilder(services.getTermFactory(), services); Term exactInstance = tb.exactInstance(kjt.getSort(), tb.var(o)); @@ -162,10 +161,10 @@ private static void addFormulas(List result, KeYJavaType kjt, Cl exactInstanceEquiv = tb.all(h, tb.all(o, exactInstanceEquiv)); instanceImpl = tb.all(h, tb.all(o, instanceImpl)); - result.add(new SequentFormula(exactInstanceEquiv)); + result.add(exactInstanceEquiv); if (!right.equals(tb.tt())) { - result.add(new SequentFormula(instanceImpl)); + result.add(instanceImpl); } } else if (right.op().name().equals(inv.op().name())) { @@ -176,21 +175,17 @@ private static void addFormulas(List result, KeYJavaType kjt, Cl exactInstanceEquiv = tb.all(h, tb.all(o, exactInstanceEquiv)); instanceImpl = tb.all(h, tb.all(o, instanceImpl)); - result.add(new SequentFormula(exactInstanceEquiv)); + result.add(exactInstanceEquiv); if (!left.equals(tb.tt())) { - result.add(new SequentFormula(instanceImpl)); + result.add(instanceImpl); } } else { - Term f = t; - f = tb.all(h, tb.all(o, f)); - result.add(new SequentFormula(f)); + result.add(tb.all(h, tb.all(o, t))); } } else { - Term f = t; - f = tb.all(h, tb.all(o, f)); - result.add(new SequentFormula(f)); + result.add(tb.all(h, tb.all(o, t))); } } catch (Exception e) { } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/FinishSymbolicExecutionUntilMergePointMacro.java b/key.core/src/main/java/de/uka/ilkd/key/macros/FinishSymbolicExecutionUntilMergePointMacro.java index 59b6f499d5f..f9a5a8e94d7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/FinishSymbolicExecutionUntilMergePointMacro.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/FinishSymbolicExecutionUntilMergePointMacro.java @@ -150,9 +150,9 @@ public void taskFinished(TaskFinishedInfo info) { * @return true iff the given succedent has one formula with a break point statement. */ private boolean hasBreakPoint(Semisequent succedent) { - for (SequentFormula formula : succedent.asList()) { + for (Term formula : succedent.asList()) { if (blockElems.contains(JavaTools - .getActiveStatement(MergeRuleUtils.getJavaBlockRecursive(formula.formula())))) { + .getActiveStatement(MergeRuleUtils.getJavaBlockRecursive(formula)))) { return true; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/ModalityCache.java b/key.core/src/main/java/de/uka/ilkd/key/macros/ModalityCache.java index b55b1137bc9..99dad89cc9c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/ModalityCache.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/ModalityCache.java @@ -6,7 +6,6 @@ import java.util.Map; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.ParameterlessTermLabel; import de.uka.ilkd.key.logic.op.Modality; @@ -79,8 +78,8 @@ public boolean hasModality(Sequent sequent) { } var result = false; - for (SequentFormula sequentFormula : sequent) { - if (termHasModality(sequentFormula.formula())) { + for (Term fml : sequent) { + if (termHasModality(fml)) { result = true; break; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/FocusCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/FocusCommand.java index a27f4613191..2b83dd87ccb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/FocusCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/FocusCommand.java @@ -73,23 +73,27 @@ private void hideAll(Sequent toKeep) throws ScriptException { assert goal != null : "not null by contract of the method"; // The formulas to keep in the antecedent - ImmutableList keepAnte = toKeep.antecedent().asList().map(SequentFormula::formula); - ImmutableList ante = goal.sequent().antecedent().asList(); + ImmutableList keepAnte = toKeep.antecedent().asList().map(term1 -> term1); + ImmutableList ante = goal.sequent().antecedent().asList(); - for (SequentFormula seqFormula : ante) { + for (Term seqFormula : ante) { // This means "!keepAnte.contains(seqFormula.formula)" but with equality mod renaming! if (!keepAnte.exists( - it -> it.equalsModProperty(seqFormula.formula(), RENAMING_PROPERTY))) { + it -> { + return it.equalsModProperty(seqFormula, RENAMING_PROPERTY); + })) { Taclet tac = getHideTaclet("left"); makeTacletApp(goal, seqFormula, tac, true); } } - ImmutableList keepSucc = toKeep.succedent().asList().map(SequentFormula::formula); - ImmutableList succ = goal.sequent().succedent().asList(); - for (SequentFormula seqFormula : succ) { + ImmutableList keepSucc = toKeep.succedent().asList().map(term -> term); + ImmutableList succ = goal.sequent().succedent().asList(); + for (Term seqFormula : succ) { if (!keepSucc.exists( - it -> it.equalsModProperty(seqFormula.formula(), RENAMING_PROPERTY))) { + it -> { + return it.equalsModProperty(seqFormula, RENAMING_PROPERTY); + })) { Taclet tac = getHideTaclet("right"); makeTacletApp(goal, seqFormula, tac, false); } @@ -110,7 +114,7 @@ private Taclet getHideTaclet(String pos) { * @param tac the taclet top apply (either hide_left or hide_right) * @param antec whether the formula is in the antecedent */ - private void makeTacletApp(Goal g, SequentFormula toHide, Taclet tac, boolean antec) { + private void makeTacletApp(Goal g, Term toHide, Taclet tac, boolean antec) { // hide rules only applicable to top-level terms/sequent formulas PosInTerm pit = PosInTerm.getTopLevel(); @@ -126,7 +130,7 @@ private void makeTacletApp(Goal g, SequentFormula toHide, Taclet tac, boolean an TacletApp app = PosTacletApp.createPosTacletApp((FindTaclet) tac, inst, pio, proof.getServices()); - app = app.addCheckedInstantiation(sv, toHide.formula(), proof.getServices(), true); + app = app.addCheckedInstantiation(sv, toHide, proof.getServices(), true); g.apply(app); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java index 85edd078c0b..f1458b91d73 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/HideCommand.java @@ -5,11 +5,7 @@ import java.util.Map; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.macros.scripts.meta.Option; import de.uka.ilkd.key.proof.Goal; @@ -56,11 +52,11 @@ public void execute(Parameters args) throws ScriptException, InterruptedExceptio Taclet hideLeft = state.getProof().getEnv().getInitConfigForEnvironment().lookupActiveTaclet(HIDE_LEFT); - for (SequentFormula s : args.sequent.antecedent()) { + for (Term s : args.sequent.antecedent()) { TacletApp app = NoPosTacletApp.createNoPosTacletApp(hideLeft); - SequentFormula s2 = find(s, goal.sequent().antecedent()); + Term s2 = find(s, goal.sequent().antecedent()); SchemaVariable sv = app.uninstantiatedVars().iterator().next(); - app = app.addCheckedInstantiation(sv, s2.formula(), service, true); + app = app.addCheckedInstantiation(sv, s2, service, true); app = app.setPosInOccurrence(new PosInOccurrence(s2, PosInTerm.getTopLevel(), true), service); goal.apply(app); @@ -68,20 +64,20 @@ public void execute(Parameters args) throws ScriptException, InterruptedExceptio Taclet hideRight = state.getProof().getEnv().getInitConfigForEnvironment().lookupActiveTaclet(HIDE_RIGHT); - for (SequentFormula s : args.sequent.succedent()) { + for (Term s : args.sequent.succedent()) { TacletApp app = NoPosTacletApp.createNoPosTacletApp(hideRight); - SequentFormula s2 = find(s, goal.sequent().succedent()); + Term s2 = find(s, goal.sequent().succedent()); SchemaVariable sv = app.uninstantiatedVars().iterator().next(); - app = app.addCheckedInstantiation(sv, s2.formula(), service, true); + app = app.addCheckedInstantiation(sv, s2, service, true); app = app.setPosInOccurrence(new PosInOccurrence(s2, PosInTerm.getTopLevel(), false), service); goal.apply(app); } } - private SequentFormula find(SequentFormula sf, Semisequent semiseq) throws ScriptException { - for (SequentFormula s : semiseq) { - if (s.formula().equalsModProperty(sf.formula(), TERM_LABELS_PROPERTY)) { + private Term find(Term sf, Semisequent semiseq) throws ScriptException { + for (Term s : semiseq) { + if (s.equalsModProperty(sf, TERM_LABELS_PROPERTY)) { return s; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/InstantiateCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/InstantiateCommand.java index 41ee9436a12..0b676600f19 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/InstantiateCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/InstantiateCommand.java @@ -109,19 +109,21 @@ private ImmutableList findAllTacletApps(Parameters p, EngineState sta index.autoModeStopped(); ImmutableList allApps = ImmutableSLList.nil(); - for (SequentFormula sf : g.node().sequent().antecedent()) { - if (p.formula != null - && !sf.formula().equalsModProperty(p.formula, RENAMING_PROPERTY)) { - continue; + for (Term sf : g.node().sequent().antecedent()) { + if (p.formula != null) { + if (!sf.equalsModProperty(p.formula, RENAMING_PROPERTY)) { + continue; + } } allApps = allApps.append(index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), services)); } - for (SequentFormula sf : g.node().sequent().succedent()) { - if (p.formula != null - && !sf.formula().equalsModProperty(p.formula, RENAMING_PROPERTY)) { - continue; + for (Term sf : g.node().sequent().succedent()) { + if (p.formula != null) { + if (!sf.equalsModProperty(p.formula, RENAMING_PROPERTY)) { + continue; + } } allApps = allApps.append(index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), false), services)); @@ -149,8 +151,8 @@ private void computeFormula(Parameters params, Goal goal) throws ScriptException Node n = goal.node(); Sequent seq = n.sequent(); int occ = params.occ; - for (SequentFormula form : seq.antecedent().asList()) { - Term term = form.formula(); + for (Term form : seq.antecedent().asList()) { + Term term = form; Term stripped = stripUpdates(term); if (stripped.op() == Quantifier.ALL) { String varName = stripped.boundVars().get(0).name().toString(); @@ -164,8 +166,8 @@ private void computeFormula(Parameters params, Goal goal) throws ScriptException } } - for (SequentFormula form : seq.succedent().asList()) { - Term term = form.formula(); + for (Term form : seq.succedent().asList()) { + Term term = form; Term stripped = stripUpdates(term); if (stripped.op() == Quantifier.EX) { String varName = stripped.boundVars().get(0).name().toString(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/MacroCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/MacroCommand.java index 2a431b1cad5..d0e5299907b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/MacroCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/MacroCommand.java @@ -9,9 +9,7 @@ import de.uka.ilkd.key.control.AbstractUserInterfaceControl; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.Sequent; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.macros.ProofMacro; import de.uka.ilkd.key.macros.ProofMacroFinishedInfo; import de.uka.ilkd.key.macros.scripts.meta.Option; @@ -129,8 +127,9 @@ public static PosInOccurrence extractMatchingPio(final Sequent sequent, final St boolean matched = false; for (int i = 1; i < sequent.size() + 1; i++) { + Term fml = sequent.getFormulabyNr(i); final boolean matchesRegex = formatTermString( - LogicPrinter.quickPrintTerm(sequent.getFormulabyNr(i).formula(), services)) + LogicPrinter.quickPrintTerm(fml, services)) .matches(".*" + matchRegEx + ".*"); if (matchesRegex) { if (matched) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RewriteCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RewriteCommand.java index 4c15504162b..2863889ee48 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RewriteCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RewriteCommand.java @@ -111,21 +111,23 @@ private ImmutableList findAllTacletApps(Parameters p, EngineState sta // filter taclets that are applicable on the given formula // filter taclets that are applicable on the given formula in the antecedent - for (SequentFormula sf : g.node().sequent().antecedent()) { + for (Term sf : g.node().sequent().antecedent()) { - if (p.formula != null - && !sf.formula().equalsModProperty(p.formula, RENAMING_PROPERTY)) { - continue; + if (p.formula != null) { + if (!sf.equalsModProperty(p.formula, RENAMING_PROPERTY)) { + continue; + } } allApps = allApps.append(index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), services)); } // filter taclets that are applicable on the given formula in the succedent - for (SequentFormula sf : g.node().sequent().succedent()) { - if (p.formula != null - && !sf.formula().equalsModProperty(p.formula, RENAMING_PROPERTY)) { - continue; + for (Term sf : g.node().sequent().succedent()) { + if (p.formula != null) { + if (!sf.equalsModProperty(p.formula, RENAMING_PROPERTY)) { + continue; + } } allApps = allApps.append(index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), false), services)); @@ -159,7 +161,7 @@ private List findAndExecReplacement(Parameters p, RewriteTaclet rw = (RewriteTaclet) pta.taclet(); if (pta.complete()) { - SequentFormula rewriteResult = rw.getExecutor().getRewriteResult( + Term rewriteResult = rw.getExecutor().getRewriteResult( goalold, null, goalold.proof().getServices(), pta); executeRewriteTaclet(p, pta, goalold, rewriteResult); @@ -187,8 +189,8 @@ private List findAndExecReplacement(Parameters p, * @param rewriteResult */ private void executeRewriteTaclet(Parameters p, PosTacletApp pta, Goal goalold, - SequentFormula rewriteResult) { - if (rewriteResult.formula().equals(p.replace) + Term rewriteResult) { + if (rewriteResult.equals(p.replace) || getTermAtPos(rewriteResult, pta.posInOccurrence()).equals(p.replace)) { failposInOccs.remove(pta.posInOccurrence()); succposInOccs.add(pta.posInOccurrence()); @@ -207,13 +209,13 @@ private void executeRewriteTaclet(Parameters p, PosTacletApp pta, Goal goalold, * @param pio PosInOccurrence of the to be returned term * @return term at pio */ - public Term getTermAtPos(SequentFormula sf, PosInOccurrence pio) { + public Term getTermAtPos(Term sf, PosInOccurrence pio) { if (pio.isTopLevel()) { - return sf.formula(); + return sf; } else { PosInTerm pit = pio.posInTerm(); - return getSubTerm(sf.formula(), pit.iterator()); + return getSubTerm(sf, pit.iterator()); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RuleCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RuleCommand.java index a107e4c8c96..b1d07c04693 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RuleCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/RuleCommand.java @@ -254,7 +254,7 @@ private ImmutableList findBuiltInRuleApps(Parameters p, EngineS final BuiltInRuleAppIndex index = g.ruleAppIndex().builtInRuleAppIndex(); ImmutableList allApps = ImmutableSLList.nil(); - for (SequentFormula sf : g.node().sequent().antecedent()) { + for (Term sf : g.node().sequent().antecedent()) { if (!isFormulaSearchedFor(p, sf, services)) { continue; } @@ -263,7 +263,7 @@ private ImmutableList findBuiltInRuleApps(Parameters p, EngineS index.getBuiltInRule(g, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true))); } - for (SequentFormula sf : g.node().sequent().succedent()) { + for (Term sf : g.node().sequent().succedent()) { if (!isFormulaSearchedFor(p, sf, services)) { continue; } @@ -285,7 +285,7 @@ private ImmutableList findAllTacletApps(Parameters p, EngineState sta index.autoModeStopped(); ImmutableList allApps = ImmutableSLList.nil(); - for (SequentFormula sf : g.node().sequent().antecedent()) { + for (Term sf : g.node().sequent().antecedent()) { if (!isFormulaSearchedFor(p, sf, services)) { continue; } @@ -294,7 +294,7 @@ private ImmutableList findAllTacletApps(Parameters p, EngineState sta new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), services)); } - for (SequentFormula sf : g.node().sequent().succedent()) { + for (Term sf : g.node().sequent().succedent()) { if (!isFormulaSearchedFor(p, sf, services)) { continue; } @@ -307,21 +307,21 @@ private ImmutableList findAllTacletApps(Parameters p, EngineState sta } /** - * Returns true iff the given {@link SequentFormula} either matches the + * Returns true iff the given {@link Term} either matches the * {@link Parameters#formula} parameter or its String representation matches the * {@link Parameters#matches} regex. If both parameters are not supplied, always returns true. * * @param p The {@link Parameters} object. - * @param sf The {@link SequentFormula} to check. + * @param sf The {@link Term} to check. * @return true if sf matches. */ - private boolean isFormulaSearchedFor(Parameters p, SequentFormula sf, Services services) + private boolean isFormulaSearchedFor(Parameters p, Term sf, Services services) throws ScriptException { final boolean satisfiesFormulaParameter = - p.formula != null && sf.formula().equalsModProperty(p.formula, RENAMING_PROPERTY); + p.formula != null && sf.equalsModProperty(p.formula, RENAMING_PROPERTY); final boolean satisfiesMatchesParameter = p.matches != null - && formatTermString(LogicPrinter.quickPrintTerm(sf.formula(), services)) + && formatTermString(LogicPrinter.quickPrintTerm(sf, services)) .matches(".*" + p.matches + ".*"); return (p.formula == null && p.matches == null) || satisfiesFormulaParameter diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SelectCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SelectCommand.java index f43592bde92..e62b8222786 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SelectCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/SelectCommand.java @@ -11,7 +11,6 @@ import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.macros.scripts.meta.Option; import de.uka.ilkd.key.proof.Goal; @@ -134,8 +133,8 @@ private boolean contains(Sequent seq, Term formula) { } private boolean contains(Semisequent semiseq, Term formula) { - for (SequentFormula sf : semiseq.asList()) { - if (sf.formula().equalsModProperty(formula, RENAMING_PROPERTY)) { + for (Term sf : semiseq.asList()) { + if (sf.equalsModProperty(formula, RENAMING_PROPERTY)) { return true; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java index 1a1bfcf4055..4399ad0beba 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/macros/scripts/UnhideCommand.java @@ -59,10 +59,14 @@ public void execute(Parameters args) throws ScriptException, InterruptedExceptio Goal goal = state.getFirstOpenAutomaticGoal(); Set antes = new HashSet<>(); - args.sequent.antecedent().forEach(sf -> antes.add(sf.formula())); + args.sequent.antecedent().forEach(sf -> { + antes.add(sf); + }); Set succs = new HashSet<>(); - args.sequent.succedent().forEach(sf -> succs.add(sf.formula())); + args.sequent.succedent().forEach(sf -> { + succs.add(sf); + }); RuleAppIndex index = goal.ruleAppIndex(); ImmutableList apps = index.getNoFindTaclet(FILTER, service); diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java index 1d638f33534..dab8f44a1a1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ExpressionBuilder.java @@ -559,13 +559,13 @@ public Object visitTermorseq(KeYParser.TermorseqContext ctx) { if (head != null && ss != null) { // A sequent with only head in the antecedent. Semisequent ant = Semisequent.EMPTY_SEMISEQUENT; - ant = ant.insertFirst(new SequentFormula(head)).semisequent(); + ant = ant.insertFirst(head).semisequent(); return Sequent.createSequent(ant, ss); } if (head != null && s != null) { // A sequent. Prepend head to the antecedent. Semisequent newAnt = s.antecedent(); - newAnt = newAnt.insertFirst(new SequentFormula(head)).semisequent(); + newAnt = newAnt.insertFirst(head).semisequent(); return Sequent.createSequent(newAnt, s.succedent()); } if (ss != null) { @@ -583,7 +583,7 @@ public Semisequent visitSemisequent(KeYParser.SemisequentContext ctx) { } Term head = accept(ctx.term()); if (head != null) { - ss = ss.insertFirst(new SequentFormula(head)).semisequent(); + ss = ss.insertFirst(head).semisequent(); } return ss; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java index 02b4702e60d..dfbc3c110b1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/ProblemFinder.java @@ -104,7 +104,7 @@ public ProblemFinder(Services services, NamespaceSet nss) { if (obj instanceof Sequent s) return s; if (obj instanceof Term t) - return Sequent.createSuccSequent(new Semisequent(new SequentFormula(t))); + return Sequent.createSuccSequent(new Semisequent(t)); return null; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java index 3e558815f71..05f0191628e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/nparser/builder/TacletPBuilder.java @@ -151,7 +151,7 @@ public Taclet visitTaclet(KeYParser.TacletContext ctx) { } TacletBuilder b = createTacletBuilderFor(null, RewriteTaclet.NONE, ctx); currentTBuilder.push(b); - SequentFormula sform = new SequentFormula(form); + Term sform = form; Semisequent semi = new Semisequent(sform); Sequent addSeq = Sequent.createAnteSequent(semi); ImmutableList noTaclets = ImmutableSLList.nil(); @@ -322,8 +322,9 @@ private TacletBuilder createDeconstructorEQTaclet( var res = schemaVariables[argIndex]; tacletBuilder.setFind(tb.func(function, tb.var(x))); + Term uAssumptions = tb.equals(tb.var(x), tb.func(consFn, args)); tacletBuilder.setIfSequent(Sequent.createAnteSequent( - new Semisequent(new SequentFormula(tb.equals(tb.var(x), tb.func(consFn, args)))))); + new Semisequent(uAssumptions))); tacletBuilder.addTacletGoalTemplate(new RewriteTacletGoalTemplate(tb.var(res))); tacletBuilder.setApplicationRestriction(RewriteTaclet.SAME_UPDATE_LEVEL); @@ -350,7 +351,7 @@ private TacletBuilder createInductionTaclet( var use = tb.all(qvar, tb.var(phi)); var useCase = new TacletGoalTemplate( - Sequent.createAnteSequent(new Semisequent(new SequentFormula(use))), + Sequent.createAnteSequent(new Semisequent(use)), ImmutableSLList.nil()); useCase.setName("Use case of " + ctx.name.getText()); cases.add(useCase); @@ -364,7 +365,7 @@ private TacletGoalTemplate createGoalDtConstructor(KeYParser.Datatype_constructo VariableSV qvar, Term var, Sort sort) { var constr = createQuantifiedFormula(it, qvar, var, sort); var goal = new TacletGoalTemplate( - Sequent.createSuccSequent(new Semisequent(new SequentFormula(constr))), + Sequent.createSuccSequent(new Semisequent(constr)), ImmutableSLList.nil()); goal.setName(it.getText()); return goal; @@ -393,7 +394,7 @@ private RewriteTacletBuilder createAxiomTaclet( var axiom = tb.equals(find, tb.and(cases)); var goal = new TacletGoalTemplate( - Sequent.createAnteSequent(new Semisequent(new SequentFormula(axiom))), + Sequent.createAnteSequent(new Semisequent(axiom)), ImmutableSLList.nil()); tacletBuilder.addTacletGoalTemplate(goal); @@ -474,8 +475,9 @@ private RewriteTacletBuilder createConstructorSplit( for (int i = 0; i < args.length; i++) { args[i] = variables.get(context.argName.get(i).getText()); } + Term uAssumptions = tb.equals(tb.var(phi), tb.func(func, args)); Semisequent antec = - new Semisequent(new SequentFormula(tb.equals(tb.var(phi), tb.func(func, args)))); + new Semisequent(uAssumptions); Sequent addedSeq = Sequent.createAnteSequent(antec); TacletGoalTemplate goal = new TacletGoalTemplate(addedSeq, ImmutableSLList.nil()); goal.setName("#var = " + context.name.getText()); @@ -757,14 +759,14 @@ public ImmutableList visitTacletlist(KeYParser.TacletlistContext ctx) { if (findSeq.isEmpty()) { return new NoFindTacletBuilder(); } else if (findSeq.antecedent().size() == 1 && findSeq.succedent().isEmpty()) { - Term findFma = findSeq.antecedent().get(0).formula(); + Term findFma = findSeq.antecedent().get(0); AntecTacletBuilder b = new AntecTacletBuilder(); b.setFind(findFma); b.setIgnoreTopLevelUpdates( (applicationRestriction & RewriteTaclet.IN_SEQUENT_STATE) == 0); return b; } else if (findSeq.antecedent().isEmpty() && findSeq.succedent().size() == 1) { - Term findFma = findSeq.succedent().get(0).formula(); + Term findFma = findSeq.succedent().get(0); SuccTacletBuilder b = new SuccTacletBuilder(); b.setFind(findFma); b.setIgnoreTopLevelUpdates( diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/HideSequentPrintFilter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/HideSequentPrintFilter.java index cf6c0156476..1e5667184c7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/HideSequentPrintFilter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/HideSequentPrintFilter.java @@ -7,7 +7,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.pp.IdentitySequentPrintFilter.IdentityFilterEntry; import org.key_project.util.collection.ImmutableSLList; @@ -32,7 +32,7 @@ public HideSequentPrintFilter(SequentViewLogicPrinter lp, boolean regex) { @Override protected void filterSequent() { - Iterator it; + Iterator it; if (antec != null) { // Result has already been computed. No need to recompute. @@ -53,7 +53,7 @@ protected void filterSequent() { antec = ImmutableSLList.nil(); it = originalSequent.antecedent().iterator(); while (it.hasNext()) { - SequentFormula sf = it.next(); + Term sf = it.next(); lp.reset(); lp.printConstrainedFormula(sf); String formString = lp.result(); @@ -66,7 +66,7 @@ protected void filterSequent() { succ = ImmutableSLList.nil(); it = originalSequent.succedent().iterator(); while (it.hasNext()) { - SequentFormula sf = it.next(); + Term sf = it.next(); lp.reset(); lp.printConstrainedFormula(sf); String formString = lp.result(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/IdentitySequentPrintFilter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/IdentitySequentPrintFilter.java index ae73d537ebb..6230c2ea20b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/IdentitySequentPrintFilter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/IdentitySequentPrintFilter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.pp; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import org.key_project.util.collection.ImmutableList; @@ -24,11 +24,11 @@ protected void filterSequent() { /** * - * @param sequentFormula the formula to filter + * @param fml the formula to filter * @return the FilterEntry from the formula */ - protected SequentPrintFilterEntry filterFormula(SequentFormula sequentFormula) { - return new IdentityFilterEntry(sequentFormula); + protected SequentPrintFilterEntry filterFormula(Term fml) { + return new IdentityFilterEntry(fml); } /** @@ -60,14 +60,14 @@ public static class IdentityFilterEntry implements SequentPrintFilterEntry { /** * the original Formula being filtered */ - final SequentFormula originalFormula; + final Term originalFormula; /** * constructor * * @param originalFormula the original formula to be filtered */ - IdentityFilterEntry(SequentFormula originalFormula) { + IdentityFilterEntry(Term originalFormula) { this.originalFormula = originalFormula; } @@ -76,7 +76,7 @@ public static class IdentityFilterEntry implements SequentPrintFilterEntry { * * @return the original formula */ - public SequentFormula getFilteredFormula() { + public Term getFilteredFormula() { return originalFormula; } @@ -85,7 +85,7 @@ public SequentFormula getFilteredFormula() { * * @return the original formula */ - public SequentFormula getOriginalFormula() { + public Term getOriginalFormula() { return originalFormula; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/InitialPositionTable.java b/key.core/src/main/java/de/uka/ilkd/key/pp/InitialPositionTable.java index 33a568bcc7b..854726f7709 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/InitialPositionTable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/InitialPositionTable.java @@ -5,7 +5,7 @@ import de.uka.ilkd.key.logic.IntIterator; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -13,7 +13,7 @@ /** * An InitialPositionTable is a PositionTable that describes the beginning of the element/subelement * relationship. Thus, an InitialPositionTable describes the information on where the - * {@link SequentFormula}e of a sequent are located. It is the root of the tree of PositionTables + * {@link Term}e of a sequent are located. It is the root of the tree of PositionTables * and may be asked for a PosInSequent for a given index position and a given Sequent. * *

            @@ -80,7 +80,7 @@ private PosInSequent getTopPIS(ImmutableList posList, SequentPrintFilte /** * Returns the path for a given PosInOccurrence. This is built up from the initial 0, the number - * of the SequentFormula in the sequent, the position in the constrained formula, and possibly + * of the Term in the sequent, the position in the constrained formula, and possibly * inside a Metavariable instantiation. * * @param pio the given PosInOccurrence @@ -90,7 +90,7 @@ private PosInSequent getTopPIS(ImmutableList posList, SequentPrintFilte public ImmutableList pathForPosition(PosInOccurrence pio, SequentPrintFilter filter) { ImmutableList p = ImmutableSLList.nil(); p = prependPathInFormula(p, pio); - int index = indexOfCfma(pio.sequentFormula(), filter); + int index = indexOfCfma(pio.sequentLevelFormula(), filter); if (index == -1) { return null; } @@ -116,7 +116,7 @@ private ImmutableList prependPathInFormula(ImmutableList p, * @param filter the current filter * @return the index of the given formula in the sequent as printed */ - private int indexOfCfma(SequentFormula cfma, SequentPrintFilter filter) { + private int indexOfCfma(Term cfma, SequentPrintFilter filter) { ImmutableList list = filter.getFilteredAntec().append(filter.getFilteredSucc()); int k; diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java index 11deca874c7..0ab328fcaf8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/LogicPrinter.java @@ -751,8 +751,8 @@ public void printSemisequent(ImmutableList formulas) { * * @param cfma the constrained formula to be printed */ - public void printConstrainedFormula(SequentFormula cfma) { - printTerm(cfma.formula()); + public void printConstrainedFormula(Term cfma) { + printTerm(cfma); } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/PosInSequent.java b/key.core/src/main/java/de/uka/ilkd/key/pp/PosInSequent.java index ce8f82b1e2a..93a17a13cc6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/PosInSequent.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/PosInSequent.java @@ -31,11 +31,11 @@ public static PosInSequent createSequentPos() { } /** - * creates a PosInSequent that points to a SequentFormula described by a PosInOccurrence. - * Additionally a boolean indicates whether the the whole SequentFormula or just the formula is + * creates a PosInSequent that points to a Term described by a PosInOccurrence. + * Additionally a boolean indicates whether the the whole Term or just the formula is * meant. * - * @param posInOcc the PositionInOccurrence describing the SequentFormula and maybe a subterm of + * @param posInOcc the PositionInOccurrence describing the Term and maybe a subterm of * its formula. */ public static PosInSequent createCfmaPos(PosInOccurrence posInOcc) { @@ -92,7 +92,7 @@ public Range getFirstJavaStatementRange() { /** - * returns the PosInOccurrence if the PosInSequent marks a SequentFormula or parts of it, null + * returns the PosInOccurrence if the PosInSequent marks a Term or parts of it, null * otherwise. */ public PosInOccurrence getPosInOccurrence() { diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/PositionTable.java b/key.core/src/main/java/de/uka/ilkd/key/pp/PositionTable.java index 1ffebb4e6d7..1ba59a1e63e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/PositionTable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/PositionTable.java @@ -5,7 +5,7 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -44,7 +44,7 @@ public class PositionTable { private final int rows; /** - * creates a new PositionTable with the number of subterms (or number of SequentFormula in a + * creates a new PositionTable with the number of subterms (or number of Term in a * Semisequent, or the number of Semisequents in a Sequent, etc.) * * @param rows the number of direct sub-elements in the term whose position information is @@ -243,7 +243,7 @@ protected PosInSequent getSequentPIS(ImmutableList posList, // This can raise a NPE sporadically. (MU 19) // This raises an NPE repeatably (JS/MU 21) #1650 - SequentFormula cfma = filterEntry.getOriginalFormula(); + Term cfma = filterEntry.getOriginalFormula(); PosInOccurrence currentPos = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), filter.getOriginalSequent().antecedent().contains(cfma)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/RegroupSequentPrintFilter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/RegroupSequentPrintFilter.java index b2ec7475952..85ad34827a4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/RegroupSequentPrintFilter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/RegroupSequentPrintFilter.java @@ -7,7 +7,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.pp.IdentitySequentPrintFilter.IdentityFilterEntry; import org.key_project.util.collection.ImmutableSLList; @@ -33,7 +33,7 @@ public RegroupSequentPrintFilter(SequentViewLogicPrinter lp, boolean regex) { @Override protected void filterSequent() { - Iterator it; + Iterator it; if (searchString == null || searchString.length() < 3) { filterIdentity(); @@ -48,7 +48,7 @@ protected void filterSequent() { antec = ImmutableSLList.nil(); it = originalSequent.antecedent().iterator(); while (it.hasNext()) { - SequentFormula sf = it.next(); + Term sf = it.next(); lp.reset(); lp.printConstrainedFormula(sf); String formString = lp.result(); @@ -63,7 +63,7 @@ protected void filterSequent() { succ = ImmutableSLList.nil(); it = originalSequent.succedent().iterator(); while (it.hasNext()) { - SequentFormula sf = it.next(); + Term sf = it.next(); lp.reset(); lp.printConstrainedFormula(sf); String formString = lp.result(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilter.java index 0018fe2a215..4d54c77793a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilter.java @@ -6,7 +6,7 @@ import java.util.Iterator; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.pp.IdentitySequentPrintFilter.IdentityFilterEntry; import org.key_project.util.collection.ImmutableList; @@ -83,7 +83,7 @@ public ImmutableList getFilteredSucc() { */ protected void filterIdentity() { antec = ImmutableSLList.nil(); - Iterator it = originalSequent.antecedent().iterator(); + Iterator it = originalSequent.antecedent().iterator(); while (it.hasNext()) { antec = antec.append(new IdentityFilterEntry(it.next())); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilterEntry.java b/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilterEntry.java index dd1e2b42fad..91129b4dc5f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilterEntry.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/SequentPrintFilterEntry.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.pp; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; /** @@ -15,11 +15,11 @@ public interface SequentPrintFilterEntry { /** * Formula to display */ - SequentFormula getFilteredFormula(); + Term getFilteredFormula(); /** * Original formula from sequent */ - SequentFormula getOriginalFormula(); + Term getOriginalFormula(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/pp/ShowSelectedSequentPrintFilter.java b/key.core/src/main/java/de/uka/ilkd/key/pp/ShowSelectedSequentPrintFilter.java index 9ac6e9acc4b..ac229e5c847 100755 --- a/key.core/src/main/java/de/uka/ilkd/key/pp/ShowSelectedSequentPrintFilter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/pp/ShowSelectedSequentPrintFilter.java @@ -4,7 +4,7 @@ package de.uka.ilkd.key.pp; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableSLList; @@ -65,25 +65,26 @@ public static final class Entry implements SequentPrintFilterEntry { /** * The filtered formula, i.e., the formula at {@code pos}. */ - private final SequentFormula filtered; + private final Term filtered; /** * The origin formula, i.e., the formula at {@code pos.getTopLevel()}. */ - private final SequentFormula original; + private final Term original; private Entry(PosInOccurrence pos) { - filtered = new SequentFormula(pos.subTerm()); - original = pos.sequentFormula(); + Term uAssumptions = pos.subTerm(); + filtered = uAssumptions; + original = pos.sequentLevelFormula(); } @Override - public SequentFormula getFilteredFormula() { + public Term getFilteredFormula() { return filtered; } @Override - public SequentFormula getOriginalFormula() { + public Term getOriginalFormula() { return original; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/BuiltInRuleAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/BuiltInRuleAppIndex.java index 350d9f0d849..4b65c4f88f9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/BuiltInRuleAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/BuiltInRuleAppIndex.java @@ -87,13 +87,13 @@ private void scanSimplificationRule(ImmutableList rules, Goal goal, final Node node = goal.node(); final Sequent seq = node.sequent(); - for (final SequentFormula sf : (antec ? seq.antecedent() : seq.succedent())) { + for (final Term sf : (antec ? seq.antecedent() : seq.succedent())) { scanSimplificationRule(rules, goal, antec, sf, listener); } } private void scanSimplificationRule(ImmutableList rules, Goal goal, boolean antec, - SequentFormula cfma, NewRuleListener listener) { + Term cfma, NewRuleListener listener) { final PosInOccurrence pos = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), antec); ImmutableList subrules = ImmutableSLList.nil(); while (!rules.isEmpty()) { @@ -145,9 +145,9 @@ public void sequentChanged(Goal goal, SequentChangeInfo sci, NewRuleListener lis private void scanAddedFormulas(Goal goal, boolean antec, SequentChangeInfo sci, NewRuleListener listener) { - ImmutableList cfmas = sci.addedFormulas(antec); + ImmutableList cfmas = sci.addedFormulas(antec); while (!cfmas.isEmpty()) { - final SequentFormula cfma = cfmas.head(); + final Term cfma = cfmas.head(); scanSimplificationRule(index.rules(), goal, antec, cfma, listener); cfmas = cfmas.tail(); } @@ -160,7 +160,7 @@ private void scanModifiedFormulas(Goal goal, boolean antec, SequentChangeInfo sc while (!fcis.isEmpty()) { final FormulaChangeInfo fci = fcis.head(); - final SequentFormula cfma = fci.newFormula(); + final Term cfma = fci.newFormula(); scanSimplificationRule(index.rules(), goal, antec, cfma, listener); fcis = fcis.tail(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/FormulaTagManager.java b/key.core/src/main/java/de/uka/ilkd/key/proof/FormulaTagManager.java index b71df3fa24a..415d2d1869c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/FormulaTagManager.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/FormulaTagManager.java @@ -102,7 +102,7 @@ private void updateTags(SequentChangeInfo sci, boolean p_antec, Goal p_goal) { } private void addTags(SequentChangeInfo sci, boolean p_antec, Goal p_goal) { - for (SequentFormula constrainedFormula : sci.addedFormulas(p_antec)) { + for (Term constrainedFormula : sci.addedFormulas(p_antec)) { final PosInOccurrence pio = new PosInOccurrence(constrainedFormula, PosInTerm.getTopLevel(), p_antec); createNewTag(pio, p_goal); @@ -110,7 +110,7 @@ private void addTags(SequentChangeInfo sci, boolean p_antec, Goal p_goal) { } private void removeTags(SequentChangeInfo sci, boolean p_antec, Goal p_goal) { - for (SequentFormula constrainedFormula : sci.removedFormulas(p_antec)) { + for (Term constrainedFormula : sci.removedFormulas(p_antec)) { final PosInOccurrence pio = new PosInOccurrence(constrainedFormula, PosInTerm.getTopLevel(), p_antec); removeTag(pio); @@ -148,7 +148,7 @@ private void createNewTags(Goal p_goal, boolean p_antec) { final Sequent seq = p_goal.sequent(); final Semisequent ss = p_antec ? seq.antecedent() : seq.succedent(); - for (SequentFormula s : ss) { + for (Term s : ss) { final PosInOccurrence pio = new PosInOccurrence(s, PosInTerm.getTopLevel(), p_antec); createNewTag(pio, p_goal); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java index 9885acd6145..48e08240c3b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java @@ -379,10 +379,10 @@ public void setSequent(SequentChangeInfo sci) { * adds a formula to the sequent before the given position and informs the rule application * index about this change * - * @param cf the SequentFormula to be added + * @param cf the Term to be added * @param p PosInOccurrence encodes the position */ - public void addFormula(SequentFormula cf, PosInOccurrence p) { + public void addFormula(Term cf, PosInOccurrence p) { setSequent(sequent().addFormula(cf, p)); } @@ -390,12 +390,12 @@ public void addFormula(SequentFormula cf, PosInOccurrence p) { * adds a formula to the antecedent or succedent of a sequent. Either at its front or back and * informs the rule application index about this change * - * @param cf the SequentFormula to be added - * @param inAntec boolean true(false) if SequentFormula has to be added to antecedent + * @param cf the Term to be added + * @param inAntec boolean true(false) if Term has to be added to antecedent * (succedent) * @param first boolean true if at the front, if false then cf is added at the back */ - public void addFormula(SequentFormula cf, boolean inAntec, boolean first) { + public void addFormula(Term cf, boolean inAntec, boolean first) { setSequent(sequent().addFormula(cf, inAntec, first)); } @@ -403,10 +403,10 @@ public void addFormula(SequentFormula cf, boolean inAntec, boolean first) { * replaces a formula at the given position and informs the rule application index about this * change * - * @param cf the SequentFormula replacing the old one + * @param cf the Term replacing the old one * @param p the PosInOccurrence encoding the position */ - public void changeFormula(SequentFormula cf, PosInOccurrence p) { + public void changeFormula(Term cf, PosInOccurrence p) { setSequent(sequent().changeFormula(cf, p)); } @@ -607,10 +607,10 @@ public ImmutableList apply(final RuleApp ruleApp) { * caught. */ NamespaceSet originalNamespaces = getLocalNamespaces(); - Services overlayServices = proof.getServices().getOverlay(originalNamespaces); final ImmutableList goalList; var time = System.nanoTime(); try { + Services overlayServices = proof.getServices().getOverlay(originalNamespaces); goalList = ruleApp.execute(this, overlayServices); } finally { PERF_APP_EXECUTE.getAndAdd(System.nanoTime() - time); @@ -702,12 +702,12 @@ public void makeLocalNamespacesFrom(NamespaceSet ns) { public List getAllBuiltInRuleApps() { final BuiltInRuleAppIndex index = ruleAppIndex().builtInRuleAppIndex(); LinkedList ruleApps = new LinkedList<>(); - for (SequentFormula sf : node().sequent().antecedent()) { + for (Term sf : node().sequent().antecedent()) { ImmutableList t = index.getBuiltInRule(this, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true)); t.forEach(ruleApps::add); } - for (SequentFormula sf : node().sequent().succedent()) { + for (Term sf : node().sequent().succedent()) { ImmutableList t = index.getBuiltInRule(this, new PosInOccurrence(sf, PosInTerm.getTopLevel(), false)); t.forEach(ruleApps::add); @@ -725,13 +725,13 @@ protected boolean filter(Taclet taclet) { return true; } }; - for (SequentFormula sf : node().sequent().antecedent()) { + for (Term sf : node().sequent().antecedent()) { ImmutableList tacletAppAtAndBelow = index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), services); tacletAppAtAndBelow.forEach(allApps::add); } - for (SequentFormula sf : node().sequent().succedent()) { + for (Term sf : node().sequent().succedent()) { ImmutableList tacletAppAtAndBelow = index.getTacletAppAtAndBelow(filter, new PosInOccurrence(sf, PosInTerm.getTopLevel(), false), services); tacletAppAtAndBelow.forEach(allApps::add); diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/ProgVarReplacer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/ProgVarReplacer.java index 730707056a3..bbf6a42dad3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/ProgVarReplacer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/ProgVarReplacer.java @@ -144,9 +144,8 @@ public SVInstantiations replace(SVInstantiations insts) { result = result.replace(sv, newA, services); } } else if (ie instanceof TermInstantiation) { - Term t = (Term) inst; - Term newT = replace(t); - if (newT != t) { + Term newT = replace((Term) inst); + if (newT != inst) { result = result.replace(sv, newT, services); } } else { @@ -183,11 +182,11 @@ public SemisequentChangeInfo replace(Semisequent s) { SemisequentChangeInfo result = new SemisequentChangeInfo(); result.setFormulaList(s.asList()); - final Iterator it = s.iterator(); + final Iterator it = s.iterator(); for (int formulaNumber = 0; it.hasNext(); formulaNumber++) { - final SequentFormula oldcf = it.next(); - final SequentFormula newcf = replace(oldcf); + final Term oldcf = it.next(); + final Term newcf = replace(oldcf); if (newcf != oldcf) { result.combine(result.semisequent().replace(formulaNumber, newcf)); @@ -197,22 +196,6 @@ public SemisequentChangeInfo replace(Semisequent s) { return result; } - - /** - * replaces in a constrained formula - */ - public SequentFormula replace(SequentFormula cf) { - SequentFormula result = cf; - - final Term newFormula = replace(cf.formula()); - - if (newFormula != cf.formula()) { - result = new SequentFormula(newFormula); - } - return result; - } - - private Term replaceProgramVariable(Term t) { final ProgramVariable pv = (ProgramVariable) t.op(); ProgramVariable o = map.get(pv); @@ -222,7 +205,6 @@ private Term replaceProgramVariable(Term t) { return t; } - private Term standardReplace(Term t) { Term result = t; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java index 1fb6157a6c0..e8121005091 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java @@ -242,7 +242,7 @@ public Proof(String name, Sequent problem, String header, InitConfig initConfig, public Proof(String name, Term problem, String header, InitConfig initConfig) { this(name, Sequent.createSuccSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(problem)).semisequent()), + Semisequent.EMPTY_SEMISEQUENT.insert(0, problem).semisequent()), initConfig.createTacletIndex(), initConfig.createBuiltInRuleIndex(), initConfig); problemHeader = header; } @@ -490,7 +490,6 @@ public ImmutableList openEnabledGoals() { return filterEnabledGoals(openGoals); } - /** * filter those goals from a list which are enabled * @@ -509,15 +508,14 @@ private ImmutableList filterEnabledGoals(ImmutableList goals) { return enabledGoals; } - /** * removes the given goal and adds the new goals in list * * @param oldGoal the old goal that has to be removed from list - * @param newGoals the IList with the new goals that were result of a rule application on - * goal + * @param newGoals the Iterable with the new goals that were result of a rule application + * on goal */ - public void replace(Goal oldGoal, ImmutableList newGoals) { + public void replace(Goal oldGoal, Iterable newGoals) { openGoals = openGoals.removeAll(oldGoal); if (closed()) { @@ -632,6 +630,21 @@ public void add(ImmutableList goals) { fireProofGoalsAdded(goals); } + /** + * adds a list with new goals to the list of open goals + * + * @param goals the Iterable to be prepended + */ + public void add(Iterable goals) { + ImmutableList addGoals; + if (goals instanceof ImmutableList asList) { + addGoals = asList; + } else { + addGoals = ImmutableList.fromList(goals); + } + add(addGoals); + } + /** * returns true if the root node is marked as closed and all goals have been removed diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/SemisequentTacletAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/SemisequentTacletAppIndex.java index f70243418f7..4a8c236ee6b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/SemisequentTacletAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/SemisequentTacletAppIndex.java @@ -24,7 +24,7 @@ public class SemisequentTacletAppIndex { public static final AtomicLong PERF_ADD = new AtomicLong(); public static final AtomicLong PERF_REMOVE = new AtomicLong(); - private ImmutableMap termIndices = + private ImmutableMap termIndices = DefaultImmutableMap.nilMap(); private TermTacletAppIndexCacheSet indexCaches; @@ -38,10 +38,10 @@ public class SemisequentTacletAppIndex { * Add indices for the given formulas to the map termIndices. Existing entries are * replaced with the new indices. Note: destructive, use only when constructing new index */ - private void addTermIndices(ImmutableList cfmas, Services services, + private void addTermIndices(ImmutableList cfmas, Services services, TacletIndex tacletIndex, NewRuleListener listener) { while (!cfmas.isEmpty()) { - final SequentFormula cfma = cfmas.head(); + final Term cfma = cfmas.head(); cfmas = cfmas.tail(); addTermIndex(cfma, services, tacletIndex, listener); } @@ -51,7 +51,7 @@ private void addTermIndices(ImmutableList cfmas, Services servic * Add an index for the given formula to the map termIndices. An existing entry is * replaced with the new one. Note: destructive, use only when constructing new index */ - private void addTermIndex(SequentFormula cfma, Services services, + private void addTermIndex(Term cfma, Services services, TacletIndex tacletIndex, NewRuleListener listener) { final PosInOccurrence pos = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), antec); termIndices = termIndices.put(cfma, TermTacletAppIndex.create(pos, services, tacletIndex, @@ -63,7 +63,7 @@ private void addTermIndex(SequentFormula cfma, Services services, * termIndices, by adding the taclets that are selected by filter * Note: destructive, use only when constructing new index */ - private void addTaclets(RuleFilter filter, SequentFormula cfma, Services services, + private void addTaclets(RuleFilter filter, Term cfma, Services services, TacletIndex tacletIndex, NewRuleListener listener) { final TermTacletAppIndex oldIndex = termIndices.get(cfma); assert oldIndex != null : "Term index that is supposed to be updated " + "does not exist"; @@ -78,8 +78,8 @@ private void addTaclets(RuleFilter filter, SequentFormula cfma, Services service * Remove the indices for the given formulas from the map termIndices. Note: * destructive, use only when constructing new index */ - private void removeTermIndices(ImmutableList cfmas) { - for (SequentFormula cfma : cfmas) { + private void removeTermIndices(ImmutableList cfmas) { + for (Term cfma : cfmas) { removeTermIndex(cfma); } } @@ -88,7 +88,7 @@ private void removeTermIndices(ImmutableList cfmas) { * Remove the index for the given formula from the map termIndices. Note: * destructive, use only when constructing new index */ - private void removeTermIndex(SequentFormula cfma) { + private void removeTermIndex(Term cfma) { termIndices = termIndices.remove(cfma); } @@ -102,7 +102,7 @@ private List removeFormulas(ImmutableList var oldIndices = new ArrayList(infos.size()); for (FormulaChangeInfo info : infos) { - final SequentFormula oldFor = info.getOriginalFormula(); + final Term oldFor = info.getOriginalFormula(); oldIndices.add(termIndices.get(oldFor)); removeTermIndex(oldFor); @@ -125,7 +125,7 @@ private void updateTermIndices(List oldIndices, while (infoIt.hasNext()) { final FormulaChangeInfo info = infoIt.next(); - final SequentFormula newFor = info.newFormula(); + final Term newFor = info.newFormula(); final TermTacletAppIndex oldIndex = oldIndexIt.next(); if (oldIndex == null) @@ -184,7 +184,7 @@ public SemisequentTacletAppIndex copy() { * Get term index for the formula to which position pos points */ private TermTacletAppIndex getTermIndex(PosInOccurrence pos) { - return termIndices.get(pos.sequentFormula()); + return termIndices.get(pos.sequentLevelFormula()); } /** @@ -240,7 +240,7 @@ public SemisequentTacletAppIndex sequentChanged(SequentChangeInfo sci, Services public SemisequentTacletAppIndex addTaclets(RuleFilter filter, Services services, TacletIndex tacletIndex, NewRuleListener listener) { final SemisequentTacletAppIndex result = copy(); - final Iterator it = termIndices.keyIterator(); + final Iterator it = termIndices.keyIterator(); while (it.hasNext()) { result.addTaclets(filter, it.next(), services, tacletIndex, listener); @@ -254,8 +254,8 @@ public SemisequentTacletAppIndex addTaclets(RuleFilter filter, Services services * taclet app. */ void reportRuleApps(NewRuleListener l) { - for (final ImmutableMapEntry entry : termIndices) { - final SequentFormula cfma = entry.key(); + for (final ImmutableMapEntry entry : termIndices) { + final Term cfma = entry.key(); final TermTacletAppIndex index = entry.value(); final PosInOccurrence pio = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), antec); diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/TermTacletAppIndex.java b/key.core/src/main/java/de/uka/ilkd/key/proof/TermTacletAppIndex.java index 1af43522d9f..5b044a194db 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/TermTacletAppIndex.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/TermTacletAppIndex.java @@ -91,9 +91,9 @@ private static ImmutableList getFindTaclet(PosInOccurrence pos, /** - * collects all AntecedentTaclet instantiations for the given heuristics and SequentFormula + * collects all AntecedentTaclet instantiations for the given heuristics and Term * - * @param pos the PosInOccurrence of the SequentFormula the taclets have to be connected to (pos + * @param pos the PosInOccurrence of the Term the taclets have to be connected to (pos * must point to the top level formula, i.e. pos.isTopLevel() must be true) * @param services the Services object encapsulating information about the java datastructures * like (static)types etc. @@ -105,9 +105,9 @@ private static ImmutableList antecTaclet(PosInOccurrence pos, Ru } /** - * collects all SuccedentTaclet instantiations for the given heuristics and SequentFormula + * collects all SuccedentTaclet instantiations for the given heuristics and Term * - * @param pos the PosInOccurrence of the SequentFormula the taclets have to be connected to (pos + * @param pos the PosInOccurrence of the Term the taclets have to be connected to (pos * must point to the top level formula, i.e. pos.isTopLevel() must be true) * @param services the Services object encapsulating information about the java datastructures * like (static)types etc. diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/delayedcut/DelayedCutProcessor.java b/key.core/src/main/java/de/uka/ilkd/key/proof/delayedcut/DelayedCutProcessor.java index cd0b76007b2..ee89b1abafc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/delayedcut/DelayedCutProcessor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/delayedcut/DelayedCutProcessor.java @@ -186,7 +186,7 @@ protected boolean filter(Taclet taclet) { */ private ImmutableList hide(DelayedCut cut, Goal goal) { - SequentFormula sf = getSequentFormula(goal, cut.isDecisionPredicateInAntecendet()); + Term sf = getTerm(goal, cut.isDecisionPredicateInAntecendet()); PosInOccurrence pio = new PosInOccurrence(sf, PosInTerm.getTopLevel(), cut.isDecisionPredicateInAntecendet()); @@ -208,9 +208,9 @@ private int getGoalForHiding(ImmutableList goals, DelayedCut cut) { String side = cut.isDecisionPredicateInAntecendet() ? "TRUE" : "FALSE"; if (goal[i].node().getNodeInfo().getBranchLabel().endsWith(side)) { - SequentFormula formula = - getSequentFormula(goal[i], cut.isDecisionPredicateInAntecendet()); - if (formula.formula() == cut.getFormula()) { + Term formula = + getTerm(goal[i], cut.isDecisionPredicateInAntecendet()); + if (formula == cut.getFormula()) { return i; } } @@ -223,7 +223,7 @@ private String getHideTacletName(DelayedCut cut) { return cut.isDecisionPredicateInAntecendet() ? HIDE_LEFT_TACLET : HIDE_RIGHT_TACLET; } - private SequentFormula getSequentFormula(Goal goal, boolean decPredInAnte) { + private Term getTerm(Goal goal, boolean decPredInAnte) { return decPredInAnte ? goal.sequent().antecedent().get(DEC_PRED_INDEX) : goal.sequent().succedent().get(DEC_PRED_INDEX); @@ -390,7 +390,7 @@ private PosInOccurrence translate(NodeGoalPair pair, TermServices services) { } int formulaNumber = pair.node.sequent().formulaNumberInSequent(oldRuleApp.posInOccurrence().isInAntec(), - oldRuleApp.posInOccurrence().sequentFormula()); + oldRuleApp.posInOccurrence().sequentLevelFormula()); return PosInOccurrence.findInSequent(pair.goal.sequent(), formulaNumber, oldRuleApp.posInOccurrence().posInTerm()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java index 4c089e3a4b5..0b2c712662f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/init/ProblemInitializer.java @@ -17,7 +17,6 @@ import de.uka.ilkd.key.ldt.HeapLDT; import de.uka.ilkd.key.logic.Namespace; import de.uka.ilkd.key.logic.NamespaceSet; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.OriginTermLabelFactory; import de.uka.ilkd.key.logic.op.*; @@ -377,8 +376,8 @@ private void populateNamespaces(Term term, NamespaceSet namespaces, Goal rootGoa private void populateNamespaces(Proof proof) { final NamespaceSet namespaces = proof.getNamespaces(); final Goal rootGoal = proof.openGoals().head(); - for (SequentFormula cf : proof.root().sequent()) { - populateNamespaces(cf.formula(), namespaces, rootGoal); + for (Term cf : proof.root().sequent()) { + populateNamespaces(cf, namespaces, rootGoal); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java index b40ef0409c1..7992e507085 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/IntermediateProofReplayer.java @@ -495,7 +495,7 @@ private TacletApp constructTacletApp(TacletAppIntermediate currInterm, Goal curr NamespaceSet nss = currGoal.getLocalNamespaces(); Term term = parseTerm(ifFormulaStr, proof, nss.variables(), nss.programVariables(), nss.functions()); - ifFormulaList = ifFormulaList.append(new IfFormulaInstDirect(new SequentFormula(term))); + ifFormulaList = ifFormulaList.append(new IfFormulaInstDirect(term)); } if (!ourApp.ifInstsCorrectSize(ifFormulaList)) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/io/OutputStreamProofSaver.java b/key.core/src/main/java/de/uka/ilkd/key/proof/io/OutputStreamProofSaver.java index 9bfd785e9e4..cf4e70129e7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/io/OutputStreamProofSaver.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/io/OutputStreamProofSaver.java @@ -172,8 +172,8 @@ public void save(OutputStream out) throws IOException { strategyProperties.put(StrategyProperties.INF_FLOW_CHECK_PROPERTY, StrategyProperties.INF_FLOW_CHECK_TRUE); strategySettings.setActiveStrategyProperties(strategyProperties); - for (final SequentFormula s : proof.root().sequent().succedent().asList()) { - ((InfFlowProof) proof).addLabeledTotalTerm(s.formula()); + for (final Term s : proof.root().sequent().succedent().asList()) { + ((InfFlowProof) proof).addLabeledTotalTerm(s); } } else { strategyProperties.put(StrategyProperties.INF_FLOW_CHECK_PROPERTY, @@ -694,7 +694,8 @@ public static String posInOccurrence2Proof(Sequent seq, PosInOccurrence pos) { if (pos == null) { return ""; } - return " (formula \"" + seq.formulaNumberInSequent(pos.isInAntec(), pos.sequentFormula()) + return " (formula \"" + + seq.formulaNumberInSequent(pos.isInAntec(), pos.sequentLevelFormula()) + "\")" + posInTerm2Proof(pos.posInTerm()); } @@ -754,15 +755,16 @@ public String ifFormulaInsts(Node node, ImmutableList l) StringBuilder s = new StringBuilder(); for (final IfFormulaInstantiation aL : l) { if (aL instanceof IfFormulaInstSeq) { - final SequentFormula f = aL.getConstrainedFormula(); + final Term f = aL.getConstrainedFormula(); s.append(" (ifseqformula \"") .append(node.sequent() .formulaNumberInSequent(((IfFormulaInstSeq) aL).inAntec(), f)) .append("\")"); } else if (aL instanceof IfFormulaInstDirect) { + Term fml = aL.getConstrainedFormula(); final String directInstantiation = - printTerm(aL.getConstrainedFormula().formula(), node.proof().getServices()); + printTerm(fml, node.proof().getServices()); s.append(" (ifdirectformula \"").append(escapeCharacters(directInstantiation)) .append("\")"); diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinIsApplicable.java b/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinIsApplicable.java index 2568f3fe8cd..072a2aa0474 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinIsApplicable.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinIsApplicable.java @@ -7,7 +7,6 @@ import java.util.List; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.op.UpdateApplication; @@ -87,8 +86,8 @@ private ProspectivePartner areProspectivePartners(Goal g1, PosInOccurrence pio, referenceFormula.op() instanceof UpdateApplication ? referenceFormula.sub(1) : referenceFormula; - for (SequentFormula sf : g2.sequent().succedent()) { - Term formula = sf.formula(); + for (Term sf : g2.sequent().succedent()) { + Term formula = sf; Term update2 = tb.skip(); if (formula.op() instanceof UpdateApplication && !formula.equalsModProperty(referenceFormula, RENAMING_PROPERTY)) { @@ -98,7 +97,8 @@ private ProspectivePartner areProspectivePartners(Goal g1, PosInOccurrence pio, } if (formula.equalsModProperty(referenceFormula, RENAMING_PROPERTY)) { - return new ProspectivePartner(referenceFormula, g1.node(), pio.sequentFormula(), + return new ProspectivePartner(referenceFormula, g1.node(), + pio.sequentLevelFormula(), update1, g2.node(), sf, update2); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinProcessor.java b/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinProcessor.java index 48bf81f8d66..8f8429f1d06 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinProcessor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/join/JoinProcessor.java @@ -115,15 +115,15 @@ private void processJoin() { } private void orRight(Goal goal) { - SequentFormula sf = goal.sequent().succedent().get(0); + Term sf = goal.sequent().succedent().get(0); PosInOccurrence pio = new PosInOccurrence(sf, PosInTerm.getTopLevel(), false); apply(new String[] { OR_RIGHT_TACLET }, goal, pio); } - private SequentFormula findFormula(Sequent sequent, Term content, boolean antecedent) { - for (SequentFormula sf : (antecedent ? sequent.antecedent() : sequent.succedent())) { - if (sf.formula().equals(content)) { + private Term findFormula(Sequent sequent, Term content, boolean antecedent) { + for (Term sf : (antecedent ? sequent.antecedent() : sequent.succedent())) { + if (sf.equals(content)) { return sf; } } @@ -132,7 +132,7 @@ private SequentFormula findFormula(Sequent sequent, Term content, boolean antece private Goal simplifyUpdate(Goal goal, DelayedCut cut) { - SequentFormula sf = findFormula(goal.sequent(), cut.getFormula(), false); + Term sf = findFormula(goal.sequent(), cut.getFormula(), false); PosInOccurrence pio = new PosInOccurrence(sf, PosInTerm.getTopLevel().down(0), false); Goal result = apply(SIMPLIFY_UPDATE, goal, pio).head(); @@ -203,10 +203,12 @@ private Term createPhi() { partner.getSequent(1).succedent(), partner.getCommonFormula()); Collection commonGamma = computeCommonFormulas(partner.getSequent(0).antecedent(), partner.getSequent(1).antecedent(), partner.getCommonFormula()); + Term partnerFormula = partner.getFormula(0); Collection delta1 = computeDifference(partner.getSequent(0).succedent(), commonDelta, - partner.getFormula(0).formula()); + partnerFormula); + Term formula = partner.getFormula(1); Collection delta2 = computeDifference(partner.getSequent(1).succedent(), commonDelta, - partner.getFormula(1).formula()); + formula); Collection gamma1 = computeDifference(partner.getSequent(0).antecedent(), commonGamma, null); @@ -262,9 +264,9 @@ private Collection createConstrainedTerms(Collection terms, Term pre private Collection computeCommonFormulas(Semisequent s1, Semisequent s2, Term exclude) { TreeSet formulas1 = createTree(s1, exclude); TreeSet result = createTree(); - for (SequentFormula sf : s2) { - if (formulas1.contains(sf.formula())) { - result.add(sf.formula()); + for (Term sf : s2) { + if (formulas1.contains(sf)) { + result.add(sf); } } return result; @@ -273,9 +275,11 @@ private Collection computeCommonFormulas(Semisequent s1, Semisequent s2, T private Collection computeDifference(Semisequent s, Collection excludeSet, Term exclude) { LinkedList result = new LinkedList<>(); - for (SequentFormula sf : s) { - if (sf.formula() != exclude && !excludeSet.contains(sf.formula())) { - result.add(sf.formula()); + for (Term sf : s) { + if (sf != exclude) { + if (!excludeSet.contains(sf)) { + result.add(sf); + } } } return result; @@ -283,9 +287,9 @@ private Collection computeDifference(Semisequent s, Collection exclu private TreeSet createTree(Semisequent semisequent, Term exclude) { TreeSet set = createTree(); - for (SequentFormula sf : semisequent) { - if (sf.formula() != exclude) { - set.add(sf.formula()); + for (Term sf : semisequent) { + if (sf != exclude) { + set.add(sf); } } return set; diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/join/LateApplicationCheck.java b/key.core/src/main/java/de/uka/ilkd/key/proof/join/LateApplicationCheck.java index 1b9db61523b..076c8782067 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/join/LateApplicationCheck.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/join/LateApplicationCheck.java @@ -7,7 +7,7 @@ import java.util.List; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.delayedcut.ApplicationCheck; @@ -27,8 +27,8 @@ public List check(Node node, Node cutNode, ApplicationCheck check) { private List check(ApplicationCheck check, Sequent sequent, Node cutNode) { List conflicts = new LinkedList<>(); - for (SequentFormula sf : sequent) { - String result = check.check(cutNode, sf.formula()); + for (Term sf : sequent) { + String result = check.check(cutNode, sf); if (result != null) { conflicts.add(result); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/join/ProspectivePartner.java b/key.core/src/main/java/de/uka/ilkd/key/proof/join/ProspectivePartner.java index f7a26bc2dce..4d54f573f9f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/join/ProspectivePartner.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/join/ProspectivePartner.java @@ -4,7 +4,6 @@ package de.uka.ilkd.key.proof.join; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Node; @@ -16,11 +15,11 @@ public class ProspectivePartner { private final Term[] updates = new Term[2]; private final Term commonFormula; - private final SequentFormula[] formula = new SequentFormula[2]; + private final Term[] formula = new Term[2]; private final Node[] nodes = new Node[2]; private Term commonPredicate = null; private Node commonParent = null; - private SequentFormula formulaForHiding = null; + private Term formulaForHiding = null; /** * Constructs a new prospective partner object, i.e. a structure comprising the information @@ -35,8 +34,8 @@ public class ProspectivePartner { * @param formula2 The second join formula. * @param update2 The second symbolic state. */ - public ProspectivePartner(Term commonFormula, Node node1, SequentFormula formula1, Term update1, - Node node2, SequentFormula formula2, Term update2) { + public ProspectivePartner(Term commonFormula, Node node1, Term formula1, Term update1, + Node node2, Term formula2, Term update2) { super(); this.commonFormula = commonFormula; formula[0] = formula1; @@ -72,15 +71,15 @@ public void setCommonParent(Node commonParent) { if (commonParent.getAppliedRuleApp() != null && commonParent.getAppliedRuleApp().posInOccurrence() != null) { setFormulaForHiding( - commonParent.getAppliedRuleApp().posInOccurrence().sequentFormula()); + commonParent.getAppliedRuleApp().posInOccurrence().sequentLevelFormula()); } } - private void setFormulaForHiding(SequentFormula formulaForHiding) { + private void setFormulaForHiding(Term formulaForHiding) { this.formulaForHiding = formulaForHiding; } - public SequentFormula getFormulaForHiding() { + public Term getFormulaForHiding() { return formulaForHiding; } @@ -92,7 +91,7 @@ public Sequent getSequent(int index) { return getNode(index).sequent(); } - public SequentFormula getFormula(int i) { + public Term getFormula(int i) { return formula[i]; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/SpecificationRepository.java b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/SpecificationRepository.java index 396590b0fc6..a11a6d47007 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/SpecificationRepository.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/mgt/SpecificationRepository.java @@ -189,7 +189,8 @@ private static Taclet getUnlimitedToLimitedTaclet(IObserverFunction limited, // create taclet final RewriteTacletBuilder tacletBuilder = new RewriteTacletBuilder<>(); tacletBuilder.setFind(tb.func(unlimited, subs)); - final SequentFormula cf = new SequentFormula(tb.equals(limitedTerm, unlimitedTerm)); + Term uAssumptions = tb.equals(limitedTerm, unlimitedTerm); + final Term cf = uAssumptions; final Sequent addedSeq = Sequent.createAnteSequent(Semisequent.EMPTY_SEMISEQUENT.insertFirst(cf).semisequent()); tacletBuilder.addTacletGoalTemplate(new RewriteTacletGoalTemplate(addedSeq, diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/proofevent/NodeReplacement.java b/key.core/src/main/java/de/uka/ilkd/key/proof/proofevent/NodeReplacement.java index 46f9447818b..6d1c9f0b213 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/proofevent/NodeReplacement.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/proofevent/NodeReplacement.java @@ -12,7 +12,7 @@ import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; import de.uka.ilkd.key.logic.SequentChangeInfo; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Node; import org.key_project.util.collection.ImmutableList; @@ -55,7 +55,7 @@ private void addNodeChanges() { } private void addNodeChange(SequentChangeInfo p_sci) { - Iterator it; + Iterator it; Iterator it2; // --- @@ -72,13 +72,13 @@ private void addNodeChange(SequentChangeInfo p_sci) { // Information about modified formulas is currently not used it2 = p_sci.modifiedFormulas(true).iterator(); while (it2.hasNext()) { - addRemovedChange(it2.next().positionOfModification().sequentFormula(), true); + addRemovedChange(it2.next().positionOfModification().sequentLevelFormula(), true); } // Information about modified formulas is currently not used it2 = p_sci.modifiedFormulas(false).iterator(); while (it2.hasNext()) { - addRemovedChange(it2.next().positionOfModification().sequentFormula(), false); + addRemovedChange(it2.next().positionOfModification().sequentLevelFormula(), false); } it = p_sci.addedFormulas(true).iterator(); @@ -119,7 +119,7 @@ private void addNodeChange(SequentChangeInfo p_sci) { } - private void addAddedChange(SequentFormula p_cf, boolean p_inAntec) { + private void addAddedChange(Term p_cf, boolean p_inAntec) { Sequent oldS = parent.sequent(); Semisequent oldSS = (p_inAntec ? oldS.antecedent() : oldS.succedent()); Sequent newS = node.sequent(); @@ -140,7 +140,7 @@ private void addAddedChange(SequentFormula p_cf, boolean p_inAntec) { * @param p_cf * @param p_inAntec */ - private void addAddedRedundantChange(SequentFormula p_cf, boolean p_inAntec) { + private void addAddedRedundantChange(Term p_cf, boolean p_inAntec) { final PosInOccurrence pio = new PosInOccurrence(p_cf, PosInTerm.getTopLevel(), p_inAntec); addNodeChange(new NodeRedundantAddChange(pio)); @@ -149,7 +149,7 @@ private void addAddedRedundantChange(SequentFormula p_cf, boolean p_inAntec) { - private void addRemovedChange(SequentFormula p_cf, boolean p_inAntec) { + private void addRemovedChange(Term p_cf, boolean p_inAntec) { Sequent oldS = parent.sequent(); Semisequent oldSS = (p_inAntec ? oldS.antecedent() : oldS.succedent()); @@ -165,7 +165,7 @@ private void addNodeChange(NodeChange p_nc) { changes = changes.prepend(p_nc); } - private void removeNodeChanges(SequentFormula p_cf, boolean p_inAntec) { + private void removeNodeChanges(Term p_cf, boolean p_inAntec) { Iterator it = changes.iterator(); changes = ImmutableSLList.nil(); NodeChange oldNC; @@ -176,7 +176,7 @@ private void removeNodeChanges(SequentFormula p_cf, boolean p_inAntec) { if (oldNC instanceof NodeChangeARFormula) { oldPio = oldNC.getPos(); - if (oldPio.isInAntec() == p_inAntec && oldPio.sequentFormula().equals(p_cf)) { + if (oldPio.isInAntec() == p_inAntec && oldPio.sequentLevelFormula().equals(p_cf)) { continue; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/replay/AbstractProofReplayer.java b/key.core/src/main/java/de/uka/ilkd/key/proof/replay/AbstractProofReplayer.java index 48538a003f3..278b897a38b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/replay/AbstractProofReplayer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/replay/AbstractProofReplayer.java @@ -14,8 +14,8 @@ import de.uka.ilkd.key.logic.PosInTerm; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Node; @@ -304,10 +304,10 @@ private TacletApp constructTacletApp(Node originalStep, Goal currGoal) { if (oldFormulaPioSpec.second) { ifFormulaList = ifFormulaList.append( new IfFormulaInstSeq(currGoal.sequent(), oldFormulaPio.isInAntec(), - newPio.sequentFormula())); + newPio.sequentLevelFormula())); } else { ifFormulaList = ifFormulaList.append( - new IfFormulaInstDirect(newPio.sequentFormula())); + new IfFormulaInstDirect(newPio.sequentLevelFormula())); } } @@ -333,11 +333,12 @@ private TacletApp constructTacletApp(Node originalStep, Goal currGoal) { * @return the formula in the sequent, or null if not found */ private PosInOccurrence findInNewSequent(PosInOccurrence oldPos, Sequent newSequent) { - SequentFormula oldFormula = oldPos.sequentFormula(); + Term oldFormula = oldPos.sequentLevelFormula(); Semisequent semiSeq = oldPos.isInAntec() ? newSequent.antecedent() : newSequent.succedent(); - for (SequentFormula newFormula : semiSeq.asList()) { - if (newFormula.equalsModProofIrrelevancy(oldFormula)) { + for (Term newFormula : semiSeq.asList()) { + if (newFormula.equalsModProperty(oldFormula, + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY)) { return oldPos.replaceConstrainedFormula(newFormula); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/prover/impl/ApplyStrategy.java b/key.core/src/main/java/de/uka/ilkd/key/prover/impl/ApplyStrategy.java index 05b6f74d9dd..5d69be261c3 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/prover/impl/ApplyStrategy.java +++ b/key.core/src/main/java/de/uka/ilkd/key/prover/impl/ApplyStrategy.java @@ -267,9 +267,9 @@ private ProofTreeListener prepareStrategy(Proof proof, ImmutableList goals ProofTreeListener treeListener = new ProofTreeAdapter() { @Override public void proofGoalsAdded(ProofTreeEvent e) { - ImmutableList newGoals = e.getGoals(); + Iterable newGoals = e.getGoals(); // Check for a closed goal ... - if (newGoals.size() == 0) { + if (!newGoals.iterator().hasNext()) { // No new goals have been generated ... closedGoals++; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBlockContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBlockContractRule.java index 69078b2e908..e0d749cd175 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBlockContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBlockContractRule.java @@ -24,7 +24,6 @@ import de.uka.ilkd.key.java.statement.JavaStatement; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.ProgramElementName; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -294,7 +293,7 @@ protected static Term buildInfFlowPostAssumption(ProofObligationVars instVars, return afterAssumptions; } - static SequentFormula buildBodyPreservesSequent(InfFlowPOSnippetFactory f, InfFlowProof proof) { + static Term buildBodyPreservesSequent(InfFlowPOSnippetFactory f, InfFlowProof proof) { Term selfComposedExec = f.create(InfFlowPOSnippetFactory.Snippet.SELFCOMPOSED_BLOCK_WITH_PRE_RELATION); Term post = f.create(InfFlowPOSnippetFactory.Snippet.INF_FLOW_INPUT_OUTPUT_RELATION); @@ -304,7 +303,7 @@ static SequentFormula buildBodyPreservesSequent(InfFlowPOSnippetFactory f, InfFl tb.imp(tb.label(selfComposedExec, ParameterlessTermLabel.SELF_COMPOSITION_LABEL), post); proof.addLabeledIFSymbol(selfComposedExec); - return new SequentFormula(finalTerm); + return finalTerm; } private static ProofObligationVars generateProofObligationVariables( @@ -347,7 +346,7 @@ private static void addProofObligation(final Goal infFlowGoal, final InfFlowProo InfFlowPOSnippetFactory infFlowFactory = POSnippetFactory.getInfFlowFactory(contract, ifVars.c1, ifVars.c2, ec, services); - final SequentFormula poFormula = buildBodyPreservesSequent(infFlowFactory, proof); + final Term poFormula = buildBodyPreservesSequent(infFlowFactory, proof); // add proof obligation to goal infFlowGoal.addFormula(poFormula, false, true); @@ -399,7 +398,7 @@ protected void setUpInfFlowPartOfUsageGoal(final Goal usageGoal, tb.applySequential(new Term[] { contextUpdate, remembranceUpdate }, tb.and(infFlowValitidyData.preAssumption, tb.apply(anonymisationUpdate, infFlowValitidyData.postAssumption))); - usageGoal.addFormula(new SequentFormula(uAssumptions), true, false); + usageGoal.addFormula(uAssumptions, true, false); } protected InfFlowValidityData setUpInfFlowValidityGoal(final Goal infFlowGoal, diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java index cc0f21552f8..7b58514ee7b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/AbstractBuiltInRuleApp.java @@ -9,6 +9,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.logic.op.LocationVariable; import de.uka.ilkd.key.proof.Goal; @@ -55,7 +56,7 @@ public BuiltInRule rule() { } /** - * returns the PositionInOccurrence (representing a SequentFormula and a position in the + * returns the PositionInOccurrence (representing a Term and a position in the * corresponding formula) of this rule application */ @Override @@ -171,7 +172,8 @@ public boolean equalsModProofIrrelevancy(Object obj) { @Override public int hashCodeModProofIrrelevancy() { return Objects.hash(rule(), getHeapContext(), - posInOccurrence().sequentFormula().hashCodeModProofIrrelevancy(), + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .hashCodeModThisProperty(posInOccurrence().sequentLevelFormula()), posInOccurrence().posInTerm()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/AuxiliaryContractBuilders.java b/key.core/src/main/java/de/uka/ilkd/key/rule/AuxiliaryContractBuilders.java index f9a3830a721..794b40aff16 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/AuxiliaryContractBuilders.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/AuxiliaryContractBuilders.java @@ -1354,7 +1354,7 @@ public Term setUpWdGoal(final Goal goal, final BlockContract contract, final Ter services.getSpecificationRepository().addWdStatement(bwd); final LocationVariable heapAtPre = variables.remembranceHeaps.get(heap); final Term anon = anonHeap != null ? services.getTermBuilder().func(anonHeap) : null; - final SequentFormula wdBlock = bwd.generateSequent(variables.self, variables.exception, + final Term wdBlock = bwd.generateSequent(variables.self, variables.exception, variables.result, heap, heapAtPre, anon, localIns, update, anonUpdate, services); if (goal != null) { @@ -1362,7 +1362,7 @@ public Term setUpWdGoal(final Goal goal, final BlockContract contract, final Ter goal.changeFormula(wdBlock, occurrence); } - return wdBlock.formula(); + return wdBlock; } /** @@ -1393,8 +1393,9 @@ public Term setUpValidityGoal(final Goal goal, final Term[] updates, Term term; if (goal != null) { + Term uAssumptions = tb.applySequential(updates, tb.and(assumptions)); goal.addFormula( - new SequentFormula(tb.applySequential(updates, tb.and(assumptions))), true, + uAssumptions, true, false); ImmutableArray labels = TermLabelManager.instantiateLabels( @@ -1407,7 +1408,7 @@ public Term setUpValidityGoal(final Goal goal, final Term[] updates, term = tb.applySequential(updates, tb.prog(instantiation.modality().kind(), newJavaBlock, newPost, labels)); - goal.changeFormula(new SequentFormula(term), occurrence); + goal.changeFormula(term, occurrence); TermLabelManager.refactorGoal(termLabelState, services, occurrence, application.rule(), goal, null, null); addInfFlow(goal); @@ -1511,7 +1512,7 @@ public Term setUpLoopValidityGoal(final Goal goal, final LoopContract contract, if (goal != null) { goal.setBranchLabel("Validity"); addInfFlow(goal); - goal.changeFormula(new SequentFormula(term), occurrence); + goal.changeFormula(term, occurrence); } return term; } @@ -1531,7 +1532,7 @@ public void setUpPreconditionGoal(final Goal goal, final Term update, fullPrecondition = TermLabelManager.refactorTerm(termLabelState, services, null, fullPrecondition, rule, goal, BlockContractInternalRule.FULL_PRECONDITION_TERM_HINT, null); - goal.changeFormula(new SequentFormula(fullPrecondition), occurrence); + goal.changeFormula(fullPrecondition, occurrence); TermLabelManager.refactorGoal(termLabelState, services, occurrence, application.rule(), goal, null, null); } @@ -1548,9 +1549,10 @@ public void setUpUsageGoal(final Goal goal, final Term[] updates, final TermBuilder tb = services.getTermBuilder(); goal.setBranchLabel("Usage"); Term uAssumptions = tb.applySequential(updates, tb.and(assumptions)); - goal.addFormula(new SequentFormula(uAssumptions), true, false); + goal.addFormula(uAssumptions, true, false); + Term uAssumptions1 = tb.applySequential(updates, buildUsageFormula(goal)); goal.changeFormula( - new SequentFormula(tb.applySequential(updates, buildUsageFormula(goal))), + uAssumptions1, occurrence); TermLabelManager.refactorGoal(termLabelState, services, occurrence, application.rule(), goal, null, null); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java index a37634a71cb..38daf66ab23 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BlockContractInternalRule.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -355,7 +354,8 @@ private void setUpValidityGoal(final ImmutableList result, final boolean i updates[1], updates[2], tb); } else { // nothing to prove -> set up trivial goal - validityGoal.addFormula(new SequentFormula(tb.tt()), false, true); + Term uAssumptions = tb.tt(); + validityGoal.addFormula(uAssumptions, false, true); } } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/BoundUniquenessChecker.java b/key.core/src/main/java/de/uka/ilkd/key/rule/BoundUniquenessChecker.java index 5b20688062a..d25d73c54c2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/BoundUniquenessChecker.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/BoundUniquenessChecker.java @@ -7,7 +7,6 @@ import java.util.LinkedHashSet; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.QuantifiableVariable; @@ -52,8 +51,8 @@ public void addTerm(Term term) { * @param seq the Sequent with the formulas to add */ public void addAll(Sequent seq) { - for (final SequentFormula cf : seq) { - terms = terms.prepend(cf.formula()); + for (final Term cf : seq) { + terms = terms.prepend(cf); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstDirect.java b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstDirect.java index 710c9da1949..dc9fcca4607 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstDirect.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstDirect.java @@ -4,7 +4,7 @@ package de.uka.ilkd.key.rule; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.io.ProofSaver; @@ -17,16 +17,16 @@ public class IfFormulaInstDirect implements IfFormulaInstantiation { /** * Simply the formula */ - private final SequentFormula cf; + private final Term cf; - public IfFormulaInstDirect(SequentFormula p_cf) { + public IfFormulaInstDirect(Term p_cf) { cf = p_cf; } /** * @return the cf this is pointing to */ - public SequentFormula getConstrainedFormula() { + public Term getConstrainedFormula() { return cf; } @@ -48,6 +48,6 @@ public int hashCode() { } public String toString(Services services) { - return ProofSaver.printAnything(cf.formula(), services); + return ProofSaver.printAnything(cf, services); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstSeq.java b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstSeq.java index d70b9e1a529..c082aa270b2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstSeq.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstSeq.java @@ -4,11 +4,7 @@ package de.uka.ilkd.key.rule; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.proof.io.OutputStreamProofSaver; import org.key_project.util.collection.ImmutableArray; @@ -25,9 +21,9 @@ public class IfFormulaInstSeq implements IfFormulaInstantiation { */ private final Sequent seq; private final boolean antec; // formula is in antecedent? - private final SequentFormula cf; + private final Term cf; - public IfFormulaInstSeq(Sequent p_seq, boolean antec, SequentFormula p_cf) { + public IfFormulaInstSeq(Sequent p_seq, boolean antec, Term p_cf) { seq = p_seq; this.antec = antec; cf = p_cf; @@ -43,7 +39,7 @@ public IfFormulaInstSeq(Sequent seq, int formulaNr) { * @return the cf this is pointing to */ @Override - public SequentFormula getConstrainedFormula() { + public Term getConstrainedFormula() { return cf; } @@ -93,7 +89,7 @@ public String toString() { @Override public String toString(Services services) { - return OutputStreamProofSaver.printAnything(cf.formula(), services); + return OutputStreamProofSaver.printAnything(cf, services); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstantiation.java b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstantiation.java index 9abb3fc3b5a..a7ab7433c88 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstantiation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/IfFormulaInstantiation.java @@ -4,7 +4,8 @@ package de.uka.ilkd.key.rule; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import org.key_project.util.EqualsModProofIrrelevancy; @@ -18,7 +19,7 @@ public interface IfFormulaInstantiation extends EqualsModProofIrrelevancy { /** * @return the cf this is pointing to */ - SequentFormula getConstrainedFormula(); + Term getConstrainedFormula(); String toString(Services services); @@ -27,11 +28,13 @@ default boolean equalsModProofIrrelevancy(Object obj) { if (!(obj instanceof IfFormulaInstantiation that)) { return false; } - return getConstrainedFormula().equalsModProofIrrelevancy(that.getConstrainedFormula()); + return getConstrainedFormula().equalsModProperty(that.getConstrainedFormula(), + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY); } @Override default int hashCodeModProofIrrelevancy() { - return getConstrainedFormula().hashCodeModProofIrrelevancy(); + return getConstrainedFormula() + .hashCodeModProperty(ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java index 87b9131b154..b3f641c0a87 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/JmlAssertRule.java @@ -158,7 +158,8 @@ public IBuiltInRuleApp createApp(PosInOccurrence occurrence, TermServices servic private void setUpValidityRule(Goal goal, PosInOccurrence occurrence, Term update, Term condition, TermBuilder tb) { goal.setBranchLabel("Validity"); - goal.changeFormula(new SequentFormula(tb.apply(update, condition)), occurrence); + Term uAssumptions = tb.apply(update, condition); + goal.changeFormula(uAssumptions, occurrence); } private void setUpUsageGoal(Goal goal, PosInOccurrence occurrence, Term update, Term target, @@ -169,7 +170,7 @@ private void setUpUsageGoal(Goal goal, PosInOccurrence occurrence, Term update, tb.imp(condition, tb.prog(((Modality) target.op()).kind(), javaBlock, target.sub(0), null))); - goal.changeFormula(new SequentFormula(newTerm), occurrence); + goal.changeFormula(newTerm, occurrence); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java index c2ed88a8cde..728bb34a756 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopApplyHeadRule.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.visitor.ProgramElementReplacer; import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -96,9 +95,9 @@ public class LoopApplyHeadRule implements BuiltInRule { } Goal result = goal.split(1).head(); + Term uAssumptions = tb.apply(update, tb.prog(modality.kind(), newJavaBlock, target.sub(0))); result.changeFormula( - new SequentFormula( - tb.apply(update, tb.prog(modality.kind(), newJavaBlock, target.sub(0)))), + uAssumptions, ruleApp.pio); return ImmutableSLList.nil().append(goal); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java index 3ae2aaed6cb..1e35409edc0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/LoopScopeInvariantRule.java @@ -21,7 +21,6 @@ import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.ProgramPrefix; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.label.ParameterlessTermLabel; @@ -240,9 +239,9 @@ private void constructPresrvAndUCGoal(Services services, RuleApp ruleApp, Goal p uBeforeLoopDefAnonVariant, invTerm); presrvAndUCGoal.setBranchLabel("Invariant Preserved and Used"); - presrvAndUCGoal.addFormula(new SequentFormula(uAnonInv), true, false); - presrvAndUCGoal.addFormula(new SequentFormula(wellFormedAnon), true, false); - presrvAndUCGoal.changeFormula(new SequentFormula(newFormula), ruleApp.posInOccurrence()); + presrvAndUCGoal.addFormula(uAnonInv, true, false); + presrvAndUCGoal.addFormula(wellFormedAnon, true, false); + presrvAndUCGoal.changeFormula(newFormula, ruleApp.posInOccurrence()); } // ------------------------------------------------------------------------- @@ -323,7 +322,7 @@ private ProgramElement newProgram(Services services, final While loop, } /** - * Creates the {@link SequentFormula} for the "initially valid" goal. + * Creates the {@link Term} for the "initially valid" goal. * * @param termLabelState The {@link TermLabelState}. * @param inst The {@link Instantiation} for this rule application. @@ -331,9 +330,9 @@ private ProgramElement newProgram(Services services, final While loop, * @param reachableState The reachable state formula. * @param services The {@link Services} object. * @param initGoal The goal containing the "initially valid" PO. - * @return The {@link SequentFormula} for the "initially valid" goal. + * @return The {@link Term} for the "initially valid" goal. */ - private SequentFormula initFormula(TermLabelState termLabelState, Instantiation inst, + private Term initFormula(TermLabelState termLabelState, Instantiation inst, final Term invTerm, Term reachableState, Services services, Goal initGoal) { final TermBuilder tb = services.getTermBuilder(); @@ -341,7 +340,7 @@ private SequentFormula initFormula(TermLabelState termLabelState, Instantiation sfTerm = TermLabelManager.refactorTerm(termLabelState, services, null, sfTerm, this, initGoal, INITIAL_INVARIANT_ONLY_HINT, null); - return new SequentFormula(sfTerm); + return sfTerm; } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/NoPosTacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/NoPosTacletApp.java index 2b6434e380e..df86c6ca0c0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/NoPosTacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/NoPosTacletApp.java @@ -282,7 +282,7 @@ protected ImmutableSet contextVars(SchemaVariable sv) { /** - * returns the PositionInOccurrence (representing a SequentFormula and a position in the + * returns the PositionInOccurrence (representing a Term and a position in the * corresponding formula) * * @return the PosInOccurrence diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/ObserverToUpdateRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/ObserverToUpdateRule.java index cc891e61ce6..420e20450d0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/ObserverToUpdateRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/ObserverToUpdateRule.java @@ -18,7 +18,6 @@ import de.uka.ilkd.key.java.reference.TypeReference; import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -194,8 +193,9 @@ private ImmutableList applyForModelFields(Goal goal, ModelFieldInstantiati // ---- create "Null Reference" branch if (nullGoal != null) { final Term actualSelfNotNull = tb.not(tb.equals(inst.receiver, tb.NULL())); + Term uAssumptions = tb.apply(inst.update, actualSelfNotNull, null); nullGoal.changeFormula( - new SequentFormula(tb.apply(inst.update, actualSelfNotNull, null)), + uAssumptions, ruleApp.posInOccurrence()); } @@ -215,7 +215,8 @@ private ImmutableList applyForModelFields(Goal goal, ModelFieldInstantiati Term update = tb.elementary(lhs, makeCall(services, inst.observerSymbol, inst.receiver, ImmutableList.of())); Term normalPost = tb.apply(update, modTerm); - contGoal.changeFormula(new SequentFormula(tb.apply(inst.update, normalPost, null)), + Term uAssumptions = tb.apply(inst.update, normalPost, null); + contGoal.changeFormula(uAssumptions, ruleApp.posInOccurrence()); TermLabelManager.refactorGoal(termLabelState, services, ruleApp.posInOccurrence(), this, @@ -255,7 +256,8 @@ private ImmutableList applyForMethods(Goal goal, Instantiation inst, Servi // ---- create "Null Reference" branch if (nullGoal != null) { final Term actualSelfNotNull = tb.not(tb.equals(inst.actualSelf, tb.NULL())); - nullGoal.changeFormula(new SequentFormula(tb.apply(inst.u, actualSelfNotNull, null)), + Term uAssumptions = tb.apply(inst.u, actualSelfNotNull, null); + nullGoal.changeFormula(uAssumptions, ruleApp.posInOccurrence()); } @@ -273,7 +275,8 @@ private ImmutableList applyForMethods(Goal goal, Instantiation inst, Servi Term update = tb.elementary(lhs, makeCall(services, inst.pm, inst.actualSelf, inst.actualParams)); Term normalPost = tb.apply(update, modTerm); - contGoal.changeFormula(new SequentFormula(tb.apply(inst.u, normalPost, null)), + Term uAssumptions = tb.apply(inst.u, normalPost, null); + contGoal.changeFormula(uAssumptions, ruleApp.posInOccurrence()); TermLabelManager.refactorGoal(termLabelState, services, ruleApp.posInOccurrence(), this, diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java index feec9a03cae..19d726d810b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/OneStepSimplifier.java @@ -15,7 +15,6 @@ import de.uka.ilkd.key.logic.PosInTerm; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.logic.label.TermLabel; @@ -83,7 +82,7 @@ public static final class Protocol extends ArrayList { .append("update_apply").append("update_join").append("elimQuantifier"); private static final boolean[] bottomUp = { false, false, true, true, true, false }; - private final Map applicabilityCache = + private final Map applicabilityCache = new LRUCache<>(APPLICABILITY_CACHE_SIZE); private Proof lastProof; @@ -241,7 +240,7 @@ public boolean isShutdown() { * * @param protocol */ - private SequentFormula simplifyPos(Goal goal, Services services, PosInOccurrence pos, + private Term simplifyPos(Goal goal, Services services, PosInOccurrence pos, int indexNr, Protocol protocol) { final ImmutableList apps = indices[indexNr].getRewriteTaclet(pos, TacletFilter.TRUE, services); @@ -257,13 +256,13 @@ private SequentFormula simplifyPos(Goal goal, Services services, PosInOccurrence } } RewriteTaclet taclet = (RewriteTaclet) app.rule(); - SequentFormula result = + Term result = taclet.getRewriteResult(goal, new TermLabelState(), services, app); if (protocol != null) { protocol.add(app); } return result; - // TODO Idea: return new Pair(null, null); + // TODO Idea: return new Pair(null, null); } return null; } @@ -275,10 +274,10 @@ private SequentFormula simplifyPos(Goal goal, Services services, PosInOccurrence * * @param protocol */ - private SequentFormula simplifySub(Goal goal, Services services, PosInOccurrence pos, + private Term simplifySub(Goal goal, Services services, PosInOccurrence pos, int indexNr, Protocol protocol) { for (int i = 0, n = pos.subTerm().arity(); i < n; i++) { - SequentFormula result = + Term result = simplifyPosOrSub(goal, services, pos.down(i), indexNr, protocol); if (result != null) { return result; @@ -294,14 +293,14 @@ private SequentFormula simplifySub(Goal goal, Services services, PosInOccurrence * * @param protocol */ - private SequentFormula simplifyPosOrSub(Goal goal, Services services, PosInOccurrence pos, + private Term simplifyPosOrSub(Goal goal, Services services, PosInOccurrence pos, int indexNr, Protocol protocol) { final Term term = pos.subTerm(); if (notSimplifiableCaches[indexNr].get(term) != null) { return null; } - SequentFormula result; + Term result; if (bottomUp[indexNr]) { result = simplifySub(goal, services, pos, indexNr, protocol); if (result == null) { @@ -376,20 +375,20 @@ private Term replaceKnownHelper(Map map, Te * (hardcoded here). The context formulas available for replace-known are passed in as * "context". The positions of the actually used context formulas are passed out as "ifInsts". */ - private SequentFormula replaceKnown(Services services, SequentFormula cf, boolean inAntecedent, + private Term replaceKnown(Services services, Term cf, boolean inAntecedent, Map context, /* out */ List ifInsts, Protocol protocol, Goal goal, RuleApp ruleApp) { if (context == null) { return null; } - final Term formula = cf.formula(); + final Term formula = cf; final Term simplifiedFormula = replaceKnownHelper(context, formula, inAntecedent, ifInsts, protocol, services, goal, ruleApp); if (simplifiedFormula.equals(formula)) { return null; } else { - return new SequentFormula(simplifiedFormula); + return simplifiedFormula; } } @@ -406,18 +405,18 @@ private RuleApp makeReplaceKnownTacletApp(Term formula, boolean inAntecedent, SVInstantiations svi = SVInstantiations.EMPTY_SVINSTANTIATIONS; FormulaSV sv = SchemaVariableFactory.createFormulaSV(new Name("b")); - svi.add(sv, pio.sequentFormula().formula(), lastProof.getServices()); + svi.add(sv, pio.sequentLevelFormula(), lastProof.getServices()); PosInOccurrence applicatinPIO = - new PosInOccurrence(new SequentFormula(formula), PosInTerm.getTopLevel(), // TODO: This - // should be - // the precise - // sub term + new PosInOccurrence(formula, PosInTerm.getTopLevel(), // TODO: This + // should be + // the precise + // sub term inAntecedent); // It is required to create a new PosInOccurrence because formula and // pio.constrainedFormula().formula() are only equals module // renamings and term labels ImmutableList ifInst = ImmutableSLList.nil(); - ifInst = ifInst.append(new IfFormulaInstDirect(pio.sequentFormula())); + ifInst = ifInst.append(new IfFormulaInstDirect(pio.sequentLevelFormula())); TacletApp ta = PosTacletApp.createPosTacletApp(taclet, svi, ifInst, applicatinPIO, lastProof.getServices()); return ta; @@ -429,11 +428,11 @@ private RuleApp makeReplaceKnownTacletApp(Term formula, boolean inAntecedent, * * @param protocol */ - private SequentFormula simplifyConstrainedFormula(Services services, SequentFormula cf, + private Term simplifyConstrainedFormula(Services services, Term cf, boolean inAntecedent, Map context, /* out */ List ifInsts, Protocol protocol, Goal goal, RuleApp ruleApp) { - SequentFormula result = + Term result = replaceKnown(services, cf, inAntecedent, context, ifInsts, protocol, goal, ruleApp); if (result != null) { return result; @@ -461,24 +460,28 @@ private Instantiation computeInstantiation(Services services, PosInOccurrence os // collect context formulas (potential if-insts for replace-known) final Map context = new LinkedHashMap<>(); - final SequentFormula cf = ossPIO.sequentFormula(); - for (SequentFormula ante : seq.antecedent()) { - if (!ante.equals(cf) && ante.formula().op() != Junctor.TRUE) { - context.put(new TermReplacementKey(ante.formula()), - new PosInOccurrence(ante, PosInTerm.getTopLevel(), true)); + final Term cf = ossPIO.sequentLevelFormula(); + for (Term ante : seq.antecedent()) { + if (!ante.equals(cf)) { + if (ante.op() != Junctor.TRUE) { + context.put(new TermReplacementKey(ante), + new PosInOccurrence(ante, PosInTerm.getTopLevel(), true)); + } } } - for (SequentFormula succ : seq.succedent()) { - if (!succ.equals(cf) && succ.formula().op() != Junctor.FALSE) { - context.put(new TermReplacementKey(succ.formula()), - new PosInOccurrence(succ, PosInTerm.getTopLevel(), false)); + for (Term succ : seq.succedent()) { + if (!succ.equals(cf)) { + if (succ.op() != Junctor.FALSE) { + context.put(new TermReplacementKey(succ), + new PosInOccurrence(succ, PosInTerm.getTopLevel(), false)); + } } } final List ifInsts = new ArrayList<>(seq.size()); // simplify as long as possible - ImmutableList list = ImmutableSLList.nil(); - SequentFormula simplifiedCf = cf; + ImmutableList list = ImmutableSLList.nil(); + Term simplifiedCf = cf; while (true) { simplifiedCf = simplifyConstrainedFormula(services, simplifiedCf, ossPIO.isInAntec(), context, ifInsts, protocol, goal, ruleApp); @@ -500,14 +503,14 @@ private Instantiation computeInstantiation(Services services, PosInOccurrence os /** * Tells whether the passed formula can be simplified */ - private synchronized boolean applicableTo(Services services, SequentFormula cf, + private synchronized boolean applicableTo(Services services, Term cf, boolean inAntecedent, Goal goal, RuleApp ruleApp) { final Boolean b = applicabilityCache.get(cf); if (b != null) { return b; } else { // try one simplification step without replace-known - final SequentFormula simplifiedCf = simplifyConstrainedFormula(services, cf, + final Term simplifiedCf = simplifyConstrainedFormula(services, cf, inAntecedent, null, null, null, goal, ruleApp); final boolean result = simplifiedCf != null && !simplifiedCf.equals(cf); applicabilityCache.put(cf, result); @@ -572,7 +575,8 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { } // applicable to the formula? - return applicableTo(goal.proof().getServices(), pio.sequentFormula(), pio.isInAntec(), goal, + return applicableTo(goal.proof().getServices(), pio.sequentLevelFormula(), pio.isInAntec(), + goal, null); } @@ -594,21 +598,21 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { if (((OneStepSimplifierRuleApp) ruleApp).shouldRestrictAssumeInsts() && !disableOSSRestriction) { ImmutableList ifInsts = ((OneStepSimplifierRuleApp) ruleApp).ifInsts(); - ImmutableList anteFormulas = ImmutableSLList.nil(); - ImmutableList succFormulas = ImmutableSLList.nil(); + ImmutableList anteFormulas = ImmutableSLList.nil(); + ImmutableList succFormulas = ImmutableSLList.nil(); if (ifInsts != null) { for (PosInOccurrence it : ifInsts) { if (it.isInAntec()) { - anteFormulas = anteFormulas.prepend(it.sequentFormula()); + anteFormulas = anteFormulas.prepend(it.sequentLevelFormula()); } else { - succFormulas = succFormulas.prepend(it.sequentFormula()); + succFormulas = succFormulas.prepend(it.sequentLevelFormula()); } } } if (pos.isInAntec()) { - anteFormulas = anteFormulas.prepend(pos.sequentFormula()); + anteFormulas = anteFormulas.prepend(pos.sequentLevelFormula()); } else { - succFormulas = succFormulas.prepend(pos.sequentFormula()); + succFormulas = succFormulas.prepend(pos.sequentLevelFormula()); } Semisequent antecedent = anteFormulas.isEmpty() ? Semisequent.EMPTY_SEMISEQUENT : new Semisequent(anteFormulas); @@ -673,11 +677,11 @@ public Set getCapturedTaclets() { // ------------------------------------------------------------------------- private static final class Instantiation { - private final SequentFormula cf; + private final Term cf; private final int numAppliedRules; private final ImmutableList ifInsts; - public Instantiation(SequentFormula cf, int numAppliedRules, + public Instantiation(Term cf, int numAppliedRules, ImmutableList ifInsts) { assert numAppliedRules >= 0; this.cf = cf; @@ -685,7 +689,7 @@ public Instantiation(SequentFormula cf, int numAppliedRules, this.ifInsts = ifInsts; } - public SequentFormula getCf() { + public Term getCf() { return cf; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/PosTacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/PosTacletApp.java index 6c5d92442ad..0baf6550866 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/PosTacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/PosTacletApp.java @@ -10,6 +10,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.logic.op.QuantifiableVariable; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.inst.SVInstantiations; @@ -277,7 +278,7 @@ public boolean complete() { } /** - * returns the PositionInOccurrence (representing a SequentFormula and a position in the + * returns the PositionInOccurrence (representing a Term and a position in the * corresponding formula) * * @return the PosInOccurrence @@ -319,7 +320,8 @@ public boolean equalsModProofIrrelevancy(Object o) { @Override public int hashCodeModProofIrrelevancy() { return Objects.hash(super.hashCodeModProofIrrelevancy(), - pos.sequentFormula().hashCodeModProofIrrelevancy(), + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .hashCodeModThisProperty(pos.sequentLevelFormula()), pos.posInTerm()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java index 492c155c269..3ffe39389eb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/QueryExpand.java @@ -88,7 +88,7 @@ public class QueryExpand implements BuiltInRule { tb.addRuleSet(new RuleSet(new Name("concrete"))); // move the query call directly to the succedent. Use box instead of diamond? - g.addFormula(new SequentFormula(queryEval.first), true, true); + g.addFormula(queryEval.first, true, true); g.addTaclet(tb.getTaclet(), SVInstantiations.EMPTY_SVINSTANTIATIONS, true); return newGoal; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RewriteTaclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RewriteTaclet.java index 6e506a3f31b..696e7405cf2 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RewriteTaclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RewriteTaclet.java @@ -258,7 +258,7 @@ public RewriteTacletExecutor getExecutor() { return (RewriteTacletExecutor) executor; } - public SequentFormula getRewriteResult(Goal goal, TermLabelState termLabelState, + public Term getRewriteResult(Goal goal, TermLabelState termLabelState, Services services, TacletApp app) { return getExecutor().getRewriteResult(goal, termLabelState, services, app); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java index af71ed4c8ec..09f069deb69 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Rule.java @@ -39,5 +39,7 @@ ImmutableList apply(Goal goal, Services services, RuleApp ruleApp) /** * returns the display name of the rule */ - String displayName(); + default String displayName() { + return name().toString(); + } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleAbortException.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleAbortException.java index 96e67cb4ea9..e10f101bd10 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleAbortException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleAbortException.java @@ -10,9 +10,7 @@ * This Exception signals the abort of a rule Application * */ - - -public class RuleAbortException extends Exception { +public class RuleAbortException extends RuntimeException { private static final long serialVersionUID = -645034125571021135L; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java index 8c505c74360..c55bd34bd9a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/RuleApp.java @@ -23,7 +23,7 @@ public interface RuleApp extends EqualsModProofIrrelevancy { Rule rule(); /** - * returns the PositionInOccurrence (representing a SequentFormula and a position in the + * returns the PositionInOccurrence (representing a Term and a position in the * corresponding formula) of this rule application */ PosInOccurrence posInOccurrence(); @@ -33,11 +33,10 @@ public interface RuleApp extends EqualsModProofIrrelevancy { * instantiated * * @param goal the Goal where to apply the rule - * @param services the Services encapsulating all java information * @return list of new created goals */ - @Nullable - ImmutableList execute(Goal goal, Services services); + // @Nullable + // ImmutableList execute(G goal); /** * returns true if all variables are instantiated @@ -46,6 +45,17 @@ public interface RuleApp extends EqualsModProofIrrelevancy { */ boolean complete(); + /** + * applies the specified rule at the specified position if all schema variables have been + * instantiated + * + * @param goal the Goal where to apply the rule + * @param services the Services encapsulating all java information + * @return list of new created goals + */ + @Nullable + ImmutableList execute(Goal goal, Services services); + /** * @return user-friendly name for this rule-application */ diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/SVNameCorrespondenceCollector.java b/key.core/src/main/java/de/uka/ilkd/key/rule/SVNameCorrespondenceCollector.java index b86aa18d2bf..dfe05eb9e5a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/SVNameCorrespondenceCollector.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/SVNameCorrespondenceCollector.java @@ -7,7 +7,6 @@ import de.uka.ilkd.key.logic.DefaultVisitor; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.JFunction; import de.uka.ilkd.key.logic.op.SchemaVariable; @@ -84,8 +83,8 @@ public ImmutableMap getCorrespondences() { * @param semiseq the Semisequent to visit */ private void visit(Semisequent semiseq) { - for (SequentFormula cf : semiseq) { - cf.formula().execPostOrder(this); + for (Term cf : semiseq) { + cf.execPostOrder(this); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/SetStatementRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/SetStatementRule.java index 6e29239f3eb..94082faab59 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/SetStatementRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/SetStatementRule.java @@ -113,7 +113,7 @@ public IBuiltInRuleApp createApp(PosInOccurrence occurrence, TermServices servic Term newTerm = tb.apply(update, tb.apply(newUpdate, term)); ImmutableList result = goal.split(1); - result.head().changeFormula(new SequentFormula(newTerm), occurrence); + result.head().changeFormula(newTerm, occurrence); return result; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index 5f61d57f92b..f110d474dd5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -7,6 +7,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.*; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; @@ -492,10 +493,14 @@ public boolean equalsModProofIrrelevancy(Object o) { || (ifSequent != null && t2.ifSequent == null)) { return false; } else { - ImmutableList if1 = ifSequent.asList(); - ImmutableList if2 = t2.ifSequent.asList(); - while (!if1.isEmpty() && !if2.isEmpty() - && if1.head().equalsModProofIrrelevancy(if2.head())) { + ImmutableList if1 = ifSequent.asList(); + ImmutableList if2 = t2.ifSequent.asList(); + while (!if1.isEmpty() && !if2.isEmpty()) { + Term term = if1.head(); + Term head = if2.head(); + if (!(boolean) ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .equalsModThisProperty(term, head)) + break; if1 = if1.tail(); if2 = if2.tail(); } @@ -529,7 +534,9 @@ public int hashCode() { @Override public int hashCodeModProofIrrelevancy() { if (hashcode2 == 0) { - hashcode2 = ifSequent.getFormulabyNr(1).hashCodeModProofIrrelevancy(); + Term term = ifSequent.getFormulabyNr(1); + hashcode2 = + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY.hashCodeModThisProperty(term); if (hashcode2 == 0) { hashcode2 = -1; } @@ -740,8 +747,8 @@ public Set collectSchemaVars() { private void collectSchemaVarsHelper(Sequent s, OpCollector oc) { - for (SequentFormula cf : s) { - cf.formula().execPostOrder(oc); + for (Term cf : s) { + cf.execPostOrder(oc); } } @@ -762,9 +769,9 @@ public static class TacletLabelHint { private final Sequent sequent; /** - * The optional {@link SequentFormula} contained in {@link #getSequent()}. + * The optional {@link Term} contained in {@link #getSequent()}. */ - private final SequentFormula sequentFormula; + private final Term seqFormula; /** * The optional replace {@link Term} of the taclet. @@ -788,7 +795,7 @@ public TacletLabelHint(TacletOperation tacletOperation, Sequent sequent) { assert sequent != null; this.tacletOperation = tacletOperation; this.sequent = sequent; - this.sequentFormula = null; + this.seqFormula = null; this.term = null; } @@ -796,30 +803,30 @@ public TacletLabelHint(TacletOperation tacletOperation, Sequent sequent) { * Constructor creating a hint indicating * {@link TacletOperation#REPLACE_TERM} as the currently performed operation. * - * @param term The optional replace {@link Term} of the taclet. + * @param replaceTerm The optional replace {@link Term} of the taclet. */ - public TacletLabelHint(Term term) { - assert term != null; + public TacletLabelHint(Term replaceTerm) { + assert replaceTerm != null; this.tacletOperation = TacletOperation.REPLACE_TERM; this.sequent = null; - this.sequentFormula = null; - this.term = term; + this.seqFormula = null; + this.term = seqFormula; } /** * Constructor. * * @param labelHint The previous {@link TacletLabelHint} which is now specialised. - * @param sequentFormula The optional {@link SequentFormula} contained in + * @param formula The optional {@link Term} contained in * {@link #getSequent()}. */ - public TacletLabelHint(TacletLabelHint labelHint, SequentFormula sequentFormula) { + public TacletLabelHint(TacletLabelHint labelHint, Term formula) { assert labelHint != null; assert !TacletOperation.REPLACE_TERM.equals(labelHint.getTacletOperation()); - assert sequentFormula != null; + assert formula != null; this.tacletOperation = labelHint.getTacletOperation(); this.sequent = labelHint.getSequent(); - this.sequentFormula = sequentFormula; + this.seqFormula = formula; this.term = labelHint.getTerm(); } @@ -842,12 +849,12 @@ public Sequent getSequent() { } /** - * Returns the optional {@link SequentFormula} contained in {@link #getSequent()}. + * Returns the optional {@link Term} contained in {@link #getSequent()}. * - * @return The optional {@link SequentFormula} contained in {@link #getSequent()}. + * @return The optional {@link Term} contained in {@link #getSequent()}. */ - public SequentFormula getSequentFormula() { - return sequentFormula; + public Term getSeqFormula() { + return seqFormula; } /** @@ -883,7 +890,7 @@ public Term getTerm() { @Override public String toString() { return tacletOperation + ", sequent = " + sequent + ", sequent formula = " - + sequentFormula + ", term = " + term; + + seqFormula + ", term = " + term; } /** @@ -894,20 +901,20 @@ public String toString() { public enum TacletOperation { /** * Add clause of a {@link Taclet} applied to the antecedent. Available information are - * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSeqFormula()}. */ ADD_ANTECEDENT, /** * Add clause of a {@link Taclet} applied to the succedent. Available information are - * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSeqFormula()}. */ ADD_SUCCEDENT, /** * Replace clause of a {@link Taclet} provides a {@link Sequent} and currently * additional adds to the antecedent are performed. Available information are - * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSeqFormula()}. */ REPLACE_TO_ANTECEDENT, @@ -915,7 +922,7 @@ public enum TacletOperation { * Replace clause of a {@link Taclet} provides a {@link Sequent} and currently the * current {@link PosInOccurrence} on the succedent is modified. Available information * are {@link TacletLabelHint#getSequent()} and - * {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSeqFormula()}. */ REPLACE_AT_SUCCEDENT, @@ -923,21 +930,21 @@ public enum TacletOperation { * Replace clause of a {@link Taclet} provides a {@link Sequent} and currently the * current {@link PosInOccurrence} on the antecedent is modified. Available information * are {@link TacletLabelHint#getSequent()} and - * {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSeqFormula()}. */ REPLACE_AT_ANTECEDENT, /** * Replace clause of a {@link Taclet} provides a {@link Sequent} and currently * additional adds to the succedent are performed. Available information are - * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSequentFormula()}. + * {@link TacletLabelHint#getSequent()} and {@link TacletLabelHint#getSeqFormula()}. */ REPLACE_TO_SUCCEDENT, /** * Replace clause of a {@link Taclet} provides a {@link Term} which is currently used to * modify the {@link PosInOccurrence}. Available information are - * {@link TacletLabelHint#getTerm()}. + * {@link TacletLabelHint#getSeqFormula()}. */ REPLACE_TERM } @@ -955,7 +962,7 @@ public enum TacletOperation { */ @Override public @NonNull ImmutableList apply(Goal goal, Services services, RuleApp tacletApp) { - return getExecutor().apply(goal, services, tacletApp); + return getExecutor().apply((Goal) goal, services, tacletApp); } public TacletExecutor getExecutor() { diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java index a98632eb8ef..feecc41cc5d 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java @@ -236,8 +236,8 @@ private static Term getTermBelowQuantifier(SchemaVariable varSV, Term term) { * @return the term below the given quantifier in the find and if-parts of the Taclet */ private static Term getTermBelowQuantifier(Taclet taclet, SchemaVariable varSV) { - for (SequentFormula sequentFormula : taclet.ifSequent()) { - Term result = getTermBelowQuantifier(varSV, sequentFormula.formula()); + for (Term assumesFml : taclet.ifSequent()) { + Term result = getTermBelowQuantifier(varSV, assumesFml); if (result != null) { return result; } @@ -895,7 +895,7 @@ public ImmutableList findIfFormulaInstantiations(Sequent seq, Service * @return a list of tacletapps with the found if formula instantiations */ private ImmutableList findIfFormulaInstantiationsHelp( - ImmutableList ruleSuccTail, ImmutableList ruleAntecTail, + ImmutableList ruleSuccTail, ImmutableList ruleAntecTail, ImmutableArray instSucc, ImmutableArray instAntec, ImmutableList instAlreadyMatched, MatchConditions matchCond, @@ -918,8 +918,8 @@ private ImmutableList findIfFormulaInstantiationsHelp( } // Match the current formula - IfMatchResult mr = taclet().getMatcher().matchIf(instSucc, ruleSuccTail.head().formula(), - matchCond, services); + Term fml = ruleSuccTail.head(); + IfMatchResult mr = taclet().getMatcher().matchIf(instSucc, fml, matchCond, services); // For each matching formula call the method again to match // the remaining terms @@ -935,10 +935,10 @@ private ImmutableList findIfFormulaInstantiationsHelp( return res; } - private ImmutableList createSemisequentList(Semisequent p_ss) { - ImmutableList res = ImmutableSLList.nil(); + private ImmutableList createSemisequentList(Semisequent p_ss) { + ImmutableList res = ImmutableSLList.nil(); - for (SequentFormula p_s : p_ss) { + for (Term p_s : p_ss) { res = res.prepend(p_s); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletSchemaVariableCollector.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletSchemaVariableCollector.java index 04d610c2326..60356bf5e21 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletSchemaVariableCollector.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletSchemaVariableCollector.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.logic.JavaBlock; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.*; @@ -159,8 +158,8 @@ public boolean contains(SchemaVariable var) { * @param semiseq the Semisequent to visit */ private void visit(Semisequent semiseq) { - for (SequentFormula aSemiseq : semiseq) { - aSemiseq.formula().execPostOrder(this); + for (Term aSemiseq : semiseq) { + aSemiseq.execPostOrder(this); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java index 20c4103252c..26c7109e5a8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseDependencyContractRule.java @@ -56,8 +56,8 @@ private UseDependencyContractRule() { private static List getEqualityDefs(Term term, Sequent seq) { final List result = new LinkedList<>(); - for (SequentFormula cf : seq.antecedent()) { - final Term formula = cf.formula(); + for (Term cf : seq.antecedent()) { + final Term formula = cf; if (formula.op() instanceof Equality && formula.sub(1).equals(term)) { result.add(formula.sub(0)); } @@ -69,8 +69,8 @@ private static List getEqualityDefs(Term term, Sequent seq) { private static List> getEqualityDefsAndPos(Term term, Sequent seq) { final List> result = new LinkedList<>(); - for (SequentFormula cf : seq.antecedent()) { - final Term formula = cf.formula(); + for (Term cf : seq.antecedent()) { + final Term formula = cf; if (formula.op() instanceof Equality && formula.sub(1).equals(term)) { final PosInOccurrence pos = new PosInOccurrence(cf, PosInTerm.getTopLevel(), true); result.add(new Pair<>(formula.sub(0), pos)); @@ -83,8 +83,8 @@ private static List> getEqualityDefsAndPos(Term term private ImmutableSet addEqualDefs(ImmutableSet terms, Goal g) { ImmutableList result = ImmutableSLList.nil(); - for (SequentFormula cf : g.sequent().antecedent()) { - final Term formula = cf.formula(); + for (Term cf : g.sequent().antecedent()) { + final Term formula = cf; if (formula.op() instanceof Equality && terms.contains(formula.sub(1))) { result = result.prepend(formula.sub(0)); } @@ -234,11 +234,11 @@ private static void collectBaseOccsHelper(Term focus, PosInOccurrence pos, private static Map collectBaseOccs(Term focus, Sequent seq) { assert focus.op() instanceof IObserverFunction; final Map result = new LinkedHashMap<>(); - for (SequentFormula cf : seq.antecedent()) { + for (Term cf : seq.antecedent()) { final PosInOccurrence pos = new PosInOccurrence(cf, PosInTerm.getTopLevel(), true); collectBaseOccsHelper(focus, pos, result); } - for (SequentFormula cf : seq.succedent()) { + for (Term cf : seq.succedent()) { final PosInOccurrence pos = new PosInOccurrence(cf, PosInTerm.getTopLevel(), false); collectBaseOccsHelper(focus, pos, result); } @@ -537,7 +537,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { final ImmutableList result = goal.split(1); final Term termWithBaseHeap = TB.func(target, subs); final Term implication = TB.imp(cutFormula, TB.equals(focus, termWithBaseHeap)); - result.head().addFormula(new SequentFormula(implication), true, false); + result.head().addFormula(implication, true, false); return result; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java index ddad13b73f7..5bdc4d06df1 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/UseOperationContractRule.java @@ -40,7 +40,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.PosInProgram; import de.uka.ilkd.key.logic.ProgramPrefix; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermFactory; @@ -430,13 +429,13 @@ private static void applyInfFlow(Goal goal, final FunctionalOperationContract co Taclet informationFlowContractApp = ifContractBuilder.buildTaclet(goal); // add term and taclet to post goal - goal.addFormula(new SequentFormula(contractApplPredTerm), true, false); + goal.addFormula(contractApplPredTerm, true, false); goal.addTaclet(informationFlowContractApp, SVInstantiations.EMPTY_SVINSTANTIATIONS, true); // information flow proofs might get easier if we add the (proved) // method contract precondition as an assumption to the post goal // (in case the precondition cannot be proved easily) - goal.addFormula(new SequentFormula(finalPreTerm), true, false); + goal.addFormula(finalPreTerm, true, false); final InfFlowProof proof = (InfFlowProof) goal.proof(); proof.addIFSymbol(contractApplPredTerm); proof.addIFSymbol(informationFlowContractApp); @@ -745,7 +744,7 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { finalPreTerm = TermLabelManager.refactorTerm(termLabelState, services, null, finalPreTerm, this, preGoal, FINAL_PRE_TERM_HINT, null); - preGoal.changeFormula(new SequentFormula(finalPreTerm), ruleApp.posInOccurrence()); + preGoal.changeFormula(finalPreTerm, ruleApp.posInOccurrence()); TermLabelManager.refactorGoal(termLabelState, services, ruleApp.posInOccurrence(), this, preGoal, null, null); @@ -769,10 +768,11 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { new ImmutableArray<>(inst.progPost.sub(0)), null, inst.progPost.getLabels()))), null); - postGoal.addFormula(new SequentFormula(wellFormedAnon), true, false); - postGoal.changeFormula(new SequentFormula(tb.apply(inst.u, normalPost, null)), + postGoal.addFormula(wellFormedAnon, true, false); + Term uAssumptions2 = tb.apply(inst.u, normalPost, null); + postGoal.changeFormula(uAssumptions2, ruleApp.posInOccurrence()); - postGoal.addFormula(new SequentFormula(postAssumption), true, false); + postGoal.addFormula(postAssumption, true, false); applyInfFlow(postGoal, contract, inst, contractSelf, contractParams, contractResult, tb.var(excVar), mby, atPreUpdates, finalPreTerm, anonUpdateDatas, services); @@ -791,15 +791,17 @@ public boolean isApplicable(Goal goal, PosInOccurrence pio) { null); final Term excPost = globalDefs == null ? originalExcPost : tb.apply(globalDefs, originalExcPost); - excPostGoal.addFormula(new SequentFormula(wellFormedAnon), true, false); - excPostGoal.changeFormula(new SequentFormula(tb.apply(inst.u, excPost, null)), + excPostGoal.addFormula(wellFormedAnon, true, false); + Term uAssumptions1 = tb.apply(inst.u, excPost, null); + excPostGoal.changeFormula(uAssumptions1, ruleApp.posInOccurrence()); - excPostGoal.addFormula(new SequentFormula(excPostAssumption), true, false); + excPostGoal.addFormula(excPostAssumption, true, false); // create "Null Reference" branch if (nullGoal != null) { final Term actualSelfNotNull = tb.not(tb.equals(inst.actualSelf, tb.NULL())); - nullGoal.changeFormula(new SequentFormula(tb.apply(inst.u, actualSelfNotNull, null)), + Term uAssumptions = tb.apply(inst.u, actualSelfNotNull, null); + nullGoal.changeFormula(uAssumptions, ruleApp.posInOccurrence()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java index 008099a3094..b4a1515d858 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/WhileInvariantRule.java @@ -34,7 +34,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.ProgramElementName; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -414,7 +413,7 @@ private static void setUpInfFlowPartOfUseGoal(final InfFlowData infData, final T final Term infFlowAssumptions = tb.apply(infData.updates.first, tb.and(beforeAssumptions, tb.apply(infData.updates.second, tb.and(afterAssumptions, infData.applPredTerm)))); - goal.addFormula(new SequentFormula(infFlowAssumptions), true, false); + goal.addFormula(infFlowAssumptions, true, false); goal.addTaclet(infData.infFlowApp, SVInstantiations.EMPTY_SVINSTANTIATIONS, true); final InfFlowProof proof = (InfFlowProof) goal.proof(); proof.addIFSymbol(infData.applPredTerm); @@ -464,7 +463,7 @@ private static InfFlowData setUpInfFlowValidityGoal(Goal infFlowGoal, final Term finalTerm = tb.imp(tb.label(selfComposedExec, ParameterlessTermLabel.SELF_COMPOSITION_LABEL), post); ((InfFlowProof) infFlowGoal.proof()).addLabeledIFSymbol(selfComposedExec); - infFlowGoal.addFormula(new SequentFormula(finalTerm), false, true); + infFlowGoal.addFormula(finalTerm, false, true); return infFlowData; } @@ -545,13 +544,13 @@ private Term bodyTerm(TermLabelState termLabelState, Services services, RuleApp } - private SequentFormula initFormula(TermLabelState termLabelState, Instantiation inst, + private Term initFormula(TermLabelState termLabelState, Instantiation inst, final Term invTerm, Term reachableState, Services services, Goal initGoal) { final TermBuilder tb = services.getTermBuilder(); Term sfTerm = tb.apply(inst.u, tb.and(invTerm, reachableState), null); sfTerm = TermLabelManager.refactorTerm(termLabelState, services, null, sfTerm, this, initGoal, INITIAL_INVARIANT_ONLY_HINT, null); - return new SequentFormula(sfTerm); + return sfTerm; } private Term useCaseFormula(TermLabelState termLabelState, Services services, RuleApp ruleApp, @@ -614,15 +613,16 @@ private void prepareBodyPreservesBranch(TermLabelState termLabelState, Services final Term[] uBeforeLoopDefAnonVariant, final Term uAnonInv) { final TermBuilder tb = services.getTermBuilder(); bodyGoal.setBranchLabel(BODY_PRESERVES_INVARIANT_LABEL); - bodyGoal.addFormula(new SequentFormula(wellFormedAnon), true, false); + bodyGoal.addFormula(wellFormedAnon, true, false); - bodyGoal.addFormula(new SequentFormula(uAnonInv), true, false); + bodyGoal.addFormula(uAnonInv, true, false); Term guardTrueBody = bodyTerm(termLabelState, services, ruleApp, applicationSequent, inst, invTerm, frameCondition, variantPO, bodyGoal, guardJb, guardTrueTerm); + Term uAssumptions = tb.applySequential(uBeforeLoopDefAnonVariant, guardTrueBody); bodyGoal.changeFormula( - new SequentFormula(tb.applySequential(uBeforeLoopDefAnonVariant, guardTrueBody)), + uAssumptions, ruleApp.posInOccurrence()); } @@ -632,13 +632,14 @@ private void prepareUseCaseBranch(TermLabelState termLabelState, Services servic final JavaBlock guardJb, final Term guardFalseTerm, final Term[] uAnon, final Term uAnonInv) { useGoal.setBranchLabel("Use Case"); - useGoal.addFormula(new SequentFormula(wellFormedAnon), true, false); - useGoal.addFormula(new SequentFormula(uAnonInv), true, false); + useGoal.addFormula(wellFormedAnon, true, false); + useGoal.addFormula(uAnonInv, true, false); final TermBuilder tb = services.getTermBuilder(); Term guardFalseRestPsi = useCaseFormula(termLabelState, services, ruleApp, inst, useGoal, guardJb, guardFalseTerm); - useGoal.changeFormula(new SequentFormula(tb.applySequential(uAnon, guardFalseRestPsi)), + Term uAssumptions = tb.applySequential(uAnon, guardFalseRestPsi); + useGoal.changeFormula(uAssumptions, ruleApp.posInOccurrence()); } @@ -696,7 +697,7 @@ private void setupWdGoal(final Goal goal, final LoopSpecification inv, final Ter self = null; } services.getSpecificationRepository().addWdStatement(lwd); - final SequentFormula wdInv = + final Term wdInv = lwd.generateSequent(self, heap, anonHeap, localIns, update, localAnonUpdate, services); goal.changeFormula(wdInv, pio); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/AntecTacletExecutor.java b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/AntecTacletExecutor.java index 2033daf4d37..311577b10eb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/AntecTacletExecutor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/AntecTacletExecutor.java @@ -7,7 +7,7 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; import de.uka.ilkd.key.logic.SequentChangeInfo; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabelState; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.rule.AntecTaclet; @@ -60,7 +60,7 @@ matchCond, new TacletLabelHint(TacletOperation.REPLACE_AT_ANTECEDENT, replWith), /** * applies the {@code add}-expressions of taclet goal descriptions * - * @param add the {@link Sequent} with the uninstantiated {@link SequentFormula}'s to be added + * @param add the {@link Sequent} with the uninstantiated {@link Term}'s to be added * to the goal's sequent * @param termLabelState The {@link TermLabelState} of the current rule application. * @param currentSequent the {@link SequentChangeInfo} which is the current (intermediate) diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/FindTacletExecutor.java b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/FindTacletExecutor.java index 2866c6d0e12..03c1c6b5c33 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/FindTacletExecutor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/FindTacletExecutor.java @@ -52,7 +52,7 @@ protected abstract void applyReplacewith(TacletGoalTemplate gt, TermLabelState t /** * applies the {@code add}-expressions of taclet goal descriptions * - * @param add the {@link Sequent} with the uninstantiated {@link SequentFormula}'s to be added + * @param add the {@link Sequent} with the uninstantiated {@link Term}'s to be added * to the goal's sequent * @param termLabelState The {@link TermLabelState} of the current rule application. * @param currentSequent the {@link SequentChangeInfo} which is the current (intermediate) diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/RewriteTacletExecutor.java b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/RewriteTacletExecutor.java index 0ea5c2ecb63..793053ae10a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/RewriteTacletExecutor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/RewriteTacletExecutor.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; import de.uka.ilkd.key.logic.SequentChangeInfo; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabelManager; import de.uka.ilkd.key.logic.label.TermLabelState; @@ -64,26 +63,26 @@ private Term replace(Term term, Term with, TermLabelState termLabelState, } - private SequentFormula applyReplacewithHelper(Goal goal, TermLabelState termLabelState, + private Term applyReplacewithHelper(Goal goal, TermLabelState termLabelState, RewriteTacletGoalTemplate gt, PosInOccurrence posOfFind, Services services, MatchConditions matchCond, RuleApp ruleApp) { - final Term term = posOfFind.sequentFormula().formula(); + final Term term = posOfFind.sequentLevelFormula(); final IntIterator it = posOfFind.posInTerm().iterator(); final Term rwTemplate = gt.replaceWith(); Term formula = replace(term, rwTemplate, termLabelState, new TacletLabelHint(rwTemplate), posOfFind, it, matchCond, term.sort(), goal, services, ruleApp); - formula = TermLabelManager.refactorSequentFormula(termLabelState, services, formula, + formula = TermLabelManager.refactorTerm(termLabelState, services, formula, posOfFind, taclet, goal, null, rwTemplate); if (term == formula) { - return posOfFind.sequentFormula(); + return posOfFind.sequentLevelFormula(); } else { - return new SequentFormula(formula); + return formula; } } - public SequentFormula getRewriteResult(Goal goal, TermLabelState termLabelState, + public Term getRewriteResult(Goal goal, TermLabelState termLabelState, Services services, TacletApp app) { assert taclet.goalTemplates().size() == 1; assert taclet.goalTemplates().head().sequent().isEmpty(); @@ -104,19 +103,19 @@ protected void applyReplacewith(TacletGoalTemplate gt, TermLabelState termLabelS SequentChangeInfo currentSequent, PosInOccurrence posOfFind, MatchConditions matchCond, Goal goal, RuleApp ruleApp, Services services) { if (gt instanceof RewriteTacletGoalTemplate) { - final SequentFormula cf = applyReplacewithHelper(goal, termLabelState, + final Term cf = applyReplacewithHelper(goal, termLabelState, (RewriteTacletGoalTemplate) gt, posOfFind, services, matchCond, ruleApp); currentSequent.combine(currentSequent.sequent().changeFormula(cf, posOfFind)); } else { // Then there was no replacewith... // This is strange in a RewriteTaclet, but who knows... // However, term label refactorings have to be performed. - final Term oldFormula = posOfFind.sequentFormula().formula(); - final Term newFormula = TermLabelManager.refactorSequentFormula(termLabelState, + final Term oldFormula = posOfFind.sequentLevelFormula(); + final Term newFormula = TermLabelManager.refactorTerm(termLabelState, services, oldFormula, posOfFind, taclet, goal, null, null); if (oldFormula != newFormula) { currentSequent.combine(currentSequent.sequent() - .changeFormula(new SequentFormula(newFormula), posOfFind)); + .changeFormula(newFormula, posOfFind)); } } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/TacletExecutor.java b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/TacletExecutor.java index e9ca72c22c6..c49c334b9bb 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/TacletExecutor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/executor/javadl/TacletExecutor.java @@ -13,7 +13,6 @@ import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.SemisequentChangeInfo; import de.uka.ilkd.key.logic.SequentChangeInfo; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.logic.VariableNamer; @@ -89,17 +88,17 @@ protected Term syntacticalReplace(Term term, TermLabelState termLabelState, } /** - * adds SequentFormula to antecedent or succedent depending on position information or the + * adds Term to antecedent or succedent depending on position information or the * boolean antec contrary to "addToPos" frm will not be modified * - * @param frm the {@link SequentFormula} that should be added + * @param frm the {@link Term} that should be added * @param currentSequent the {@link SequentChangeInfo} which is the current (intermediate) * result of applying the taclet * @param pos the {@link PosInOccurrence} describing the place in the sequent * @param antec boolean true(false) if elements have to be added to the antecedent(succedent) * (only looked at if pos == null) */ - private void addToPosWithoutInst(SequentFormula frm, SequentChangeInfo currentSequent, + private void addToPosWithoutInst(Term frm, SequentChangeInfo currentSequent, PosInOccurrence pos, boolean antec) { if (pos != null) { currentSequent.combine(currentSequent.sequent().addFormula(frm, pos)); @@ -116,23 +115,23 @@ private void addToPosWithoutInst(SequentFormula frm, SequentChangeInfo currentSe * instantiated formula) is returned. * * @param termLabelState The {@link TermLabelState} of the current rule application. - * @param schemaFormula the SequentFormula to be instantiated + * @param schemaFormula the Term to be instantiated * @param services the Services object carrying ja related information * @param matchCond the MatchConditions object with the instantiations of the schemavariables, * constraints etc. * @param applicationPosInOccurrence The {@link PosInOccurrence} of the {@link Term} which is * rewritten * @param labelHint The hint used to maintain {@link TermLabel}s. - * @return the as far as possible instantiated SequentFormula + * @return the as far as possible instantiated Term */ - private SequentFormula instantiateReplacement(TermLabelState termLabelState, - SequentFormula schemaFormula, Services services, MatchConditions matchCond, + private Term instantiateReplacement(TermLabelState termLabelState, + Term schemaFormula, Services services, MatchConditions matchCond, PosInOccurrence applicationPosInOccurrence, TacletLabelHint labelHint, Goal goal, RuleApp tacletApp) { final SVInstantiations svInst = matchCond.getInstantiations(); - Term instantiatedFormula = syntacticalReplace(schemaFormula.formula(), termLabelState, + Term instantiatedFormula = syntacticalReplace(schemaFormula, termLabelState, new TacletLabelHint(labelHint, schemaFormula), applicationPosInOccurrence, matchCond, goal, tacletApp, services); @@ -141,7 +140,7 @@ private SequentFormula instantiateReplacement(TermLabelState termLabelState, .applyUpdatePairsSequential(svInst.getUpdateContext(), instantiatedFormula); } - return new SequentFormula(instantiatedFormula); + return instantiatedFormula; } /** @@ -157,14 +156,14 @@ private SequentFormula instantiateReplacement(TermLabelState termLabelState, * @param services the Services * @return the instantiated formulas of the semisequent as list */ - protected ImmutableList instantiateSemisequent(Semisequent semi, + protected ImmutableList instantiateSemisequent(Semisequent semi, TermLabelState termLabelState, TacletLabelHint labelHint, PosInOccurrence applicationPosInOccurrence, MatchConditions matchCond, Goal goal, RuleApp tacletApp, Services services) { - ImmutableList replacements = ImmutableSLList.nil(); + ImmutableList replacements = ImmutableSLList.nil(); - for (SequentFormula sf : semi) { + for (Term sf : semi) { replacements = replacements.append(instantiateReplacement(termLabelState, sf, services, matchCond, applicationPosInOccurrence, labelHint, goal, tacletApp)); } @@ -191,7 +190,7 @@ protected ImmutableList instantiateSemisequent(Semisequent semi, protected void replaceAtPos(Semisequent semi, TermLabelState termLabelState, SequentChangeInfo currentSequent, PosInOccurrence pos, MatchConditions matchCond, TacletLabelHint labelHint, Goal goal, RuleApp ruleApp, Services services) { - final ImmutableList replacements = instantiateSemisequent(semi, + final ImmutableList replacements = instantiateSemisequent(semi, termLabelState, labelHint, pos, matchCond, goal, ruleApp, services); currentSequent.combine(currentSequent.sequent().changeFormula(replacements, pos)); } @@ -219,7 +218,7 @@ private void addToPos(Semisequent semi, TermLabelState termLabelState, PosInOccurrence applicationPosInOccurrence, boolean antec, TacletLabelHint labelHint, MatchConditions matchCond, Goal goal, Services services, RuleApp tacletApp) { - final ImmutableList replacements = + final ImmutableList replacements = instantiateSemisequent(semi, termLabelState, labelHint, applicationPosInOccurrence, matchCond, goal, tacletApp, services); if (pos != null) { @@ -230,7 +229,7 @@ private void addToPos(Semisequent semi, TermLabelState termLabelState, } /** - * adds SequentFormula to antecedent depending on position information (if none is handed over + * adds Term to antecedent depending on position information (if none is handed over * it is added at the head of the antecedent). Of course it has to be ensured that the position * information describes one occurrence in the antecedent of the sequent. * @@ -256,7 +255,7 @@ protected void addToAntec(Semisequent semi, TermLabelState termLabelState, } /** - * adds SequentFormula to succedent depending on position information (if none is handed over it + * adds Term to succedent depending on position information (if none is handed over it * is added at the head of the succedent). Of course it has to be ensured that the position * information describes one occurrence in the succedent of the sequent. * @@ -419,7 +418,7 @@ protected ImmutableList checkIfGoals(Goal p_goal, for (final IfFormulaInstantiation inst : p_list) { if (!(inst instanceof IfFormulaInstSeq)) { // build the if obligation formula - ifPart = inst.getConstrainedFormula().formula(); + ifPart = inst.getConstrainedFormula(); // negate formulas of the if-succedent final TermServices services = p_goal.proof().getServices(); @@ -470,7 +469,7 @@ protected ImmutableList checkIfGoals(Goal p_goal, seq = itNewGoalSequents.next(); } - addToPosWithoutInst(new SequentFormula(ifObl), seq, null, false); + addToPosWithoutInst(ifObl, seq, null, false); } return res; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelMerger.java b/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelMerger.java index dd2fa9e20fb..a1e0d567191 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelMerger.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelMerger.java @@ -7,7 +7,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.label.TermLabelManager; @@ -16,7 +15,7 @@ *

            * A {@link TermLabelMerger} is used by * {@link TermLabelManager#mergeLabels(Services, de.uka.ilkd.key.logic.SequentChangeInfo)} to merge - * {@link TermLabel}s in case a {@link SequentFormula} was rejected to be added to the resulting + * {@link TermLabel}s in case a {@link Term} was rejected to be added to the resulting * {@link Sequent}. *

            *

            @@ -32,18 +31,18 @@ public interface TermLabelMerger { /** * Merges the existing and the rejected {@link TermLabel} by updating the merged {@link List}. * - * @param existingSF The existing {@link SequentFormula}. - * @param existingTerm The {@link Term} of the existing {@link SequentFormula}. + * @param existingSF The existing {@link Term}. + * @param existingTerm The {@link Term} of the existing {@link Term}. * @param existingLabel The existing {@link TermLabel} if available or {@code null} otherwise. - * @param rejectedSF The rejected {@link SequentFormula}. - * @param rejectedTerm The {@link Term} of the rejected {@link SequentFormula}. + * @param rejectedSF The rejected {@link Term}. + * @param rejectedTerm The {@link Term} of the rejected {@link Term}. * @param rejectedLabel The rejected {@link TermLabel}. * @param mergedLabels The {@link List} with new {@link TermLabel}s which will be visible in the * resulting {@link Sequent}. * @return {@code true} if the {@link List} of {@link TermLabel} was modified and {@code false} * otherwise. */ - boolean mergeLabels(SequentFormula existingSF, Term existingTerm, - TermLabel existingLabel, SequentFormula rejectedSF, Term rejectedTerm, + boolean mergeLabels(Term existingSF, Term existingTerm, + TermLabel existingLabel, Term rejectedSF, Term rejectedTerm, TermLabel rejectedLabel, List mergedLabels); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelRefactoring.java b/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelRefactoring.java index 85fed275c36..606cc7262a0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelRefactoring.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/label/TermLabelRefactoring.java @@ -6,7 +6,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.label.LabelCollection; @@ -161,7 +160,7 @@ enum RefactoringScope { APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE, /** - * Refactor the {@link SequentFormula} on which the rule is applied. + * Refactor the {@link Term} on which the rule is applied. */ APPLICATION_CHILDREN_AND_GRANDCHILDREN_SUBTREE_AND_PARENTS, diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java b/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java index 7832eae3b67..409bb2008e9 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/match/vm/VMTacletMatcher.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.ProgramElement; import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Operator; import de.uka.ilkd.key.logic.op.QuantifiableVariable; @@ -101,8 +100,8 @@ public VMTacletMatcher(Taclet taclet) { findMatchProgram = TacletMatchProgram.EMPTY_PROGRAM; } - for (SequentFormula sf : assumesSequent) { - assumesMatchPrograms.put(sf.formula(), TacletMatchProgram.createProgram(sf.formula())); + for (Term sf : assumesSequent) { + assumesMatchPrograms.put(sf, TacletMatchProgram.createProgram(sf)); } } @@ -132,7 +131,7 @@ public final IfMatchResult matchIf(Iterable p_toMatch, } for (var cf : p_toMatch) { - Term formula = cf.getConstrainedFormula().formula(); + Term formula = cf.getConstrainedFormula(); if (updateContextPresent) { formula = matchUpdateContext(context, formula); @@ -189,8 +188,8 @@ private Term matchUpdateContext(ImmutableList context, Term for public final MatchConditions matchIf(Iterable p_toMatch, MatchConditions p_matchCond, Services p_services) { - final Iterator anteIterator = assumesSequent.antecedent().iterator(); - final Iterator succIterator = assumesSequent.succedent().iterator(); + final Iterator anteIterator = assumesSequent.antecedent().iterator(); + final Iterator succIterator = assumesSequent.succedent().iterator(); ImmutableList newMC; @@ -204,13 +203,13 @@ public final MatchConditions matchIf(Iterable p_toMatch, // Default: just take the next ante formula, else succ formula && anteIterator.hasNext(); - Iterator itIfSequent = candidateInAntec ? anteIterator : succIterator; + Iterator itIfSequent = candidateInAntec ? anteIterator : succIterator; // Fix end assert itIfSequent.hasNext() : "p_toMatch and assumes sequent must have same number of elements"; newMC = matchIf(ImmutableSLList.nil().prepend(candidateInst), - itIfSequent.next().formula(), p_matchCond, p_services).getMatchConditions(); + itIfSequent.next(), p_matchCond, p_services).getMatchConditions(); if (newMC.isEmpty()) { return null; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java index 19b3b4b36e2..b3c8e4d7d63 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/CloseAfterMerge.java @@ -13,7 +13,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.JavaDLTheory; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -133,7 +132,7 @@ public void proofGoalsAdded(ProofTreeEvent e) { // a closed goal when loading a proof without the GUI (e.g. // in a JUnit test). - if (e.getGoals().size() == 0 && mergeNodeF.isClosed()) { + if (e.getGoals().isEmpty() && mergeNodeF.isClosed()) { // The merged node was closed; now also close this node. e.getSource().closeGoal(linkedGoal); @@ -154,7 +153,7 @@ public void proofGoalsAdded(ProofTreeEvent e) { // Delete previous sequents clearSemisequent(ruleIsWeakeningGoal, true); clearSemisequent(ruleIsWeakeningGoal, false); - ruleIsWeakeningGoal.addFormula(new SequentFormula(isWeakeningForm), false, true); + ruleIsWeakeningGoal.addFormula(isWeakeningForm, false, true); TermLabelManager.refactorGoal(termLabelState, services, ruleApp.posInOccurrence(), this, ruleIsWeakeningGoal, null, null); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java index 3b83dceb151..332a94aed64 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/merge/MergeRule.java @@ -14,7 +14,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.PosInTerm; import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -235,13 +234,13 @@ public String toString() { // Add new antecedent (path condition) for (Term antecedentFormula : getConjunctiveElementsFor(resultPathCondition)) { - final SequentFormula newAntecedent = new SequentFormula(antecedentFormula); + final Term newAntecedent = antecedentFormula; newGoal.addFormula(newAntecedent, true, false); } // Add new succedent (symbolic state & program counter) final Term succedentFormula = tb.apply(mergedState.first, thisSEState.third); - final SequentFormula newSuccedent = new SequentFormula(succedentFormula); + final Term newSuccedent = succedentFormula; newGoal.addFormula(newSuccedent, new PosInOccurrence(newSuccedent, PosInTerm.getTopLevel(), false)); @@ -276,7 +275,7 @@ public String toString() { clearSemisequent(sideConditionGoal, false); final Term sideCondition = sideCondIt.next(); - sideConditionGoal.addFormula(new SequentFormula(sideCondition), + sideConditionGoal.addFormula(sideCondition, new PosInOccurrence(newSuccedent, PosInTerm.getTopLevel(), false)); i++; @@ -686,7 +685,7 @@ public static ImmutableList findPotentialMergePartners(Goal goal, if (!g.equals(goal) && !g.isLinked()) { Semisequent succedent = g.sequent().succedent(); for (int i = 0; i < succedent.size(); i++) { - final SequentFormula f = succedent.get(i); + final Term f = succedent.get(i); final PosInTerm pit = PosInTerm.getTopLevel(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/RewriteTacletBuilderSchemaVarCollector.java b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/RewriteTacletBuilderSchemaVarCollector.java index 0e933eec771..de0dcc617fa 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/RewriteTacletBuilderSchemaVarCollector.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/RewriteTacletBuilderSchemaVarCollector.java @@ -7,7 +7,6 @@ import java.util.Set; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.rule.RewriteTaclet; @@ -86,8 +85,8 @@ public void subtreeLeft(Term subtreeRoot) { private Set collectSchemaVariables(Sequent s) { Set result = new LinkedHashSet<>(); - for (final SequentFormula cf : s) { - result.addAll(collectSchemaVariables(cf.formula())); + for (final Term cf : s) { + result.addAll(collectSchemaVariables(cf)); } return result; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletBuilder.java index a52fd22bfb0..724dd06fb98 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletBuilder.java @@ -67,8 +67,8 @@ private static boolean containsFreeVarSV(Term t) { } private static boolean containsFreeVarSV(Sequent sequent) { - for (final SequentFormula cf : sequent) { - if (containsFreeVarSV(cf.formula())) { + for (final Term cf : sequent) { + if (containsFreeVarSV(cf)) { return true; } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletGenerator.java index 09dd56b2c45..9460eed80a5 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletGenerator.java @@ -52,7 +52,7 @@ public static TacletGenerator getInstance() { private TacletGoalTemplate createAxiomGoalTemplate(Term goalTerm) { - final SequentFormula axiomSf = new SequentFormula(goalTerm); + final Term axiomSf = goalTerm; final Semisequent axiomSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(axiomSf).semisequent(); final Sequent axiomSeq = Sequent.createAnteSequent(axiomSemiSeq); @@ -146,7 +146,7 @@ public Taclet generateRelationalRepresentsTaclet(Name tacletName, Term originalA final TermAndBoundVarPair schemaAxiom = createSchemaTerm(originalAxiom, pvs, svs, services); // create goal template - SequentFormula guardedSchemaAxiom = generateGuard(kjt, target, services, selfSV, heapSVs, + Term guardedSchemaAxiom = generateGuard(kjt, target, services, selfSV, heapSVs, paramSVs, schemaAxiom.term, tacletBuilder, satisfiabilityGuard); final Sequent addedSeq = Sequent.createAnteSequent( Semisequent.EMPTY_SEMISEQUENT.insertFirst(guardedSchemaAxiom).semisequent()); @@ -249,14 +249,14 @@ public ImmutableSet generateFunctionalRepresentsTaclets(Name name, Term */ // ifSeq = null; final Term ifFormula = TB.equals(TB.var(selfSV), TB.NULL()); - final SequentFormula ifCf = new SequentFormula(ifFormula); + final Term ifCf = ifFormula; final Semisequent ifSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(ifCf).semisequent(); ifSeq = Sequent.createSuccSequent(ifSemiSeq); } else { /* \assumes ( Sort.exactInstance(self) ==> ) */ final Term ifFormula = TB.exactInstance(kjt.getSort(), TB.var(selfSV)); - final SequentFormula ifCf = new SequentFormula(ifFormula); + final Term ifCf = ifFormula; final Semisequent ifSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(ifCf).semisequent(); ifSeq = Sequent.createAnteSequent(ifSemiSeq); @@ -351,7 +351,7 @@ private void functionalRepresentsAddSatisfiabilityBranch(IObserverFunction targe final RewriteTacletBuilder tacletBuilder) { final Term axiomSatisfiable = functionalRepresentsSatisfiability(target, services, heapSVs, selfSV, paramSVs, schemaRepresents, tacletBuilder); - SequentFormula addedCf = new SequentFormula(axiomSatisfiable); + Term addedCf = axiomSatisfiable; final Semisequent addedSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(addedCf).semisequent(); final Sequent addedSeq = Sequent.createSuccSequent(addedSemiSeq); @@ -526,7 +526,7 @@ public ImmutableSet generateContractAxiomTaclets(Name name, Term origina pvs, svs, services); final Term addedFormula = schemaAdd.term; - final SequentFormula addedCf = new SequentFormula(addedFormula); + final Term addedCf = addedFormula; final Semisequent addedSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(addedCf).semisequent(); final Sequent addedSeq = Sequent.createAnteSequent(addedSemiSeq); @@ -662,7 +662,7 @@ public ImmutableSet generatePartialInvTaclet(Name name, List hea result = result.union(limited.second); // create added sequent - final SequentFormula addedCf = new SequentFormula(limitedAxiom); + final Term addedCf = limitedAxiom; final Semisequent addedSemiSeq = Semisequent.EMPTY_SEMISEQUENT.insertFirst(addedCf).semisequent(); final Sequent addedSeq = Sequent.createAnteSequent(addedSemiSeq); @@ -707,8 +707,8 @@ public ImmutableSet generatePartialInvTaclet(Name name, List hea // \assumes( self = EQ ==> EQ = null ) final Term selfEQ = TB.equals(TB.var(selfSV), TB.var(eqSV)); final Term eqNull = TB.equals(TB.var(eqSV), TB.NULL()); - final SequentFormula selfEQSF = new SequentFormula(selfEQ); - final SequentFormula eqNullSF = new SequentFormula(eqNull); + final Term selfEQSF = selfEQ; + final Term eqNullSF = eqNull; final Semisequent succ = Semisequent.EMPTY_SEMISEQUENT.insertFirst(selfEQSF).semisequent(); final Semisequent ant = @@ -718,7 +718,7 @@ public ImmutableSet generatePartialInvTaclet(Name name, List hea } else if (!isStatic) { // \assumes( ==> self = null ) final Term selfNull = TB.equals(TB.var(selfSV), TB.NULL()); - final SequentFormula selfNullSF = new SequentFormula(selfNull); + final Term selfNullSF = selfNull; final Semisequent succ = Semisequent.EMPTY_SEMISEQUENT.insertFirst(selfNullSF).semisequent(); final Sequent ifSeq = Sequent.createSuccSequent(succ); @@ -930,7 +930,7 @@ private Pair> limitTerm(Term t, } - private SequentFormula generateGuard(KeYJavaType kjt, IObserverFunction target, + private Term generateGuard(KeYJavaType kjt, IObserverFunction target, TermServices services, final OperatorSV selfSV, List heapSVs, ImmutableList paramSVs, final Term schemaAxiom, final RewriteTacletBuilder tacletBuilder, boolean addGuard) { @@ -942,7 +942,7 @@ private SequentFormula generateGuard(KeYJavaType kjt, IObserverFunction target, : TB.tt(); // assemble formula final Term guardedAxiom = TB.imp(TB.and(exactInstance, axiomSatisfiable), schemaAxiom); - final SequentFormula guardedAxiomCf = new SequentFormula(guardedAxiom); + final Term guardedAxiomCf = guardedAxiom; return guardedAxiomCf; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletPrefixBuilder.java b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletPrefixBuilder.java index c7574e69260..948b838fb76 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletPrefixBuilder.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/tacletbuilder/TacletPrefixBuilder.java @@ -6,7 +6,6 @@ import java.util.Iterator; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.label.TermLabel; import de.uka.ilkd.key.logic.op.*; @@ -103,8 +102,8 @@ private void visit(Term t) { } private void visit(Sequent s) { - for (final SequentFormula cf : s) { - visit(cf.formula()); + for (final Term cf : s) { + visit(cf); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTFocusResults.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTFocusResults.java index 4a20c0867c4..08d0ae975db 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTFocusResults.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTFocusResults.java @@ -71,7 +71,7 @@ public static boolean focus(SMTProblem smtProblem, Services services) { Semisequent succedent = goalNode.sequent().succedent(); int i = 1; - for (SequentFormula sf : antecedent) { + for (Term sf : antecedent) { PosInOccurrence pio = PosInOccurrence.findInSequent(goalNode.sequent(), i, PosInTerm.getTopLevel()); if (!unsatCore.contains(pio)) { @@ -80,13 +80,13 @@ public static boolean focus(SMTProblem smtProblem, Services services) { TacletApp app = PosTacletApp.createPosTacletApp(hideLeft, new MatchConditions(), new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), services); - app = app.addCheckedInstantiation(schema, sf.formula(), services, true); + app = app.addCheckedInstantiation(schema, sf, services, true); goal = goal.apply(app).iterator().next(); } i++; } - for (SequentFormula sf : succedent) { + for (Term sf : succedent) { PosInOccurrence pio = PosInOccurrence.findInSequent(goalNode.sequent(), i, PosInTerm.getTopLevel()); if (!unsatCore.contains(pio)) { @@ -96,7 +96,7 @@ public static boolean focus(SMTProblem smtProblem, Services services) { PosTacletApp.createPosTacletApp(hideRight, new MatchConditions(), new PosInOccurrence(sf, PosInTerm.getTopLevel(), false), services); - app = app.addCheckedInstantiation(schema, sf.formula(), services, true); + app = app.addCheckedInstantiation(schema, sf, services, true); goal = goal.apply(app).iterator().next(); } i++; @@ -146,7 +146,7 @@ public static ImmutableList getUnsatCore(SMTProblem problem) { Semisequent antecedent = goalNode.sequent().antecedent(); int i = 1; - for (SequentFormula sf : antecedent) { + for (Term sf : antecedent) { if (unsatCore.contains(i)) { unsatCoreFormulas = unsatCoreFormulas.prepend(PosInOccurrence .findInSequent(goalNode.sequent(), i, PosInTerm.getTopLevel())); @@ -155,7 +155,7 @@ public static ImmutableList getUnsatCore(SMTProblem problem) { } Semisequent succedent = goalNode.sequent().succedent(); - for (SequentFormula sf : succedent) { + for (Term sf : succedent) { if (unsatCore.contains(i)) { unsatCoreFormulas = unsatCoreFormulas.prepend(PosInOccurrence .findInSequent(goalNode.sequent(), i, PosInTerm.getTopLevel())); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTProblem.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTProblem.java index 79176217814..e6cfce8a099 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTProblem.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTProblem.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.proof.Goal; @@ -162,14 +161,14 @@ public static Term sequentToTerm(Sequent s, Services services) { final TermBuilder tb = services.getTermBuilder(); ante = ante.append(tb.tt()); - for (SequentFormula f : s.antecedent()) { - ante = ante.append(f.formula()); + for (Term f : s.antecedent()) { + ante = ante.append(f); } ImmutableList succ = ImmutableSLList.nil(); succ = succ.append(tb.ff()); - for (SequentFormula f : s.succedent()) { - succ = succ.append(f.formula()); + for (Term f : s.succedent()) { + succ = succ.append(f); } return tb.imp(tb.and(ante), tb.or(succ)); @@ -183,14 +182,14 @@ private Term sequentToTerm(Sequent s) { final TermBuilder tb = goal.proof().getServices().getTermBuilder(); ante = ante.append(tb.tt()); - for (SequentFormula f : s.antecedent()) { - ante = ante.append(f.formula()); + for (Term f : s.antecedent()) { + ante = ante.append(f); } ImmutableList succ = ImmutableSLList.nil(); succ = succ.append(tb.ff()); - for (SequentFormula f : s.succedent()) { - succ = succ.append(f.formula()); + for (Term f : s.succedent()) { + succ = succ.append(f); } return tb.imp(tb.and(ante), tb.or(succ)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTRuleApp.java b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTRuleApp.java index 9674a9ed1b8..cfb03d9e9cd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/SMTRuleApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/SMTRuleApp.java @@ -160,10 +160,10 @@ public SMTRuleApp tryToInstantiate(Goal goal) { SMTRuleApp app = RULE.createApp(pio, goal.proof().getServices()); Sequent seq = goal.sequent(); List ifInsts = new ArrayList<>(); - for (SequentFormula ante : seq.antecedent()) { + for (Term ante : seq.antecedent()) { ifInsts.add(new PosInOccurrence(ante, PosInTerm.getTopLevel(), true)); } - for (SequentFormula succ : seq.succedent()) { + for (Term succ : seq.succedent()) { ifInsts.add(new PosInOccurrence(succ, PosInTerm.getTopLevel(), false)); } return app.setIfInsts(ImmutableList.fromList(ifInsts)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java index fc459866dd8..d31949e01fc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/smt/newsmt2/ModularSMTLib2Translator.java @@ -13,7 +13,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.smt.SMTSettings; @@ -226,11 +225,11 @@ private static String readResource(String s) { private List getTermsFromSequent(Sequent seq, Services serv) { TermBuilder tb = serv.getTermBuilder(); List res = new LinkedList<>(); - for (SequentFormula sf : seq.antecedent()) { - res.add(sf.formula()); + for (Term sf : seq.antecedent()) { + res.add(sf); } - for (SequentFormula sf : seq.succedent()) { - res.add(tb.not(sf.formula())); + for (Term sf : seq.succedent()) { + res.add(tb.not(sf)); } return res; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/BlockWellDefinedness.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/BlockWellDefinedness.java index 121c03c21e5..bc74bf244c8 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/BlockWellDefinedness.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/BlockWellDefinedness.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.declaration.modifier.VisibilityModifier; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -68,11 +67,11 @@ public BlockWellDefinedness map(UnaryOperator op, Services services) { } @Override - SequentFormula generateSequent(SequentTerms seq, TermServices services) { + Term generateSequent(SequentTerms seq, TermServices services) { // wd(pre) & (pre & wf(anon) -> wd(mod) & {anon^mod}(wd(post))) final Term imp = TB.imp(TB.and(seq.pre, seq.wfAnon), TB.and(seq.wdMod, seq.anonWdPost)); final Term wdPre = TB.wd(seq.pre); - return new SequentFormula(TB.apply(seq.context, TB.and(wdPre, imp))); + return TB.apply(seq.context, TB.and(wdPre, imp)); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopWellDefinedness.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopWellDefinedness.java index a083300a4b8..b9fb0c6ffe6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopWellDefinedness.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/LoopWellDefinedness.java @@ -8,7 +8,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.java.declaration.modifier.VisibilityModifier; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.TermServices; @@ -48,12 +47,12 @@ public LoopWellDefinedness(LoopSpecification inv, ImmutableSet } @Override - SequentFormula generateSequent(SequentTerms seq, TermServices services) { + Term generateSequent(SequentTerms seq, TermServices services) { // wd(phi) & (phi & wf(anon) -> wd(mod) & wd(variant) & {anon^mod}(wd(phi) & wd(variant))) final Term imp = TB.imp(TB.and(seq.pre, seq.wfAnon), TB.and(seq.wdMod, seq.wdRest, seq.anonWdPost)); final Term wdPre = TB.wd(seq.pre); - return new SequentFormula(TB.apply(seq.context, TB.and(wdPre, imp))); + return TB.apply(seq.context, TB.and(wdPre, imp)); } @Override diff --git a/key.core/src/main/java/de/uka/ilkd/key/speclang/QueryAxiom.java b/key.core/src/main/java/de/uka/ilkd/key/speclang/QueryAxiom.java index a828c667e37..8e5aaccc030 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/speclang/QueryAxiom.java +++ b/key.core/src/main/java/de/uka/ilkd/key/speclang/QueryAxiom.java @@ -18,7 +18,6 @@ import de.uka.ilkd.key.logic.ProgramElementName; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.logic.op.*; @@ -188,7 +187,7 @@ public ImmutableSet getTaclets(ImmutableSet getTaclets(ImmutableSet ps, Term leadingUpdate, Term localAnonUpdate, @@ -153,7 +152,7 @@ public SequentFormula generateSequent(LocationVariable self, LocationVariable ex * @param services * @return The proof sequent for the well-definedness check */ - public SequentFormula generateSequent(LocationVariable self, LocationVariable heap, + public Term generateSequent(LocationVariable self, LocationVariable heap, Term anonHeap, ImmutableSet ps, Term leadingUpdate, Term localAnonUpdate, Services services) { return generateSequent(self, null, null, heap, null, anonHeap, ps, leadingUpdate, diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/BuiltInRuleAppContainer.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/BuiltInRuleAppContainer.java index 5e47e52d8d0..a853dea7996 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/BuiltInRuleAppContainer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/BuiltInRuleAppContainer.java @@ -64,7 +64,8 @@ private boolean isStillApplicable(Goal goal) { // the formula does not exist anymore, bail out return false; } else { - return topPos.sequentFormula().equals(applicationPosition.sequentFormula()); + return topPos.sequentLevelFormula() + .equals(applicationPosition.sequentLevelFormula()); } } } @@ -78,7 +79,7 @@ private PosInOccurrence getPosInOccurrence(Goal p_goal) { assert topPos != null; - return applicationPosition.replaceConstrainedFormula(topPos.sequentFormula()); + return applicationPosition.replaceConstrainedFormula(topPos.sequentLevelFormula()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/FindTacletAppContainer.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/FindTacletAppContainer.java index 10313f11e9e..0ed3573d86a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/FindTacletAppContainer.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/FindTacletAppContainer.java @@ -6,7 +6,6 @@ import de.uka.ilkd.key.logic.FormulaChangeInfo; import de.uka.ilkd.key.logic.PIOPathIterator; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Modality; import de.uka.ilkd.key.logic.op.Operator; @@ -79,8 +78,8 @@ private boolean subformulaOrPreceedingUpdateHasChanged(Goal goal) { final FormulaChangeInfo info = infoList.head(); infoList = infoList.tail(); - final SequentFormula newFormula = info.newFormula(); - if (newFormula == applicationPosition.sequentFormula()) { + final Term newFormula = info.newFormula(); + if (newFormula == applicationPosition.sequentLevelFormula()) { // then there were no relevant modifications since the creation // of the rule app object return false; @@ -106,7 +105,7 @@ private boolean subformulaOrPreceedingUpdateHasChanged(Goal goal) { * formulas) and no indirect relationship exists which is established by a modification * that occurred inside an update */ - private boolean independentSubformulas(PosInOccurrence changePos, SequentFormula newFormula) { + private boolean independentSubformulas(PosInOccurrence changePos, Term newFormula) { final PIOPathIterator changePIO = changePos.iterator(); final PIOPathIterator appPIO = applicationPosition.iterator(); @@ -172,7 +171,7 @@ private boolean updateContextIsRecorded() { protected PosInOccurrence getPosInOccurrence(Goal p_goal) { final PosInOccurrence topPos = p_goal.getFormulaTagManager().getPosForTag(positionTag); assert topPos != null; - return applicationPosition.replaceConstrainedFormula(topPos.sequentFormula()); + return applicationPosition.replaceConstrainedFormula(topPos.sequentLevelFormula()); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/FocussedRuleApplicationManager.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/FocussedRuleApplicationManager.java index 7a0153fb9a9..dabc0f36297 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/FocussedRuleApplicationManager.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/FocussedRuleApplicationManager.java @@ -140,7 +140,7 @@ public void rulesAdded(ImmutableList rules, PosInOccurrence p private boolean isSameFormula(PosInOccurrence pio1, PosInOccurrence pio2) { return pio2.isInAntec() == pio1.isInAntec() - && pio2.sequentFormula().equals(pio1.sequentFormula()); + && pio2.sequentLevelFormula().equals(pio1.sequentLevelFormula()); } private PosInOccurrence getPIOForFocussedSubterm() { @@ -150,7 +150,7 @@ private PosInOccurrence getPIOForFocussedSubterm() { return null; } - return focussedSubterm.replaceConstrainedFormula(formula.sequentFormula()); + return focussedSubterm.replaceConstrainedFormula(formula.sequentLevelFormula()); } private boolean isBelow(PosInOccurrence over, PosInOccurrence under) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/IfInstantiator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/IfInstantiator.java index ae00ddba01d..c64397f7005 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/IfInstantiator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/IfInstantiator.java @@ -6,10 +6,7 @@ import java.util.Iterator; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.proof.FormulaTag; import de.uka.ilkd.key.proof.FormulaTagManager; import de.uka.ilkd.key.proof.Goal; @@ -94,21 +91,21 @@ private Taclet getTaclet() { * @return a list of potential if-formula instantiations (analogously to * IfFormulaInstSeq.createList) */ - private ImmutableArray getSequentFormulas(boolean p_antec, + private ImmutableArray getTerms(boolean p_antec, boolean p_all) { if (p_all) { - return getAllSequentFormulas(p_antec); + return getAllTerms(p_antec); } final ImmutableArray cache = - getNewSequentFormulasFromCache(p_antec); + getNewTermsFromCache(p_antec); if (cache != null) { return cache; } final ImmutableArray newFormulas = selectNewFormulas(p_antec); - addNewSequentFormulasToCache(newFormulas, p_antec); + addNewTermsToCache(newFormulas, p_antec); return newFormulas; } @@ -120,12 +117,12 @@ private ImmutableArray getSequentFormulas(boolean p_ante * true */ private ImmutableArray selectNewFormulas(boolean p_antec) { - final ImmutableArray allSequentFormulas = - getAllSequentFormulas(p_antec); - final IfFormulaInstantiation[] res = new IfFormulaInstantiation[allSequentFormulas.size()]; + final ImmutableArray allTerms = + getAllTerms(p_antec); + final IfFormulaInstantiation[] res = new IfFormulaInstantiation[allTerms.size()]; int i = 0; - for (final IfFormulaInstantiation ifInstantiation : allSequentFormulas) { + for (final IfFormulaInstantiation ifInstantiation : allTerms) { if (isNewFormulaDirect((IfFormulaInstSeq) ifInstantiation)) { res[i] = ifInstantiation; ++i; @@ -142,7 +139,7 @@ private ImmutableArray selectNewFormulas(boolean p_antec private boolean isNewFormula(IfFormulaInstSeq p_ifInstantiation) { final boolean antec = p_ifInstantiation.inAntec(); - final ImmutableArray cache = getNewSequentFormulasFromCache(antec); + final ImmutableArray cache = getNewTermsFromCache(antec); if (cache != null) { return cache.contains(p_ifInstantiation); @@ -159,7 +156,7 @@ private boolean isNewFormula(IfFormulaInstSeq p_ifInstantiation) { private boolean isNewFormulaDirect(IfFormulaInstSeq p_ifInstantiation) { final boolean antec = p_ifInstantiation.inAntec(); - final SequentFormula cfma = p_ifInstantiation.getConstrainedFormula(); + final Term cfma = p_ifInstantiation.getConstrainedFormula(); final PosInOccurrence pio = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), antec); final FormulaTagManager tagManager = goal.getFormulaTagManager(); @@ -173,17 +170,17 @@ private boolean isNewFormulaDirect(IfFormulaInstSeq p_ifInstantiation) { return tacletAppContainer.getAge() < formulaAge; } - private ImmutableArray getNewSequentFormulasFromCache(boolean p_antec) { + private ImmutableArray getNewTermsFromCache(boolean p_antec) { return ifInstCache.get(p_antec, tacletAppContainer.getAge()); } - private void addNewSequentFormulasToCache(ImmutableArray p_list, + private void addNewTermsToCache(ImmutableArray p_list, boolean p_antec) { ifInstCache.put(p_antec, tacletAppContainer.getAge(), p_list); } - private ImmutableArray getAllSequentFormulas(boolean p_antec) { + private ImmutableArray getAllTerms(boolean p_antec) { return p_antec ? allAntecFormulas : allSuccFormulas; } @@ -197,8 +194,8 @@ private ImmutableArray getAllSequentFormulas(boolean p_a * @param p_alreadyMatchedNewFor at least one new formula has already been matched, i.e. a * formula that has been modified recently */ - private void findIfFormulaInstantiationsHelp(ImmutableList p_ifSeqTail, - ImmutableList p_ifSeqTail2nd, + private void findIfFormulaInstantiationsHelp(ImmutableList p_ifSeqTail, + ImmutableList p_ifSeqTail2nd, ImmutableList p_alreadyMatched, MatchConditions p_matchCond, boolean p_alreadyMatchedNewFor) { @@ -219,9 +216,9 @@ private void findIfFormulaInstantiationsHelp(ImmutableList p_ifS final boolean lastIfFormula = p_ifSeqTail.size() == 1 && (p_ifSeqTail2nd == null || p_ifSeqTail2nd.isEmpty()); final ImmutableArray formulas = - getSequentFormulas(antec, !lastIfFormula || p_alreadyMatchedNewFor); + getTerms(antec, !lastIfFormula || p_alreadyMatchedNewFor); final IfMatchResult mr = getTaclet().getMatcher().matchIf(formulas, - p_ifSeqTail.head().formula(), p_matchCond, getServices()); + p_ifSeqTail.head(), p_matchCond, getServices()); // For each matching formula call the method again to match // the remaining terms diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AbstractBetaFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AbstractBetaFeature.java index 512404467a9..88a5b4ff43b 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AbstractBetaFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/AbstractBetaFeature.java @@ -329,7 +329,7 @@ public RuleAppCost computeCost(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { assert pos != null : "Feature is only applicable to rules with find"; - final Term findTerm = pos.sequentFormula().formula(); + final Term findTerm = pos.sequentLevelFormula(); return doComputation(pos, findTerm, goal.proof().getServices().getCaches()); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/CheckApplyEqFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/CheckApplyEqFeature.java index 3951cae6d33..754c253c535 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/CheckApplyEqFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/CheckApplyEqFeature.java @@ -39,7 +39,7 @@ protected boolean filter(TacletApp p_app, PosInOccurrence pos, Goal goal, Mutabl private boolean isNotSelfApplication(PosInOccurrence pos, IfFormulaInstantiation ifInst) { if (!(ifInst instanceof IfFormulaInstSeq) - || ifInst.getConstrainedFormula() != pos.sequentFormula() + || ifInst.getConstrainedFormula() != pos.sequentLevelFormula() || ((IfFormulaInstSeq) ifInst).inAntec() != pos.isInAntec()) { return true; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/DiffFindAndIfFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/DiffFindAndIfFeature.java index 624855765f9..dfdead87396 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/DiffFindAndIfFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/DiffFindAndIfFeature.java @@ -4,7 +4,7 @@ package de.uka.ilkd.key.strategy.feature; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.rule.IfFormulaInstSeq; import de.uka.ilkd.key.rule.IfFormulaInstantiation; @@ -28,7 +28,7 @@ protected boolean filter(TacletApp app, PosInOccurrence pos, Goal goal, MutableS assert pos != null : "Feature is only applicable to rules with find"; ImmutableList list = app.ifFormulaInstantiations(); - final SequentFormula findFormula = pos.sequentFormula(); + final Term findFormula = pos.sequentLevelFormula(); final boolean findIsInAntec = pos.isInAntec(); assert list != null; @@ -36,7 +36,7 @@ protected boolean filter(TacletApp app, PosInOccurrence pos, Goal goal, MutableS for (final IfFormulaInstantiation aList : list) { final IfFormulaInstSeq iffi = (IfFormulaInstSeq) aList; assert iffi != null; - final SequentFormula ifFormula = iffi.getConstrainedFormula(); + final Term ifFormula = iffi.getConstrainedFormula(); final boolean result = findIsInAntec != iffi.inAntec() || !findFormula.equals(ifFormula); diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FocusIsSubFormulaOfInfFlowContractAppFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FocusIsSubFormulaOfInfFlowContractAppFeature.java index 7f758b320d7..cee42d2d437 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FocusIsSubFormulaOfInfFlowContractAppFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FocusIsSubFormulaOfInfFlowContractAppFeature.java @@ -46,7 +46,7 @@ public RuleAppCost computeCost(RuleApp ruleApp, PosInOccurrence pos, Goal goal, return NumberRuleAppCost.getZeroCost(); } - final Term focusFor = pos.sequentFormula().formula(); + final Term focusFor = pos.sequentLevelFormula(); ImmutableList contractAppls = goal.getStrategyInfo(InfFlowContractAppTacletExecutor.INF_FLOW_CONTRACT_APPL_PROPERTY); if (contractAppls == null) { diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FormulaAddedByRuleFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FormulaAddedByRuleFeature.java index 59ce82fc587..e9020db82a7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FormulaAddedByRuleFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/FormulaAddedByRuleFeature.java @@ -5,7 +5,7 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.rulefilter.RuleFilter; @@ -31,7 +31,7 @@ public static Feature create(RuleFilter p_filter) { public boolean filter(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { assert pos != null : "Feature is only applicable to rules with find"; - final SequentFormula cfma = pos.sequentFormula(); + final Term cfma = pos.sequentLevelFormula(); final boolean antec = pos.isInAntec(); Node node = goal.node(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/InfFlowContractAppFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/InfFlowContractAppFeature.java index 0c9588ccb8d..05db3ffad2c 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/InfFlowContractAppFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/InfFlowContractAppFeature.java @@ -10,10 +10,7 @@ import de.uka.ilkd.key.informationflow.po.InfFlowContractPO; import de.uka.ilkd.key.informationflow.po.LoopInvExecutionPO; import de.uka.ilkd.key.informationflow.po.SymbolicExecutionPO; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.logic.op.SchemaVariable; import de.uka.ilkd.key.logic.op.SkolemTermSV; import de.uka.ilkd.key.logic.op.VariableSV; @@ -59,7 +56,7 @@ protected boolean comparePio(TacletApp newApp, TacletApp oldApp, PosInOccurrence * Check whether a semisequent contains a formula. Again, one can either search for the same or * an equal formula */ - protected boolean semiSequentContains(Semisequent semisequent, SequentFormula cfma) { + protected boolean semiSequentContains(Semisequent semisequent, Term cfma) { return semisequent.containsEqual(cfma); } @@ -155,9 +152,9 @@ protected boolean duplicateFindTaclet(TacletApp app, PosInOccurrence pos, Goal g assert app.ifFormulaInstantiations().size() >= 1 : "Featureis only applicable to rules with at least one assumes."; - final SequentFormula focusFor = pos.sequentFormula(); + final Term focusFor = pos.sequentLevelFormula(); final boolean antec = pos.isInAntec(); - final SequentFormula assumesFor = + final Term assumesFor = app.ifFormulaInstantiations().iterator().next().getConstrainedFormula(); // assumtion has to occour before the find-term in the sequent in order @@ -220,11 +217,11 @@ public RuleAppCost computeCost(RuleApp ruleApp, PosInOccurrence pos, Goal goal, // only relate the n-th called method in execution A with the n-th // called method in execution B automatically - final SequentFormula focusFor = pos.sequentFormula(); - final SequentFormula assumesFor = + final Term focusFor = pos.sequentLevelFormula(); + final Term assumesFor = app.ifFormulaInstantiations().iterator().next().getConstrainedFormula(); - ArrayList relatesTerms = getRelatesTerms(goal); + ArrayList relatesTerms = getRelatesTerms(goal); final int numOfContractAppls = relatesTerms.size() / 2; int assumesApplNumber = 0; for (int i = 0; i < numOfContractAppls; i++) { @@ -249,11 +246,11 @@ private boolean isInfFlowProof(Proof proof) { } - private ArrayList getRelatesTerms(Goal goal) { - ArrayList list = new ArrayList<>(); + private ArrayList getRelatesTerms(Goal goal) { + ArrayList list = new ArrayList<>(); Semisequent antecedent = goal.node().sequent().antecedent(); - for (SequentFormula f : antecedent) { - if (f.formula().op().toString().startsWith("RELATED_BY_")) { + for (Term f : antecedent) { + if (f.op().toString().startsWith("RELATED_BY_")) { list.add(f); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/NoSelfApplicationFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/NoSelfApplicationFeature.java index de00a63a054..263e6bf2eb6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/NoSelfApplicationFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/NoSelfApplicationFeature.java @@ -38,7 +38,7 @@ protected boolean filter(TacletApp p_app, PosInOccurrence pos, Goal goal, Mutabl boolean noSelfApplication = true; for (IfFormulaInstantiation ifInst : ifInsts) { noSelfApplication = - noSelfApplication && (ifInst.getConstrainedFormula() != pos.sequentFormula()); + noSelfApplication && (ifInst.getConstrainedFormula() != pos.sequentLevelFormula()); } return noSelfApplication; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/SeqContainsExecutableCodeFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/SeqContainsExecutableCodeFeature.java index fc204cf81f4..9a4a2f74c14 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/SeqContainsExecutableCodeFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/feature/SeqContainsExecutableCodeFeature.java @@ -7,7 +7,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.rule.RuleApp; import de.uka.ilkd.key.strategy.termfeature.BinaryTermFeature; @@ -36,10 +36,10 @@ protected boolean filter(RuleApp app, PosInOccurrence pos, Goal goal, MutableSta goal.proof().getServices()); } - private boolean containsExec(Iterator it, MutableState mState, + private boolean containsExec(Iterator it, MutableState mState, Services services) { while (it.hasNext()) { - if (tf.compute(it.next().formula(), mState, services) + if (tf.compute(it.next(), mState, services) .equals(BinaryTermFeature.ZERO_COST)) { return true; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/ExistentiallyConnectedFormulasFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/ExistentiallyConnectedFormulasFeature.java index 1eebfa51ed5..1bf8efb4e0a 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/ExistentiallyConnectedFormulasFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/ExistentiallyConnectedFormulasFeature.java @@ -30,7 +30,7 @@ public static Feature create(ProjectionToTerm for0, ProjectionToTerm for1) { protected boolean filter(TacletApp app, PosInOccurrence pos, Goal goal, MutableState mState) { assert pos != null : "Feature is only applicable to rules with find"; - final ClausesGraph graph = ClausesGraph.create(pos.sequentFormula().formula(), + final ClausesGraph graph = ClausesGraph.create(pos.sequentLevelFormula(), goal.proof().getServices().getCaches()); return graph.connected(for0.toTerm(app, pos, goal, mState), diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/HeuristicInstantiation.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/HeuristicInstantiation.java index 6aa01776eec..225659251ba 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/HeuristicInstantiation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/HeuristicInstantiation.java @@ -30,7 +30,7 @@ public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { assert pos != null : "Feature is only applicable to rules with find"; - final Term qf = pos.sequentFormula().formula(); + final Term qf = pos.sequentLevelFormula(); final Instantiation ia = Instantiation.create(qf, goal.sequent(), goal.proof().getServices()); final QuantifiableVariable var = qf.varsBoundHere(0).last(); diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Instantiation.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Instantiation.java index ad1fee4514c..1bf26258226 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Instantiation.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/Instantiation.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.JavaDLTheory; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.logic.op.Operator; @@ -76,8 +75,8 @@ static Instantiation create(Term qf, Sequent seq, Services services) { private static ImmutableSet sequentToTerms(Sequent seq) { ImmutableList res = ImmutableSLList.nil(); - for (final SequentFormula cf : seq) { - res = res.prepend(cf.formula()); + for (final Term cf : seq) { + res = res.prepend(cf); } return DefaultImmutableSet.fromImmutableList(res); } @@ -148,15 +147,15 @@ private void addInstance(Substitution sub, long cost) { */ private ImmutableSet initAssertLiterals(Sequent seq, TermServices services) { ImmutableList assertLits = ImmutableSLList.nil(); - for (final SequentFormula cf : seq.antecedent()) { - final Term atom = cf.formula(); + for (final Term cf : seq.antecedent()) { + final Term atom = cf; final Operator op = atom.op(); if (!(op == Quantifier.ALL || op == Quantifier.EX)) { assertLits = assertLits.prepend(atom); } } - for (final SequentFormula cf : seq.succedent()) { - final Term atom = cf.formula(); + for (final Term cf : seq.succedent()) { + final Term atom = cf; final Operator op = atom.op(); if (!(op == Quantifier.ALL || op == Quantifier.EX)) { assertLits = assertLits.prepend(services.getTermBuilder().not(atom)); diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/InstantiationCost.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/InstantiationCost.java index 28e96e73d5b..7710d80ab67 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/InstantiationCost.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/InstantiationCost.java @@ -34,7 +34,7 @@ public RuleAppCost computeCost(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { assert pos != null : "Projection is only applicable to rules with find"; - final Term formula = pos.sequentFormula().formula(); + final Term formula = pos.sequentLevelFormula(); final Term instance = varInst.toTerm(app, pos, goal, mState); return Instantiation.computeCost(instance, formula, goal.sequent(), diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/SplittableQuantifiedFormulaFeature.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/SplittableQuantifiedFormulaFeature.java index 4b6ee9436cd..91b737e8eb0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/SplittableQuantifiedFormulaFeature.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/quantifierHeuristics/SplittableQuantifiedFormulaFeature.java @@ -28,7 +28,7 @@ protected boolean filter(RuleApp app, PosInOccurrence pos, Goal goal, MutableSta assert pos != null : "Feature is only applicable to rules with find"; final Analyser analyser = new Analyser(); - if (!analyser.analyse(pos.sequentFormula().formula())) { + if (!analyser.analyse(pos.sequentLevelFormula())) { return false; } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/AssumptionProjection.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/AssumptionProjection.java index 4119f587f55..29f2bb0ccf7 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/AssumptionProjection.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/AssumptionProjection.java @@ -36,6 +36,6 @@ public Term toTerm(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mut : "Projection is only applicable to taclet apps with assumptions," + " but got " + app; - return tapp.ifFormulaInstantiations().take(no).head().getConstrainedFormula().formula(); + return tapp.ifFormulaInstantiations().take(no).head().getConstrainedFormula(); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/FocusFormulaProjection.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/FocusFormulaProjection.java index eca4c0ffe95..01bc65e77af 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/FocusFormulaProjection.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termProjection/FocusFormulaProjection.java @@ -18,7 +18,7 @@ private FocusFormulaProjection() {} public Term toTerm(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mutableState) { assert pos != null : "Projection is only applicable to rules with find"; - return pos.sequentFormula().formula(); + return pos.sequentLevelFormula(); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/AllowedCutPositionsGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/AllowedCutPositionsGenerator.java index d4263852cca..816ccc9b945 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/AllowedCutPositionsGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/AllowedCutPositionsGenerator.java @@ -26,7 +26,7 @@ private AllowedCutPositionsGenerator() {} public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { - return new ACPIterator(pos.sequentFormula().formula(), pos.isInAntec()); + return new ACPIterator(pos.sequentLevelFormula(), pos.isInAntec()); } private static class ACPIterator implements Iterator { diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/HeapGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/HeapGenerator.java index 4e292f35a5e..bbe48e9b74f 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/HeapGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/HeapGenerator.java @@ -9,7 +9,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.UpdateApplication; import de.uka.ilkd.key.proof.Goal; @@ -40,8 +39,8 @@ public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { LinkedHashSet heaps = new LinkedHashSet<>(); Sequent seq = goal.sequent(); - for (SequentFormula sf : seq) { - collectHeaps(sf.formula(), heaps, goal.proof().getServices()); + for (Term sf : seq) { + collectHeaps(sf, heaps, goal.proof().getServices()); } return heaps.iterator(); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/MultiplesModEquationsGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/MultiplesModEquationsGenerator.java index 2e95e5be36a..f73c27c5371 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/MultiplesModEquationsGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/MultiplesModEquationsGenerator.java @@ -11,7 +11,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.IntegerLDT; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.op.Equality; import de.uka.ilkd.key.proof.Goal; @@ -145,9 +144,9 @@ private List extractPolys(Goal goal, Services services) { final List res = new ArrayList<>(); - for (final SequentFormula cfm : goal.sequent().antecedent()) { + for (final Term cfm : goal.sequent().antecedent()) { - final Term t = cfm.formula(); + final Term t = cfm; if (t.op() != Equality.EQUALS || t.sub(0).sort() != numbers.targetSort() || t.sub(1).sort() != numbers.targetSort()) { continue; diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SequentFormulasGenerator.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SequentFormulasGenerator.java index 0f54c39ae17..8baf0daefdd 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SequentFormulasGenerator.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/SequentFormulasGenerator.java @@ -6,7 +6,6 @@ import java.util.Iterator; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.rule.RuleApp; @@ -21,7 +20,7 @@ protected SequentFormulasGenerator() {} public static SequentFormulasGenerator antecedent() { return new SequentFormulasGenerator() { - protected Iterator generateForIt(Goal goal) { + protected Iterator generateForIt(Goal goal) { return goal.sequent().antecedent().iterator(); } }; @@ -29,7 +28,7 @@ protected Iterator generateForIt(Goal goal) { public static SequentFormulasGenerator succedent() { return new SequentFormulasGenerator() { - protected Iterator generateForIt(Goal goal) { + protected Iterator generateForIt(Goal goal) { return goal.sequent().succedent().iterator(); } }; @@ -37,40 +36,17 @@ protected Iterator generateForIt(Goal goal) { public static SequentFormulasGenerator sequent() { return new SequentFormulasGenerator() { - protected Iterator generateForIt(Goal goal) { + protected Iterator generateForIt(Goal goal) { return goal.sequent().iterator(); } }; } - protected abstract Iterator generateForIt(Goal goal); + protected abstract Iterator generateForIt(Goal goal); public Iterator generate(RuleApp app, PosInOccurrence pos, Goal goal, MutableState mState) { - return new SFIterator(generateForIt(goal)); + return generateForIt(goal); } - private static class SFIterator implements Iterator { - private final Iterator forIt; - - public boolean hasNext() { - return forIt.hasNext(); - } - - public Term next() { - return forIt.next().formula(); - } - - public SFIterator(Iterator forIt) { - this.forIt = forIt; - } - - /** - * throw an unsupported operation exception - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/TriggeredInstantiations.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/TriggeredInstantiations.java index 95fb98f2926..d4cb7624dde 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/TriggeredInstantiations.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/termgenerator/TriggeredInstantiations.java @@ -12,7 +12,6 @@ import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermServices; import de.uka.ilkd.key.logic.label.TermLabelState; @@ -156,12 +155,12 @@ private void collectAxiomsAndCandidateTerms(final Set terms, final Set getFormulaeOfSemisequent(Semisequent s) { ImmutableList terms = ImmutableSLList.nil(); - for (SequentFormula cf : s) { - terms = terms.append(cf.formula()); + for (Term cf : s) { + terms = terms.append(cf); } return terms; diff --git a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/TacletVisitor.java b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/TacletVisitor.java index 39885889d7f..14e2520941e 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/TacletVisitor.java +++ b/key.core/src/main/java/de/uka/ilkd/key/taclettranslation/TacletVisitor.java @@ -3,10 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.taclettranslation; -import de.uka.ilkd.key.logic.DefaultVisitor; -import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.rule.FindTaclet; import de.uka.ilkd.key.rule.Taclet; import de.uka.ilkd.key.rule.tacletbuilder.AntecSuccTacletGoalTemplate; @@ -19,8 +16,8 @@ public abstract class TacletVisitor implements DefaultVisitor { private String failureDescription = null; private void visit(Semisequent semiseq) { - for (SequentFormula aSemiseq : semiseq) { - aSemiseq.formula().execPostOrder(this); + for (Term aSemiseq : semiseq) { + aSemiseq.execPostOrder(this); } } diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/HelperClassForTests.java b/key.core/src/main/java/de/uka/ilkd/key/util/HelperClassForTests.java index 1033dfe3f41..e6ad15022b4 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/HelperClassForTests.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/HelperClassForTests.java @@ -95,7 +95,7 @@ public ProofAggregate parseThrowException(File file, Profile profile) } public Term extractProblemTerm(Proof p) { - return p.root().sequent().succedent().iterator().next().formula(); + return p.root().sequent().succedent().iterator().next(); } /** diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/ProofStarter.java b/key.core/src/main/java/de/uka/ilkd/key/util/ProofStarter.java index d0b1454bedd..72be773d293 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/ProofStarter.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/ProofStarter.java @@ -6,7 +6,6 @@ import de.uka.ilkd.key.java.abstraction.KeYJavaType; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Proof; @@ -63,7 +62,7 @@ public UserProvidedInput(Sequent seq, ProofEnvironment env, String proofName) { public UserProvidedInput(Term formula, ProofEnvironment env) { this(Sequent.createSuccSequent(Semisequent.EMPTY_SEMISEQUENT - .insertFirst(new SequentFormula(formula)).semisequent()), + .insertFirst(formula).semisequent()), env); } diff --git a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java index aeb78f68cde..571607cb435 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java +++ b/key.core/src/main/java/de/uka/ilkd/key/util/mergerule/MergeRuleUtils.java @@ -236,8 +236,8 @@ public static HashSet getLocationVariablesHashSet(Sequent sequ Services services) { HashSet result = new HashSet<>(); - for (SequentFormula f : sequent) { - result.addAll(getLocationVariablesHashSet(f.formula(), services)); + for (Term f : sequent) { + result.addAll(getLocationVariablesHashSet(f, services)); } return result; @@ -800,7 +800,7 @@ public static Term trySimplify(final Proof parentProof, final Term term, public static void clearSemisequent(Goal goal, boolean antec) { final Semisequent semiseq = antec ? goal.sequent().antecedent() : goal.sequent().succedent(); - for (final SequentFormula f : semiseq) { + for (final Term f : semiseq) { final PosInOccurrence gPio = new PosInOccurrence(f, PosInTerm.getTopLevel(), antec); goal.removeFormula(gPio); } @@ -1055,15 +1055,16 @@ public static SymbolicExecutionState sequentToSEPair(Node node, PosInOccurrence public static SymbolicExecutionStateWithProgCnt sequentToSETriple(Node node, PosInOccurrence pio, Services services) { - ImmutableList pathConditionSet = ImmutableSLList.nil(); + ImmutableList pathConditionSet = ImmutableSLList.nil(); pathConditionSet = pathConditionSet.prepend(node.sequent().antecedent().asList()); Term selected = pio.subTerm(); - for (SequentFormula sf : node.sequent().succedent()) { - if (!sf.formula().equals(selected)) { + for (Term sf : node.sequent().succedent()) { + if (!sf.equals(selected)) { + Term uAssumptions = services.getTermBuilder().not(sf); pathConditionSet = pathConditionSet - .prepend(new SequentFormula(services.getTermBuilder().not(sf.formula()))); + .prepend(uAssumptions); } } @@ -1373,14 +1374,14 @@ public static LocationVariable rename(Name newName, LocationVariable lv) { * @param services The services object. * @return And-formula connecting the given terms. */ - private static Term joinListToAndTerm(ImmutableList formulae, + private static Term joinListToAndTerm(ImmutableList formulae, Services services) { if (formulae.size() == 0) { return services.getTermBuilder().tt(); } else if (formulae.size() == 1) { - return formulae.head().formula(); + return formulae.head(); } else { - return services.getTermBuilder().and(formulae.head().formula(), + return services.getTermBuilder().and(formulae.head(), joinListToAndTerm(formulae.tail(), services)); } } @@ -1471,7 +1472,7 @@ private static ApplyStrategyInfo tryToProve(Term toProve, Services services, boo String sideProofName, int timeout) throws ProofInputException { return tryToProve(Sequent.createSequent( // Sequent to prove - Semisequent.EMPTY_SEMISEQUENT, new Semisequent(new SequentFormula(toProve))), services, + Semisequent.EMPTY_SEMISEQUENT, new Semisequent(toProve)), services, doSplit, sideProofName, timeout); } @@ -1620,12 +1621,12 @@ private static Term sequentToFormula(Sequent sequent, Services services) { ImmutableList succedentForms = ImmutableSLList.nil(); // Shift antecedent formulae to the succedent by negation - for (SequentFormula sf : sequent.antecedent().asList()) { - negAntecedentForms = negAntecedentForms.prepend(tb.not(sf.formula())); + for (Term sf : sequent.antecedent().asList()) { + negAntecedentForms = negAntecedentForms.prepend(tb.not(sf)); } - for (SequentFormula sf : sequent.succedent().asList()) { - succedentForms = succedentForms.prepend(sf.formula()); + for (Term sf : sequent.succedent().asList()) { + succedentForms = succedentForms.prepend(sf); } return tb.or(negAntecedentForms.prepend(succedentForms)); diff --git a/key.core/src/main/java/org/key_project/proof/LocationVariableTracker.java b/key.core/src/main/java/org/key_project/proof/LocationVariableTracker.java index 52f96ac8848..ac859d6d395 100644 --- a/key.core/src/main/java/org/key_project/proof/LocationVariableTracker.java +++ b/key.core/src/main/java/org/key_project/proof/LocationVariableTracker.java @@ -56,9 +56,9 @@ public void ruleApplied(ProofEvent e) { var it = x.getNodeChanges(); while (it.hasNext()) { var change = it.next(); - var sf = change.getPos().sequentFormula(); + var sf = change.getPos().sequentLevelFormula(); var collect = new OpCollectorJavaBlock(); - sf.formula().execPreOrder(collect); + sf.execPreOrder(collect); for (var op : collect.ops()) { if (!(op instanceof LocationVariable) || createdBy.containsKey(op)) { continue; diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestPosInOcc.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestPosInOcc.java index dfa27b88653..028228d5d9b 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestPosInOcc.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestPosInOcc.java @@ -41,7 +41,7 @@ public void testIterator() { terms[2] = TB.func(p, new Term[] { terms[1] }); PosInOccurrence pio = - new PosInOccurrence(new SequentFormula(terms[2]), PosInTerm.getTopLevel(), true); + new PosInOccurrence(terms[2], PosInTerm.getTopLevel(), true); PIOPathIterator it = pio.iterator(); @@ -84,14 +84,14 @@ public void testReplaceConstrainedFormula() { terms[0] = TB.var(x); terms[1] = TB.func(f, new Term[] { terms[0] }); terms[2] = TB.func(p, new Term[] { terms[1] }); - SequentFormula cfma = new SequentFormula(terms[2]); + Term cfma = terms[2]; Term[] terms2 = new Term[4]; terms2[0] = TB.func(c); terms2[1] = TB.func(f, new Term[] { terms2[0] }); terms2[2] = TB.func(f, new Term[] { terms2[1] }); terms2[3] = TB.func(p, new Term[] { terms2[2] }); - SequentFormula cfma2 = new SequentFormula(terms2[3]); + Term cfma2 = terms2[3]; final PosInOccurrence topPIO = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), true); diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java index 8df3490b235..8d82cf1d9e2 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java @@ -25,7 +25,7 @@ public class TestSemisequent { - private SequentFormula[] con; + private Term[] con; @BeforeEach public void setUp() { @@ -48,14 +48,14 @@ public void setUp() { Term t_c = TB.func(c, new Term[] {}); - con = new SequentFormula[7]; - con[0] = new SequentFormula(t_p); - con[1] = new SequentFormula(t_q); - con[2] = new SequentFormula(t_r); - con[3] = new SequentFormula(t_r); - con[4] = new SequentFormula(t_a); - con[5] = new SequentFormula(t_b); - con[6] = new SequentFormula(t_c); + con = new Term[7]; + con[0] = t_p; + con[1] = t_q; + con[2] = t_r; + con[3] = t_r; + con[4] = t_a; + con[5] = t_b; + con[6] = t_c; Sort s = new SortImpl(new Name("test")); Function f = new JFunction(new Name("f"), s, new Sort[] {}); @@ -75,7 +75,7 @@ public void testContains() { Semisequent seq = Semisequent.EMPTY_SEMISEQUENT; seq = extract(seq.insert(0, con[0])); seq = extract(seq.insert(1, con[1])); - SequentFormula eq2con0 = new SequentFormula(con[0].formula()); + Term eq2con0 = con[0]; assertFalse(seq.contains(eq2con0), "Contains should test of identity and not equality."); } @@ -84,7 +84,7 @@ public void testContainsEquals() { Semisequent seq = Semisequent.EMPTY_SEMISEQUENT; seq = extract(seq.insert(0, con[0])); seq = extract(seq.insert(1, con[1])); - SequentFormula eq2con0 = new SequentFormula(con[0].formula()); + Term eq2con0 = con[0]; assertTrue(seq.containsEqual(eq2con0), "Contains tests of equality and should find the formula."); } @@ -238,7 +238,7 @@ public void testListInsert() { Semisequent expected = extract( extract(extract(origin.insertLast(con[4])).insertLast(con[5])).insertLast(con[6])); - ImmutableList insertionList = ImmutableSLList.nil() + ImmutableList insertionList = ImmutableSLList.nil() .prepend(con[0]).prepend(con[1]).prepend(con[6]).prepend(con[5]).prepend(con[4]); Semisequent result = extract(origin.insert(origin.size(), insertionList)); assertEquals(expected, result, "Both semisequents should be equal."); @@ -252,7 +252,7 @@ public void testListInsertInMid() { .insertLast(con[2])); Semisequent expected = extract(extract(extract(origin.insert(2, con[4])).insert(3, con[5])).insert(4, con[6])); - ImmutableList insertionList = ImmutableSLList.nil() + ImmutableList insertionList = ImmutableSLList.nil() .prepend(con[0]).prepend(con[1]).prepend(con[6]).prepend(con[5]).prepend(con[4]); Semisequent result = extract(origin.insert(origin.size() - 1, insertionList)); assertEquals(expected, result, "Both semisequents should be equal."); @@ -270,16 +270,16 @@ public void testListReplace() { extract(extract(extract(origin.remove(2)).insertLast(con[4])).insertLast(con[5])) .insertLast(con[6])); // insert: [a,b,c,q,p] - ImmutableList insertionList = ImmutableSLList.nil() + ImmutableList insertionList = ImmutableSLList.nil() .prepend(con[0]).prepend(con[1]).prepend(con[6]).prepend(con[5]).prepend(con[4]); SemisequentChangeInfo result = origin.replace(origin.size() - 1, insertionList); assertEquals( - ImmutableSLList.nil().prepend(con[4]).prepend(con[5]).prepend(con[6]), + ImmutableSLList.nil().prepend(con[4]).prepend(con[5]).prepend(con[6]), result.addedFormulas(), "SemisequentChangeInfo is corrupt due to wrong added formula list:"); - assertEquals(ImmutableSLList.nil().prepend(con[2]), + assertEquals(ImmutableSLList.nil().prepend(con[2]), result.removedFormulas(), "SemisequentChangeInfo is corrupt due to wrong removed formula list:"); assertEquals(expected, extract(result), "Both semisequents should be equal."); @@ -296,17 +296,17 @@ public void testListReplaceAddRedundantList() { extract(extract(origin.insertLast(con[4])).insertLast(con[5])).insertLast(con[6])) .insertLast(con[2])); // insert:[a,b,c,r,r,q,p] - ImmutableList insertionList = - ImmutableSLList.nil().prepend(con[0]).prepend(con[1]).prepend(con[2]) + ImmutableList insertionList = + ImmutableSLList.nil().prepend(con[0]).prepend(con[1]).prepend(con[2]) .prepend(con[3]).prepend(con[6]).prepend(con[5]).prepend(con[4]); SemisequentChangeInfo sci = origin.replace(origin.size(), insertionList); assertEquals( - ImmutableSLList.nil().prepend(con[4]).prepend(con[5]).prepend(con[6]) + ImmutableSLList.nil().prepend(con[4]).prepend(con[5]).prepend(con[6]) .prepend(con[3]), sci.addedFormulas(), "SemisequentChangeInfo is corrupt due to wrong added formula list:"); - assertEquals(ImmutableSLList.nil(), sci.removedFormulas(), + assertEquals(ImmutableSLList.nil(), sci.removedFormulas(), "SemisequentChangeInfo is corrupt due to wrong removed formula list:"); assertEquals(expected, extract(sci), "Both semisequents should be equal."); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java index 8599f8d81d3..7bdcc70c978 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestTermLabelManager.java @@ -119,9 +119,11 @@ protected void doRefactoringTestLogging(boolean ruleChanged, boolean notSupporte one = TB.label(one, new ParameterlessTermLabel(new Name("APPLICATION"))); two = TB.label(two, new ParameterlessTermLabel(new Name("APPLICATION"))); Sequent sequent = Sequent.EMPTY_SEQUENT; - sequent = sequent.addFormula(new SequentFormula(TB.inInt(one)), true, true).sequent(); - sequent = sequent.addFormula(pos.sequentFormula(), true, false).sequent(); - sequent = sequent.addFormula(new SequentFormula(TB.inInt(two)), false, true).sequent(); + Term uAssumptions1 = TB.inInt(one); + sequent = sequent.addFormula(uAssumptions1, true, true).sequent(); + sequent = sequent.addFormula(pos.sequentLevelFormula(), true, false).sequent(); + Term uAssumptions = TB.inInt(two); + sequent = sequent.addFormula(uAssumptions, false, true).sequent(); // Test supported rule Rule rule = new DummyRule("rule"); Term taclet = TB.tt(); @@ -147,12 +149,12 @@ protected Goal createGoal(InitConfig initConfig, Sequent sequent) { protected void compareSequents(Sequent expected, Sequent current, boolean changed, RefactoringScope scope) { - Iterator expectedIter = expected.iterator(); - Iterator currentIter = current.iterator(); + Iterator expectedIter = expected.iterator(); + Iterator currentIter = current.iterator(); while (expectedIter.hasNext() && currentIter.hasNext()) { - SequentFormula expectedSF = expectedIter.next(); - SequentFormula currentSF = currentIter.next(); - compareTerms(expectedSF.formula(), currentSF.formula(), changed, scope); + Term expectedSF = expectedIter.next(); + Term currentSF = currentIter.next(); + compareTerms(expectedSF, currentSF, changed, scope); } assertFalse(expectedIter.hasNext()); assertFalse(currentIter.hasNext()); @@ -450,7 +452,7 @@ public void testInstantiateLabels_modalityTermPolicies() { Term updateApp = TB.apply(update, modality, new ImmutableArray<>(new ParameterlessTermLabel(new Name("UPDATE-APPLICATION")))); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(updateApp), PosInTerm.getTopLevel(), true); + new PosInOccurrence(updateApp, PosInTerm.getTopLevel(), true); Term taclet = TB.tt(); Rule rule = new DummyRule("rule"); // Create labels @@ -526,7 +528,7 @@ public void testInstantiateLabels_null() { protected PosInOccurrence createTestPosInOccurrence(Services services) { Term testTerm = createTestTerm(services); Term inInt = services.getTermBuilder().inInt(testTerm); - return new PosInOccurrence(new SequentFormula(inInt), PosInTerm.parseReverseString("0"), + return new PosInOccurrence(inInt, PosInTerm.parseReverseString("0"), true); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestVariableNamer.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestVariableNamer.java index 25570005100..5e5e42ac945 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestVariableNamer.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestVariableNamer.java @@ -45,9 +45,9 @@ public class TestVariableNamer { private final LocationVariable x_2 = constructProgramVariable("x_2"); private final LocationVariable var_1 = constructProgramVariable("var_1"); private final LocationVariable var_2 = constructProgramVariable("var_2"); - private final SequentFormula formulaWithX = constructFormula(x); - private final SequentFormula formulaWithX_1 = constructFormula(x_1); - private final SequentFormula formulaWithVar_1 = constructFormula(var_1); + private final Term formulaWithX = constructFormula(x); + private final Term formulaWithX_1 = constructFormula(x_1); + private final Term formulaWithVar_1 = constructFormula(var_1); private final SchemaVariable variableSV = SchemaVariableFactory .createProgramSV(new ProgramElementName("sv"), ProgramSVSort.VARIABLE, false); @@ -63,23 +63,23 @@ private LocationVariable constructProgramVariable(String name) { return constructProgramVariable(pen); } - private SequentFormula constructFormula(ProgramVariable containedVar) { + private Term constructFormula(ProgramVariable containedVar) { Statement statement = new PostIncrement(containedVar); StatementBlock statementBlock = new StatementBlock(statement); JavaBlock javaBlock = JavaBlock.createJavaBlock(statementBlock); Term term = services.getTermBuilder().dia(javaBlock, services.getTermBuilder().tt()); - return new SequentFormula(term); + return term; } - private PosInOccurrence constructPIO(SequentFormula formula) { + private PosInOccurrence constructPIO(Term formula) { return new PosInOccurrence(formula, PosInTerm.getTopLevel(), true); } - private Goal constructGoal(SequentFormula containedFormula) { + private Goal constructGoal(Term containedFormula) { Semisequent empty = Semisequent.EMPTY_SEMISEQUENT; Semisequent ante = empty.insert(0, containedFormula).semisequent(); @@ -148,7 +148,7 @@ private void testTemporaryNames(VariableNamer vn) { assertNotEquals("x", name.getProgramName()); LocationVariable v = constructProgramVariable(name); - SequentFormula formula = constructFormula(v); + Term formula = constructFormula(v); Goal goal = constructGoal(formula); PosInOccurrence pio = constructPIO(formula); v = vn.rename(v, goal, pio); diff --git a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTacletParser.java b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTacletParser.java index 3a83e98d474..404e477f4a3 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/parser/TestTacletParser.java +++ b/key.core/src/test/java/de/uka/ilkd/key/parser/TestTacletParser.java @@ -95,8 +95,8 @@ public Term parseFma(String s) { return parseTerm(s); } - public SequentFormula cf(String s) { - return new SequentFormula(parseFma(s)); + public Term cf(String s) { + return parseFma(s); } public Semisequent sseq(String s) { diff --git a/key.core/src/test/java/de/uka/ilkd/key/proof/TestGoal.java b/key.core/src/test/java/de/uka/ilkd/key/proof/TestGoal.java index 5e186bcbe8c..a56f54d288c 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/proof/TestGoal.java +++ b/key.core/src/test/java/de/uka/ilkd/key/proof/TestGoal.java @@ -8,7 +8,7 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.init.AbstractProfile; import de.uka.ilkd.key.proof.init.InitConfig; import de.uka.ilkd.key.rule.TacletForTests; @@ -43,8 +43,9 @@ public void tearDown() { @Test public void testSetBack0() { + Term uAssumptions = TacletForTests.parseTerm("A"); Sequent seq = Sequent.createSuccSequent(Semisequent.EMPTY_SEMISEQUENT - .insert(0, new SequentFormula(TacletForTests.parseTerm("A"))).semisequent()); + .insert(0, uAssumptions).semisequent()); final InitConfig initConfig = new InitConfig(new Services(AbstractProfile.getDefaultProfile())); @@ -85,8 +86,9 @@ public void testSetBack0() { @Test public void testSetBack1() throws Exception { + Term uAssumptions = TacletForTests.parseTerm("A"); Sequent seq = Sequent.createSuccSequent(Semisequent.EMPTY_SEMISEQUENT - .insert(0, new SequentFormula(TacletForTests.parseTerm("A"))).semisequent()); + .insert(0, uAssumptions).semisequent()); Node root = new Node(proof, seq); proof.setRoot(root); Goal g = new Goal(root, TacletIndexKit.getKit().createTacletIndex(), diff --git a/key.core/src/test/java/de/uka/ilkd/key/proof/TestProofTree.java b/key.core/src/test/java/de/uka/ilkd/key/proof/TestProofTree.java index 58fb09fa3ca..fa8e6dfb90d 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/proof/TestProofTree.java +++ b/key.core/src/test/java/de/uka/ilkd/key/proof/TestProofTree.java @@ -62,25 +62,25 @@ public void setUp() { Term t_b7 = tf.createTerm(Equality.EQUALS, tf.createTerm(b7), tf.createTerm(b7)); Sequent s1 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b1)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b1).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s2 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b2)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b2).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s3 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b3)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b3).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s4 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b4)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b4).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s5 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b5)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b5).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s6 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b6)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b6).semisequent(), Semisequent.EMPTY_SEMISEQUENT); Sequent s7 = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t_b7)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, t_b7).semisequent(), Semisequent.EMPTY_SEMISEQUENT); p = new Proof("TestProofTree", diff --git a/key.core/src/test/java/de/uka/ilkd/key/proof/TestTacletIndex.java b/key.core/src/test/java/de/uka/ilkd/key/proof/TestTacletIndex.java index f2813d73211..bf1039a55dc 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/proof/TestTacletIndex.java +++ b/key.core/src/test/java/de/uka/ilkd/key/proof/TestTacletIndex.java @@ -115,7 +115,7 @@ public void disabled_testNonInteractiveIsShownOnlyIfHeuristicIsMissed() { ImmutableList listofHeuristic = ImmutableSLList.nil(); listofHeuristic = listofHeuristic.prepend(h3); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(term_p1), PosInTerm.getTopLevel(), true); + new PosInOccurrence(term_p1, PosInTerm.getTopLevel(), true); assertTrue( isRuleIn(variante_one.getAntecedentTaclet(pos, new IHTacletFilter(true, listofHeuristic), null), ruleRewriteNonH1H2), @@ -150,7 +150,7 @@ public void testShownIfHeuristicFits() { Term term_p1 = TacletForTests.parseTerm("p(one, zero)"); - SequentFormula cfma = new SequentFormula(term_p1); + Term cfma = term_p1; PosInOccurrence posSucc = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), false); @@ -183,9 +183,9 @@ public void testNoMatchingFindRule() { Term term_p2 = TacletForTests.parseTerm("\\forall nat z; p(z, one)").sub(0); PosInOccurrence posAntec = - new PosInOccurrence(new SequentFormula(term_p2), PosInTerm.getTopLevel(), true); + new PosInOccurrence(term_p2, PosInTerm.getTopLevel(), true); PosInOccurrence posSucc = - new PosInOccurrence(new SequentFormula(term_p2), PosInTerm.getTopLevel(), true); + new PosInOccurrence(term_p2, PosInTerm.getTopLevel(), true); assertFalse( @@ -216,7 +216,7 @@ public void testMatchConflictOccurs() { ImmutableList listofHeuristic = ImmutableSLList.nil(); PosInOccurrence posAntec = - new PosInOccurrence(new SequentFormula(term_p4), PosInTerm.getTopLevel(), true); + new PosInOccurrence(term_p4, PosInTerm.getTopLevel(), true); assertFalse( isRuleIn(ruleIdx.getAntecedentTaclet(posAntec, @@ -231,7 +231,7 @@ public void testNotFreeInYConflict() { ruleIdx.add(notfreeconflict); Term term_p5 = TacletForTests.parseTerm("\\forall nat z; p(f(z), z)"); - SequentFormula cfma_p5 = new SequentFormula(term_p5); + Term cfma_p5 = term_p5; Sequent seq_p5 = Sequent.createAnteSequent( Semisequent.EMPTY_SEMISEQUENT.insertFirst(cfma_p5).semisequent()); PosInOccurrence pio_p5 = new PosInOccurrence(cfma_p5, PosInTerm.getTopLevel(), true); @@ -243,7 +243,7 @@ public void testNotFreeInYConflict() { Term term_p6 = TacletForTests.parseTerm("\\forall nat z; p(zero, z)"); - SequentFormula cfma_p6 = new SequentFormula(term_p6); + Term cfma_p6 = term_p6; Sequent seq_p6 = Sequent.createAnteSequent( Semisequent.EMPTY_SEMISEQUENT.insertFirst(cfma_p6).semisequent()); PosInOccurrence pio_p6 = new PosInOccurrence(cfma_p6, PosInTerm.getTopLevel(), true); diff --git a/key.core/src/test/java/de/uka/ilkd/key/proof/TestTermTacletAppIndex.java b/key.core/src/test/java/de/uka/ilkd/key/proof/TestTermTacletAppIndex.java index 78e1af4fa9d..1fd6e267c92 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/proof/TestTermTacletAppIndex.java +++ b/key.core/src/test/java/de/uka/ilkd/key/proof/TestTermTacletAppIndex.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.logic.PosInOccurrence; import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.PrefixTermTacletAppIndexCacheImpl.CacheKey; import de.uka.ilkd.key.proof.rulefilter.SetRuleFilter; @@ -121,7 +120,7 @@ private void doTestIndex0(TermTacletAppIndexCacheSet cache) { ruleIdx.add(remove_zero); Term term = TacletForTests.parseTerm("f(f(f(zero)))=one"); - SequentFormula cfma = new SequentFormula(term); + Term cfma = term; PosInOccurrence pio = new PosInOccurrence(cfma, PosInTerm.getTopLevel(), false); @@ -138,7 +137,7 @@ private void doTestIndex0(TermTacletAppIndexCacheSet cache) { // now a real change Term term2 = TacletForTests.parseTerm("f(f(zero))=one"); - SequentFormula cfma2 = new SequentFormula(term2); + Term cfma2 = term2; PosInOccurrence pio2 = new PosInOccurrence(cfma2, PosInTerm.getTopLevel(), false); termIdx = termIdx.update(pio2.down(0).down(0).down(0), serv, ruleIdx, diff --git a/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/NodeData.java b/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/NodeData.java index a5cedbd4ef4..ea43f21c613 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/NodeData.java +++ b/key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/performance/NodeData.java @@ -7,7 +7,6 @@ import java.util.Map; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Node; @@ -41,11 +40,11 @@ private static int countAST(Node n) { private static int countAST(Sequent sequent) { int sum = 0; - for (SequentFormula f : sequent.antecedent().asList()) { - sum += countAST(f.formula()); + for (Term f : sequent.antecedent().asList()) { + sum += countAST(f); } - for (SequentFormula f : sequent.succedent().asList()) { - sum += countAST(f.formula()); + for (Term f : sequent.succedent().asList()) { + sum += countAST(f); } return sum; } diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/CreateTacletForTests.java b/key.core/src/test/java/de/uka/ilkd/key/rule/CreateTacletForTests.java index c9b0b017cd4..8b61d735ea5 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/CreateTacletForTests.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/CreateTacletForTests.java @@ -247,13 +247,13 @@ public void setUp() throws IOException { Term t_test1 = null; try { t_test1 = io.load(test1).loadDeclarations().loadProblem().getProblem().succedent() - .get(0).formula(); + .get(0); } catch (Exception e) { LOGGER.error("Parser Error or Input Error", e); fail("Parser Error"); } - SequentFormula cf = new SequentFormula(t_test1); - SequentFormula cf2 = new SequentFormula(t_test1); + Term cf = t_test1; + Term cf2 = t_test1; seq_test1 = Sequent.createSequent(Semisequent.EMPTY_SEMISEQUENT, Semisequent.EMPTY_SEMISEQUENT.insert(0, cf).semisequent()); seq_test2 = Sequent.createSequent(Semisequent.EMPTY_SEMISEQUENT.insert(0, cf).semisequent(), @@ -288,13 +288,13 @@ public void setUp() throws IOException { // => (c+d) = ((d -1 +1) +c) -> (c +1)+d = (d+c) +1 seq_testNat = Sequent.createSequent(Semisequent.EMPTY_SEMISEQUENT, - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(tnat)).semisequent()); + Semisequent.EMPTY_SEMISEQUENT.insert(0, tnat).semisequent()); z = new LogicVariable(new Name("z"), sort1); Term t_z = tf.createTerm(z); Term t_allzpz = services.getTermBuilder().all(z, tf.createTerm(func_p, t_z)); - SequentFormula cf3 = new SequentFormula(t_allzpz); + Term cf3 = t_allzpz; seq_testAll = Sequent.createSequent(Semisequent.EMPTY_SEMISEQUENT, Semisequent.EMPTY_SEMISEQUENT.insert(0, cf3).semisequent()); diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java b/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java index 2052f3a8e75..30a30c21435 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java @@ -68,8 +68,8 @@ private static Semisequent parseTermForSemisequent(String t) { if ("".equals(t)) { return Semisequent.EMPTY_SEMISEQUENT; } - SequentFormula cf0 = new SequentFormula(TacletForTests.parseTerm(t)); - return Semisequent.EMPTY_SEMISEQUENT.insert(0, cf0).semisequent(); + return Semisequent.EMPTY_SEMISEQUENT.insert(0, + TacletForTests.parseTerm(t)).semisequent(); } @BeforeEach @@ -100,7 +100,7 @@ public void tearDown() { @Test public void testSuccTacletWithoutIf() { - Term fma = proof[0].root().sequent().succedent().getFirst().formula(); + Term fma = proof[0].root().sequent().succedent().getFirst(); NoPosTacletApp impright = TacletForTests.getRules().lookup("imp_right"); TacletIndex tacletIndex = TacletIndexKit.getKit().createTacletIndex(); tacletIndex.add(impright); @@ -115,16 +115,16 @@ public void testSuccTacletWithoutIf() { ImmutableList goals = rApp.execute(goal, TacletForTests.services()); assertEquals(1, goals.size(), "Too many or zero goals for imp-right."); Sequent seq = goals.head().sequent(); - assertEquals(seq.antecedent().getFirst().formula(), fma.sub(0), + assertEquals(seq.antecedent().getFirst(), fma.sub(0), "Wrong antecedent after imp-right"); - assertEquals(seq.succedent().getFirst().formula(), fma.sub(1), + assertEquals(seq.succedent().getFirst(), fma.sub(1), "Wrong succedent after imp-right"); } @Test public void testAddingRule() { - Term fma = proof[0].root().sequent().succedent().getFirst().formula(); + Term fma = proof[0].root().sequent().succedent().getFirst(); NoPosTacletApp imprightadd = TacletForTests.getRules().lookup("TestApplyTaclet_imp_right_add"); TacletIndex tacletIndex = TacletIndexKit.getKit().createTacletIndex(); @@ -140,9 +140,9 @@ public void testAddingRule() { ImmutableList goals = rApp.execute(goal, TacletForTests.services()); assertEquals(1, goals.size(), "Too many or zero goals for imp_right_add."); Sequent seq = goals.head().sequent(); - assertEquals(seq.antecedent().getFirst().formula(), fma.sub(0), + assertEquals(seq.antecedent().getFirst(), fma.sub(0), "Wrong antecedent after imp_right_add"); - assertEquals(seq.succedent().getFirst().formula(), fma.sub(1), + assertEquals(seq.succedent().getFirst(), fma.sub(1), "Wrong succedent after imp_right_add"); ImmutableList nfapp = goals.head().indexOfTaclets() .getNoFindTaclet(new IHTacletFilter(true, ImmutableSLList.nil()), null); @@ -157,13 +157,17 @@ public void testAddingRule() { Sequent seq1 = goals.head().sequent(); Sequent seq2 = goals.tail().head().sequent(); assertEquals(2, goals.size(), "Preinstantiated cut-rule should be executed"); + Term fml = seq2.succedent().get(1); + Term fml1 = seq1.succedent().get(1); + Term fml2 = seq2.succedent().getFirst(); + Term fml3 = seq1.succedent().getFirst(); assertTrue( - seq1.succedent().getFirst().formula().equals(aimpb) - || seq2.succedent().getFirst().formula().equals(aimpb) + fml3.equals(aimpb) + || fml2.equals(aimpb) || (seq1.succedent().get(1) != null - && seq1.succedent().get(1).formula().equals(aimpb)) + && fml1.equals(aimpb)) || (seq2.succedent().get(1) != null - && seq2.succedent().get(1).formula().equals(aimpb)), + && fml.equals(aimpb)), "A->B should be in the succedent of one of the new goals now, " + "it's in the antecedent, anyway."); } @@ -188,7 +192,7 @@ public void testSuccTacletAllRight() { Sequent seq = goals.head().sequent(); assertEquals(seq.antecedent(), Semisequent.EMPTY_SEMISEQUENT, "Wrong antecedent after all-right"); - assertEquals(seq.succedent().getFirst().formula().op(), + assertEquals(seq.succedent().getFirst().op(), TacletForTests.getFunctions().lookup(new Name("p")), "Wrong succedent after all-right (op mismatch)"); } @@ -230,7 +234,7 @@ public void testTacletWithIf() { @Test public void testAntecTacletWithoutIf() { - Term fma = proof[3].root().sequent().antecedent().getFirst().formula(); + Term fma = proof[3].root().sequent().antecedent().getFirst(); NoPosTacletApp impleft = TacletForTests.getRules().lookup("imp_left"); TacletIndex tacletIndex = TacletIndexKit.getKit().createTacletIndex(); tacletIndex.add(impleft); @@ -246,19 +250,19 @@ public void testAntecTacletWithoutIf() { assertEquals(2, goals.size(), "Too many or zero goals for imp-left."); Sequent seq = goals.head().sequent(); if (!seq.succedent().isEmpty()) { - assertEquals(seq.succedent().getFirst().formula(), fma.sub(0), + assertEquals(seq.succedent().getFirst(), fma.sub(0), "Wrong succedent after imp-left"); goals = goals.tail(); seq = goals.head().node().sequent(); - assertEquals(seq.antecedent().getFirst().formula(), fma.sub(1), + assertEquals(seq.antecedent().getFirst(), fma.sub(1), "Wrong antecedent after imp-left"); } else { - assertEquals(seq.antecedent().getFirst().formula(), fma.sub(1), + assertEquals(seq.antecedent().getFirst(), fma.sub(1), "Wrong antecedent after imp-left"); goals = goals.tail(); seq = goals.head().node().sequent(); - assertEquals(seq.succedent().getFirst().formula(), fma.sub(0), + assertEquals(seq.succedent().getFirst(), fma.sub(0), "Wrong succedent after imp-left"); } } @@ -282,7 +286,7 @@ public void testRewriteTacletWithoutIf() { ImmutableList goals = rApp.execute(goal, TacletForTests.services()); assertEquals(1, goals.size(), "Too many or zero goals for contradiction."); Sequent seq = goals.head().sequent(); - Term term = seq.succedent().getFirst().formula().sub(1).sub(0).sub(0); + Term term = seq.succedent().getFirst().sub(1).sub(0).sub(0); assertEquals(term, TacletForTests.parseTerm("!B -> !A")); } @@ -308,17 +312,17 @@ public void testNoFindTacletWithoutIf() { Sequent seq1 = goals.head().sequent(); goals = goals.tail(); Sequent seq2 = goals.head().sequent(); - if (!seq1.antecedent().isEmpty() && seq1.antecedent().getFirst().formula().equals(t_c)) { + if (!seq1.antecedent().isEmpty() && seq1.antecedent().getFirst().equals(t_c)) { assertTrue( - seq2.succedent().getFirst().formula().equals(t_c) - || seq2.succedent().get(1).formula().equals(t_c), + seq2.succedent().getFirst().equals(t_c) + || seq2.succedent().get(1).equals(t_c), "D is in antecedent of 1st goal but not in succedent of 2nd"); } else { assertTrue( - seq1.succedent().getFirst().formula().equals(t_c) - || seq1.succedent().get(1).formula().equals(t_c), + seq1.succedent().getFirst().equals(t_c) + || seq1.succedent().get(1).equals(t_c), "D is not in antecedent and not in succedent " + "of first new goal"); - assertEquals(seq2.antecedent().getFirst().formula(), t_c, + assertEquals(seq2.antecedent().getFirst(), t_c, "D is in succedent of first new goal, but not in antecedent " + "of second new goal"); } @@ -330,10 +334,10 @@ public void testNoFindTacletWithoutIf() { * public String automaticProof(Sequent initSeq, TacletIndex index){ String out=""; Proof * proof=new Proof(); proof.setRoot(new Node(proof, initSeq)); IList * goals=ImmSLList.nil(); Goal goal=new Goal(proof.root(),new RuleAppIndex(index)); - * goals=goals.prepend(goal); while (goals.size()!=0) { SequentFormula cfma=null; SequentFormula + * goals=goals.prepend(goal); while (goals.size()!=0) { Term cfma=null; Term * userCfma=null; // in the real system the //user would select this IList * rapplist=ImmSLList.nil(); out="\n"+out+("Goals: "+goals+"\n"); goal=goals.head(); - * Iterator it=goal.node().sequent().antecedent().iterator(); while + * Iterator it=goal.node().sequent().antecedent().iterator(); while * (it.hasNext()) { userCfma=it.next(); rapplist=rapplist.prepend(goal.ruleAppIndex(). * getTacletAppAtAndBelow(TacletFilter.TRUE, new PosInOccurrence(userCfma, PosInTerm.TOP_LEVEL, * goal.node().sequent()))); } if (rapplist.isEmpty()) { @@ -446,19 +450,22 @@ public void testBugBrokenApply() { ImmutableList goals = rApplist.head().execute(goal, TacletForTests.services); assertEquals(2, goals.size(), "Expected two goals"); + Term fml1 = goals.head().sequent().succedent().iterator().next(); + Term fml2 = goals.head().sequent().antecedent().iterator().next(); assertTrue( goals.head().sequent().antecedent().size() == 1 - && goals.head().sequent().antecedent().iterator().next().formula() + && fml2 .op() == Quantifier.ALL && goals.head().sequent().succedent().size() == 1 - && goals.head().sequent().succedent().iterator().next().formula() + && fml1 .op() == Quantifier.ALL, "First goal should be 'b==>b', but is " + goals.head().sequent()); goals = goals.tail(); + Term succFml = goals.head().sequent().succedent().iterator().next(); assertTrue( goals.head().sequent().antecedent().size() == 0 && goals.head().sequent().succedent().size() == 1 - && goals.head().sequent().succedent().iterator().next().formula() + && succFml .op() == Quantifier.ALL, "Second goal should be '==>b', but is " + goals.head().sequent()); @@ -506,11 +513,13 @@ public void testBugID177() { assertEquals(1, goals.size(), "Expected one goal"); - Iterator it = goals.head().sequent().antecedent().iterator(); + Iterator it = goals.head().sequent().antecedent().iterator(); + Term fml = it.next(); + Term fml1 = it.next(); assertTrue( goals.head().sequent().antecedent().size() == 2 - && it.next().formula().equals(TacletForTests.parseTerm("A")) - && it.next().formula().equals(TacletForTests.parseTerm("B")), + && fml1.equals(TacletForTests.parseTerm("A")) + && fml.equals(TacletForTests.parseTerm("B")), "Expected 'A, B ==>', but is " + goals.head().sequent()); } @@ -546,13 +555,15 @@ public void testBugID188() { assertEquals(1, goals.size(), "Expected one goal"); - Iterator it = goals.head().sequent().antecedent().iterator(); + Iterator it = goals.head().sequent().antecedent().iterator(); + Term fml = it.next(); + Term fml1 = it.next(); assertTrue( goals.head().sequent().antecedent().size() == 2 && goals.head().sequent().succedent().size() == 0 - && it.next().formula().equals(TacletForTests.parseTerm("A")) - && it.next().formula().equals(TacletForTests.parseTerm("B")), + && fml1.equals(TacletForTests.parseTerm("A")) + && fml.equals(TacletForTests.parseTerm("B")), "Expected 'A, B ==>', but is " + goals.head().sequent()); } @@ -611,10 +622,9 @@ public void testModalityLevel1() { assertEquals(0, appList.size(), "Did not expect a match."); - Term ifterm = TacletForTests.parseTerm("{i:=0}(f(const)=f(f(const)))"); - SequentFormula ifformula = new SequentFormula(ifterm); + Term assumesFormula = TacletForTests.parseTerm("{i:=0}(f(const)=f(f(const)))"); ImmutableList ifInsts = ImmutableSLList - .nil().prepend(new IfFormulaInstDirect(ifformula)); + .nil().prepend(new IfFormulaInstDirect(assumesFormula)); appIt = rApplist.iterator(); while (appIt.hasNext()) { TacletApp a = @@ -632,13 +642,13 @@ public void testModalityLevel1() { { // Goal one Sequent correctSeq = - proof[11].root().sequent().addFormula(ifformula, true, true).sequent(); + proof[11].root().sequent().addFormula(assumesFormula, true, true).sequent(); assertEquals(goals.head().sequent(), correctSeq, "Wrong result"); } { // Goal two Sequent correctSeq = - proof[10].root().sequent().addFormula(ifformula, false, true).sequent(); + proof[10].root().sequent().addFormula(assumesFormula, false, true).sequent(); assertEquals(goals.tail().head().sequent(), correctSeq, "Wrong result"); } } @@ -737,8 +747,8 @@ private void doTestCatchList(int p_proof) { Sequent correctSeq = proof[p_proof + 1].root().sequent(); - Term resultFormula = goals.head().sequent().getFormulabyNr(1).formula(); - Term correctFormula = correctSeq.getFormulabyNr(1).formula(); + Term resultFormula = goals.head().sequent().getFormulabyNr(1); + Term correctFormula = correctSeq.getFormulabyNr(1); assertTrue(resultFormula.equalsModProperty(correctFormula, RENAMING_PROPERTY), "Wrong result. Expected:" @@ -808,10 +818,12 @@ public void testCompleteContextAddBug() { assertEquals(1, goals.size(), "Expected one goal."); // the content of the diamond must not have changed + Term fml1 = proof[22].root().sequent().getFormulabyNr(1); ProgramElement expected = - proof[22].root().sequent().getFormulabyNr(1).formula().javaBlock().program(); + fml1.javaBlock().program(); + Term fml = goals.head().sequent().getFormulabyNr(1); ProgramElement is = - goals.head().sequent().getFormulabyNr(1).formula().sub(0).javaBlock().program(); + fml.sub(0).javaBlock().program(); assertEquals(expected, is, "Context has been thrown away."); } @@ -844,8 +856,9 @@ public void testContextAdding() { TacletForTests.parsePrg("{try{ ; while (1==1) {if (1==2) {break;}} return 1==3; " + "int i=17; } catch (Exception e) { return null;}}"); + Term fml = goals.head().sequent().getFormulabyNr(1); ProgramElement is = - goals.head().sequent().getFormulabyNr(1).formula().javaBlock().program(); + fml.javaBlock().program(); // FIXME weigl: This test case is spurious: // actual.toString() == expected.toString() but internally there is a difference. assertTrue(expected.equalsModRenaming(is, new NameAbstractionTable()), @@ -880,8 +893,7 @@ public void testRemoveEmptyBlock() { TacletForTests.parsePrg("{try{while (1==1) {if (1==2) {break;}} return 1==3; " + "int i=17; } catch (Exception e) { return null;}}"); - ProgramElement is = - goals.head().sequent().getFormulabyNr(1).formula().javaBlock().program(); + ProgramElement is = goals.head().sequent().getFormulabyNr(1).javaBlock().program(); assertTrue(expected.equalsModRenaming(is, new NameAbstractionTable()), "Expected:" + expected + "\n but was:" + is); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/TestCollisionResolving.java b/key.core/src/test/java/de/uka/ilkd/key/rule/TestCollisionResolving.java index cc1acbca408..19b8b4c404a 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/TestCollisionResolving.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/TestCollisionResolving.java @@ -120,7 +120,7 @@ public void testCollisionResolvingWithContext() { (FindTaclet) TacletForTests.getTaclet("TestCollisionResolving_coll_context").taclet(); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(term), PosInTerm.getTopLevel().down(0), true); + new PosInOccurrence(term, PosInTerm.getTopLevel().down(0), true); TacletApp result = PosTacletApp.createPosTacletApp(coll_varSV, coll_varSV.getMatcher().matchFind( @@ -145,7 +145,7 @@ public void testVarNamespaceCreationWithContext() { FindTaclet taclet = (FindTaclet) TacletForTests.getTaclet("TestCollisionResolving_ns1").taclet(); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(term), PosInTerm.getTopLevel().down(0), true); + new PosInOccurrence(term, PosInTerm.getTopLevel().down(0), true); TacletApp app = PosTacletApp.createPosTacletApp(taclet, taclet.getMatcher().matchFind(term.sub(0), MatchConditions.EMPTY_MATCHCONDITIONS, null), pos, services); @@ -214,10 +214,12 @@ public void testNameConflict1() { SchemaVariable v = TacletForTests.getSchemaVariables().lookup(new Name("v")); FindTaclet taclet = (FindTaclet) TacletForTests.getTaclet("TestCollisionResolving_name_conflict").taclet(); + Term uAssumptions = TacletForTests.parseTerm("\\exists s x; p(x)"); + Term uAssumptions1 = TacletForTests.parseTerm("\\forall s x; p(x)"); Semisequent semiseq = Semisequent.EMPTY_SEMISEQUENT - .insert(0, new SequentFormula(TacletForTests.parseTerm("\\forall s x; p(x)"))) + .insert(0, uAssumptions1) .semisequent() - .insert(1, new SequentFormula(TacletForTests.parseTerm("\\exists s x; p(x)"))) + .insert(1, uAssumptions) .semisequent(); Sequent seq = Sequent.createSuccSequent(semiseq); PosInOccurrence pos = new PosInOccurrence(semiseq.get(0), PosInTerm.getTopLevel(), false); @@ -304,8 +306,8 @@ public void testNameConflictAfterInput() throws SVInstantiationException { * SchemaVariable v = TacletForTests.getVariables().lookup(new Name("v")); FindTaclet taclet = * (FindTaclet) TacletForTests.getTaclet * ("TestCollisionResolving_name_conflict_with_context").taclet(); Semisequent semiseq = - * Semisequent.EMPTY_SEMISEQUENT .insert(0, new SequentFormula(TacletForTests.parseTerm("ex x:s" - * +".p(x)"))) .insert(1, new SequentFormula(TacletForTests.parseTerm("all x:s" +".p(x)"))); + * Semisequent.EMPTY_SEMISEQUENT .insert(0, Term.create(TacletForTests.parseTerm("ex x:s" + * +".p(x)"))) .insert(1, Term.create(TacletForTests.parseTerm("all x:s" +".p(x)"))); * Sequent seq=Sequent.createSuccSequent(semiseq); PosInOccurrence pos=new * PosInOccurrence(semiseq.get(1), PosInTerm.TOP_LEVEL.down(0), seq); IList * sviList=taclet.matchIf (seq, taclet.match(semiseq.get(1).formula().sub(0), taclet.find(), @@ -327,7 +329,7 @@ public void testNameConflictWithContextAfterInput() throws SVInstantiationExcept .getTaclet("TestCollisionResolving_name_conflict_with_context2").taclet(); Term term = TacletForTests.parseTerm("\\forall s x; p(x)"); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(term), PosInTerm.getTopLevel().down(0), true); + new PosInOccurrence(term, PosInTerm.getTopLevel().down(0), true); MatchConditions mc = taclet.getMatcher().matchFind(term.sub(0), MatchConditions.EMPTY_MATCHCONDITIONS, null); TacletApp app = PosTacletApp.createPosTacletApp(taclet, mc, pos, services); diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/TestMatchTaclet.java b/key.core/src/test/java/de/uka/ilkd/key/rule/TestMatchTaclet.java index f2e55c57052..448af059941 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/TestMatchTaclet.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/TestMatchTaclet.java @@ -125,8 +125,9 @@ public void testVarOccursInIfAndAddRule() { // test at the subformula p(z) -> A that has a free variable // therefore no match should be found + Term uAssumptions = match.sub(0); Sequent seq = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(match.sub(0))).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, uAssumptions).semisequent(), Semisequent.EMPTY_SEMISEQUENT); assertEquals(0, @@ -137,7 +138,7 @@ public void testVarOccursInIfAndAddRule() { // we bind the free variable now a match should be found seq = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(match)).semisequent(), + Semisequent.EMPTY_SEMISEQUENT.insert(0, match).semisequent(), Semisequent.EMPTY_SEMISEQUENT); assertNotEquals(0, @@ -159,7 +160,7 @@ public void testVarOccursInFindAndAddRule() { find_addrule_conflict.getMatcher() .matchFind(match.sub(0), MatchConditions.EMPTY_MATCHCONDITIONS, services) .getInstantiations(), - new PosInOccurrence(new SequentFormula(match), PosInTerm.getTopLevel().down(0), true), + new PosInOccurrence(match, PosInTerm.getTopLevel().down(0), true), services); @@ -173,7 +174,7 @@ public void testVarOccursInFindAndAddRule() { find_addrule_conflict.getMatcher() .matchFind(match, MatchConditions.EMPTY_MATCHCONDITIONS, services) .getInstantiations(), - new PosInOccurrence(new SequentFormula(match), PosInTerm.getTopLevel(), true), + new PosInOccurrence(match, PosInTerm.getTopLevel(), true), services); assertNotNull(app, "A match should have been found," + " because here there formerly free variable is bound."); @@ -188,13 +189,14 @@ public void testRWVarOccursFindAndIf() { // seq contains term that can match but has a free variable, so // matching to a should be not possible Term match = TacletForTests.parseTerm("\\forall testSort z; (p(z) -> A)"); + Term uAssumptions = match.sub(0); TacletApp app = PosTacletApp .createPosTacletApp(if_find_clash, if_find_clash.getMatcher() .matchFind(match.sub(0), MatchConditions.EMPTY_MATCHCONDITIONS, services) .getInstantiations(), - new PosInOccurrence(new SequentFormula(match.sub(0)), + new PosInOccurrence(uAssumptions, PosInTerm.getTopLevel().down(0), true), services); @@ -247,14 +249,14 @@ public void testCloseWithBoundRenaming() { Term closeable_one = TacletForTests.parseTerm("\\forall testSort z; p(z)"); Term closeable_two = TacletForTests.parseTerm("\\forall testSort y; p(y)"); Sequent seq = Sequent.createSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(closeable_one)) + Semisequent.EMPTY_SEMISEQUENT.insert(0, closeable_one) .semisequent(), - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(closeable_two)) + Semisequent.EMPTY_SEMISEQUENT.insert(0, closeable_two) .semisequent()); TacletIndex index = TacletIndexKit.getKit().createTacletIndex(); index.add(close_rule.taclet()); PosInOccurrence pio = - new PosInOccurrence(new SequentFormula(closeable_two), PosInTerm.getTopLevel(), false); + new PosInOccurrence(closeable_two, PosInTerm.getTopLevel(), false); TacletApp tacletApp = index.getSuccedentTaclet(pio, new IHTacletFilter(true, ImmutableSLList.nil()), services) diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/TestSchemaModalOperators.java b/key.core/src/test/java/de/uka/ilkd/key/rule/TestSchemaModalOperators.java index 00360649d89..cdbe9d57518 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/TestSchemaModalOperators.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/TestSchemaModalOperators.java @@ -47,7 +47,8 @@ private static Semisequent parseTermForSemisequent(String t) { if ("".equals(t)) { return Semisequent.EMPTY_SEMISEQUENT; } - SequentFormula cf0 = new SequentFormula(TacletForTests.parseTerm(t)); + Term uAssumptions = TacletForTests.parseTerm(t); + Term cf0 = uAssumptions; return Semisequent.EMPTY_SEMISEQUENT.insert(0, cf0).semisequent(); } @@ -94,8 +95,8 @@ public void setUp() { * consMV_f_c_X = Constraint.BOTTOM.unify(t_mv, t_f_c_X); consMV_f_X_c = * Constraint.BOTTOM.unify(t_mv, t_f_X_c); * - * SequentFormula cf1 = new SequentFormula(TacletForTests.parseTerm("A & B"), consMV_f_c_X); - * SequentFormula cf2 = new SequentFormula(TacletForTests.parseTerm("!(A | B)"), + * Term cf1 = Term.create(TacletForTests.parseTerm("A & B"), consMV_f_c_X); + * Term cf2 = Term.create(TacletForTests.parseTerm("!(A | B)"), * consMV_f_X_c); * * Sequent seq = Sequent.createSequent @@ -152,10 +153,9 @@ public void testSchemaModalities1() { assertSame(Modality.JavaModalityKind.DIA, mc.getInstantiations().getInstantiation(osv)); PosInOccurrence pos = - new PosInOccurrence(new SequentFormula(goal), PosInTerm.getTopLevel(), true); + new PosInOccurrence(goal, PosInTerm.getTopLevel(), true); PosTacletApp tacletApp = PosTacletApp.createPosTacletApp(t, mc, pos, services); - Term instReplace = - t.getRewriteResult(null, new TermLabelState(), services, tacletApp).formula(); + Term instReplace = t.getRewriteResult(null, new TermLabelState(), services, tacletApp); assertNotNull(instReplace); assertSame(Modality.JavaModalityKind.DIA, ((Modality) instReplace.op()).kind()); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/tacletbuilder/TestTacletBuild.java b/key.core/src/test/java/de/uka/ilkd/key/rule/tacletbuilder/TestTacletBuild.java index 6cdd90af208..e97aea5da65 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/tacletbuilder/TestTacletBuild.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/tacletbuilder/TestTacletBuild.java @@ -78,7 +78,7 @@ public void testUniquenessOfIfAndFindVarSVsInIfAndFind() { Term A = tf.createTerm(TacletForTests.getFunctions().lookup(new Name("A")), NO_SUBTERMS); Term t1 = tb.all((QuantifiableVariable) u, A); Sequent seq = Sequent.createSuccSequent( - Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t1)).semisequent()); + Semisequent.EMPTY_SEMISEQUENT.insert(0, t1).semisequent()); Term t2 = tb.ex((QuantifiableVariable) u, A); SuccTacletBuilder sb = new SuccTacletBuilder(); sb.setIfSequent(seq); @@ -100,8 +100,8 @@ public void testUniquenessOfIfAndFindVarSVBothInIf() { Term t1 = tb.all((QuantifiableVariable) u, A); Term t2 = tb.ex((QuantifiableVariable) u, A); Sequent seq = Sequent - .createSuccSequent(Semisequent.EMPTY_SEMISEQUENT.insert(0, new SequentFormula(t1)) - .semisequent().insert(1, new SequentFormula(t2)).semisequent()); + .createSuccSequent(Semisequent.EMPTY_SEMISEQUENT.insert(0, t1) + .semisequent().insert(1, t2).semisequent()); SuccTacletBuilder sb = new SuccTacletBuilder(); sb.setIfSequent(seq); sb.setFind(A); diff --git a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/ProveSMTLemmasTest.java b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/ProveSMTLemmasTest.java index b05f4767d35..1c4b18b9fcc 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/ProveSMTLemmasTest.java +++ b/key.core/src/test/java/de/uka/ilkd/key/smt/newsmt2/ProveSMTLemmasTest.java @@ -91,7 +91,7 @@ public void testSMTLemmaSoundness(String name, String lemmaString) throws Except // and check if proofs are actually for the right theorem! KeyIO io = new KeyIO(loadedProof.getServices()); Term parsedLemma = io.parseExpression(lemmaString); - Term actual = loadedProof.root().sequent().succedent().get(0).formula(); + Term actual = loadedProof.root().sequent().succedent().get(0); if (!actual.equalsModProperty(parsedLemma, RENAMING_PROPERTY)) { LOGGER.info("Stored : {}", parsedLemma); LOGGER.warn("Proven : {}", actual); diff --git a/key.core/src/test/java/de/uka/ilkd/key/util/TestEqualsModProofIrrelevancy.java b/key.core/src/test/java/de/uka/ilkd/key/util/TestEqualsModProofIrrelevancy.java index f8347da086e..5927c33693d 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/util/TestEqualsModProofIrrelevancy.java +++ b/key.core/src/test/java/de/uka/ilkd/key/util/TestEqualsModProofIrrelevancy.java @@ -7,7 +7,8 @@ import de.uka.ilkd.key.control.DefaultUserInterfaceControl; import de.uka.ilkd.key.control.KeYEnvironment; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Proof; @@ -48,9 +49,10 @@ void testJavaProof() throws Exception { Assertions.assertNotNull(node1); Assertions.assertNotNull(node2); for (int j = 1; j <= node1.sequent().size(); j++) { - SequentFormula sf1 = node1.sequent().getFormulabyNr(j); - SequentFormula sf2 = node2.sequent().getFormulabyNr(j); - Assertions.assertTrue(sf1.equalsModProofIrrelevancy(sf2)); + Term sf1 = node1.sequent().getFormulabyNr(j); + Term sf2 = node2.sequent().getFormulabyNr(j); + Assertions.assertTrue(ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .equalsModThisProperty(sf1, sf2)); } if (node1.getAppliedRuleApp() != null) { Assertions.assertTrue( diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/InspectorForDecisionPredicates.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/InspectorForDecisionPredicates.java index 78df3ba18cb..5676ef78b9f 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/InspectorForDecisionPredicates.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/InspectorForDecisionPredicates.java @@ -10,7 +10,6 @@ import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.ldt.JavaDLTheory; import de.uka.ilkd.key.logic.Semisequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.nparser.KeyIO; import de.uka.ilkd.key.proof.Node; @@ -50,8 +49,8 @@ public String check(String toBeChecked) { String position = cutMode == DelayedCut.DECISION_PREDICATE_IN_ANTECEDENT ? "antecedent" : "succedent"; - for (SequentFormula sf : semisequent) { - if (sf.formula() == term) { + for (Term sf : semisequent) { + if (sf == term) { return "Formula already exists in " + position + "."; } } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/LoopInvariantRuleCompletion.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/LoopInvariantRuleCompletion.java index fea7e23bb8c..2307cc5837a 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/LoopInvariantRuleCompletion.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/LoopInvariantRuleCompletion.java @@ -10,6 +10,7 @@ import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.rule.*; +import de.uka.ilkd.key.rule.RuleAbortException; import de.uka.ilkd.key.speclang.LoopSpecImpl; import de.uka.ilkd.key.speclang.LoopSpecification; import de.uka.ilkd.key.util.MiscTools; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/mergerule/MergePartnerSelectionDialog.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/mergerule/MergePartnerSelectionDialog.java index a09d0a39715..609394256ea 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/mergerule/MergePartnerSelectionDialog.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/mergerule/MergePartnerSelectionDialog.java @@ -431,16 +431,17 @@ private static boolean checkProvability(Sequent seq, Term formulaToProve, Servic Semisequent antecedent = seq.antecedent(); - for (SequentFormula succedentFormula : seq.succedent()) { - if (!succedentFormula.formula().containsJavaBlockRecursive()) { + for (Term succedentFormula : seq.succedent()) { + if (!succedentFormula.containsJavaBlockRecursive()) { + Term uAssumptions = tb.not(succedentFormula); antecedent = - antecedent.insertFirst(new SequentFormula(tb.not(succedentFormula.formula()))) + antecedent.insertFirst(uAssumptions) .semisequent(); } } return MergeRuleUtils.isProvable( - Sequent.createSequent(antecedent, new Semisequent(new SequentFormula(formulaToProve))), + Sequent.createSequent(antecedent, new Semisequent(formulaToProve)), services, 1000); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/DragNDropInstantiator.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/DragNDropInstantiator.java index ad048dbd1b3..79733ecce59 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/DragNDropInstantiator.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/DragNDropInstantiator.java @@ -351,7 +351,7 @@ private ImmutableList completeIfInstantiations(ImmutableListnil().prepend(ifInst); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentView.java index 0db35e40024..c5ac08a3604 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/nodeviews/SequentView.java @@ -761,7 +761,7 @@ protected void updateHeatmapSFHighlights(int max_age, boolean newest) { } } else { // all formulas below MAX_AGE_FOR_HEATMAP are highlighted. for (SequentPrintFilterEntry entry : entryList) { - SequentFormula form = entry.getFilteredFormula(); + Term form = entry.getFilteredFormula(); int age = computeSeqFormulaAge(getMainWindow().getMediator().getSelectedNode(), form, max_age + 2); if (age < max_age) { @@ -806,15 +806,15 @@ protected void updateHeatmapTermHighlights(int max_age, boolean newest) { while (it.hasNext()) { node = it.next(); if (node.getNodeInfo().getSequentChangeInfo() != null) { - ImmutableList added_ante = + ImmutableList added_ante = node.getNodeInfo().getSequentChangeInfo().addedFormulas(true); - ImmutableList added_succ = + ImmutableList added_succ = node.getNodeInfo().getSequentChangeInfo().addedFormulas(false); - for (SequentFormula sf : added_ante) { + for (Term sf : added_ante) { pio_age_list.add( new PIO_age(new PosInOccurrence(sf, PosInTerm.getTopLevel(), true), age)); } - for (SequentFormula sf : added_succ) { + for (Term sf : added_succ) { pio_age_list.add( new PIO_age(new PosInOccurrence(sf, PosInTerm.getTopLevel(), false), age)); } @@ -824,7 +824,7 @@ protected void updateHeatmapTermHighlights(int max_age, boolean newest) { PosInOccurrence positionOfMod = fci.positionOfModification(); pio_age_list.add(new PIO_age(positionOfMod, age)); for (PIO_age pair : pio_age_list) { - if (pair.get_pio().sequentFormula().equals(fci.getOriginalFormula())) { + if (pair.get_pio().sequentLevelFormula().equals(fci.getOriginalFormula())) { if (positionOfMod.posInTerm().isPrefixOf(pair.get_pio().posInTerm())) { pair.active = false; } else { @@ -834,19 +834,19 @@ protected void updateHeatmapTermHighlights(int max_age, boolean newest) { } } } - for (SequentFormula sf : node.getNodeInfo().getSequentChangeInfo() + for (Term sf : node.getNodeInfo().getSequentChangeInfo() .removedFormulas(true)) { for (PIO_age pair : pio_age_list) { - if (pair.get_pio().sequentFormula().equals(sf) + if (pair.get_pio().sequentLevelFormula().equals(sf) && pair.get_pio().isInAntec()) { pair.active = false; } } } - for (SequentFormula sf : node.getNodeInfo().getSequentChangeInfo() + for (Term sf : node.getNodeInfo().getSequentChangeInfo() .removedFormulas(false)) { for (PIO_age pair : pio_age_list) { - if (pair.get_pio().sequentFormula().equals(sf) + if (pair.get_pio().sequentLevelFormula().equals(sf) && !pair.get_pio().isInAntec()) { pair.active = false; } @@ -930,7 +930,7 @@ private Color computeColorForAge(int max_age, int age) { * @param max_age the maximum age, specified in viewSettings * @return the sf's age */ - private int computeSeqFormulaAge(Node node, SequentFormula form, int max_age) { + private int computeSeqFormulaAge(Node node, Term form, int max_age) { int age = -1; while (age < max_age && node != null && node.sequent().contains(form)) { age++; diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/originlabels/OriginTermLabelVisualizer.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/originlabels/OriginTermLabelVisualizer.java index e08bdb030a5..0be5786e726 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/originlabels/OriginTermLabelVisualizer.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/originlabels/OriginTermLabelVisualizer.java @@ -409,7 +409,7 @@ private PosInOccurrence convertPio(PosInOccurrence pio) { if (termPio == null) { return pio; } else if (pio == null) { - return new PosInOccurrence(termPio.sequentFormula(), termPio.posInTerm(), + return new PosInOccurrence(termPio.sequentLevelFormula(), termPio.posInTerm(), termPio.isInAntec()); } else { PosInTerm completePos = termPio.posInTerm(); @@ -419,7 +419,8 @@ private PosInOccurrence convertPio(PosInOccurrence pio) { completePos = completePos.down(it.next()); } - return new PosInOccurrence(termPio.sequentFormula(), completePos, termPio.isInAntec()); + return new PosInOccurrence(termPio.sequentLevelFormula(), completePos, + termPio.isInAntec()); } } @@ -435,9 +436,9 @@ private void buildModel(TreeNode parentNode, PosInOccurrence parentPos, if (parentPos == null) { int index = 0; - ImmutableList children = sequent.antecedent().asList(); + ImmutableList children = sequent.antecedent().asList(); - for (SequentFormula child : children) { + for (Term child : children) { PosInOccurrence childPos = new PosInOccurrence(child, PosInTerm.getTopLevel(), true); TreeNode childNode = new TreeNode(childPos); @@ -450,7 +451,7 @@ private void buildModel(TreeNode parentNode, PosInOccurrence parentPos, children = sequent.succedent().asList(); - for (SequentFormula child : children) { + for (Term child : children) { PosInOccurrence childPos = new PosInOccurrence(child, PosInTerm.getTopLevel(), false); TreeNode childNode = new TreeNode(childPos); diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/proofdiff/ProofDifference.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/proofdiff/ProofDifference.java index abcbed2365a..b10161c32e9 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/proofdiff/ProofDifference.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/proofdiff/ProofDifference.java @@ -45,7 +45,9 @@ public static ProofDifference create(Node left, Node right, Function initialise(Function printer, Semisequent semisequent) { - return semisequent.asList().stream().map(it -> printer.apply(it.formula())) + return semisequent.asList().stream().map(it -> { + return printer.apply(it); + }) .collect(Collectors.toList()); } diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java index 5ccd3abc9fc..329ac53aae7 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/prooftree/ProofTreeView.java @@ -959,7 +959,8 @@ public void valueChanged(TreeSelectionEvent e) { var ossParentNode = ((GUIProofTreeNode) ossNode.getParent()); var newSequent = ossParentNode.getNode().sequent(); var modifiedSequent = newSequent - .replaceFormula(ossNode.getFormulaNr(), pio.sequentFormula()).sequent(); + .replaceFormula(ossNode.getFormulaNr(), pio.sequentLevelFormula()) + .sequent(); mediator.getSelectionModel().setSelectedSequentAndRuleApp( ossParentNode.getNode(), modifiedSequent, ossNode.getRuleApp()); } else { diff --git a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java index 1ee7b710b81..6e8fea862a1 100644 --- a/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java +++ b/key.ui/src/main/java/de/uka/ilkd/key/gui/sourceview/SourceView.java @@ -234,7 +234,7 @@ private void ensureProofJavaSourceCollectionExists(Proof proof) { proof.register(sources, ProofJavaSourceCollection.class); proof.root().sequent().forEach(formula -> { OriginTermLabel originLabel = - (OriginTermLabel) formula.formula().getLabel(OriginTermLabel.NAME); + (OriginTermLabel) formula.getLabel(OriginTermLabel.NAME); if (originLabel != null) { if (originLabel.getOrigin() instanceof OriginTermLabel.FileOrigin) { ((OriginTermLabel.FileOrigin) originLabel.getOrigin()) @@ -736,64 +736,71 @@ private LinkedList> constructLinesSet(Node node) { // proof obligation belongs to is always loaded. node.sequent().forEach( - formula -> formula.formula().execPostOrder(new Visitor() { + formula -> { + formula.execPostOrder(new Visitor() { - @Override - public boolean visitSubtree(Term visited) { - return visited.containsJavaBlockRecursive(); - } + @Override + public boolean visitSubtree(Term visited) { + return visited.containsJavaBlockRecursive(); + } - @Override - public void visit(Term visited) {} - - @Override - public void subtreeLeft(Term subtreeRoot) {} - - @Override - public void subtreeEntered(Term subtreeRoot) { - if (subtreeRoot.javaBlock() != null) { - JavaASTVisitor visitor = - new JavaASTVisitor(subtreeRoot.javaBlock().program(), - mainWindow.getMediator().getServices()) { - - @Override - protected void doDefaultAction(SourceElement el) { - if (el instanceof MethodBodyStatement mb) { - Statement body = mb.getBody(services); - PositionInfo posInf = null; - // try to find position information of the source - // element - if (body != null) { - posInf = body.getPositionInfo(); - } else { - // the method is declared without a body - // -> we try to show the file either way - IProgramMethod pm = mb.getProgramMethod(services); - if (pm != null) { - posInf = pm.getPositionInfo(); + @Override + public void visit(Term visited) {} + + @Override + public void subtreeLeft(Term subtreeRoot) {} + + @Override + public void subtreeEntered(Term subtreeRoot) { + if (subtreeRoot.javaBlock() != null) { + JavaASTVisitor visitor = + new JavaASTVisitor(subtreeRoot.javaBlock().program(), + mainWindow.getMediator().getServices()) { + + @Override + protected void doDefaultAction(SourceElement el) { + if (el instanceof MethodBodyStatement mb) { + Statement body = mb.getBody(services); + PositionInfo posInf = null; + // try to find position information of the source + // element + if (body != null) { + posInf = body.getPositionInfo(); + } else { + // the method is declared without a body + // -> we try to show the file either way + IProgramMethod pm = + mb.getProgramMethod(services); + if (pm != null) { + posInf = pm.getPositionInfo(); + } } - } - if (posInf != null && posInf.getURI().isPresent()) { - // sometimes the useful file info is only stored in - // parentClassURI for some reason ... - if (posInf.getURI().isPresent()) { - node.proof() - .lookup(ProofJavaSourceCollection.class) - .addRelevantFile(posInf.getURI().get()); - } else if (posInf.getParentClassURI() != null) { - node.proof() - .lookup(ProofJavaSourceCollection.class) - .addRelevantFile( - posInf.getParentClassURI()); + if (posInf != null && posInf.getURI().isPresent()) { + // sometimes the useful file info is only stored + // in + // parentClassURI for some reason ... + if (posInf.getURI().isPresent()) { + node.proof() + .lookup( + ProofJavaSourceCollection.class) + .addRelevantFile( + posInf.getURI().get()); + } else if (posInf.getParentClassURI() != null) { + node.proof() + .lookup( + ProofJavaSourceCollection.class) + .addRelevantFile( + posInf.getParentClassURI()); + } } } } - } - }; - visitor.start(); + }; + visitor.start(); + } } - } - })); + }); + }); } return list; diff --git a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java index b46809d980a..b0b75675647 100644 --- a/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java +++ b/key.util/src/main/java/org/key_project/util/collection/ImmutableList.java @@ -37,7 +37,7 @@ public interface ImmutableList * @param list a List. * @return an ImmutableList containing the same elements as the specified list. */ - static ImmutableList fromList(Collection list) { + static ImmutableList fromList(Iterable list) { ImmutableList result = ImmutableSLList.nil(); for (T el : list) { diff --git a/keyext.caching/src/main/java/de/uka/ilkd/key/proof/reference/ReferenceSearcher.java b/keyext.caching/src/main/java/de/uka/ilkd/key/proof/reference/ReferenceSearcher.java index 14b5265c330..387f6eb45c2 100644 --- a/keyext.caching/src/main/java/de/uka/ilkd/key/proof/reference/ReferenceSearcher.java +++ b/keyext.caching/src/main/java/de/uka/ilkd/key/proof/reference/ReferenceSearcher.java @@ -5,12 +5,11 @@ import java.util.*; import java.util.stream.Collectors; -import javax.swing.*; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.rule.NoPosTacletApp; @@ -146,10 +145,11 @@ public static ClosedBy findPreviousProof(List previousProofs, Node newNod * @return whether all formulas are present */ private static boolean containedIn(Semisequent superset, Semisequent subset) { - for (SequentFormula sf : subset) { + for (Term sf : subset) { boolean found = false; - for (SequentFormula sf2 : superset) { - if (sf2.equalsModProofIrrelevancy(sf)) { + for (Term sf2 : superset) { + if (ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY.equalsModThisProperty(sf2, + sf)) { found = true; break; } @@ -173,7 +173,7 @@ public static boolean suitableForCloseByReference(Node node) { ProgramMethodFinder f = new ProgramMethodFinder(); Sequent seq = node.sequent(); for (int i = 1; i <= seq.size(); i++) { - Term term = seq.getFormulabyNr(i).formula(); + Term term = seq.getFormulabyNr(i); // first, check for a java block if (term.containsJavaBlockRecursive()) { // not suitable for caching diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java index 310148a5efd..b0ccf0fedde 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/ProofExplorationService.java @@ -105,10 +105,10 @@ private FindTaclet getHideTaclet(boolean inAntec) { public @NonNull Node soundAddition(@NonNull Goal g, @NonNull Term t, boolean antecedent) { Taclet cut = g.proof().getEnv().getInitConfigForEnvironment().lookupActiveTaclet(new Name("cut")); - Semisequent semisequent = new Semisequent(new SequentFormula(t)); + Semisequent semisequent = new Semisequent(t); TacletApp app = NoPosTacletApp.createNoPosTacletApp(cut); SchemaVariable sv = app.uninstantiatedVars().iterator().next(); - app = app.addCheckedInstantiation(sv, semisequent.getFirst().formula(), services, true); + app = app.addCheckedInstantiation(sv, semisequent.getFirst(), services, true); ExplorationNodeData explorationNodeData = new ExplorationNodeData(); if (antecedent) { explorationNodeData.setExplorationAction("Added " + t + " ==>"); @@ -186,11 +186,10 @@ public Node applyChangeFormula(@NonNull Goal g, @NonNull PosInOccurrence pio, private TacletApp soundChange(@NonNull PosInOccurrence pio, @NonNull Term term, @NonNull Term newTerm) { Taclet cut = getCutTaclet(); - Semisequent semisequent = new Semisequent(new SequentFormula(newTerm)); + Semisequent semisequent = new Semisequent(newTerm); TacletApp app = NoPosTacletApp.createNoPosTacletApp(cut); SchemaVariable sv = app.uninstantiatedVars().iterator().next(); - app = app.addCheckedInstantiation(sv, semisequent.getFirst().formula(), services, true); - return app; + return app.addCheckedInstantiation(sv, semisequent.getFirst(), services, true); } public void soundHide(Goal g, PosInOccurrence pio, Term term) { diff --git a/keyext.exploration/src/main/java/org/key_project/exploration/actions/EditFormulaAction.java b/keyext.exploration/src/main/java/org/key_project/exploration/actions/EditFormulaAction.java index 754adf282d8..aed6f0c5186 100644 --- a/keyext.exploration/src/main/java/org/key_project/exploration/actions/EditFormulaAction.java +++ b/keyext.exploration/src/main/java/org/key_project/exploration/actions/EditFormulaAction.java @@ -7,7 +7,6 @@ import de.uka.ilkd.key.gui.MainWindow; import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.SequentFormula; import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.logic.TermBuilder; import de.uka.ilkd.key.pp.PosInSequent; @@ -50,7 +49,7 @@ public void actionPerformed(ActionEvent e) { TermBuilder tb = getMediator().getServices().getTermBuilder(); PosInOccurrence pio = posInSeq.getPosInOccurrence(); Term term = pio.subTerm(); - SequentFormula sf = pio.sequentFormula(); + Term sf = pio.sequentLevelFormula(); Goal g = getMediator().getSelectedGoal(); Term newTerm = promptForTerm(mainWindow, term); @@ -59,8 +58,8 @@ public void actionPerformed(ActionEvent e) { } ProofExplorationService api = ProofExplorationService.get(getMediator()); - Node toBeSelected = api.applyChangeFormula(g, pio, sf.formula(), - tb.replace(sf.formula(), pio.posInTerm(), newTerm)); + Node toBeSelected = api.applyChangeFormula(g, pio, sf, + tb.replace(sf, pio.posInTerm(), newTerm)); getMediator().getSelectionModel().setSelectedNode(toBeSelected); } } diff --git a/keyext.exploration/src/test/java/org/key_project/exploration/ProofExplorationServiceTest.java b/keyext.exploration/src/test/java/org/key_project/exploration/ProofExplorationServiceTest.java index b65232317fe..3faa2e75c6f 100644 --- a/keyext.exploration/src/test/java/org/key_project/exploration/ProofExplorationServiceTest.java +++ b/keyext.exploration/src/test/java/org/key_project/exploration/ProofExplorationServiceTest.java @@ -150,7 +150,7 @@ public void testChangeFormula() { Sequent sequent = goals.head().node().sequent(); PosInOccurrence pio = new PosInOccurrence(sequent.succedent().get(0), PosInTerm.getTopLevel(), false); - expService.applyChangeFormula(goals.head(), pio, sequent.succedent().get(0).formula(), + expService.applyChangeFormula(goals.head(), pio, sequent.succedent().get(0), change); ImmutableList newCreatedGoals = currentProof.openGoals(); @@ -199,7 +199,7 @@ private void testAddition(Goal withAddedTerm, Goal justification, Term added, bo assertSame(semiSeqAdded.size(), parentSemiSeqOfAdded.size() + 1, "The size of the added semisequent has changed"); - assertEquals(semiSeqAdded.get(0).formula(), added, "Added Term is indeed added"); + assertEquals(semiSeqAdded.get(0), added, "Added Term is indeed added"); assertFalse(justification.isAutomatic(), "Justification branch is marked as interactive"); assertSame(semiSeqUntouched.size(), parentSemiSeqOfUntouched.size(), diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java b/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java index 1e629f71944..6ed6b7cc945 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java @@ -146,7 +146,7 @@ private List> inputsOfNode(Node n, Set boolean added = false; for (int i = 0; i <= size; i++) { TrackedFormula formula = - new TrackedFormula(in.sequentFormula(), loc, in.isInAntec(), + new TrackedFormula(in.sequentLevelFormula(), loc, in.isInAntec(), proof.getServices()); if (graph.containsNode(formula)) { input.add(new Pair<>(formula, removed.contains(in))); @@ -159,12 +159,13 @@ private List> inputsOfNode(Node n, Set } if (!added) { // should only happen if the formula is the initial proof obligation - if (!proof.root().sequent().contains(in.sequentFormula())) { + if (!proof.root().sequent().contains(in.sequentLevelFormula())) { throw new IllegalStateException( - "found formula that was not produced by any rule! " + in.sequentFormula()); + "found formula that was not produced by any rule! " + + in.sequentLevelFormula()); } TrackedFormula formula = - new TrackedFormula(in.sequentFormula(), loc, in.isInAntec(), + new TrackedFormula(in.sequentLevelFormula(), loc, in.isInAntec(), proof.getServices()); input.add(new Pair<>(formula, removed.contains(in))); } @@ -302,7 +303,7 @@ public void ruleApplied(ProofEvent e) { loc = loc.append(new Pair<>(n, out.second)); } TrackedFormula formula = new TrackedFormula( - out.first.sequentFormula(), + out.first.sequentLevelFormula(), loc, out.first.isInAntec(), proof.getServices()); @@ -386,7 +387,7 @@ public void trackNode(Node n) { loc = loc.append(new Pair<>(n, out.second)); } TrackedFormula formula = new TrackedFormula( - out.first.sequentFormula(), + out.first.sequentLevelFormula(), loc, out.first.isInAntec(), proof.getServices()); diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/analysis/AnalysisResults.java b/keyext.slicing/src/main/java/org/key_project/slicing/analysis/AnalysisResults.java index 0b0e0b0e578..8175547b001 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/analysis/AnalysisResults.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/analysis/AnalysisResults.java @@ -13,7 +13,7 @@ import de.uka.ilkd.key.logic.PosInTerm; import de.uka.ilkd.key.logic.Semisequent; import de.uka.ilkd.key.logic.Sequent; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; import de.uka.ilkd.key.proof.BranchLocation; import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Proof; @@ -164,8 +164,8 @@ public Sequent reduceSequent(Node node) { } private Semisequent reduce(Semisequent semi, Node node, boolean antec) { - var semiList = new ArrayList(); - for (SequentFormula sf : semi) { + var semiList = new ArrayList(); + for (Term sf : semi) { var graphNode = dependencyGraph.getGraphNode(node.proof(), node.getBranchLocation(), new PosInOccurrence(sf, PosInTerm.getTopLevel(), antec)); if (usefulNodes.contains(graphNode)) { diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/graph/DependencyGraph.java b/keyext.slicing/src/main/java/org/key_project/slicing/graph/DependencyGraph.java index 02f109322a2..c0d23160060 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/graph/DependencyGraph.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/graph/DependencyGraph.java @@ -350,7 +350,7 @@ public GraphNode getGraphNode(Proof proof, BranchLocation locationGuess, PosInOc } while (true) { TrackedFormula formula = - new TrackedFormula(pio.sequentFormula(), locationGuess, pio.isInAntec(), + new TrackedFormula(pio.sequentLevelFormula(), locationGuess, pio.isInAntec(), proof.getServices()); if (containsNode(formula)) { return formula; diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java b/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java index 2c24e4dbee0..4d118f5b973 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java @@ -6,7 +6,8 @@ import java.util.Objects; import de.uka.ilkd.key.java.Services; -import de.uka.ilkd.key.logic.SequentFormula; +import de.uka.ilkd.key.logic.Term; +import de.uka.ilkd.key.logic.equality.ProofIrrelevancyProperty; import de.uka.ilkd.key.pp.LogicPrinter; import de.uka.ilkd.key.proof.BranchLocation; @@ -30,7 +31,7 @@ public class TrackedFormula extends GraphNode implements EqualsModProofIrrelevan /** * The formula. */ - public final SequentFormula formula; + public final Term formula; /** * Whether the formula is in the antecedent. */ @@ -49,7 +50,7 @@ public class TrackedFormula extends GraphNode implements EqualsModProofIrrelevan * @param services services */ public TrackedFormula( - SequentFormula formula, + Term formula, BranchLocation branchLocation, boolean inAntec, Services services) { @@ -70,7 +71,7 @@ public String toString(boolean abbreviated, boolean omitBranch) { return Integer.toHexString(hashCode()); } String term = LogicPrinter.quickPrintTerm( - formula.formula(), + formula, services, true, // pretty print true // using unicode symbols @@ -110,12 +111,15 @@ public boolean equalsModProofIrrelevancy(Object o) { } TrackedFormula that = (TrackedFormula) o; return inAntec == that.inAntec - && formula.equalsModProofIrrelevancy(that.formula) + && ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .equalsModThisProperty(formula, that.formula) && Objects.equals(branchLocation, that.branchLocation); } @Override public int hashCodeModProofIrrelevancy() { - return Objects.hash(inAntec, formula.hashCodeModProofIrrelevancy(), branchLocation); + return Objects.hash(inAntec, + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY.hashCodeModThisProperty(formula), + branchLocation); } } diff --git a/settings.gradle b/settings.gradle index 171f3b1d56c..aa955f87e87 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,4 +18,4 @@ include 'keyext.caching' // ENABLE NULLNESS here or on the CLI // This flag is activated to enable the checker framework. -// System.setProperty("ENABLE_NULLNESS", "true") \ No newline at end of file +// System.setProperty("ENABLE_NULLNESS", "true") From 5f71f2413e0ee32b3cd71bb08e13cb47a180252e Mon Sep 17 00:00:00 2001 From: Richard Bubel Date: Thu, 13 Jun 2024 11:05:48 +0200 Subject: [PATCH 13/15] Fix tests --- .../uka/ilkd/key/logic/TestSemisequent.java | 3 ++- .../de/uka/ilkd/key/rule/TestApplyTaclet.java | 25 ++++++------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java b/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java index 8d82cf1d9e2..0bdb3d2b24b 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java +++ b/key.core/src/test/java/de/uka/ilkd/key/logic/TestSemisequent.java @@ -75,7 +75,8 @@ public void testContains() { Semisequent seq = Semisequent.EMPTY_SEMISEQUENT; seq = extract(seq.insert(0, con[0])); seq = extract(seq.insert(1, con[1])); - Term eq2con0 = con[0]; + TermBuilder TB = TacletForTests.services().getTermBuilder(false); + Term eq2con0 = TB.func((JFunction) con[0].op(), new Term[] {}); assertFalse(seq.contains(eq2con0), "Contains should test of identity and not equality."); } diff --git a/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java b/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java index 30a30c21435..df7f53e8dd0 100644 --- a/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java +++ b/key.core/src/test/java/de/uka/ilkd/key/rule/TestApplyTaclet.java @@ -157,17 +157,13 @@ public void testAddingRule() { Sequent seq1 = goals.head().sequent(); Sequent seq2 = goals.tail().head().sequent(); assertEquals(2, goals.size(), "Preinstantiated cut-rule should be executed"); - Term fml = seq2.succedent().get(1); - Term fml1 = seq1.succedent().get(1); - Term fml2 = seq2.succedent().getFirst(); - Term fml3 = seq1.succedent().getFirst(); assertTrue( - fml3.equals(aimpb) - || fml2.equals(aimpb) + seq1.succedent().getFirst().equals(aimpb) + || seq2.succedent().getFirst().equals(aimpb) || (seq1.succedent().get(1) != null - && fml1.equals(aimpb)) + && seq1.succedent().get(1).equals(aimpb)) || (seq2.succedent().get(1) != null - && fml.equals(aimpb)), + && seq2.succedent().get(1).equals(aimpb)), "A->B should be in the succedent of one of the new goals now, " + "it's in the antecedent, anyway."); } @@ -514,12 +510,10 @@ public void testBugID177() { assertEquals(1, goals.size(), "Expected one goal"); Iterator it = goals.head().sequent().antecedent().iterator(); - Term fml = it.next(); - Term fml1 = it.next(); assertTrue( goals.head().sequent().antecedent().size() == 2 - && fml1.equals(TacletForTests.parseTerm("A")) - && fml.equals(TacletForTests.parseTerm("B")), + && it.next().equals(TacletForTests.parseTerm("A")) + && it.next().equals(TacletForTests.parseTerm("B")), "Expected 'A, B ==>', but is " + goals.head().sequent()); } @@ -556,14 +550,11 @@ public void testBugID188() { assertEquals(1, goals.size(), "Expected one goal"); Iterator it = goals.head().sequent().antecedent().iterator(); - - Term fml = it.next(); - Term fml1 = it.next(); assertTrue( goals.head().sequent().antecedent().size() == 2 && goals.head().sequent().succedent().size() == 0 - && fml1.equals(TacletForTests.parseTerm("A")) - && fml.equals(TacletForTests.parseTerm("B")), + && it.next().equals(TacletForTests.parseTerm("A")) + && it.next().equals(TacletForTests.parseTerm("B")), "Expected 'A, B ==>', but is " + goals.head().sequent()); } From b9d724a8c24fe218c4d9aefc67719ed22dc726a3 Mon Sep 17 00:00:00 2001 From: Richard Bubel Date: Thu, 13 Jun 2024 14:41:42 +0200 Subject: [PATCH 14/15] Fix more tests --- .../src/main/java/de/uka/ilkd/key/logic/Semisequent.java | 2 +- .../java/de/uka/ilkd/key/strategy/JavaCardDLStrategy.java | 4 ++-- .../java/org/key_project/slicing/graph/TrackedFormula.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java b/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java index 7e494a4e5c5..f858fe328cc 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/Semisequent.java @@ -379,7 +379,7 @@ public SemisequentChangeInfo remove(int idx) { /** * returns the index of the given {@link Term} or {@code -1} if the sequent formula is - * not found. Equality of sequent formulas is checked sing the identy check (i.e., + * not found. Identity (not equality) of sequent formulas is checked (i.e., * ==) * * @param fml the {@link Term} to look for diff --git a/key.core/src/main/java/de/uka/ilkd/key/strategy/JavaCardDLStrategy.java b/key.core/src/main/java/de/uka/ilkd/key/strategy/JavaCardDLStrategy.java index 960cd033f50..bd322207345 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/strategy/JavaCardDLStrategy.java +++ b/key.core/src/main/java/de/uka/ilkd/key/strategy/JavaCardDLStrategy.java @@ -1919,9 +1919,9 @@ private RuleSetDispatchFeature setupApprovalDispatcher() { bindRuleSet(d, "apply_select_eq", add(isInstantiated("s"), isInstantiated("t1"), + NoSelfApplicationFeature.INSTANCE, or(applyTF("s", rec(any(), SimplifiedSelectTermFeature.create(heapLDT))), - add(NoSelfApplicationFeature.INSTANCE, - applyTF("t1", IsSelectSkolemConstantTermFeature.INSTANCE))))); + add(applyTF("t1", IsSelectSkolemConstantTermFeature.INSTANCE))))); bindRuleSet(d, "apply_auxiliary_eq", add(NoSelfApplicationFeature.INSTANCE, isInstantiated("s"), applyTF("s", diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java b/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java index 4d118f5b973..f49e9683ed6 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/graph/TrackedFormula.java @@ -111,15 +111,15 @@ public boolean equalsModProofIrrelevancy(Object o) { } TrackedFormula that = (TrackedFormula) o; return inAntec == that.inAntec - && ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY - .equalsModThisProperty(formula, that.formula) + && formula.equalsModProperty(that.formula, + ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY) && Objects.equals(branchLocation, that.branchLocation); } @Override public int hashCodeModProofIrrelevancy() { return Objects.hash(inAntec, - ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY.hashCodeModThisProperty(formula), + formula.hashCodeModProperty(ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY), branchLocation); } } From c09bf0ffa56b7291079fbfb2db4168f3a4378917 Mon Sep 17 00:00:00 2001 From: Richard Bubel Date: Thu, 13 Jun 2024 20:28:57 +0200 Subject: [PATCH 15/15] Fix slicing to work with terms instead of SequentFormulas --- .../uka/ilkd/key/logic/PosInOccurrence.java | 12 ++-- .../java/de/uka/ilkd/key/rule/Taclet.java | 16 +++-- .../slicing/DependencyTracker.java | 61 +++++++++++-------- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java b/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java index aef1c55a869..03c6dd859e0 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java +++ b/key.core/src/main/java/de/uka/ilkd/key/logic/PosInOccurrence.java @@ -3,9 +3,11 @@ * SPDX-License-Identifier: GPL-2.0-only */ package de.uka.ilkd.key.logic; +import java.util.Objects; + /** - * This class describes a position in an occurrence of a term. A Term and a PosInTerm - * determine an object of this class exactly. + * This class describes the position of an occurrence of a term within a formula. + * The top level formula and a {@link PosInTerm} which describes the exact occurrence. */ public final class PosInOccurrence { @@ -28,7 +30,7 @@ public static PosInOccurrence findInSequent(Sequent seq, int formulaNumber, PosI */ private final boolean inAntec; - /** the position in Term.formula() */ + /** the position in sequentLevelFormula */ private final PosInTerm posInTerm; /** @@ -42,7 +44,7 @@ public PosInOccurrence(Term sequentLevelFormula, PosInTerm posInTerm, boolean in this.inAntec = inAntec; this.sequentLevelFormula = sequentLevelFormula; this.posInTerm = posInTerm; - this.hashCode = (short) (sequentLevelFormula.hashCode() * 13 + posInTerm.hashCode()); + this.hashCode = (short) Objects.hash(sequentLevelFormula, inAntec, posInTerm); } /** @@ -153,7 +155,7 @@ public PIOPathIterator iterator() { * The usage of this method is strongly discouraged, use {@link PosInOccurrence#iterator} * instead. describes the exact occurrence of the referred term * - * @return the position in the formula of the Term of this PosInOccurrence. + * @return the position of the occurrence within the sequent level formula. */ public PosInTerm posInTerm() { return posInTerm; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java index f110d474dd5..c1adfe7c326 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/Taclet.java @@ -492,21 +492,19 @@ public boolean equalsModProofIrrelevancy(Object o) { if ((ifSequent == null && t2.ifSequent != null) || (ifSequent != null && t2.ifSequent == null)) { return false; + } else if (ifSequent.size() != t2.ifSequent.size()) { + return false; } else { ImmutableList if1 = ifSequent.asList(); ImmutableList if2 = t2.ifSequent.asList(); - while (!if1.isEmpty() && !if2.isEmpty()) { - Term term = if1.head(); - Term head = if2.head(); - if (!(boolean) ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY - .equalsModThisProperty(term, head)) - break; + while (!if1.isEmpty()) { + if (!ProofIrrelevancyProperty.PROOF_IRRELEVANCY_PROPERTY + .equalsModThisProperty(if1.head(), if2.head())) { + return false; + } if1 = if1.tail(); if2 = if2.tail(); } - if (!if1.isEmpty() || !if2.isEmpty()) { - return false; - } } if (!choices.equals(t2.choices)) { diff --git a/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java b/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java index 6ed6b7cc945..420dd23a323 100644 --- a/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java +++ b/keyext.slicing/src/main/java/org/key_project/slicing/DependencyTracker.java @@ -11,9 +11,7 @@ import java.util.WeakHashMap; import java.util.stream.Stream; -import de.uka.ilkd.key.logic.PosInOccurrence; -import de.uka.ilkd.key.logic.PosInTerm; -import de.uka.ilkd.key.logic.Sequent; +import de.uka.ilkd.key.logic.*; import de.uka.ilkd.key.proof.BranchLocation; import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Node; @@ -194,21 +192,26 @@ private Set formulasRemovedBy(RuleAppInfo ruleAppInfo) { } private Set formulasRemovedBy(Node node) { - Set removed = new HashSet<>(); // compare parent sequent to new sequent Node parent = node.parent(); if (parent == null) { - return removed; + return new HashSet<>(); } - Sequent seqParent = parent.sequent(); - var seqNew = new IdentityHashSet<>(node.sequent().asList()); - int i = 1; - for (final var parentFormula : seqParent) { + var removed = computeRemovedFormulas(node.sequent().antecedent(), + parent.sequent().antecedent(), true); + removed.addAll(computeRemovedFormulas(node.sequent().succedent(), + parent.sequent().succedent(), false)); + return removed; + } + + private Set computeRemovedFormulas(Semisequent newSemi, Semisequent parentSemi, + boolean inAntec) { + final Set removed = new HashSet<>(); + final var seqNew = new IdentityHashSet<>(newSemi.asList()); + for (final var parentFormula : parentSemi) { if (!seqNew.contains(parentFormula)) { - removed.add(new PosInOccurrence(parentFormula, PosInTerm.getTopLevel(), - seqParent.numberInAntec(i))); + removed.add(new PosInOccurrence(parentFormula, PosInTerm.getTopLevel(), inAntec)); } - i++; } return removed; } @@ -240,22 +243,27 @@ private List> outputsOfNode(Node node) { int sibling = 0; for (Node b : node.children()) { // compare sequents - var oldSeq = new IdentityHashSet<>(node.sequent().asList()); - Sequent newSeq = b.sequent(); - int index = 1; - for (var f : newSeq) { - if (!oldSeq.contains(f)) { - var pio = new PosInOccurrence(f, PosInTerm.getTopLevel(), - newSeq.numberInAntec(index)); - outputs.add(new Pair<>(pio, node.childrenCount() > 1 ? sibling : -1)); - } - index++; - } + computeOutputForSemisequent(node, b, true, outputs, sibling); + computeOutputForSemisequent(node, b, false, outputs, sibling); sibling++; } return outputs; } + private void computeOutputForSemisequent(Node parent, Node child, boolean inAntec, + List> outputs, int sibling) { + ImmutableList oldSemi = inAntec ? parent.sequent().antecedent().asList() + : parent.sequent().succedent().asList(); + Semisequent newSeq = inAntec ? child.sequent().antecedent() : child.sequent().succedent(); + var oldSeq = new IdentityHashSet<>(oldSemi); + for (var f : newSeq) { + if (!oldSeq.contains(f)) { + var pio = new PosInOccurrence(f, PosInTerm.getTopLevel(), inAntec); + outputs.add(new Pair<>(pio, parent.childrenCount() > 1 ? sibling : -1)); + } + } + } + @Override public void ruleApplied(ProofEvent e) { if (e.getSource() != proof) { @@ -273,14 +281,15 @@ public void ruleApplied(ProofEvent e) { // record any rules added by this rule application for (NodeReplacement newNode : ruleAppInfo.getReplacementNodes()) { for (NoPosTacletApp newRule : newNode.getNode().getLocalIntroducedRules()) { + Taclet newTaclet = newRule.taclet(); final var justification = newNode.getNode().proof().getInitConfig().getJustifInfo() - .getJustification(newRule.taclet()); + .getJustification(newTaclet); if (justification instanceof RuleJustificationByAddRules justAddRule && justAddRule.node() == n) { - AddedRule ruleNode = new AddedRule(newRule.rule().name().toString()); + AddedRule ruleNode = new AddedRule(newTaclet.name().toString()); output.add(ruleNode); - dynamicRules.put((Taclet) newRule.rule(), ruleNode); + dynamicRules.put(newTaclet, ruleNode); } } }