/** * Constructs a new prover with the given <code>SymbolTable</code> and sets it immediately to work * on the verification conditions represented in the provided <code>Collection</code> of <code> * AssertiveCode</code>. If this constructor returns without throwing an exception, the VCs have * been proved. Otherwise, an exception is thrown indicating which VC could not be proved (or was * proved inconsistent). * * @param symbolTable The current symbol table. May not be <code>null</code>. * @param vCs A list of verification conditions in the form of <code>AssertiveCode</code>. May not * be <code>null</code>. * @param maxDepth The maximum length of proof the prover should consider. * @throws UnableToProveException If a given VC cannot be proved in a reasonable amount of time. * @throws VCInconsistentException If a given VC can be proved inconsistent. * @throes NullPointerException If <code>symbolTable</code> or <code>vC</code> is <code>null * </code>. */ public Prover( final MathExpTypeResolver typer, final Iterable<VerificationCondition> vCs, final CompileEnvironment instanceEnvironment) throws ProverException { if (instanceEnvironment.flags.isFlagSet(FLAG_TIMEOUT)) { TIMEOUT = Long.parseLong( instanceEnvironment.flags.getFlagArgument(FLAG_TIMEOUT, FLAG_TIMEOUT_ARG_NAME)); } else { TIMEOUT = Integer.MAX_VALUE; } myInstanceEnvironment = instanceEnvironment; allProved = true; if (!myInstanceEnvironment.flags.isFlagSet(FLAG_NOGUI)) { myProgressWindow = new ProofProgressWindow("VC", null); } myTyper = typer; buildTheories(); try { proveVCs(vCs); CompileReport myReport = myInstanceEnvironment.getCompileReport(); if (!myReport.hasError() && allProved) { myReport.setProveSuccess(); } } catch (UnsupportedOperationException e) { // Exp.equivalent() is not consistently implemented throughout the // absyn package. By default, it will just throw an // UnsupportedOperationException if it is called and has not been // overridden. This will catch this case and produce a useful // error message. // On the other hand, it's sometimes useful for debugging to see a // full stack trace. Uncomment this next line to see that instead: if (true) throw new RuntimeException(e); ErrorHandler handler = myInstanceEnvironment.getErrorHandler(); handler.error(e.getMessage() + "\n\nTry disabling the -prove option."); } if (!myInstanceEnvironment.flags.isFlagSet(FLAG_NOGUI)) { myProgressWindow.dispose(); } }
/** * Attempts to prove a single VC. If this method returns without throwing an exception, then the * VC was proved. * * @param vC The verification condition to be proved. May not be <code>null</code>. * @param theorems A list of theorems that may be applied as part of the proof. May not be <code> * null</code>. * @param maxDepth The maximum number of steps the prover should attempt before giving up on a * proof. * @param metrics A reference to the metrics the prover should keep on the proof in progress. May * not be <code>null</code>. * @param p The prover to be used if we're using the new prover, or <code>null</code> if we're * supposed to use to legacy prover. * @throws UnableToProveException If the VC cannot be proved in a reasonable amount of time. * @throws VCInconsistentException If the VC can be proved inconsistent. * @throws NullPointerException If <code>vC</code>, <code>theorems</code>, or <code>metrics</code> * is <code>null</code>. */ private void proveVC( final VerificationCondition vC, final Metrics metrics, FileWriter proofFile, VCProver p) throws VCInconsistentException { if (myInstanceEnvironment.flags.isFlagSet(FLAG_VERBOSE)) { System.out.println("\n\n############################# VC " + "#############################"); System.out.println(vC); } long startTime = System.currentTimeMillis(); vC.propagateExpansionsInPlace(); ProverException exitInformation = null; ActionCanceller c = new ActionCanceller(); if (!myInstanceEnvironment.flags.isFlagSet(FLAG_NOGUI)) { myProgressWindow.setTitle("VC " + vC.getName()); myProgressWindow.setActionCanceller(c); } if (p == null) { if (myInstanceEnvironment.flags.isFlagSet(FLAG_DEBUG)) { p = setUpOldProverDebug(vC); } else { p = setUpOldProver(vC); } } if (myInstanceEnvironment.flags.isFlagSet(ResolveCompiler.FLAG_WEB)) { output.append("<vcProve id=\"" + vC.getName() + "\">"); } else { output.append(vC.getName() + " "); } // System.out.print(vC.getName() + " "); try { p.prove(vC.copy(), myProgressWindow, c, System.currentTimeMillis() + TIMEOUT); } catch (UnableToProveException e) { exitInformation = e; output.append("Skipped after "); // System.out.print("Skipped after "); allProved = false; if (proofFile != null) { try { proofFile.append(vC.getName() + " failed.\n\n"); } catch (IOException ex) { } } } catch (VCProvedException e) { exitInformation = e; output.append("Proved in "); // System.out.print("Proved in "); if (proofFile != null) { try { proofFile.append(vC.getName() + " succeeded.\n\n"); proofFile.append(e.toString()); } catch (IOException ex) { } } } printExitReport(startTime, exitInformation); if (myInstanceEnvironment.flags.isFlagSet(ResolveCompiler.FLAG_WEB)) { output.append("</vcProve>"); myInstanceEnvironment.getCompileReport().setProveVCs(output.toString()); } }