Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isabelle Translation #3514

Open
wants to merge 263 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
263 commits
Select commit Hold shift + click to select a range
3dab8bd
Added QuantifierHandler
BookWood7th Mar 3, 2024
9dbc690
Fixed negative numbers getting two neg signs
BookWood7th Mar 3, 2024
1547228
Fixed negative numbers getting two neg signs
BookWood7th Mar 3, 2024
2498b62
Now create typedef for all sorts in sequent
BookWood7th Mar 3, 2024
2876c25
Removed some unused fields and methods in IsabelleTranslator
BookWood7th Mar 3, 2024
ece3842
Added correct predefined sorts in UninterpretedSymbolsHandler
BookWood7th Mar 3, 2024
80b7f27
removed unused translation parts and added class instantiation for ex…
BookWood7th Mar 3, 2024
223fb93
changed some instanceall functions in preamble
BookWood7th Mar 3, 2024
0abb4a1
corrected predefined sorts
BookWood7th Mar 5, 2024
9017582
added length to preamble
BookWood7th Mar 5, 2024
0e78f3f
field handler v1
BookWood7th Mar 5, 2024
e01b85f
fix indentation
BookWood7th Mar 5, 2024
d356980
redundant escape in regex
BookWood7th Mar 6, 2024
ff01f54
added SortDependingFunctionHandler
BookWood7th Mar 6, 2024
dc147ed
added DefinedSymbolsHandler
BookWood7th Mar 6, 2024
d9f8fe9
added comments improved lemmata for sort declarations
BookWood7th Mar 6, 2024
50f8949
ensured fieldhandler only handles field constants
BookWood7th Mar 6, 2024
29f1a1d
handleAsUnkownValue now functions better
BookWood7th Mar 6, 2024
96de5f0
slight preamble changes and changed translation for eqv
BookWood7th Mar 6, 2024
763732c
renamed Object to java_lang_Object in preamble
BookWood7th Mar 6, 2024
e69ae64
ensure illegal chars in name are not translated in UninterpretedSymbo…
BookWood7th Mar 6, 2024
984b1d7
now looks for sorts parents only among given sorts (and any, Object)
BookWood7th Mar 6, 2024
24d52e3
fixed some remaining illegal sort names
BookWood7th Mar 6, 2024
fa94d5f
preamble change so all rep abs have the same format
BookWood7th Mar 7, 2024
bd3aa86
added coercions to parent types
BookWood7th Mar 7, 2024
97a5f93
added length function and axiom to preamble
BookWood7th Mar 7, 2024
ffb7f29
formatting integers.locale
BookWood7th Mar 7, 2024
69126d3
fix length axiom
BookWood7th Mar 7, 2024
17baf33
locale formatting
BookWood7th Mar 7, 2024
fb8ccbc
accounted for 2nd field syntax
BookWood7th Mar 7, 2024
962aa3a
added ObserverFunctionHandler
BookWood7th Mar 7, 2024
5250146
added BSumHandler for bounded sums
BookWood7th Mar 7, 2024
2f66287
translation now translates antecedents as assumptions of a theorem
BookWood7th Mar 7, 2024
f23d9a8
now throws exception when encountering unknown values
BookWood7th Mar 8, 2024
6c1df63
fixing pipeline
BookWood7th Mar 8, 2024
3e4af59
revert pipeline changes
BookWood7th Mar 8, 2024
381c8ea
ensured FieldHandler fixes unknown fields
BookWood7th Mar 9, 2024
67b0849
changed sort name translations to better account for predefined sorts…
BookWood7th Mar 9, 2024
bf211e6
changed any type class instantiations to use fun instead of definition.
BookWood7th Mar 9, 2024
6b67f3d
fix error in sort depending functions
BookWood7th Mar 9, 2024
6a8c37b
added axiomatizations for function symbols in preamble
BookWood7th Mar 9, 2024
110d020
adjusted translation name for length of objects
BookWood7th Mar 9, 2024
918d951
fixed bug where translation crashes on non open goals
BookWood7th Mar 9, 2024
7a18eb9
add arr function to defined symbols
BookWood7th Mar 9, 2024
e3cdbad
added LocSet function definitions
BookWood7th Mar 10, 2024
04b2b18
made BSum use at least less than instead of subtracting one
BookWood7th Mar 10, 2024
b29c834
1st version of reasoning over Sequences
BookWood7th Mar 10, 2024
081078b
bug fixes
BookWood7th Mar 11, 2024
2c06f40
added locale interpretation for int and bool to access additional lem…
BookWood7th Mar 13, 2024
4992fbe
better translation of array sorts
BookWood7th Mar 13, 2024
060d992
added lots of axioms and types to preamble
BookWood7th Mar 14, 2024
dc1262b
added some more defined symbols in DefinedSymbolsHandler
BookWood7th Mar 14, 2024
b3e03e4
inverted knownSymbol and knownSort functions
BookWood7th Mar 15, 2024
6639c6e
added jdiv and jmod to IntegerOpHandler
BookWood7th Mar 15, 2024
4dc07de
added InstanceOperatorHandler
BookWood7th Mar 15, 2024
75e262b
added function to switch from int bSum to nat bSum in preamble
BookWood7th Mar 16, 2024
2e4619e
field names should not include .
BookWood7th Mar 16, 2024
e5fe37c
neg, jdiv, jmod translation fixes
BookWood7th Mar 17, 2024
e2da013
removed fulfilled TODO
BookWood7th Mar 17, 2024
10417ae
fix javaDL_type declaration
BookWood7th Mar 17, 2024
30f6720
currying applied to elementOf function
BookWood7th Mar 17, 2024
48101e5
now saves translation file to subdirectory of .key folder
BookWood7th Mar 18, 2024
da0aa66
moved services parameter of methods to field in Translator
BookWood7th Mar 18, 2024
0d2a1e5
added scala-isabelle project to dependencies
BookWood7th Mar 20, 2024
44f50f2
opens the translation file in Isabelle
BookWood7th Mar 20, 2024
a037d50
added naive concurrency implementation for opening Isabelle
BookWood7th Mar 20, 2024
1da460a
cleanup
BookWood7th Mar 21, 2024
4b7aad3
handling other observer functions
BookWood7th Mar 21, 2024
4bddd78
Seq handling improved
BookWood7th Mar 22, 2024
233c483
changed function signatures in preamble to match KeY
BookWood7th Mar 25, 2024
47b0abd
parameter order fixes in functions
BookWood7th Apr 2, 2024
5b0d9a1
further fixes
BookWood7th Apr 2, 2024
d10d8da
removed div_nonzero
BookWood7th Apr 2, 2024
8c515d1
temp
BookWood7th Apr 8, 2024
388c6c4
further temp
BookWood7th Apr 11, 2024
900db5e
Now calls sledgehammer and outputs result to command line
BookWood7th Apr 12, 2024
ce55e0b
added type to lambda parameter
BookWood7th Apr 13, 2024
ea7ee25
Merge remote-tracking branch 'refs/remotes/key-origin/ScalaAutomation…
BookWood7th Apr 13, 2024
db3e478
removed unused converter stumps
BookWood7th Apr 13, 2024
4a42667
auto closes selected goal if proven by sledgehammer
BookWood7th Apr 13, 2024
4a5d889
added all default provers to sledgehammer
BookWood7th Apr 13, 2024
493603d
added settings to change save file path and isabelle path
BookWood7th Apr 14, 2024
9a679e1
better default path handling
BookWood7th Apr 14, 2024
2d10f4b
added GUI settings
BookWood7th Apr 14, 2024
5911eda
fixed file store location
BookWood7th Apr 14, 2024
1339185
now destroys isabelle resources
BookWood7th Apr 14, 2024
a727966
splitting into preamble and sequent
BookWood7th Apr 15, 2024
3d16ccd
handle missing isabelle correctly
BookWood7th Apr 15, 2024
5a4f8c1
rename settings window
BookWood7th Apr 15, 2024
e308a88
default translation path rename
BookWood7th Apr 15, 2024
c47c919
fix translation preamble
BookWood7th Apr 15, 2024
eba83d1
improve close message
BookWood7th Apr 15, 2024
e950c8b
better Log messages
BookWood7th Apr 15, 2024
c9c4ad4
add SeqPerm
BookWood7th Apr 16, 2024
7528970
now built around having a ROOT session and unchanging preamble
BookWood7th Apr 16, 2024
eba422e
load settings at startup
BookWood7th Apr 16, 2024
2c4ce32
file path changes
BookWood7th Apr 16, 2024
82ed6e5
create session files at startup and when changing translation path
BookWood7th Apr 16, 2024
dd1e262
fix file loading errors and translation imports
BookWood7th Apr 16, 2024
cefc94a
remove interpretations as subtypes of any (might interfere with induc…
BookWood7th Apr 16, 2024
ab3d918
fix observer functions
BookWood7th Apr 18, 2024
2c63a1e
add infiniteUnion
BookWood7th Apr 18, 2024
9e39900
fix translation when multiple invariants occur
BookWood7th Apr 18, 2024
6c7a204
fix infiniteUnion and add preamble definition for it
BookWood7th Apr 18, 2024
cf717b6
add broken main file
BookWood7th Apr 16, 2024
8d7e497
fixed main file
BookWood7th Apr 16, 2024
295635f
bugs in main file
BookWood7th Apr 16, 2024
9fb3910
remove replay from stats
BookWood7th Apr 16, 2024
958a812
write files down in file crawler
BookWood7th Apr 17, 2024
c1fb9e9
run SMT Prep and launch solvers on all goals
BookWood7th Apr 17, 2024
ee43f0b
first attempt at recording stats for each goal
BookWood7th Apr 17, 2024
48b960e
message improvement add timeout for valid file search
BookWood7th Apr 17, 2024
bed3a44
evaluation now works for KeY and Z3
BookWood7th Apr 17, 2024
368cd48
fixes statistics save
BookWood7th Apr 18, 2024
a4429c8
fix csv
BookWood7th Apr 18, 2024
2a52750
add timeout and listeners to IsabelleProblem
BookWood7th Apr 18, 2024
8cde773
add Isabelle to evaluation class
BookWood7th Apr 18, 2024
cab98ce
fix result not being set when notifying listeners
BookWood7th Apr 18, 2024
ac7cb91
change runtimeexception to illegal formula exception
BookWood7th Apr 18, 2024
0745812
fix Isabelle actually starting
BookWood7th Apr 18, 2024
5268259
add isabelle stats to csv
BookWood7th Apr 18, 2024
f941eb4
change return timing to get notifications
BookWood7th Apr 18, 2024
d3e5e38
fix exactInstance overlapping for multiple instances
BookWood7th Apr 18, 2024
2c73ff0
fix exactInstance overlapping for multiple instances
BookWood7th Apr 18, 2024
e9929c2
fix array types being defined before their base type
BookWood7th Apr 18, 2024
e43235f
Merge branch 'refs/heads/isabelleTranslation' into Evaluation
BookWood7th Apr 18, 2024
25f3302
add timeout in other places it should occur
BookWood7th Apr 18, 2024
d5d2661
add isabelle proof to csv
BookWood7th Apr 18, 2024
0203874
try try0 before sledgehammering
BookWood7th Apr 19, 2024
b6aaba2
add right sum induct lemma to preamble
BookWood7th Apr 19, 2024
35a4985
various fixes, adding a timeout
BookWood7th Apr 19, 2024
ee33591
verit missing from sledgehammer
BookWood7th Apr 19, 2024
bae7037
wrong timeout being thrown
BookWood7th Apr 19, 2024
99ee8ff
string for empty results
BookWood7th Apr 19, 2024
9a16c07
add create to defined symbols
BookWood7th Apr 19, 2024
5a86b7b
add create to defined symbols
BookWood7th Apr 19, 2024
38dd299
fix invariants for different types colliding
BookWood7th Apr 19, 2024
422cdd2
add back falsify to sledgehammer
BookWood7th Apr 19, 2024
355a457
strategy settings messed up the SMT Prep macro
BookWood7th Apr 19, 2024
93ddcb3
fix locale for no variables in sequent and destroy isabelle process e…
BookWood7th Apr 20, 2024
26c04b4
added launcher for Isabelle to avoid loading theory for each problem
BookWood7th Apr 20, 2024
1749913
observer function naming fix
BookWood7th Apr 20, 2024
4fa03e7
move logger outputs in IsabelleProblem to debug
BookWood7th Apr 20, 2024
2d0f65d
remove settings parameter from individual sledgehammer calls, fix bug…
BookWood7th Apr 21, 2024
2817fc7
logger outputs and setting max steps to max value
BookWood7th Apr 21, 2024
838bbcd
fix unknowns with #
BookWood7th Apr 21, 2024
59529ff
add assumption to locale to make sure all fields are distinct.
BookWood7th Apr 21, 2024
77ab9a6
Change to LOGGER from System.out.println, parallelize Z3, hopefully c…
BookWood7th Apr 21, 2024
fb11bff
stop Z3 launcher to hopefully prevent zombie Z3 instances
BookWood7th Apr 21, 2024
bca4777
add created field to distinct field lemma
BookWood7th Apr 22, 2024
198ca2f
move outdir to home/tmp
BookWood7th Apr 22, 2024
622fe17
fix last commit
BookWood7th Apr 22, 2024
acad9df
example now dependent on user home
BookWood7th Apr 22, 2024
a3ed40f
need to create directories before session files
BookWood7th Apr 22, 2024
ce9d405
write translation files on launcher start
BookWood7th Apr 22, 2024
a41e62f
add shutdown hook for saving csv and increase concurrency
BookWood7th Apr 22, 2024
d7ec385
switch to expansion without splits and set indices for goals
BookWood7th Apr 23, 2024
33ac488
improve concurrency and resource management
BookWood7th Apr 23, 2024
ffff417
take advantage of more Z3 launches, and Isabelle concurrency
BookWood7th Apr 23, 2024
5c6dd54
add shadow plugin to create executable jars for evaluation deployment
BookWood7th Apr 23, 2024
c6b9e35
remove non pooled sledgehammerAll, was redundant
BookWood7th Apr 23, 2024
5a8de75
inline begin theory parameter
BookWood7th Apr 23, 2024
62de571
fix csv header, illegal characters
BookWood7th Apr 23, 2024
d55e4fa
fix typo of seqGetOutside
BookWood7th Apr 24, 2024
9e87fca
load smt settings instead of using default instance
BookWood7th Apr 24, 2024
00f345d
add seqNPerm
BookWood7th Apr 24, 2024
50956de
add seqNPerm to DefinedSymbolsHandler
BookWood7th Apr 24, 2024
2078118
add seqSwap and seqRemove
BookWood7th Apr 24, 2024
2303777
ensure try0 is not waited on indefinitely
BookWood7th Apr 25, 2024
64e64c8
fix seqRemove
BookWood7th Apr 25, 2024
50ad2e8
seqIndexOf undefined case
BookWood7th Apr 25, 2024
7e7b400
replace seqIndexOf with nonexhaustive function
BookWood7th Apr 26, 2024
e5e73b4
add back interpretations
BookWood7th Apr 26, 2024
a9614a7
add disjoint types axioms and assumptions
BookWood7th May 3, 2024
59dbc6e
fix indent
BookWood7th May 3, 2024
af496ef
add disjointModNull for java types
BookWood7th May 4, 2024
b348d44
fix java type disjoint
BookWood7th May 4, 2024
645ed2a
change the disjointModNull assumptions for java types to be easier to…
BookWood7th May 4, 2024
ae284ef
give names to assumptions disjoint types
BookWood7th May 4, 2024
b08a696
change disjointModNull
BookWood7th May 6, 2024
03de9d9
set KeY strategy before preparation
BookWood7th May 6, 2024
e4dd0af
ensure timeouts sent by sledgehammer are recognized as timeouts
BookWood7th May 7, 2024
005be5d
listener change to avoid mislabelling state
BookWood7th May 7, 2024
26a62d2
remove strategy settings before prep, caused prep to stop prematurely
BookWood7th May 7, 2024
0878b35
fix goalNr in csv
BookWood7th May 7, 2024
dfe148d
change input file format to save parent directory name
BookWood7th May 7, 2024
aaa067d
wrong order of setting goalNr
BookWood7th May 7, 2024
e161552
add back strategy with right timeouts before prep
BookWood7th May 7, 2024
514afd4
timeout recognition problem
BookWood7th May 7, 2024
caa8c12
change distinct types to include standard types
BookWood7th May 7, 2024
2cdc2ed
unfolded disjoint Types assumptions
BookWood7th May 7, 2024
cef85d3
fix distinctSortsAssumptions
BookWood7th May 7, 2024
2d35493
flipflop strategy for prep
BookWood7th May 7, 2024
aa4caf2
fix disjoint types assumptions
BookWood7th May 7, 2024
2dbba8f
fix disjoint types assumptions name collision by binding to quantifier
BookWood7th May 7, 2024
bb7b93c
run instead of start shutdownResources
BookWood7th May 7, 2024
68c592e
revert new disjoint type changes. Assumptions overwhelmed sledgehammer
BookWood7th May 8, 2024
973df0f
remove the disjoint types as they did not help
BookWood7th May 8, 2024
ac67336
Merge branch 'refs/heads/isabelleTranslation'
BookWood7th Jul 4, 2024
ece94de
remove evaluation artifacts
BookWood7th Jul 4, 2024
443a7ab
renamed translation package
BookWood7th Jul 4, 2024
0c6861f
Refactored Handler classes to use the new ncore package
BookWood7th Jul 17, 2024
51d85cd
Major Launcher reworks and first version of UI (nonfunctional)
BookWood7th Aug 21, 2024
fee0baf
Further Launcher Structure reworks and adding TranslateAllAction
BookWood7th Aug 21, 2024
46b2f28
Update scala-isabelle version
BookWood7th Sep 4, 2024
311aafe
Better naming in Isabelle dialog
BookWood7th Sep 4, 2024
a3cba4a
Remove unsuitable start method
BookWood7th Sep 4, 2024
4014b57
Let Launcher write back files, no need for double writing, add interf…
BookWood7th Sep 4, 2024
d211ae5
IsabelleResourceController now uses ThreadPool for instance creation …
BookWood7th Sep 4, 2024
74f3f18
Allow IsabelleLauncher to be shutdown
BookWood7th Sep 4, 2024
5f99dc0
Implement stop button in Isabelle dialog
BookWood7th Sep 4, 2024
9aaa6ac
Make final fields final in IsabelleResourceController
BookWood7th Sep 4, 2024
fda17ae
first version of reporting solver status in dialog
BookWood7th Sep 4, 2024
861a3cd
report result of solvers instead of simply state
BookWood7th Sep 4, 2024
c30fbc5
tracking down some uncaught exceptions when interrupting Isabelle sol…
BookWood7th Sep 4, 2024
5b797f3
Change interrupt behaviour for Isabelle solvers
BookWood7th Sep 5, 2024
061c43b
rename package
BookWood7th Sep 19, 2024
34fef8f
add new IsabelleResult to replace SledgehammerResult prototype
BookWood7th Sep 22, 2024
74b631f
replacing SledgehammerResult
BookWood7th Sep 22, 2024
a2f6a87
fix running additional solvers after user interruptions
BookWood7th Sep 23, 2024
83008bc
notify listener when launcher finishes work
BookWood7th Sep 24, 2024
2de6895
discard button functionality
BookWood7th Sep 24, 2024
5d800ec
show solver progress in dialog, remove bugs in dialog, remove info bu…
BookWood7th Sep 24, 2024
3038ce1
separate IsabelleProblem from solvers, remove result
BookWood7th Sep 24, 2024
3a784bb
add prototypical apply action for dialog that does not require change…
BookWood7th Sep 24, 2024
a7f8af2
make solvers callable. Add timeout settings
BookWood7th Oct 8, 2024
27f5083
package refactoring
BookWood7th Oct 8, 2024
d16bdd6
fix progress bars
BookWood7th Oct 10, 2024
c1b990e
major documentation and spotless compliance push
BookWood7th Oct 11, 2024
f51cf41
preparing to handle partially translatable proofs
BookWood7th Oct 17, 2024
09c70e9
fix interrupts during preparations causing dialog to freeze
BookWood7th Oct 20, 2024
12d129f
now opens launcher when some problems are untranslatable instead of o…
BookWood7th Oct 20, 2024
6a4df92
changed prefix to postfix to avoid isabelle errors for UninterpretedS…
BookWood7th Oct 21, 2024
edac00d
add information buttons to display solver input, output and exception…
BookWood7th Oct 22, 2024
48cfb76
Merge branch 'KeYMainBranch' into isabelleTranslation
BookWood7th Oct 23, 2024
6cccf8e
resolve differences to main in .gitlab-ci.yml
BookWood7th Oct 23, 2024
08a518d
Merge branch 'ExternalSolverRuleApp' into isabelleTranslation
BookWood7th Oct 23, 2024
b6d9b73
add custom IsabelleRuleApp to close goals
BookWood7th Oct 23, 2024
ee123ff
applied spotless
BookWood7th Oct 23, 2024
65e6d84
Merge branch 'ExternalSolverRuleApp' into isabelleTranslation
BookWood7th Nov 12, 2024
90f4556
update IsabelleRuleApp to implement necessary Override methods
BookWood7th Nov 12, 2024
0fc279a
settings GUI updates
BookWood7th Nov 13, 2024
ee9adc2
first support check for Isabelle
BookWood7th Nov 13, 2024
ff77893
switch to JOptionPane from IssueDialog
BookWood7th Nov 13, 2024
f7d7a26
Merge branch 'KeYProject:main' into isabelleTranslation
BookWood7th Jan 23, 2025
901d869
Merge branch 'KeYProject:main' into main
BookWood7th Jan 23, 2025
2977fc6
Merge branch 'KeYMainBranch' into isabelleTranslation
BookWood7th Feb 12, 2025
425218c
fix issues causing interrupts to be ignored
BookWood7th Feb 12, 2025
b3f46dd
remove eprover from sledgehammer to avoid runaway instances
BookWood7th Feb 12, 2025
3c124cd
Merge branch 'isabelleTranslation'
BookWood7th Feb 12, 2025
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
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ before_script:
- export SONAR_SCANNER_OPTS="-Xmx8G"

stages:
- primary
- secondary
- ternary
- deploy
- primary
- secondary
- ternary
- deploy

compile:classes:
stage: primary
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ subprojects {
// specific delimiter: normally just 'package', but spotless crashes for files in default package
// (see https://github.com/diffplug/spotless/issues/30), therefore 'import' is needed. '//' is for files
// with completely commented out code (which would probably better just be removed in future).
if(project.name == 'recoder') {
if (project.name == 'recoder') {
licenseHeaderFile("$rootDir/gradle/header-recoder", '(package|import|//)')
}else {
} else {
licenseHeaderFile("$rootDir/gradle/header", '(package|import|//)')
}
}
Expand Down
1 change: 1 addition & 0 deletions key.ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
runtimeOnly project(":keyext.exploration")
runtimeOnly project(":keyext.slicing")
runtimeOnly project(":keyext.proofmanagement")
runtimeOnly project(":keyext.isabelletranslation")
}

task createExamplesZip(type: Zip) {
Expand Down
7 changes: 7 additions & 0 deletions keyext.isabelletranslation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description "Translation of Sequents to Isabelle"

dependencies {
implementation project(':key.core')
implementation project(':key.ui')
implementation("de.unruh:scala-isabelle_2.13:0.4.3-RC1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/* 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.isabelletranslation;

import java.io.IOException;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;
import javax.swing.*;

import de.uka.ilkd.key.gui.MainWindow;
import de.uka.ilkd.key.gui.settings.InvalidSettingsInputException;
import de.uka.ilkd.key.gui.settings.SettingsPanel;
import de.uka.ilkd.key.gui.settings.SettingsProvider;
import de.uka.ilkd.key.settings.Configuration;

/**
* {@link SettingsProvider} for Isabelle translation extension
*/
public class IsabelleSettingsProvider extends SettingsPanel implements SettingsProvider {
private static final String INFO_TIMEOUT_FIELD =
"""
Timeout for the external solvers in seconds.
""";
private static final String infoTranslationPathPanel =
"""
Choose where the isabelle translation files are stored.
""";
private static final String infoIsabellePathPanel =
"""
Specify the absolute path of the Isabelle folder.
Currently supports Isabelle2024-RC1.
""";

private static final Collection<String> SUPPORTED_VERSIONS_TEXT = List.of("Isabelle2024-RC1");

/**
* Panel for inputting the path to where translations are stored
*/
private final JTextField translationPathPanel;

/**
* Panel for inputting the path to Isabelle installation
*/
private final JTextField isabellePathPanel;

/**
* Input field for timeout in seconds
*/
private final JSpinner timeoutField;

/**
* Supported version info for user
*/
private final JTextField versionSupported;

/**
* The current settings object
*/
private final IsabelleTranslationSettings settings;

public IsabelleSettingsProvider() {
super();
setHeaderText(getDescription());
setSubHeaderText(
"Isabelle settings are stored in: "
+ IsabelleTranslationSettings.SETTINGS_FILE_NEW.getAbsolutePath());
translationPathPanel = createTranslationPathPanel();
isabellePathPanel = createIsabellePathPanel();
timeoutField = createTimeoutField();

createCheckSupportButton();
this.versionSupported = createSolverSupported();
this.settings = IsabelleTranslationSettings.getInstance();
}

@Override
public String getDescription() {
return "Isabelle Translation";
}

@Override
public JPanel getPanel(MainWindow window) {
isabellePathPanel
.setText(settings.getIsabellePath().toString());
translationPathPanel
.setText(settings.getTranslationPath().toString());
timeoutField.setValue(settings.getTimeout());
return this;
}

private JTextField createTranslationPathPanel() {
return addFileChooserPanel("Location for translation files:", "", infoTranslationPathPanel,
true, e -> {
});
}

private JTextField createIsabellePathPanel() {
return addFileChooserPanel("Isabelle installation folder:", "", infoIsabellePathPanel,
true, e -> {
});
}

private JSpinner createTimeoutField() {
// Use doubles so that the formatter doesn't make every entered String into integers.
// [see NumberFormatter#stringToValue()].
JSpinner timeoutSpinner = addNumberField("Timeout:", 1, Integer.MAX_VALUE, 1,
INFO_TIMEOUT_FIELD,
e -> settings.setTimeout(e.intValue()));
// Set the editor so that entered Strings only have three decimal places.
JSpinner.NumberEditor editor = new JSpinner.NumberEditor(timeoutSpinner, "#");
// Use floor rounding to be consistent with the value that will be set for the timeout.
editor.getFormat().setRoundingMode(RoundingMode.FLOOR);
timeoutSpinner.setEditor(editor);
return timeoutSpinner;
}

protected JButton createCheckSupportButton() {
JButton checkForSupportButton = new JButton("Check for support");
checkForSupportButton.setEnabled(true);
checkForSupportButton
.addActionListener(arg0 -> versionSupported.setText(getSolverSupportText()));
addRowWithHelp(null, new JLabel(), checkForSupportButton);
return checkForSupportButton;
}

private boolean checkForSupport() {
String isabelleVersion;
Path isabelleIdentifierPath =
Paths.get(isabellePathPanel.getText(), "/etc/ISABELLE_IDENTIFIER");
try {
isabelleVersion = Files.readAllLines(isabelleIdentifierPath).getFirst();
} catch (IOException e) {
return false;
}
return SUPPORTED_VERSIONS_TEXT.contains(isabelleVersion);
}

protected JTextField createSolverSupported() {
JTextField txt = addTextField("Support", getSolverSupportText(),
createSupportedVersionText(),
emptyValidator());
txt.setEditable(false);
return txt;
}

private String createSupportedVersionText() {
String supportText = "Supports these Isabelle versions: ";
supportText = supportText + String.join(", ", SUPPORTED_VERSIONS_TEXT);
return supportText;
}

private String getSolverSupportText() {
return checkForSupport() ? "Version of Isabelle is supported."
: "Version of Isabelle may not be supported.";
}


@Override
public void applySettings(MainWindow window) throws InvalidSettingsInputException {
Configuration newConfig = new Configuration();
newConfig.set(IsabelleTranslationSettings.translationPathKey,
translationPathPanel.getText());
newConfig.set(IsabelleTranslationSettings.isabellePathKey, isabellePathPanel.getText());
settings.readSettings(newConfig);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* 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.isabelletranslation;

import java.util.ArrayList;
import java.util.List;
import javax.swing.*;

import de.uka.ilkd.key.core.KeYMediator;
import de.uka.ilkd.key.gui.MainWindow;
import de.uka.ilkd.key.gui.extension.api.ContextMenuAdapter;
import de.uka.ilkd.key.gui.extension.api.ContextMenuKind;
import de.uka.ilkd.key.gui.extension.api.KeYGuiExtension;
import de.uka.ilkd.key.gui.settings.SettingsProvider;
import de.uka.ilkd.key.pp.PosInSequent;

import org.key_project.isabelletranslation.gui.controller.TranslateAllAction;
import org.key_project.isabelletranslation.gui.controller.TranslationAction;

import org.jspecify.annotations.NonNull;

/**
* Extension class for Isabelle translation
*/
@KeYGuiExtension.Info(name = "Isabelle Translation", optional = true,
experimental = false)
public class IsabelleTranslationExtension implements KeYGuiExtension, KeYGuiExtension.Settings,
KeYGuiExtension.ContextMenu, KeYGuiExtension.Startup {
@Override
public SettingsProvider getSettings() {
return new IsabelleSettingsProvider();
}


/**
* The context menu adapter used by the extension.
*/
private final ContextMenuAdapter adapter = new ContextMenuAdapter() {
@Override
public List<Action> getContextActions(
KeYMediator mediator, ContextMenuKind kind, PosInSequent pos) {
if (pos.getPosInOccurrence() != null || mediator.getSelectedGoal() == null) {
return List.of();
}
List<Action> list = new ArrayList<>();
list.add(new TranslationAction(MainWindow.getInstance()));
list.add(new TranslateAllAction(MainWindow.getInstance()));
return list;
}
};

@Override
public @NonNull List<Action> getContextActions(@NonNull KeYMediator mediator,
@NonNull ContextMenuKind kind, @NonNull Object underlyingObject) {
return adapter.getContextActions(mediator, kind, underlyingObject);
}

@Override
public void init(MainWindow window, KeYMediator mediator) {
IsabelleTranslationSettings.getInstance();
}
}
Loading
Loading