Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import de.uka.ilkd.key.proof.io.ProblemLoaderException;
import de.uka.ilkd.key.proof.io.SingleThreadProblemLoader;
import de.uka.ilkd.key.proof.mgt.ProofEnvironment;
import de.uka.ilkd.key.settings.Configuration;

import org.key_project.prover.engine.ProverCore;
import org.key_project.prover.engine.ProverTaskListener;
Expand Down Expand Up @@ -257,7 +258,8 @@ public void loadingStarted(AbstractProblemLoader loader) {

@Override
public void loadingFinished(AbstractProblemLoader loader, LoadedPOContainer poContainer,
ProofAggregate proofList, ReplayResult result) throws ProblemLoaderException {
ProofAggregate proofList, ReplayResult result, Configuration settings)
throws ProblemLoaderException {
if (proofList != null) {
// avoid double registration at spec repos as that is done already earlier in
// createProof
Expand Down
11 changes: 11 additions & 0 deletions key.core/src/main/java/de/uka/ilkd/key/nparser/KeyAst.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ public String getProblemHeader() {
}
return "";
}

/// Returns the raw settings within a [de.uka.ilkd.key.proof.io.KeYFile].
public Configuration findSettings() {
final var cfg = new ConfigurationBuilder();
if (ctx.preferences() == null || ctx.preferences().cvalue() == null) {
return new Configuration();
}

var c = ctx.preferences().cvalue();
return (Configuration) c.accept(cfg);
}
}

public static class ConfigurationFile extends KeyAst<KeYParser.CfileContext> {
Expand Down
84 changes: 63 additions & 21 deletions key.core/src/main/java/de/uka/ilkd/key/proof/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
* SPDX-License-Identifier: GPL-2.0-only */
package de.uka.ilkd.key.proof;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.*;

import de.uka.ilkd.key.logic.RenamingTable;
import de.uka.ilkd.key.logic.op.IProgramVariable;
Expand Down Expand Up @@ -50,10 +42,14 @@ public class Node implements Iterable<Node> {

private static final String NODES = "nodes";

/** the proof the node belongs to */
/**
* the proof the node belongs to
*/
private final Proof proof;

/** The parent node. **/
/**
* The parent node.
**/
private @Nullable Node parent = null;
/**
* The branch location of this proof node.
Expand Down Expand Up @@ -82,7 +78,9 @@ public class Node implements Iterable<Node> {

private boolean closed = false;

/** contains non-logical content, used for user feedback */
/**
* contains non-logical content, used for user feedback
*/
private NodeInfo nodeInfo;

/**
Expand Down Expand Up @@ -161,7 +159,9 @@ public void setSequent(Sequent seq) {
this.seq = seq;
}

/** returns the sequent of this node */
/**
* returns the sequent of this node
*/
public Sequent sequent() {
return seq;
}
Expand All @@ -175,7 +175,9 @@ public NodeInfo getNodeInfo() {
return nodeInfo;
}

/** returns the proof the Node belongs to */
/**
* returns the proof the Node belongs to
*/
public Proof proof() {
return proof;
}
Expand Down Expand Up @@ -225,7 +227,9 @@ public RuleApp getAppliedRuleApp() {
return appliedRuleApp;
}

/** Returns the set of NoPosTacletApps at this node */
/**
* Returns the set of NoPosTacletApps at this node
*/
public Iterable<NoPosTacletApp> getLocalIntroducedRules() {
return localIntroducedRules;
}
Expand All @@ -249,7 +253,7 @@ public void addLocalProgVars(Iterable<? extends IProgramVariable> elements) {

/**
* Returns the set of freshly created function symbols known to this node.
*
* <p>
* In the resulting list, the newest additions come first.
*
* @return a non-null immutable list of function symbols.
Expand Down Expand Up @@ -471,13 +475,14 @@ public Iterator<Node> subtreeIterator() {
return new SubtreeIterator(this);
}

/** @return number of children */
/**
* @return number of children
*/
public int childrenCount() {
return children.size();
}

/**
*
* @param i an index (starting at 0).
* @return the i-th child of this node.
*/
Expand Down Expand Up @@ -667,7 +672,9 @@ public boolean sanityCheckDoubleLinks() {
return true;
}

/** marks a node as closed */
/**
* marks a node as closed
*/
Node close() {
closed = true;
Node tmp = parent;
Expand All @@ -684,7 +691,7 @@ Node close() {
/**
* Opens a previously closed node and all its closed parents.
* <p>
*
* <p>
* This is, for instance, needed for the {@link MergeRule}: In a situation where a merge node
* and its associated partners have been closed and the merge node is then pruned away, the
* partners have to be reopened again. Otherwise, we have a soundness issue.
Expand All @@ -699,7 +706,9 @@ void reopen() {
clearNameCache();
}

/** @return true iff this inner node is closeable */
/**
* @return true iff this inner node is closeable
*/
private boolean isCloseable() {
assert childrenCount() > 0;
for (Node child : children) {
Expand Down Expand Up @@ -838,4 +847,37 @@ public int getStepIndex() {
void setStepIndex(int stepIndex) {
this.stepIndex = stepIndex;
}

/**
* Calculates an array is the path from root node to this node. Each entry defines the child to
* be selected.
*
* @see #traversePath(Iterator)
*/
public int[] getPosInProof() {
// collect the path from the current to node to the root of the proof.
// each entry is the children position
var path = new LinkedList<Integer>();
var current = this;
while (current.parent != null) {
path.add(0, current.parent.getChildNr(current));
current = current.parent;
}
return path.stream().mapToInt(it -> it).toArray();
}


/**
* Traverses a given iterator (child selection).
*
* @param traverse non-null
*/
public Node traversePath(Iterator<Integer> traverse) {
var current = this;
while (traverse.hasNext()) {
int child = traverse.next();
current = current.child(child);
}
return current;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
* obligation.
*/
public final class KeYUserProblemFile extends KeYFile implements ProofOblInput {
@Nullable
private Sequent problem = null;

@Nullable
private Configuration settings;

// -------------------------------------------------------------------------
// constructors
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -119,6 +123,13 @@ public ImmutableSet<PositionedString> read() throws ProofInputException {
return warnings;
}

public Configuration readSettings() {
if (settings == null) {
settings = getParseContext().findSettings();
}
return settings;
}

@Override
public void readProblem() throws ProofInputException {
if (initConfig == null) {
Expand Down Expand Up @@ -270,4 +281,5 @@ private Profile getDefaultProfile() {
public KeYJavaType getContainerType() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ public final void load(Consumer<Proof> callbackProofLoaded)
loadSelectedProof(poContainer, proofList, callbackProofLoaded);
}
} finally {
control.loadingFinished(this, poContainer, proofList, result);
var settings = (envInput instanceof KeYUserProblemFile kupf) ? kupf.readSettings()
: new Configuration();
control.loadingFinished(this, poContainer, proofList, result, settings);
}
}

Expand Down Expand Up @@ -646,9 +648,6 @@ private ReplayResult replayProof(Proof proof) {
problemInitializer.tryReadProof(parser, (KeYUserProblemFile) envInput);
parserResult = parser.getResult();

// Parser is no longer needed, set it to null to free memory.
parser = null;

// For loading, we generally turn on one step simplification to be
// able to load proofs that used it even if the user has currently
// turned OSS off.
Expand Down
Loading
Loading