-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into highprecision
- Loading branch information
Showing
19 changed files
with
563 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
examples/quickcheck/src/main/java/quickcheck/commands/QCRunCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
|
||
package quickcheck.commands; | ||
|
||
import static com.fujitsu.vdmj.plugins.PluginConsole.println; | ||
|
||
import com.fujitsu.vdmj.plugins.AnalysisCommand; | ||
import com.fujitsu.vdmj.plugins.analyses.POPlugin; | ||
import com.fujitsu.vdmj.plugins.commands.PrintCommand; | ||
import com.fujitsu.vdmj.pog.ProofObligation; | ||
import com.fujitsu.vdmj.pog.ProofObligationList; | ||
|
||
/** | ||
* Launch a "print" command for a PO counterexample or witness. | ||
*/ | ||
public class QCRunCommand extends AnalysisCommand | ||
{ | ||
private final static String CMD = "qcrun <PO number>"; | ||
private final static String USAGE = "Usage: " + CMD; | ||
|
||
public QCRunCommand(String line) | ||
{ | ||
super(line); | ||
|
||
if (!argv[0].equals("qcrun")) | ||
{ | ||
throw new IllegalArgumentException(USAGE); | ||
} | ||
} | ||
|
||
@Override | ||
public String run(String line) | ||
{ | ||
POPlugin po = registry.getPlugin("PO"); | ||
ProofObligationList all = po.getProofObligations(); | ||
|
||
if (argv.length == 2) | ||
{ | ||
int number = 0; | ||
|
||
try | ||
{ | ||
number = Integer.parseInt(argv[1]); | ||
} | ||
catch (NumberFormatException e) | ||
{ | ||
return USAGE; | ||
} | ||
|
||
for (ProofObligation obligation: all) | ||
{ | ||
if (obligation.number == number) | ||
{ | ||
String launch = null; | ||
|
||
if (!obligation.counterexample.isEmpty()) | ||
{ | ||
launch = obligation.getCexLaunch(); | ||
} | ||
else if (!obligation.witness.isEmpty()) | ||
{ | ||
launch = obligation.getWitnessLaunch(); | ||
} | ||
else | ||
{ | ||
return "Obligation does not have a counterexample/witness. Run qc?"; | ||
} | ||
|
||
String pline = "print " + launch; | ||
println("> " + pline); | ||
PrintCommand cmd = new PrintCommand(pline); | ||
return cmd.run(pline); | ||
} | ||
} | ||
|
||
return "No such obligation: " + number; | ||
} | ||
else | ||
{ | ||
return USAGE; | ||
} | ||
} | ||
|
||
public static void help() | ||
{ | ||
println(CMD + " - execute counterexample/witness"); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
examples/quickcheck/src/main/java/quickcheck/commands/QCRunLSPCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
package quickcheck.commands; | ||
|
||
import static com.fujitsu.vdmj.plugins.PluginConsole.println; | ||
|
||
import com.fujitsu.vdmj.pog.ProofObligation; | ||
import com.fujitsu.vdmj.pog.ProofObligationList; | ||
|
||
import dap.DAPMessageList; | ||
import dap.DAPRequest; | ||
import dap.ExpressionExecutor; | ||
import vdmj.commands.AnalysisCommand; | ||
import workspace.PluginRegistry; | ||
import workspace.plugins.POPlugin; | ||
|
||
/** | ||
* Launch a "print" command for a PO counterexample or witness. | ||
*/ | ||
public class QCRunLSPCommand extends AnalysisCommand | ||
{ | ||
public static final String USAGE = "Usage: qcrun <PO number>"; | ||
public static final String HELP = "qcrun <PO number> - execute counterexample/witness"; | ||
|
||
private final int number; | ||
|
||
public QCRunLSPCommand(String line) | ||
{ | ||
super(line); | ||
String[] parts = line.split("\\s+", 2); | ||
|
||
if (parts.length != 2) | ||
{ | ||
throw new IllegalArgumentException(USAGE); | ||
} | ||
|
||
try | ||
{ | ||
number = Integer.parseInt(argv[1]); | ||
} | ||
catch (NumberFormatException e) | ||
{ | ||
throw new IllegalArgumentException(USAGE); | ||
} | ||
} | ||
|
||
@Override | ||
public DAPMessageList run(DAPRequest request) | ||
{ | ||
POPlugin po = PluginRegistry.getInstance().getPlugin("PO"); | ||
ProofObligationList all = po.getProofObligations(); | ||
|
||
for (ProofObligation obligation: all) | ||
{ | ||
if (obligation.number == number) | ||
{ | ||
String launch = null; | ||
|
||
if (!obligation.counterexample.isEmpty()) | ||
{ | ||
launch = obligation.getCexLaunch(); | ||
} | ||
else if (!obligation.witness.isEmpty()) | ||
{ | ||
launch = obligation.getWitnessLaunch(); | ||
} | ||
else | ||
{ | ||
return new DAPMessageList(request, false, | ||
"Obligation does not have a counterexample/witness. Run qc?", null); | ||
} | ||
|
||
println("print " + launch); | ||
ExpressionExecutor executor = new ExpressionExecutor("print", request, launch); | ||
executor.start(); | ||
return null; | ||
} | ||
} | ||
|
||
return new DAPMessageList(request, false, "No such obligation: " + number, null); | ||
} | ||
|
||
@Override | ||
public boolean notWhenRunning() | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.