Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ca76ac1
some functions for tff
wadoon Oct 4, 2023
c1ae3cd
different clients
wadoon Oct 8, 2023
3ed82ba
wip
wadoon Oct 13, 2023
3be1705
Creating an JSON-RPC API
wadoon Oct 15, 2023
0c7299c
working on a working minimal version
wadoon Oct 29, 2023
f03cabd
more doc and py generation
wadoon Oct 29, 2023
76feb49
running for primitive data types, somethings wrong in de-/serialization
wadoon Nov 1, 2023
689ea88
add throwable adapter
wadoon Nov 3, 2023
f8d2e73
spotless and merge errors
wadoon Nov 18, 2023
db9b132
fix after refactoring + spotless
wadoon Jun 26, 2024
465482d
wip
wadoon Oct 20, 2024
fe11e41
start of a simple Java client
wadoon Nov 22, 2024
7e56ba1
- Shutdown Callbacks
samysweb Feb 19, 2025
aecef0f
Error message for python generation
samysweb Feb 19, 2025
f8a2b2b
Updated library and example
samysweb Feb 19, 2025
4ba49b5
Added proof api endpoint
samysweb Feb 20, 2025
314f13d
Attempt at reseting proof control
samysweb Feb 20, 2025
3f55ef2
First (incomplete) working proof management endpoint
samysweb Feb 20, 2025
3f09207
Updated python client for proof endpoint
samysweb Feb 20, 2025
ac9c61c
Improved interface, environment disposal
samysweb Feb 20, 2025
a29a0cb
Fixed JSON type annotation&retrieval
samysweb Mar 24, 2025
737b3b9
Updated json type annotation on codegen/python side
samysweb Mar 24, 2025
84d94e0
Merge branch 'steuber/jsonrpc' into weigl/jsonrpc
samysweb Mar 24, 2025
e0930aa
Configurable Strategy (not Streategy) options for proof auto mode
samysweb Mar 24, 2025
c1f5cfa
Extracted node description function
samysweb Mar 24, 2025
43ce5ee
Null serialization (necessary due to python class initialization), no…
samysweb Mar 24, 2025
04d0d8c
reformat / remove weakrefs from the data model
wadoon Apr 6, 2025
f2bf95c
fix compile error
wadoon Jul 8, 2025
691b3d3
spotless
wadoon Aug 24, 2025
59e3c2f
fixing the missing javadoc in the api generator
wadoon Nov 28, 2025
4f5d28f
better documentation
wadoon Nov 29, 2025
a628ad6
working on documentation, now with json examples
wadoon Nov 30, 2025
6e5f53b
try to make the documentation better
wadoon Dec 21, 2025
466b42d
better documentation
wadoon Dec 27, 2025
c8409a6
repair branch after rewriting
wadoon Feb 1, 2026
7d268f9
spotless
wadoon Jun 11, 2026
6bb60e4
Extensions to the KeY API: Server changes allow now a reconnect
unp1 Jun 10, 2026
f3092ad
Fix server API name and example chooser
unp1 Jun 11, 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();
}
}
8 changes: 8 additions & 0 deletions key.core/src/main/java/de/uka/ilkd/key/pp/PositionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ public PositionTable getChild(int i) {
return children[i];
}

public int getRows() {
return rows;
}

public Range getRange(int i) {
return new Range(startPos[i], endPos[i]);
}

