Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3ca1d45
some functions for tff
wadoon Oct 4, 2023
c4b52eb
different clients
wadoon Oct 8, 2023
e621c7e
wip
wadoon Oct 13, 2023
bc80e90
Creating an JSON-RPC API
wadoon Oct 15, 2023
525a65e
working on a working minimal version
wadoon Oct 29, 2023
1837682
more doc and py generation
wadoon Oct 29, 2023
cd995db
running for primitive data types, somethings wrong in de-/serialization
wadoon Nov 1, 2023
1017621
add throwable adapter
wadoon Nov 3, 2023
c5efc62
spotless and merge errors
wadoon Nov 18, 2023
e8fed80
fix after refactoring + spotless
wadoon Jun 26, 2024
254e64b
wip
wadoon Oct 20, 2024
dda37d1
start of a simple Java client
wadoon Nov 22, 2024
9762e65
- Shutdown Callbacks
samysweb Feb 19, 2025
daceaa5
Error message for python generation
samysweb Feb 19, 2025
fb7f809
Updated library and example
samysweb Feb 19, 2025
edc620c
Added proof api endpoint
samysweb Feb 20, 2025
7515dc8
Attempt at reseting proof control
samysweb Feb 20, 2025
f6b37d1
First (incomplete) working proof management endpoint
samysweb Feb 20, 2025
c3eb4dd
Updated python client for proof endpoint
samysweb Feb 20, 2025
536e048
Improved interface, environment disposal
samysweb Feb 20, 2025
088f211
Fixed JSON type annotation&retrieval
samysweb Mar 24, 2025
dac1cc3
Updated json type annotation on codegen/python side
samysweb Mar 24, 2025
e885888
Merge branch 'steuber/jsonrpc' into weigl/jsonrpc
samysweb Mar 24, 2025
87fe291
Configurable Strategy (not Streategy) options for proof auto mode
samysweb Mar 24, 2025
6c12272
Extracted node description function
samysweb Mar 24, 2025
189537a
Null serialization (necessary due to python class initialization), no…
samysweb Mar 24, 2025
51ba5d4
reformat / remove weakrefs from the data model
wadoon Apr 6, 2025
fa42f50
fix compile error
wadoon Jul 8, 2025
a351765
spotless
wadoon Aug 24, 2025
994992a
fixing the missing javadoc in the api generator
wadoon Nov 28, 2025
2d65dff
better documentation
wadoon Nov 29, 2025
28527a8
working on documentation, now with json examples
wadoon Nov 30, 2025
7cba540
try to make the documentation better
wadoon Dec 21, 2025
fb89f0d
better documentation
wadoon Dec 27, 2025
0d37477
repair branch after rewriting
wadoon Feb 1, 2026
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
4 changes: 3 additions & 1 deletion key.core.example/src/main/java/org/key_project/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private static void proveEnvironmemt(KeYEnvironment<?> env) {
LOGGER.info("Found contract '" + contract.getDisplayName());
proveContract(env, contract);
}
} catch (InterruptedException ignored) {
} finally {
env.dispose(); // Ensure always that all instances of KeYEnvironment are disposed
}
Expand Down Expand Up @@ -135,7 +136,8 @@ private static List<Contract> getContracts(KeYEnvironment<?> env) {
* @param env the {@link KeYEnvironment} in which to prove the contract
* @param contract the {@link Contract} to be proven
*/
private static void proveContract(KeYEnvironment<?> env, Contract contract) {
private static void proveContract(KeYEnvironment<?> env, Contract contract)
throws InterruptedException {
Proof proof = null;
try {
// Create proof
Expand Down
14 changes: 14 additions & 0 deletions key.core/src/main/java/de/uka/ilkd/key/Identifiable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* 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;

/**
* @author Alexander Weigl
* @version 1 (14.10.23)
*/
public interface Identifiable {
default String identification() {
return getClass().getName() + "_" + hashCode();
}
}
40 changes: 40 additions & 0 deletions key.core/src/main/java/de/uka/ilkd/key/control/KeYEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.uka.ilkd.key.proof.io.AbstractProblemLoader.ReplayResult;
import de.uka.ilkd.key.proof.io.ProblemLoaderException;
import de.uka.ilkd.key.proof.mgt.SpecificationRepository;
import de.uka.ilkd.key.rule.Rule;
import de.uka.ilkd.key.speclang.Contract;
import de.uka.ilkd.key.util.KeYTypeUtil;

Expand Down Expand Up @@ -333,6 +334,45 @@ public boolean isDisposed() {
return proofScript;
}

/**
* Retrieve a list of all available contracts for all known Java types.
*
* @return a non-null list, possible empty
*/
public List<Contract> getAvailableContracts() {
List<Contract> proofContracts = new ArrayList<>(512);
Set<KeYJavaType> kjts = getJavaInfo().getAllKeYJavaTypes();
for (KeYJavaType type : kjts) {
if (!KeYTypeUtil.isLibraryClass(type)) {
ImmutableSet<IObserverFunction> targets =
getSpecificationRepository().getContractTargets(type);
for (IObserverFunction target : targets) {
ImmutableSet<Contract> contracts =
getSpecificationRepository().getContracts(type, target);
for (Contract contract : contracts) {
proofContracts.add(contract);
}
}
}
}
return proofContracts;
}


/**
* Constructs a list containing all known rules that are registered in the current
* environment.
*
* @return always returns a non-null list
*/
public List<Rule> getRules() {
var rules = new ArrayList<Rule>(4096);
rules.addAll(getInitConfig().activatedTaclets());
getInitConfig().builtInRules().forEach(rules::add);
return rules;
}


/**
* constructs the possible proof contracts from the java info in the environment.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void taskStarted(TaskStartedInfo info) {
numOfInvokedMacros++;
if (superordinateListener != null) {
superordinateListener.taskStarted(new DefaultTaskStartedInfo(TaskKind.Macro,
macroName + (macroName.length() == 0 ? "" : " -- ") + info.message(),
macroName + (macroName.isEmpty() ? "" : " -- ") + info.message(),
info.size()));
}
}
Expand Down
47 changes: 43 additions & 4 deletions key.core/src/main/java/de/uka/ilkd/key/proof/Goal.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
import de.uka.ilkd.key.logic.op.ProgramVariable;
import de.uka.ilkd.key.pp.LogicPrinter;
import de.uka.ilkd.key.pp.NotationInfo;
import de.uka.ilkd.key.proof.mgt.RuleJustification;
import de.uka.ilkd.key.proof.proofevent.NodeChangeJournal;
import de.uka.ilkd.key.proof.proofevent.RuleAppInfo;
import de.uka.ilkd.key.rule.AbstractExternalSolverRuleApp;
import de.uka.ilkd.key.rule.IBuiltInRuleApp;
import de.uka.ilkd.key.rule.NoPosTacletApp;
import de.uka.ilkd.key.rule.TacletApp;
import de.uka.ilkd.key.rule.*;
import de.uka.ilkd.key.rule.inst.SVInstantiations;
import de.uka.ilkd.key.rule.merge.MergeRule;
import de.uka.ilkd.key.strategy.QueueRuleApplicationManager;
import de.uka.ilkd.key.strategy.Strategy;
import de.uka.ilkd.key.util.MiscTools;
import de.uka.ilkd.key.util.properties.MapProperties;
import de.uka.ilkd.key.util.properties.Properties;
import de.uka.ilkd.key.util.properties.Properties.Property;
Expand Down Expand Up @@ -757,6 +756,13 @@ public List<RuleApp> getAllBuiltInRuleApps() {
return ruleApps;
}

/**
* Return a list with available taclet application on this goal.
*/
public List<TacletApp> getAllTacletApps() {
return getAllTacletApps(proof().getServices());
}

public List<TacletApp> getAllTacletApps(Services services) {
RuleAppIndex index = ruleAppIndex();
index.autoModeStopped();
Expand All @@ -781,4 +787,37 @@ protected boolean filter(Taclet taclet) {
return allApps;
}

/**
* Returns a list with all known rule applications within this proof goal.
*/
public List<RuleApp> getAllAvailableRules() {
var taclets = getAllTacletApps();
var builtin = getAllBuiltInRuleApps();
builtin.addAll(taclets);
return builtin;
}

public List<Rule> getAvailableRules() {
var s = new ArrayList<Rule>(2048);
for (final BuiltInRule br : ruleAppIndex().builtInRuleAppIndex()
.builtInRuleIndex().rules()) {
s.add(br);
}

Set<NoPosTacletApp> set = ruleAppIndex().tacletIndex().allNoPosTacletApps();
OneStepSimplifier simplifier = MiscTools.findOneStepSimplifier(proof());
if (simplifier != null && !simplifier.isShutdown()) {
set.addAll(simplifier.getCapturedTaclets());
}

for (final NoPosTacletApp app : set) {
RuleJustification just = proof().mgt().getJustification(app);
if (just == null) {
continue; // do not break system because of this
}
s.add(app.taclet()); // TODO not good
}
return s;
}

}
6 changes: 6 additions & 0 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,6 +3,7 @@
* SPDX-License-Identifier: GPL-2.0-only */
package de.uka.ilkd.key.proof;

import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -12,6 +13,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.stream.Stream;

import de.uka.ilkd.key.logic.RenamingTable;
import de.uka.ilkd.key.logic.op.IProgramVariable;
Expand Down Expand Up @@ -838,4 +840,8 @@ public int getStepIndex() {
void setStepIndex(int stepIndex) {
this.stepIndex = stepIndex;
}

public Stream<Node> childrenStream() {
return children.stream();
}
}
12 changes: 11 additions & 1 deletion key.core/src/main/java/de/uka/ilkd/key/proof/Proof.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.function.Consumer;
import java.util.function.Predicate;

import de.uka.ilkd.key.Identifiable;
import de.uka.ilkd.key.java.JavaInfo;
import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.logic.*;
Expand Down Expand Up @@ -42,6 +43,7 @@
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.lookup.Lookup;

import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

Expand All @@ -56,7 +58,7 @@
* goals, namespaces and several other information about the current state of the proof.
*/
@NullMarked
public class Proof implements ProofObject<Goal>, Named {
public class Proof implements ProofObject<Goal>, Named, Identifiable {

/**
* The time when the {@link Proof} instance was created.
Expand Down Expand Up @@ -1381,4 +1383,12 @@ public void printSymbols(PrintWriter ps) {
public long getCreationTime() {
return creationTime;
}

/**
* {@inheritDoc}
*/
@Override
public String identification() {
return getClass().getName() + "_" + name + "_" + hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* 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.proof;

import java.io.Serializable;

public class ProofNodeDescription implements Serializable {
/**
* Collects the information from the tree to which branch the current node belongs:
* <ul>
* <li>Invariant Initially Valid</li>
* <li>Body Preserves Invariant</li>
* <li>Use Case</li>
* <li>...</li>
* </ul>
*
* @param node the current node
* @return a String containing the path information to display
*/
public static String collectPathInformation(Node node) {
while (node != null) {
if (node.getNodeInfo() != null && node.getNodeInfo().getBranchLabel() != null) {
String label = node.getNodeInfo().getBranchLabel();
/*
* Are there other interesting labels? Please feel free to add them here.
*/
if (label.equals("Invariant Initially Valid")
|| label.equals("Invariant Preserved and Used") // for loop scope invariant
|| label.equals("Body Preserves Invariant") || label.equals("Use Case")
|| label.equals("Show Axiom Satisfiability") || label.startsWith("Pre (")
|| label.startsWith("Exceptional Post (") // exceptional postcondition
|| label.startsWith("Post (") // postcondition of a method
|| label.contains("Normal Execution") || label.contains("Null Reference")
|| label.contains("Index Out of Bounds") || label.contains("Validity")
|| label.contains("Precondition") || label.contains("Usage")) {
return label;
}
}
node = node.parent();
}
// if no label was found we have to prove the postcondition
return "Show Postcondition/Modifiable";
}
}
22 changes: 12 additions & 10 deletions key.ui/src/main/java/de/uka/ilkd/key/core/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,25 +448,27 @@ private AbstractMediatorUserInterfaceControl createUserInterface(List<Path> file
}

public static void ensureExamplesAvailable() {
File examplesDir = getExamplesDir() == null ? ExampleChooser.lookForExamples()
: new File(getExamplesDir());
if (!examplesDir.exists()) {
Path examplesDir =
getExamplesDir() == null ? ExampleChooser.lookForExamples() : getExamplesDir();
if (!Files.exists(examplesDir)) {
examplesDir = setupExamples();
}
setExamplesDir(examplesDir.getAbsolutePath());
if (examplesDir == null) {
setExamplesDir(examplesDir.toAbsolutePath());
}
}

private static File setupExamples() {
private static @Nullable Path setupExamples() {
try {
URL examplesURL = Main.class.getResource("/examples.zip");
if (examplesURL == null) {
throw new IOException("Missing examples.zip in resources");
}

File tempDir = createTempDirectory();
Path tempDir = Files.createTempDirectory("key-examples");

if (tempDir != null) {
IOUtil.extractZip(examplesURL.openStream(), tempDir.toPath());
IOUtil.extractZip(examplesURL.openStream(), tempDir);
}
return tempDir;
} catch (IOException e) {
Expand Down Expand Up @@ -524,9 +526,9 @@ private void preProcessInput()
}
}

private static String EXAMPLE_DIR = null;
private static Path EXAMPLE_DIR = null;

public static @Nullable String getExamplesDir() {
public static @Nullable Path getExamplesDir() {
return EXAMPLE_DIR;
}

Expand All @@ -537,7 +539,7 @@ private void preProcessInput()
*
* @param newExamplesDir The new examples directory to use.
*/
public static void setExamplesDir(String newExamplesDir) {
public static void setExamplesDir(Path newExamplesDir) {
EXAMPLE_DIR = newExamplesDir;
}
}
Loading
Loading