Skip to content

Commit 70d3e58

Browse files
yanntmclaude
andcommitted
-hsc for CTL: libHSC's symbolic checker runs beside its-ctl and the PetriSpot walk on the CTL examinations — HscRunner.runCtl writes (ctl prop<i> f) forms and streams the FORMULA lines, ParallelWalk.startHscCtl publishes them to DoneProperties
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 4de73ff commit 70d3e58

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

hsc/fr.lip6.move.hsc.runner/src/fr/lip6/move/hsc/runner/HscRunner.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,34 @@ public static Verdicts run(ISparsePetriNet net, List<String> forms, int totalSec
258258
}
259259
}
260260

261+
/**
262+
* The CTL formulas at the initial marking, by libHSC's symbolic checker
263+
* (forward form over the saturated reachable set, the inverse relation for
264+
* what the forward form leaves). One (ctl prop&lt;i&gt; formula) form per
265+
* property; hsc-pn runs them in rounds of growing per-property budget under
266+
* totalSeconds, so the cheap ones come first. Verdicts stream to the
267+
* listener as FORMULA lines arrive; a formula the checker leaves open has
268+
* no verdict.
269+
*
270+
* @return one verdict per formula, or null when the binary could not run
271+
*/
272+
public static Verdicts runCtl(ISparsePetriNet net, List<Expression> formulas, int totalSeconds, Shape shape,
273+
boolean force, Listener listener) {
274+
if (formulas.isEmpty()) {
275+
return new Verdicts(0);
276+
}
277+
List<String> forms = new ArrayList<>(formulas.size());
278+
try {
279+
for (int i = 0; i < formulas.size(); i++) {
280+
forms.add(SexprPropertyPrinter.ctl("prop" + i, formulas.get(i)));
281+
}
282+
} catch (UnsupportedOperationException e) {
283+
System.out.println("hsc-pn CTL skipped: " + e.getMessage());
284+
return null;
285+
}
286+
return run(net, forms, totalSeconds, shape, force, listener);
287+
}
288+
261289
/** The bundled binary, or the one named by the system property hsc.bin (tests outside OSGi). */
262290
private static String binaryPath() throws IOException {
263291
String override = System.getProperty("hsc.bin");

pnmcc/fr.lip6.move.gal.application.pnmcc/src/fr/lip6/move/gal/application/Application.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import fr.lip6.move.gal.application.runner.spot.SpotRunner;
5151
import fr.lip6.move.gal.application.solver.ExclusiveImplicantsComputer;
5252
import fr.lip6.move.gal.application.solver.GALSolver;
53+
import fr.lip6.move.gal.application.solver.ParallelWalk;
5354
import fr.lip6.move.gal.application.solver.ReachabilitySolver;
5455
import fr.lip6.move.gal.application.solver.UpperBoundsSolver;
5556
import fr.lip6.move.gal.application.solver.ExclusiveImplicantsComputer.Constraint;
@@ -361,6 +362,7 @@ public Object startNoEx(String[] args) throws Exception {
361362
doITS = true;
362363
} else if (HSC.equals(args[i])) {
363364
doHSC = true;
365+
ParallelWalk.HSC_CTL = true;
364366
} else if (HSC_BENCH.equals(args[i])) {
365367
hscBench = true;
366368
} else if (HSC_BENCH_REDUCE.equals(args[i])) {

pnmcc/fr.lip6.move.gal.application.pnmcc/src/fr/lip6/move/gal/application/solver/ParallelWalk.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import fr.lip6.move.gal.structural.StructuralReduction;
1212
import fr.lip6.move.gal.structural.expr.Expression;
1313
import fr.lip6.move.petrispot.runner.PetriSpotWalker;
14+
import fr.lip6.move.hsc.runner.HscRunner;
1415

1516
/**
1617
* A PetriSpot walk running beside a decision diagram attempt.
@@ -35,6 +36,12 @@ public class ParallelWalk {
3536
/** Whether a walk accompanies every decision diagram attempt. */
3637
public static final boolean ENABLED = true;
3738

39+
/**
40+
* Whether libHSC's symbolic CTL checker (hsc-pn) also runs beside a CTL
41+
* attempt, on the same reduced net: set by the -hsc flag.
42+
*/
43+
public static boolean HSC_CTL = false;
44+
3845
/** Cores left to the walk. The diagram engine uses one of the four. */
3946
private static final int THREADS = 3;
4047

@@ -141,9 +148,41 @@ public void formula(int index, String value, String techniques) {
141148
}, "petrispot-ctl-beside-dd");
142149
thread.setDaemon(true);
143150
thread.start();
151+
if (HSC_CTL) {
152+
startHscCtl(sr, props, formulas, doneProps, seconds);
153+
}
144154
return new ParallelWalk(thread, cancel);
145155
}
146156

157+
/**
158+
* libHSC's symbolic CTL checker beside a CTL attempt (-hsc): the same
159+
* reduced net and formulas go to hsc-pn, whose verdicts are proofs and
160+
* land in doneProps as they stream. Bounded by seconds like the walk; not
161+
* cancelled with it, the process ends with its budget.
162+
*/
163+
private static void startHscCtl(StructuralReduction sr, List<Property> props, List<Expression> formulas,
164+
DoneProperties doneProps, int seconds) {
165+
HscRunner.Listener listener = (index, value, techniques) -> {
166+
try {
167+
doneProps.put(props.get(index).getName(), "TRUE".equals(value), "DECISION_DIAGRAMS SATURATION HSC");
168+
} catch (GlobalPropertySolverException e) {
169+
// the verdict decided the whole examination: the printer has said so
170+
}
171+
};
172+
Thread thread = new Thread(() -> {
173+
try {
174+
HscRunner.Verdicts v = HscRunner.runCtl(sr, formulas, seconds, HscRunner.Shape.LOUVAIN, true, listener);
175+
if (v != null && v.solved() > 0) {
176+
System.out.println("libHSC CTL check beside the decision diagrams solved " + v.solved() + " properties.");
177+
}
178+
} catch (RuntimeException e) {
179+
System.out.println("libHSC CTL check beside the decision diagrams failed : " + e.getMessage());
180+
}
181+
}, "hsc-ctl-beside-dd");
182+
thread.setDaemon(true);
183+
thread.start();
184+
}
185+
147186
/** Stop the walk and wait for its verdicts to be published. */
148187
public void stop() {
149188
cancel.cancel();

0 commit comments

Comments
 (0)