mirror of
https://github.com/AdaCore/cvc5.git
synced 2026-02-12 12:32:16 -08:00
This PR enables CI for java tests by adding --java-bindings to ci.yml. It also replaces the unreliable finalize method and instead uses AutoCloseable and explicit close method to clean up dynamic memory allocated by java native interface. The PR fixes compile errors for SolverTest.java and runtime errors for Solver.defineFun.
55 lines
1.7 KiB
Java
55 lines
1.7 KiB
Java
/******************************************************************************
|
|
* Top contributors (to current version):
|
|
* Aina Niemetz, Makai Mann, Clark Barrett
|
|
*
|
|
* This file is part of the cvc5 project.
|
|
*
|
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
|
|
* in the top-level source directory and their institutional affiliations.
|
|
* All rights reserved. See the file COPYING in the top-level source
|
|
* directory for licensing information.
|
|
* ****************************************************************************
|
|
*
|
|
* A simple demonstration of the solving capabilities of the cvc5
|
|
* bit-vector solver.
|
|
*
|
|
*/
|
|
|
|
import io.github.cvc5.api.*;
|
|
|
|
public class Extract
|
|
{
|
|
public static void main(String args[]) throws CVC5ApiException
|
|
{
|
|
try (Solver slv = new Solver())
|
|
{
|
|
slv.setLogic("QF_BV"); // Set the logic
|
|
|
|
Sort bitvector32 = slv.mkBitVectorSort(32);
|
|
|
|
Term x = slv.mkConst(bitvector32, "a");
|
|
|
|
Op ext_31_1 = slv.mkOp(Kind.BITVECTOR_EXTRACT, 31, 1);
|
|
Term x_31_1 = slv.mkTerm(ext_31_1, x);
|
|
|
|
Op ext_30_0 = slv.mkOp(Kind.BITVECTOR_EXTRACT, 30, 0);
|
|
Term x_30_0 = slv.mkTerm(ext_30_0, x);
|
|
|
|
Op ext_31_31 = slv.mkOp(Kind.BITVECTOR_EXTRACT, 31, 31);
|
|
Term x_31_31 = slv.mkTerm(ext_31_31, x);
|
|
|
|
Op ext_0_0 = slv.mkOp(Kind.BITVECTOR_EXTRACT, 0, 0);
|
|
Term x_0_0 = slv.mkTerm(ext_0_0, x);
|
|
|
|
Term eq = slv.mkTerm(Kind.EQUAL, x_31_1, x_30_0);
|
|
System.out.println(" Asserting: " + eq);
|
|
slv.assertFormula(eq);
|
|
|
|
Term eq2 = slv.mkTerm(Kind.EQUAL, x_31_31, x_0_0);
|
|
System.out.println(" Check entailment assuming: " + eq2);
|
|
System.out.println(" Expect ENTAILED. ");
|
|
System.out.println(" cvc5: " + slv.checkEntailed(eq2));
|
|
}
|
|
}
|
|
}
|