/**
* returns a String representation of the position table
*/
Expand Down
5 changes: 5 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 @@ -12,6 +12,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 +839,8 @@ public int getStepIndex() {
void setStepIndex(int stepIndex) {
this.stepIndex = stepIndex;
}

public Stream<Node> childrenStream() {
return children.stream();
}
}
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;
}
}
198 changes: 198 additions & 0 deletions key.ui/src/main/java/de/uka/ilkd/key/gui/Example.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/* 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.gui;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This class wraps a {@link java.io.File} and has a special {@link #toString()} method only using
* the
* short file name w/o path.
* <p>
* Used for displaying files in the examples list w/o prefix
*/
public class Example {
private static final Logger LOGGER = LoggerFactory.getLogger(Example.class);
/**
* This constant is accessed by the eclipse based projects.
*/
public static final String KEY_FILE_NAME = "project.key";

private static final String PROOF_FILE_NAME = "project.proof";

/**
* The default category under which examples range if they do not have {@link #KEY_PATH}
* set.
*/
public static final String DEFAULT_CATEGORY_PATH = "Unsorted";

/**
* The {@link Properties} key to specify the path in the tree.
*/
public static final String KEY_PATH = "example.path";

/**
* The {@link Properties} key to specify the name of the example. Directory name if left
* open.
*/
public static final String KEY_NAME = "example.name";

/**
* The {@link Properties} key to specify the file for the example. KEY_FILE_NAME by default
*/
public static final String KEY_FILE = "example.file";

/**
* The {@link Properties} key to specify the proof file in the tree. May be left open
*/
public static final String KEY_PROOF_FILE = "example.proofFile";

/**
* The {@link Properties} key to specify the path in the tree. Prefix to specify additional
* files to load. Append 1, 2, 3, ...
*/
public static final String ADDITIONAL_FILE_PREFIX = "example.additionalFile.";

/**
* The {@link Properties} key to specify the path in the tree. Prefix to specify export
* files which are not shown as tabs in the example wizard but are extracted to Java
* projects in the Eclipse integration. Append 1, 2, 3, ...
*/
public static final String EXPORT_FILE_PREFIX = "example.exportFile.";

public final Path exampleFile;
public final Path directory;
public final String description;
public final Properties properties;

public Example(Path file) throws IOException {
this.exampleFile = file;
this.directory = file.getParent();
this.properties = new Properties();
StringBuilder sb = new StringBuilder();
extractDescription(file, sb, properties);
this.description = sb.toString();
}

public Path getDirectory() {
return directory;
}

public Path getProofFile() {
return directory.resolve(properties.getProperty(KEY_PROOF_FILE, PROOF_FILE_NAME));
}

public Path getObligationFile() {
return directory.resolve(properties.getProperty(KEY_FILE, KEY_FILE_NAME));
}

public String getName() {
return properties.getProperty(KEY_NAME, directory.getFileName().toString());
}

public String getDescription() {
return description;
}

public Path getExampleFile() {
return exampleFile;
}

public List<Path> getAdditionalFiles() {
var result = new ArrayList<Path>();
int i = 1;
while (properties.containsKey(ADDITIONAL_FILE_PREFIX + i)) {
result.add(directory.resolve(properties.getProperty(ADDITIONAL_FILE_PREFIX + i)));
i++;
}
return result;
}

public List<Path> getExportFiles() {
var result = new ArrayList<Path>();
int i = 1;
while (properties.containsKey(EXPORT_FILE_PREFIX + i)) {
result.add(directory.resolve(properties.getProperty(EXPORT_FILE_PREFIX + i)));
i++;
}
return result;
}

public String[] getPath() {
return properties.getProperty(KEY_PATH, DEFAULT_CATEGORY_PATH).split("/");
}

@Override
public String toString() {
return getName();
}

public void addToTreeModel(DefaultTreeModel model) {
DefaultMutableTreeNode node =
findChild((DefaultMutableTreeNode) model.getRoot(), getPath(), 0);
node.add(new DefaultMutableTreeNode(this));
}

private DefaultMutableTreeNode findChild(DefaultMutableTreeNode root, String[] path,
int from) {
if (from == path.length) {
return root;
}
Enumeration<?> en = root.children();
while (en.hasMoreElements()) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) en.nextElement();
if (node.getUserObject().equals(path[from])) {
return findChild(node, path, from + 1);
}
}
// not found ==> add new
DefaultMutableTreeNode node = new DefaultMutableTreeNode(path[from]);
root.add(node);
return findChild(node, path, from + 1);
}

public boolean hasProof() {
return properties.containsKey(KEY_PROOF_FILE);
}

private static StringBuilder extractDescription(Path file, StringBuilder sb,
Properties properties) {
try {
boolean emptyLineSeen = false;
for (var line : Files.readAllLines(file, StandardCharsets.UTF_8)) {
if (emptyLineSeen) {
sb.append(line).append("\n");
} else {
String trimmed = line.trim();
if (trimmed.isEmpty()) {
emptyLineSeen = true;
} else {
if (!trimmed.startsWith("#")) {
String[] entry = trimmed.split(" *[:=] *", 2);
if (entry.length > 1) {
properties.put(entry[0], entry[1]);
}
}
}
}
}
} catch (IOException e) {
LOGGER.error("", e);
return sb;
}
return sb;
}
}
Loading
Loading