Interface Model<Name>

interface Model<Name extends string = "main"> {
    ctx: Context<Name>;
    ptr: Z3_model;
    "[iterator]"(): Iterator<
        FuncDecl<Name, Sort<Name>[], Sort<Name>>,
        any,
        any,
    >;
    addFuncInterp<
        DomainSort extends Sort<Name>[] = Sort<Name>[],
        RangeSort extends Sort<Name> = Sort<Name>,
    >(
        decl: FuncDecl<Name, DomainSort, RangeSort>,
        defaultValue: CoercibleToMap<SortToExprMap<RangeSort, Name>, Name>,
    ): FuncInterp<Name>;
    decls(): FuncDecl<Name, Sort<Name>[], Sort<Name>>[];
    entries(): IterableIterator<
        [number, FuncDecl<Name, Sort<Name>[], Sort<Name>>],
        any,
        any,
    >;
    eval(expr: Bool<Name>, modelCompletion?: boolean): Bool<Name>;
    eval(expr: Arith<Name>, modelCompletion?: boolean): Arith<Name>;
    eval<Bits extends number = number>(
        expr: BitVec<Bits, Name>,
        modelCompletion?: boolean,
    ): BitVecNum<Bits, Name>;
    eval(
        expr: Expr<Name, AnySort<Name>, unknown>,
        modelCompletion?: boolean,
    ): Expr<Name, AnySort<Name>, unknown>;
    get(i: number): FuncDecl<Name, Sort<Name>[], Sort<Name>>;
    get(from: number, to: number): FuncDecl<Name, Sort<Name>[], Sort<Name>>[];
    get(
        declaration: FuncDecl<Name, Sort<Name>[], Sort<Name>>,
    ): Expr<Name, AnySort<Name>, unknown> | FuncInterp<Name>;
    get(
        constant: Expr<Name, AnySort<Name>, unknown>,
    ): Expr<Name, AnySort<Name>, unknown>;
    get(sort: Sort<Name>): AstVector<Name, AnyExpr<Name>>;
    getSort(i: number): Sort<Name>;
    getSorts(): Sort<Name>[];
    keys(): IterableIterator<number, any, any>;
    length(): number;
    numSorts(): number;
    release(): void;
    sexpr(): string;
    sortUniverse(sort: Sort<Name>): AstVector<Name, AnyExpr<Name>>;
    updateValue(
        decl:
            | FuncDecl<Name, Sort<Name>[], Sort<Name>>
            | Expr<Name, AnySort<Name>, unknown>,
        a: FuncInterp<Name> | Ast<Name, unknown>,
    ): void;
    values(): IterableIterator<
        FuncDecl<Name, Sort<Name>[], Sort<Name>>,
        any,
        any,
    >;
}

Type Parameters

  • Name extends string = "main"

Hierarchy

Properties

ptr: Z3_model

Methods

  • Return the uninterpreted sort at the given index.

    Parameters

    • i: number

      Index of the sort (must be less than numSorts())

    Returns Sort<Name>

    The sort at the given index

    const model = solver.model();
    for (let i = 0; i < model.numSorts(); i++) {
    const sort = model.getSort(i);
    console.log('Sort:', sort.toString());
    }
  • Return all uninterpreted sorts that have an interpretation in the model.

    Returns Sort<Name>[]

    An array of all uninterpreted sorts

    const model = solver.model();
    const sorts = model.getSorts();
    for (const sort of sorts) {
    console.log('Sort:', sort.toString());
    const universe = model.sortUniverse(sort);
    console.log('Universe size:', universe.length());
    }
  • Return the number of uninterpreted sorts that have an interpretation in the model.

    Returns number

    The number of uninterpreted sorts

    const { Solver, Sort } = await init();
    const solver = new Solver();
    const A = Sort.declare('A');
    const x = Const('x', A);
    solver.add(x.eq(x));
    await solver.check();
    const model = solver.model();
    console.log('Number of sorts:', model.numSorts());
  • Manually decrease the reference count of the model This is automatically done when the model is garbage collected, but calling this eagerly can help release memory sooner.

    Returns void

  • Return the finite set of elements that represent the interpretation for the given sort. This is only applicable to uninterpreted sorts with finite interpretations.

    Parameters

    • sort: Sort<Name>

      The sort to get the universe for

    Returns AstVector<Name, AnyExpr<Name>>

    An AstVector containing all elements in the sort's universe

    const { Solver, Sort, Const } = await init();
    const solver = new Solver();
    const A = Sort.declare('A');
    const x = Const('x', A);
    const y = Const('y', A);
    solver.add(x.neq(y));
    await solver.check();
    const model = solver.model();
    const universe = model.sortUniverse(A);
    console.log('Universe has', universe.length(), 'elements');
    for (let i = 0; i < universe.length(); i++) {
    console.log('Element:', universe.get(i).toString());
    }