2021-09-28 19:30:24 -05:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Top contributors (to current version):
|
2023-05-09 11:06:18 -07:00
|
|
|
* Mudathir Mohamed, Aina Niemetz, Andrew Reynolds
|
2021-09-28 19:30:24 -05:00
|
|
|
*
|
|
|
|
|
* This file is part of the cvc5 project.
|
|
|
|
|
*
|
2025-01-23 09:54:20 -08:00
|
|
|
* Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
|
2021-09-28 19:30:24 -05:00
|
|
|
* 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.
|
|
|
|
|
* ****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Black box testing of the guards of the Java API functions.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-10-22 18:00:06 -05:00
|
|
|
package tests;
|
2022-03-30 21:09:03 -07:00
|
|
|
import static io.github.cvc5.Kind.*;
|
2023-01-17 13:37:10 -06:00
|
|
|
import static io.github.cvc5.SortKind.*;
|
2021-09-28 19:30:24 -05:00
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
|
2022-03-30 21:09:03 -07:00
|
|
|
import io.github.cvc5.*;
|
2021-09-28 19:30:24 -05:00
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
class SortTest
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
private TermManager d_tm;
|
2021-09-28 19:30:24 -05:00
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@BeforeEach
|
|
|
|
|
void setUp()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
d_tm = new TermManager();
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@AfterEach
|
|
|
|
|
void tearDown()
|
2021-11-03 16:32:10 -05:00
|
|
|
{
|
2022-10-04 12:06:02 -05:00
|
|
|
Context.deletePointers();
|
2021-11-03 16:32:10 -05:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 19:30:24 -05:00
|
|
|
Sort create_datatype_sort() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeDecl dtypeSpec = d_tm.mkDatatypeDecl("list");
|
|
|
|
|
DatatypeConstructorDecl cons = d_tm.mkDatatypeConstructorDecl("cons");
|
|
|
|
|
cons.addSelector("head", d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
cons.addSelectorSelf("tail");
|
|
|
|
|
dtypeSpec.addConstructor(cons);
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeConstructorDecl nil = d_tm.mkDatatypeConstructorDecl("nil");
|
2021-09-28 19:30:24 -05:00
|
|
|
dtypeSpec.addConstructor(nil);
|
2024-04-02 09:42:06 -07:00
|
|
|
return d_tm.mkDatatypeSort(dtypeSpec);
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Sort create_param_datatype_sort() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sort = d_tm.mkParamSort("T");
|
|
|
|
|
DatatypeDecl paramDtypeSpec = d_tm.mkDatatypeDecl("paramlist", new Sort[] {sort});
|
|
|
|
|
DatatypeConstructorDecl paramCons = d_tm.mkDatatypeConstructorDecl("cons");
|
|
|
|
|
DatatypeConstructorDecl paramNil = d_tm.mkDatatypeConstructorDecl("nil");
|
2021-09-28 19:30:24 -05:00
|
|
|
paramCons.addSelector("head", sort);
|
|
|
|
|
paramDtypeSpec.addConstructor(paramCons);
|
|
|
|
|
paramDtypeSpec.addConstructor(paramNil);
|
2024-04-02 09:42:06 -07:00
|
|
|
return d_tm.mkDatatypeSort(paramDtypeSpec);
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void operators_comparison()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertDoesNotThrow(() -> d_tm.getIntegerSort() == new Sort());
|
|
|
|
|
assertDoesNotThrow(() -> d_tm.getIntegerSort() != new Sort());
|
|
|
|
|
assertDoesNotThrow(() -> d_tm.getIntegerSort().compareTo(new Sort()));
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2024-07-10 12:54:21 -07:00
|
|
|
@Test
|
|
|
|
|
void hash()
|
|
|
|
|
{
|
|
|
|
|
assertEquals(d_tm.getIntegerSort().hashCode(), d_tm.getIntegerSort().hashCode());
|
|
|
|
|
assertNotEquals(d_tm.getIntegerSort().hashCode(), d_tm.getStringSort().hashCode());
|
|
|
|
|
assertNotEquals(d_tm.getIntegerSort().hashCode(), (new Sort()).hashCode());
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 13:37:10 -06:00
|
|
|
@Test
|
|
|
|
|
void getKind() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort b = d_tm.getBooleanSort();
|
2023-01-17 13:37:10 -06:00
|
|
|
Sort dt_sort = create_datatype_sort();
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort arr_sort = d_tm.mkArraySort(d_tm.getRealSort(), d_tm.getIntegerSort());
|
2023-01-17 13:37:10 -06:00
|
|
|
assertEquals(b.getKind(), BOOLEAN_SORT);
|
|
|
|
|
assertEquals(dt_sort.getKind(), DATATYPE_SORT);
|
|
|
|
|
assertEquals(arr_sort.getKind(), ARRAY_SORT);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void hasGetSymbol() throws CVC5ApiException
|
2021-12-16 10:50:01 -08:00
|
|
|
{
|
2022-10-04 12:06:02 -05:00
|
|
|
Sort n = new Sort();
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort b = d_tm.getBooleanSort();
|
|
|
|
|
Sort s0 = d_tm.mkParamSort("s0");
|
|
|
|
|
Sort s1 = d_tm.mkParamSort("|s1\\|");
|
2021-12-16 10:50:01 -08:00
|
|
|
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> n.hasSymbol());
|
|
|
|
|
assertFalse(b.hasSymbol());
|
|
|
|
|
assertTrue(s0.hasSymbol());
|
|
|
|
|
assertTrue(s1.hasSymbol());
|
|
|
|
|
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> n.getSymbol());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> b.getSymbol());
|
|
|
|
|
assertEquals(s0.getSymbol(), "s0");
|
|
|
|
|
assertEquals(s1.getSymbol(), "|s1\\|");
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isBoolean()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getBooleanSort().isBoolean());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isBoolean());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isInteger()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getIntegerSort().isInteger());
|
|
|
|
|
assertTrue(!d_tm.getRealSort().isInteger());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isInteger());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isReal()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getRealSort().isReal());
|
|
|
|
|
assertTrue(!d_tm.getIntegerSort().isReal());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isReal());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isString()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getStringSort().isString());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isString());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isRegExp()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getRegExpSort().isRegExp());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isRegExp());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isRoundingMode() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.getRoundingModeSort().isRoundingMode());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isRoundingMode());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isBitVector() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.mkBitVectorSort(8).isBitVector());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isBitVector());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isFloatingPoint() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.mkFloatingPointSort(8, 24).isFloatingPoint());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isFloatingPoint());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isDatatype() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort dt_sort = create_datatype_sort();
|
|
|
|
|
assertTrue(dt_sort.isDatatype());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isDatatype());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
2022-03-31 13:50:45 -07:00
|
|
|
void isDatatypeConstructor() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort dt_sort = create_datatype_sort();
|
|
|
|
|
Datatype dt = dt_sort.getDatatype();
|
2022-04-02 11:57:50 -07:00
|
|
|
Sort cons_sort = dt.getConstructor(0).getTerm().getSort();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(cons_sort.isDatatypeConstructor());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isDatatypeConstructor());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
2022-03-31 13:50:45 -07:00
|
|
|
void isDatatypeSelector() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort dt_sort = create_datatype_sort();
|
|
|
|
|
Datatype dt = dt_sort.getDatatype();
|
2022-04-02 11:57:50 -07:00
|
|
|
Sort cons_sort = dt.getConstructor(0).getSelector(1).getTerm().getSort();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(cons_sort.isDatatypeSelector());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isDatatypeSelector());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
2022-03-31 13:50:45 -07:00
|
|
|
void isDatatypeTester() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort dt_sort = create_datatype_sort();
|
|
|
|
|
Datatype dt = dt_sort.getDatatype();
|
|
|
|
|
Sort cons_sort = dt.getConstructor(0).getTesterTerm().getSort();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(cons_sort.isDatatypeTester());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isDatatypeTester());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-05-10 07:55:44 -07:00
|
|
|
@Test
|
|
|
|
|
void isDatatypeUpdater() throws CVC5ApiException
|
|
|
|
|
{
|
|
|
|
|
Sort dt_sort = create_datatype_sort();
|
|
|
|
|
Datatype dt = dt_sort.getDatatype();
|
|
|
|
|
Sort updater_sort = dt.getConstructor(0).getSelector(0).getUpdaterTerm().getSort();
|
|
|
|
|
assertTrue(updater_sort.isDatatypeUpdater());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isDatatypeUpdater());
|
2022-05-10 07:55:44 -07:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isFunction()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort fun_sort = d_tm.mkFunctionSort(d_tm.getRealSort(), d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(fun_sort.isFunction());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isFunction());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isPredicate()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort pred_sort = d_tm.mkPredicateSort(new Sort[] {d_tm.getRealSort()});
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(pred_sort.isPredicate());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isPredicate());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isTuple()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort tup_sort = d_tm.mkTupleSort(new Sort[] {d_tm.getRealSort()});
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(tup_sort.isTuple());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isTuple());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 15:29:14 -06:00
|
|
|
@Test
|
|
|
|
|
void isNullable()
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sort = d_tm.mkNullableSort(d_tm.getRealSort());
|
2024-01-31 15:29:14 -06:00
|
|
|
assertTrue(sort.isNullable());
|
|
|
|
|
assertDoesNotThrow(() -> new Sort().isNullable());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isRecord()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort rec_sort =
|
2024-04-02 09:42:06 -07:00
|
|
|
d_tm.mkRecordSort(new Pair[] {new Pair<String, Sort>("asdf", d_tm.getRealSort())});
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(rec_sort.isRecord());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isRecord());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isArray()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort arr_sort = d_tm.mkArraySort(d_tm.getRealSort(), d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(arr_sort.isArray());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isArray());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isSet()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort set_sort = d_tm.mkSetSort(d_tm.getRealSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(set_sort.isSet());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isSet());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isBag()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bag_sort = d_tm.mkBagSort(d_tm.getRealSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(bag_sort.isBag());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isBag());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isSequence()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort seq_sort = d_tm.mkSequenceSort(d_tm.getRealSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(seq_sort.isSequence());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isSequence());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 13:17:50 -06:00
|
|
|
@Test
|
|
|
|
|
void isAbstract()
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertTrue(d_tm.mkAbstractSort(SortKind.BITVECTOR_SORT).isAbstract());
|
2023-01-20 13:17:50 -06:00
|
|
|
// ?Array is syntax sugar for (Array ? ?), thus the constructed sort
|
|
|
|
|
// is an Array sort, not an abstract sort.
|
2024-04-02 09:42:06 -07:00
|
|
|
assertFalse(d_tm.mkAbstractSort(SortKind.ARRAY_SORT).isAbstract());
|
|
|
|
|
assertTrue(d_tm.mkAbstractSort(SortKind.ABSTRACT_SORT).isAbstract());
|
2023-01-20 13:17:50 -06:00
|
|
|
assertDoesNotThrow(() -> new Sort().isAbstract());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isUninterpreted()
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort un_sort = d_tm.mkUninterpretedSort("asdf");
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(un_sort.isUninterpretedSort());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isUninterpretedSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isUninterpretedSortSortConstructor() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sc_sort = d_tm.mkUninterpretedSortConstructorSort(1, "asdf");
|
2022-03-25 22:40:42 -07:00
|
|
|
assertTrue(sc_sort.isUninterpretedSortConstructor());
|
2022-10-04 12:06:02 -05:00
|
|
|
assertDoesNotThrow(() -> new Sort().isUninterpretedSortConstructor());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getDatatype() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
Sort dtypeSort = create_datatype_sort();
|
|
|
|
|
assertDoesNotThrow(() -> dtypeSort.getDatatype());
|
|
|
|
|
// create bv sort, check should fail
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getDatatype());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void datatypeSorts() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort intSort = d_tm.getIntegerSort();
|
2021-09-28 19:30:24 -05:00
|
|
|
Sort dtypeSort = create_datatype_sort();
|
|
|
|
|
Datatype dt = dtypeSort.getDatatype();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertFalse(dtypeSort.isDatatypeConstructor());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> dtypeSort.getDatatypeConstructorCodomainSort());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> dtypeSort.getDatatypeConstructorDomainSorts());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> dtypeSort.getDatatypeConstructorArity());
|
2021-09-28 19:30:24 -05:00
|
|
|
|
|
|
|
|
// get constructor
|
|
|
|
|
DatatypeConstructor dcons = dt.getConstructor(0);
|
2022-04-02 11:57:50 -07:00
|
|
|
Term consTerm = dcons.getTerm();
|
2021-09-28 19:30:24 -05:00
|
|
|
Sort consSort = consTerm.getSort();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(consSort.isDatatypeConstructor());
|
|
|
|
|
assertFalse(consSort.isDatatypeTester());
|
|
|
|
|
assertFalse(consSort.isDatatypeSelector());
|
|
|
|
|
assertEquals(consSort.getDatatypeConstructorArity(), 2);
|
|
|
|
|
Sort[] consDomSorts = consSort.getDatatypeConstructorDomainSorts();
|
2021-09-28 19:30:24 -05:00
|
|
|
assertEquals(consDomSorts[0], intSort);
|
|
|
|
|
assertEquals(consDomSorts[1], dtypeSort);
|
2022-03-31 13:50:45 -07:00
|
|
|
assertEquals(consSort.getDatatypeConstructorCodomainSort(), dtypeSort);
|
2021-09-28 19:30:24 -05:00
|
|
|
|
|
|
|
|
// get tester
|
|
|
|
|
Term isConsTerm = dcons.getTesterTerm();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(isConsTerm.getSort().isDatatypeTester());
|
|
|
|
|
assertEquals(isConsTerm.getSort().getDatatypeTesterDomainSort(), dtypeSort);
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort booleanSort = d_tm.getBooleanSort();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertEquals(isConsTerm.getSort().getDatatypeTesterCodomainSort(), booleanSort);
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> booleanSort.getDatatypeTesterDomainSort());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> booleanSort.getDatatypeTesterCodomainSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
|
|
|
|
|
// get selector
|
|
|
|
|
DatatypeSelector dselTail = dcons.getSelector(1);
|
2022-04-02 11:57:50 -07:00
|
|
|
Term tailTerm = dselTail.getTerm();
|
2022-03-31 13:50:45 -07:00
|
|
|
assertTrue(tailTerm.getSort().isDatatypeSelector());
|
|
|
|
|
assertEquals(tailTerm.getSort().getDatatypeSelectorDomainSort(), dtypeSort);
|
|
|
|
|
assertEquals(tailTerm.getSort().getDatatypeSelectorCodomainSort(), dtypeSort);
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> booleanSort.getDatatypeSelectorDomainSort());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> booleanSort.getDatatypeSelectorCodomainSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void instantiate() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
// instantiate parametric datatype, check should not fail
|
|
|
|
|
Sort paramDtypeSort = create_param_datatype_sort();
|
2024-04-02 09:42:06 -07:00
|
|
|
assertDoesNotThrow(() -> paramDtypeSort.instantiate(new Sort[] {d_tm.getIntegerSort()}));
|
2021-09-28 19:30:24 -05:00
|
|
|
// instantiate non-parametric datatype sort, check should fail
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeDecl dtypeSpec = d_tm.mkDatatypeDecl("list");
|
|
|
|
|
DatatypeConstructorDecl cons = d_tm.mkDatatypeConstructorDecl("cons");
|
|
|
|
|
cons.addSelector("head", d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
dtypeSpec.addConstructor(cons);
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeConstructorDecl nil = d_tm.mkDatatypeConstructorDecl("nil");
|
2021-09-28 19:30:24 -05:00
|
|
|
dtypeSpec.addConstructor(nil);
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort dtypeSort = d_tm.mkDatatypeSort(dtypeSpec);
|
|
|
|
|
assertThrows(
|
|
|
|
|
CVC5ApiException.class, () -> dtypeSort.instantiate(new Sort[] {d_tm.getIntegerSort()}));
|
2022-03-28 18:37:13 -07:00
|
|
|
// instantiate uninterpreted sort constructor
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sortConsSort = d_tm.mkUninterpretedSortConstructorSort(1, "s");
|
|
|
|
|
assertDoesNotThrow(() -> sortConsSort.instantiate(new Sort[] {d_tm.getIntegerSort()}));
|
2022-03-28 18:37:13 -07:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void isInstantiated() throws CVC5ApiException
|
2022-03-28 18:37:13 -07:00
|
|
|
{
|
|
|
|
|
Sort paramDtypeSort = create_param_datatype_sort();
|
|
|
|
|
assertFalse(paramDtypeSort.isInstantiated());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort instParamDtypeSort = paramDtypeSort.instantiate(new Sort[] {d_tm.getIntegerSort()});
|
2022-03-28 18:37:13 -07:00
|
|
|
assertTrue(instParamDtypeSort.isInstantiated());
|
|
|
|
|
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sortConsSort = d_tm.mkUninterpretedSortConstructorSort(1, "s");
|
2022-03-28 18:37:13 -07:00
|
|
|
assertFalse(sortConsSort.isInstantiated());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort instSortConsSort = sortConsSort.instantiate(new Sort[] {d_tm.getIntegerSort()});
|
2022-03-28 18:37:13 -07:00
|
|
|
assertTrue(instSortConsSort.isInstantiated());
|
|
|
|
|
|
2024-04-02 09:42:06 -07:00
|
|
|
assertFalse(d_tm.getIntegerSort().isInstantiated());
|
|
|
|
|
assertFalse(d_tm.mkBitVectorSort(32).isInstantiated());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getInstantiatedParameters() throws CVC5ApiException
|
2022-03-29 14:36:12 -07:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort intSort = d_tm.getIntegerSort();
|
|
|
|
|
Sort realSort = d_tm.getRealSort();
|
|
|
|
|
Sort boolSort = d_tm.getBooleanSort();
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(8);
|
2022-03-29 14:36:12 -07:00
|
|
|
Sort[] instSorts;
|
|
|
|
|
|
|
|
|
|
// parametric datatype instantiation
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort p1 = d_tm.mkParamSort("p1");
|
|
|
|
|
Sort p2 = d_tm.mkParamSort("p2");
|
|
|
|
|
DatatypeDecl pspec = d_tm.mkDatatypeDecl("pdtype", new Sort[] {p1, p2});
|
|
|
|
|
DatatypeConstructorDecl pcons1 = d_tm.mkDatatypeConstructorDecl("cons1");
|
|
|
|
|
DatatypeConstructorDecl pcons2 = d_tm.mkDatatypeConstructorDecl("cons2");
|
|
|
|
|
DatatypeConstructorDecl pnil = d_tm.mkDatatypeConstructorDecl("nil");
|
2022-03-29 14:36:12 -07:00
|
|
|
pcons1.addSelector("sel", p1);
|
|
|
|
|
pcons2.addSelector("sel", p2);
|
|
|
|
|
pspec.addConstructor(pcons1);
|
|
|
|
|
pspec.addConstructor(pcons2);
|
|
|
|
|
pspec.addConstructor(pnil);
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort paramDtypeSort = d_tm.mkDatatypeSort(pspec);
|
2022-03-29 14:36:12 -07:00
|
|
|
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> paramDtypeSort.getInstantiatedParameters());
|
|
|
|
|
|
|
|
|
|
Sort instParamDtypeSort = paramDtypeSort.instantiate(new Sort[] {realSort, boolSort});
|
|
|
|
|
|
|
|
|
|
instSorts = instParamDtypeSort.getInstantiatedParameters();
|
|
|
|
|
assertEquals(instSorts[0], realSort);
|
|
|
|
|
assertEquals(instSorts[1], boolSort);
|
|
|
|
|
|
|
|
|
|
// uninterpreted sort constructor sort instantiation
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sortConsSort = d_tm.mkUninterpretedSortConstructorSort(4, "s");
|
2022-03-29 14:36:12 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> sortConsSort.getInstantiatedParameters());
|
|
|
|
|
|
|
|
|
|
Sort instSortConsSort =
|
|
|
|
|
sortConsSort.instantiate(new Sort[] {boolSort, intSort, bvSort, realSort});
|
|
|
|
|
|
|
|
|
|
instSorts = instSortConsSort.getInstantiatedParameters();
|
|
|
|
|
assertEquals(instSorts[0], boolSort);
|
|
|
|
|
assertEquals(instSorts[1], intSort);
|
|
|
|
|
assertEquals(instSorts[2], bvSort);
|
|
|
|
|
assertEquals(instSorts[3], realSort);
|
|
|
|
|
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> intSort.getInstantiatedParameters());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getInstantiatedParameters());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getUninterpretedSortConstructor() throws CVC5ApiException
|
2022-03-30 12:39:52 -07:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort intSort = d_tm.getIntegerSort();
|
|
|
|
|
Sort realSort = d_tm.getRealSort();
|
|
|
|
|
Sort boolSort = d_tm.getBooleanSort();
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(8);
|
|
|
|
|
Sort sortConsSort = d_tm.mkUninterpretedSortConstructorSort(4);
|
2022-03-30 12:39:52 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> sortConsSort.getUninterpretedSortConstructor());
|
|
|
|
|
Sort instSortConsSort =
|
|
|
|
|
sortConsSort.instantiate(new Sort[] {boolSort, intSort, bvSort, realSort});
|
|
|
|
|
assertEquals(sortConsSort, instSortConsSort.getUninterpretedSortConstructor());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getFunctionArity() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort funSort = d_tm.mkFunctionSort(d_tm.mkUninterpretedSort("u"), d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> funSort.getFunctionArity());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getFunctionArity());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getFunctionDomainSorts() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort funSort = d_tm.mkFunctionSort(d_tm.mkUninterpretedSort("u"), d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> funSort.getFunctionDomainSorts());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getFunctionDomainSorts());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getFunctionCodomainSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort funSort = d_tm.mkFunctionSort(d_tm.mkUninterpretedSort("u"), d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> funSort.getFunctionCodomainSort());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getFunctionCodomainSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getArrayIndexSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort elementSort = d_tm.mkBitVectorSort(32);
|
|
|
|
|
Sort indexSort = d_tm.mkBitVectorSort(32);
|
|
|
|
|
Sort arraySort = d_tm.mkArraySort(indexSort, elementSort);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> arraySort.getArrayIndexSort());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> indexSort.getArrayIndexSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getArrayElementSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort elementSort = d_tm.mkBitVectorSort(32);
|
|
|
|
|
Sort indexSort = d_tm.mkBitVectorSort(32);
|
|
|
|
|
Sort arraySort = d_tm.mkArraySort(indexSort, elementSort);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> arraySort.getArrayElementSort());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> indexSort.getArrayElementSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getSetElementSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort setSort = d_tm.mkSetSort(d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> setSort.getSetElementSort());
|
|
|
|
|
Sort elementSort = setSort.getSetElementSort();
|
2024-04-02 09:42:06 -07:00
|
|
|
assertEquals(elementSort, d_tm.getIntegerSort());
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getSetElementSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getBagElementSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bagSort = d_tm.mkBagSort(d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> bagSort.getBagElementSort());
|
|
|
|
|
Sort elementSort = bagSort.getBagElementSort();
|
2024-04-02 09:42:06 -07:00
|
|
|
assertEquals(elementSort, d_tm.getIntegerSort());
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getBagElementSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getSequenceElementSort() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort seqSort = d_tm.mkSequenceSort(d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(seqSort.isSequence());
|
|
|
|
|
assertDoesNotThrow(() -> seqSort.getSequenceElementSort());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertFalse(bvSort.isSequence());
|
|
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getSequenceElementSort());
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 13:17:50 -06:00
|
|
|
@Test
|
|
|
|
|
void getAbstractedKind() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
assertEquals(
|
|
|
|
|
d_tm.mkAbstractSort(SortKind.BITVECTOR_SORT).getAbstractedKind(), SortKind.BITVECTOR_SORT);
|
2023-01-20 13:17:50 -06:00
|
|
|
// ?Array is syntax sugar for (Array ? ?), thus the constructed sort
|
|
|
|
|
// is an Array sort, not an abstract sort and its abstract kind cannot be
|
|
|
|
|
// extracted.
|
2024-04-02 09:42:06 -07:00
|
|
|
assertThrows(
|
|
|
|
|
CVC5ApiException.class, () -> d_tm.mkAbstractSort(SortKind.ARRAY_SORT).getAbstractedKind());
|
|
|
|
|
assertEquals(
|
|
|
|
|
d_tm.mkAbstractSort(SortKind.ABSTRACT_SORT).getAbstractedKind(), SortKind.ABSTRACT_SORT);
|
2023-01-20 13:17:50 -06:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getSymbol() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort uSort = d_tm.mkUninterpretedSort("u");
|
2022-03-14 13:29:30 -05:00
|
|
|
assertDoesNotThrow(() -> uSort.getSymbol());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2022-03-14 13:29:30 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getSymbol());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getUninterpretedSortConstructorName() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sSort = d_tm.mkUninterpretedSortConstructorSort(2);
|
2022-03-14 13:29:30 -05:00
|
|
|
assertDoesNotThrow(() -> sSort.getSymbol());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2022-03-14 13:29:30 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getSymbol());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getUninterpretedSortConstructorArity() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sSort = d_tm.mkUninterpretedSortConstructorSort(2, "s");
|
2022-03-25 22:40:42 -07:00
|
|
|
assertDoesNotThrow(() -> sSort.getUninterpretedSortConstructorArity());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2022-03-25 22:40:42 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getUninterpretedSortConstructorArity());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getBitVectorSize() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-10-20 12:14:59 -07:00
|
|
|
assertDoesNotThrow(() -> bvSort.getBitVectorSize());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort setSort = d_tm.mkSetSort(d_tm.getIntegerSort());
|
2021-10-20 12:14:59 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> setSort.getBitVectorSize());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getFloatingPointExponentSize() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort fpSort = d_tm.mkFloatingPointSort(4, 8);
|
2021-10-20 12:14:59 -07:00
|
|
|
assertDoesNotThrow(() -> fpSort.getFloatingPointExponentSize());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort setSort = d_tm.mkSetSort(d_tm.getIntegerSort());
|
2021-10-20 12:14:59 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> setSort.getFloatingPointExponentSize());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getFloatingPointSignificandSize() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort fpSort = d_tm.mkFloatingPointSort(4, 8);
|
2021-10-20 12:14:59 -07:00
|
|
|
assertDoesNotThrow(() -> fpSort.getFloatingPointSignificandSize());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort setSort = d_tm.mkSetSort(d_tm.getIntegerSort());
|
2021-10-20 12:14:59 -07:00
|
|
|
assertThrows(CVC5ApiException.class, () -> setSort.getFloatingPointSignificandSize());
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getDatatypeArity() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
// create datatype sort, check should not fail
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeDecl dtypeSpec = d_tm.mkDatatypeDecl("list");
|
|
|
|
|
DatatypeConstructorDecl cons = d_tm.mkDatatypeConstructorDecl("cons");
|
|
|
|
|
cons.addSelector("head", d_tm.getIntegerSort());
|
2021-09-28 19:30:24 -05:00
|
|
|
dtypeSpec.addConstructor(cons);
|
2024-04-02 09:42:06 -07:00
|
|
|
DatatypeConstructorDecl nil = d_tm.mkDatatypeConstructorDecl("nil");
|
2021-09-28 19:30:24 -05:00
|
|
|
dtypeSpec.addConstructor(nil);
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort dtypeSort = d_tm.mkDatatypeSort(dtypeSpec);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> dtypeSort.getDatatypeArity());
|
|
|
|
|
// create bv sort, check should fail
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getDatatypeArity());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getTupleLength() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort tupleSort = d_tm.mkTupleSort(new Sort[] {d_tm.getIntegerSort(), d_tm.getIntegerSort()});
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> tupleSort.getTupleLength());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getTupleLength());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void getTupleSorts() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort tupleSort = d_tm.mkTupleSort(new Sort[] {d_tm.getIntegerSort(), d_tm.getIntegerSort()});
|
2021-09-28 19:30:24 -05:00
|
|
|
assertDoesNotThrow(() -> tupleSort.getTupleSorts());
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getTupleSorts());
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 15:29:14 -06:00
|
|
|
@Test
|
|
|
|
|
void getNullableElementSort() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort nullableSort = d_tm.mkNullableSort(d_tm.getIntegerSort());
|
2024-01-31 15:29:14 -06:00
|
|
|
assertDoesNotThrow(() -> nullableSort.getNullableElementSort());
|
|
|
|
|
Sort elementSort = nullableSort.getNullableElementSort();
|
2024-04-02 09:42:06 -07:00
|
|
|
assertEquals(elementSort, d_tm.getIntegerSort());
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
2024-01-31 15:29:14 -06:00
|
|
|
assertThrows(CVC5ApiException.class, () -> bvSort.getNullableElementSort());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void sortCompare() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort boolSort = d_tm.getBooleanSort();
|
|
|
|
|
Sort intSort = d_tm.getIntegerSort();
|
|
|
|
|
Sort bvSort = d_tm.mkBitVectorSort(32);
|
|
|
|
|
Sort bvSort2 = d_tm.mkBitVectorSort(32);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertTrue(bvSort.compareTo(bvSort2) >= 0);
|
|
|
|
|
assertTrue(bvSort.compareTo(bvSort2) <= 0);
|
|
|
|
|
assertTrue(intSort.compareTo(boolSort) > 0 != intSort.compareTo(boolSort) < 0);
|
|
|
|
|
assertTrue((intSort.compareTo(bvSort) > 0 || intSort.equals(bvSort))
|
|
|
|
|
== (intSort.compareTo(bvSort) >= 0));
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-30 16:58:08 -05:00
|
|
|
@Test
|
|
|
|
|
void sortScopedToString() throws CVC5ApiException
|
2021-09-28 19:30:24 -05:00
|
|
|
{
|
|
|
|
|
String name = "uninterp-sort";
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort bvsort8 = d_tm.mkBitVectorSort(8);
|
|
|
|
|
Sort uninterp_sort = d_tm.mkUninterpretedSort(name);
|
2021-09-28 19:30:24 -05:00
|
|
|
assertEquals(bvsort8.toString(), "(_ BitVec 8)");
|
|
|
|
|
assertEquals(uninterp_sort.toString(), name);
|
|
|
|
|
Solver solver2;
|
|
|
|
|
assertEquals(bvsort8.toString(), "(_ BitVec 8)");
|
|
|
|
|
assertEquals(uninterp_sort.toString(), name);
|
|
|
|
|
}
|
2024-03-12 12:37:45 -07:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void sortSubstitute() throws CVC5ApiException
|
|
|
|
|
{
|
2024-04-02 09:42:06 -07:00
|
|
|
Sort sortVar0 = d_tm.mkParamSort("T0");
|
|
|
|
|
Sort sortVar1 = d_tm.mkParamSort("T1");
|
|
|
|
|
Sort intSort = d_tm.getIntegerSort();
|
|
|
|
|
Sort realSort = d_tm.getRealSort();
|
|
|
|
|
Sort arraySort0 = d_tm.mkArraySort(sortVar0, sortVar0);
|
|
|
|
|
Sort arraySort1 = d_tm.mkArraySort(sortVar0, sortVar1);
|
2024-03-12 12:37:45 -07:00
|
|
|
// Now create instantiations of the defined sorts
|
|
|
|
|
assertDoesNotThrow(() -> arraySort0.substitute(sortVar0, intSort));
|
|
|
|
|
assertDoesNotThrow(()
|
|
|
|
|
-> arraySort1.substitute(
|
|
|
|
|
new Sort[] {sortVar0, sortVar1}, new Sort[] {intSort, realSort}));
|
|
|
|
|
}
|
2021-09-28 19:30:24 -05:00
|
|
|
}
|