import { Z3_ast, Z3_ast_map, Z3_ast_print_mode, Z3_ast_vector, Z3_context, Z3_decl_kind, Z3_fixedpoint, Z3_func_decl, Z3_func_entry, Z3_func_interp, Z3_model, Z3_probe, Z3_solver, Z3_optimize, Z3_sort, Z3_sort_kind, Z3_stats, Z3_tactic, Z3_goal, Z3_apply_result, Z3_goal_prec, Z3_param_descrs, Z3_params, Z3_simplifier } from '../low-level'; /** @hidden */ export type AnySort = Sort | BoolSort | ArithSort | BitVecSort | SMTArraySort | FPSort | FPRMSort | SeqSort | ReSort; /** @hidden */ export type AnyExpr = Expr | Bool | Arith | IntNum | RatNum | BitVec | BitVecNum | SMTArray | FP | FPNum | FPRM | Seq | Re; /** @hidden */ export type AnyAst = AnyExpr | AnySort | FuncDecl; /** @hidden */ export type SortToExprMap, Name extends string = 'main'> = S extends BoolSort ? Bool : S extends ArithSort ? Arith : S extends BitVecSort ? BitVec : S extends SMTArraySort ? SMTArray : S extends FPSort ? FP : S extends FPRMSort ? FPRM : S extends SeqSort ? Seq : S extends ReSort ? Re : S extends Sort ? Expr : never; /** @hidden */ export type CoercibleFromMap, Name extends string = 'main'> = S extends bigint ? Arith : S extends number | CoercibleRational ? RatNum : S extends boolean ? Bool : S extends Expr ? S : never; /** @hidden */ export type CoercibleToBitVec = bigint | number | BitVec; /** @hidden */ export type CoercibleToFP = number | FP; export type CoercibleRational = { numerator: bigint | number; denominator: bigint | number; }; /** @hidden */ export type CoercibleToExpr = number | string | bigint | boolean | CoercibleRational | Expr; /** @hidden */ export type CoercibleToArith = number | string | bigint | CoercibleRational | Arith; /** @hidden */ export type CoercibleToMap, Name extends string = 'main'> = T extends Bool ? boolean | Bool : T extends IntNum ? bigint | number | IntNum : T extends RatNum ? bigint | number | CoercibleRational | RatNum : T extends Arith ? CoercibleToArith : T extends BitVec ? CoercibleToBitVec : T extends FP ? CoercibleToFP : T extends SMTArray ? SMTArray : T extends Expr ? Expr : never; /** * Used to create a Real constant * * ```typescript * const x = from({ numerator: 1, denominator: 3 }) * * x * // 1/3 * isReal(x) * // true * isRealVal(x) * // true * x.asNumber() * // 0.3333333333333333 * ``` * @see {@link Context.from} * @category Global */ export declare class Z3Error extends Error { } export declare class Z3AssertionError extends Z3Error { } /** @category Global */ export type CheckSatResult = 'sat' | 'unsat' | 'unknown'; /** @hidden */ export interface ContextCtor { (name: Name, options?: Record): Context; new (name: Name, options?: Record): Context; } export interface Context { /** @hidden */ readonly ptr: Z3_context; /** * Name of the current Context * * ```typescript * const c = new Context('main') * * c.name * // 'main' * ``` */ readonly name: Name; /** @category Functions */ interrupt(): void; /** * Set the pretty printing mode for ASTs. * * @param mode - The print mode to use: * - Z3_PRINT_SMTLIB_FULL (0): Print AST nodes in SMTLIB verbose format. * - Z3_PRINT_LOW_LEVEL (1): Print AST nodes using a low-level format. * - Z3_PRINT_SMTLIB2_COMPLIANT (2): Print AST nodes in SMTLIB 2.x compliant format. * * @category Functions */ setPrintMode(mode: Z3_ast_print_mode): void; /** @category Functions */ isModel(obj: unknown): obj is Model; /** @category Functions */ isAst(obj: unknown): obj is Ast; /** @category Functions */ isSort(obj: unknown): obj is Sort; /** @category Functions */ isFuncDecl(obj: unknown): obj is FuncDecl; /** @category Functions */ isFuncInterp(obj: unknown): obj is FuncInterp; /** @category Functions */ isApp(obj: unknown): boolean; /** @category Functions */ isConst(obj: unknown): boolean; /** @category Functions */ isExpr(obj: unknown): obj is Expr; /** @category Functions */ isVar(obj: unknown): boolean; /** @category Functions */ isAppOf(obj: unknown, kind: Z3_decl_kind): boolean; /** @category Functions */ isBool(obj: unknown): obj is Bool; /** @category Functions */ isTrue(obj: unknown): boolean; /** @category Functions */ isFalse(obj: unknown): boolean; /** @category Functions */ isAnd(obj: unknown): boolean; /** @category Functions */ isOr(obj: unknown): boolean; /** @category Functions */ isImplies(obj: unknown): boolean; /** @category Functions */ isNot(obj: unknown): boolean; /** @category Functions */ isEq(obj: unknown): boolean; /** @category Functions */ isDistinct(obj: unknown): boolean; /** @category Functions */ isQuantifier(obj: unknown): obj is Quantifier; /** @category Functions */ isArith(obj: unknown): obj is Arith; /** @category Functions */ isArithSort(obj: unknown): obj is ArithSort; /** @category Functions */ isInt(obj: unknown): boolean; /** @category Functions */ isIntVal(obj: unknown): obj is IntNum; /** @category Functions */ isIntSort(obj: unknown): boolean; /** @category Functions */ isReal(obj: unknown): boolean; /** @category Functions */ isRealVal(obj: unknown): obj is RatNum; /** @category Functions */ isRealSort(obj: unknown): boolean; /** @category Functions */ isRCFNum(obj: unknown): obj is RCFNum; /** @category Functions */ isBitVecSort(obj: unknown): obj is BitVecSort; /** @category Functions */ isBitVec(obj: unknown): obj is BitVec; /** @category Functions */ isBitVecVal(obj: unknown): obj is BitVecNum; /** @category Functions */ isArraySort(obj: unknown): obj is SMTArraySort; /** @category Functions */ isArray(obj: unknown): obj is SMTArray; /** @category Functions */ isConstArray(obj: unknown): boolean; /** @category Functions */ isFPSort(obj: unknown): obj is FPSort; /** @category Functions */ isFP(obj: unknown): obj is FP; /** @category Functions */ isFPVal(obj: unknown): obj is FPNum; /** @category Functions */ isFPRMSort(obj: unknown): obj is FPRMSort; /** @category Functions */ isFPRM(obj: unknown): obj is FPRM; /** @category Functions */ isSeqSort(obj: unknown): obj is SeqSort; /** @category Functions */ isSeq(obj: unknown): obj is Seq; /** @category Functions */ isStringSort(obj: unknown): obj is SeqSort; /** @category Functions */ isString(obj: unknown): obj is Seq; /** @category Functions */ isProbe(obj: unknown): obj is Probe; /** @category Functions */ isTactic(obj: unknown): obj is Tactic; /** @category Functions */ isGoal(obj: unknown): obj is Goal; /** @category Functions */ isAstVector(obj: unknown): obj is AstVector>; /** * Returns whether two Asts are the same thing * @category Functions */ eqIdentity(a: Ast, b: Ast): boolean; /** @category Functions */ getVarIndex(obj: Expr): number; /** * Coerce a boolean into a Bool expression * @category Functions */ from(primitive: boolean): Bool; /** * Coerce a number to an Int or Real expression (integral numbers become Ints) * @category Functions */ from(primitive: number): IntNum | RatNum; /** * Coerce a rational into a Real expression * @category Functions */ from(primitive: CoercibleRational): RatNum; /** * Coerce a big number into a Integer expression * @category Functions */ from(primitive: bigint): IntNum; /** * Returns whatever expression was given * @category Functions */ from>(expr: E): E; /** @hidden */ from(value: CoercibleToExpr): AnyExpr; /** * Sugar function for getting a model for given assertions * * ```typescript * const x = Int.const('x'); * const y = Int.const('y'); * const result = await solve(x.le(y)); * if (isModel(result)) { * console.log('Z3 found a solution'); * console.log(`x=${result.get(x)}, y=${result.get(y)}`); * } else { * console.error('No solution found'); * } * ``` * * @see {@link Solver} * @category Functions */ solve(...assertions: Bool[]): Promise | 'unsat' | 'unknown'>; /** * Creates a Solver * @param logic - Optional logic which the solver will use. Creates a general Solver otherwise * @category Classes */ readonly Solver: new (logic?: string) => Solver; readonly Optimize: new () => Optimize; readonly Fixedpoint: new () => Fixedpoint; /** * Creates an empty Model * @see {@link Solver.model} for common usage of Model * @category Classes */ readonly Model: new () => Model; /** @category Classes */ readonly AstVector: new = AnyAst>() => AstVector; /** @category Classes */ readonly AstMap: new = AnyAst, Value extends Ast = AnyAst>() => AstMap; /** @category Classes */ readonly Tactic: new (name: string) => Tactic; /** @category Classes */ readonly Goal: new (models?: boolean, unsat_cores?: boolean, proofs?: boolean) => Goal; /** @category Classes */ readonly Params: new () => Params; /** @category Classes */ readonly Simplifier: new (name: string) => Simplifier; /** @category Expressions */ readonly Sort: SortCreation; /** @category Expressions */ readonly Function: FuncDeclCreation; /** @category Expressions */ readonly RecFunc: RecFuncCreation; /** @category Expressions */ readonly Bool: BoolCreation; /** @category Expressions */ readonly Int: IntCreation; /** @category Expressions */ readonly Real: RealCreation; /** @category Expressions */ readonly RCFNum: RCFNumCreation; /** @category Expressions */ readonly BitVec: BitVecCreation; /** @category Expressions */ readonly Float: FPCreation; /** @category Expressions */ readonly FloatRM: FPRMCreation; /** @category Expressions */ readonly String: StringCreation; /** @category Expressions */ readonly Seq: SeqCreation; /** @category Expressions */ readonly Re: ReCreation; /** @category Expressions */ readonly Array: SMTArrayCreation; /** @category Expressions */ readonly Set: SMTSetCreation; /** @category Expressions */ readonly Datatype: DatatypeCreation; /** @category Operations */ Const>(name: string, sort: S): SortToExprMap; /** @category Operations */ Consts>(name: string | string[], sort: S): SortToExprMap[]; /** @category Operations */ FreshConst>(sort: S, prefix?: string): SortToExprMap; /** @category Operations */ Var>(idx: number, sort: S): SortToExprMap; /** @category Operations */ If(condition: Probe, onTrue: Tactic, onFalse: Tactic): Tactic; /** @category Operations */ If, OnFalseRef extends CoercibleToExpr>(condition: Bool | boolean, onTrue: OnTrueRef, onFalse: OnFalseRef): CoercibleFromMap; /** @category Operations */ Distinct(...args: CoercibleToExpr[]): Bool; /** @category Operations */ Implies(a: Bool | boolean, b: Bool | boolean): Bool; /** @category Operations */ Iff(a: Bool | boolean, b: Bool | boolean): Bool; /** @category Operations */ Eq(a: CoercibleToExpr, b: CoercibleToExpr): Bool; /** @category Operations */ Xor(a: Bool | boolean, b: Bool | boolean): Bool; /** @category Operations */ Not(a: Probe): Probe; /** @category Operations */ Not(a: Bool | boolean): Bool; /** @category Operations */ And(): Bool; /** @category Operations */ And(vector: AstVector>): Bool; /** @category Operations */ And(...args: (Bool | boolean)[]): Bool; /** @category Operations */ And(...args: Probe[]): Probe; /** @category Operations */ Or(): Bool; /** @category Operations */ Or(vector: AstVector>): Bool; /** @category Operations */ Or(...args: (Bool | boolean)[]): Bool; /** @category Operations */ Or(...args: Probe[]): Probe; /** @category Operations */ PbEq(args: [Bool, ...Bool[]], coeffs: [number, ...number[]], k: number): Bool; /** @category Operations */ PbGe(args: [Bool, ...Bool[]], coeffs: [number, ...number[]], k: number): Bool; /** @category Operations */ PbLe(args: [Bool, ...Bool[]], coeffs: [number, ...number[]], k: number): Bool; /** @category Operations */ AtMost(args: [Bool, ...Bool[]], k: number): Bool; /** @category Operations */ AtLeast(args: [Bool, ...Bool[]], k: number): Bool; /** * Compose two tactics sequentially. Applies t1 to a goal, then t2 to each subgoal. * @category Tactics */ AndThen(t1: Tactic | string, t2: Tactic | string, ...ts: (Tactic | string)[]): Tactic; /** * Create a tactic that applies t1, and if it fails, applies t2. * @category Tactics */ OrElse(t1: Tactic | string, t2: Tactic | string, ...ts: (Tactic | string)[]): Tactic; /** * Repeat a tactic up to max times (default: unbounded). * @category Tactics */ Repeat(t: Tactic | string, max?: number): Tactic; /** * Apply tactic with a timeout in milliseconds. * @category Tactics */ TryFor(t: Tactic | string, ms: number): Tactic; /** * Apply tactic only if probe condition is true. * @category Tactics */ When(p: Probe, t: Tactic | string): Tactic; /** * Create a tactic that always succeeds and does nothing (skip). * @category Tactics */ Skip(): Tactic; /** * Create a tactic that always fails. * @category Tactics */ Fail(): Tactic; /** * Create a tactic that fails if probe condition is true. * @category Tactics */ FailIf(p: Probe): Tactic; /** * Apply tactics in parallel and return first successful result. * @category Tactics */ ParOr(...tactics: (Tactic | string)[]): Tactic; /** * Compose two tactics in parallel (t1 and then t2 in parallel). * @category Tactics */ ParAndThen(t1: Tactic | string, t2: Tactic | string): Tactic; /** * Apply tactic with given parameters. * @category Tactics */ With(t: Tactic | string, params: Record): Tactic; /** @category Operations */ ForAll>(quantifiers: ArrayIndexType, body: Bool, weight?: number): Quantifier> & Bool; /** @category Operations */ Exists>(quantifiers: ArrayIndexType, body: Bool, weight?: number): Quantifier> & Bool; /** @category Operations */ Lambda, RangeSort extends Sort>(quantifiers: ArrayIndexType, expr: SortToExprMap): Quantifier> & SMTArray; /** @category Operations */ ToReal(expr: Arith | bigint): Arith; /** @category Operations */ ToInt(expr: Arith | number | CoercibleRational | string): Arith; /** * Create an IsInt Z3 predicate * * ```typescript * const x = Real.const('x'); * await solve(IsInt(x.add("1/2")), x.gt(0), x.lt(1)) * // x = 1/2 * await solve(IsInt(x.add("1/2")), x.gt(0), x.lt(1), x.neq("1/2")) * // unsat * ``` * @category Operations */ IsInt(expr: Arith | number | CoercibleRational | string): Bool; /** * Returns a Z3 expression representing square root of a * * ```typescript * const a = Real.const('a'); * * Sqrt(a); * // a**(1/2) * ``` * @category Operations */ Sqrt(a: CoercibleToArith): Arith; /** * Returns a Z3 expression representing cubic root of a * * ```typescript * const a = Real.const('a'); * * Cbrt(a); * // a**(1/3) * ``` * @category Operations */ Cbrt(a: CoercibleToArith): Arith; /** @category Operations */ BV2Int(a: BitVec, isSigned: boolean): Arith; /** @category Operations */ Int2BV(a: Arith | bigint | number, bits: Bits): BitVec; /** @category Operations */ Concat(...bitvecs: BitVec[]): BitVec; /** @category Operations */ Cond(probe: Probe, onTrue: Tactic, onFalse: Tactic): Tactic; /** @category Operations */ LT(a: Arith, b: CoercibleToArith): Bool; /** @category Operations */ GT(a: Arith, b: CoercibleToArith): Bool; /** @category Operations */ LE(a: Arith, b: CoercibleToArith): Bool; /** @category Operations */ GE(a: Arith, b: CoercibleToArith): Bool; /** @category Operations */ ULT(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ UGT(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ ULE(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ UGE(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ SLT(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ SGT(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ SGE(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ SLE(a: BitVec, b: CoercibleToBitVec): Bool; /** @category Operations */ Sum(arg0: Arith, ...args: CoercibleToArith[]): Arith; Sum(arg0: BitVec, ...args: CoercibleToBitVec[]): BitVec; Sub(arg0: Arith, ...args: CoercibleToArith[]): Arith; Sub(arg0: BitVec, ...args: CoercibleToBitVec[]): BitVec; Product(arg0: Arith, ...args: CoercibleToArith[]): Arith; Product(arg0: BitVec, ...args: CoercibleToBitVec[]): BitVec; Div(arg0: Arith, arg1: CoercibleToArith): Arith; Div(arg0: BitVec, arg1: CoercibleToBitVec): BitVec; BUDiv(arg0: BitVec, arg1: CoercibleToBitVec): BitVec; Neg(a: Arith): Arith; Neg(a: BitVec): BitVec; Mod(a: Arith, b: CoercibleToArith): Arith; Mod(a: BitVec, b: CoercibleToBitVec): BitVec; /** @category Operations */ Select, RangeSort extends Sort = Sort>(array: SMTArray, ...indices: CoercibleToArrayIndexType): SortToExprMap; /** @category Operations */ Store, RangeSort extends Sort = Sort>(array: SMTArray, ...indicesAndValue: [ ...CoercibleToArrayIndexType, CoercibleToMap, Name> ]): SMTArray; /** @category Operations */ Ext, RangeSort extends Sort = Sort>(a: SMTArray, b: SMTArray): SortToExprMap; /** @category Operations */ Extract(hi: number, lo: number, val: BitVec): BitVec; /** @category Operations */ ast_from_string(s: string): Ast; /** @category Operations */ substitute(t: Expr, ...substitutions: [Expr, Expr][]): Expr; /** @category Operations */ substituteVars(t: Expr, ...to: Expr[]): Expr; /** @category Operations */ substituteFuns(t: Expr, ...substitutions: [FuncDecl, Expr][]): Expr; /** @category Operations */ updateField(t: DatatypeExpr, fieldAccessor: FuncDecl, newValue: Expr): DatatypeExpr; simplify(expr: Expr): Promise>; /** @category Operations */ SetUnion>(...args: SMTSet[]): SMTSet; /** @category Operations */ SetIntersect>(...args: SMTSet[]): SMTSet; /** @category Operations */ SetDifference>(a: SMTSet, b: SMTSet): SMTSet; /** @category Operations */ SetAdd>(set: SMTSet, elem: CoercibleToMap, Name>): SMTSet; /** @category Operations */ SetDel>(set: SMTSet, elem: CoercibleToMap, Name>): SMTSet; /** @category Operations */ SetComplement>(set: SMTSet): SMTSet; /** @category Operations */ EmptySet>(sort: ElemSort): SMTSet; /** @category Operations */ FullSet>(sort: ElemSort): SMTSet; /** @category Operations */ isMember>(elem: CoercibleToMap, Name>, set: SMTSet): Bool; /** @category Operations */ isSubset>(a: SMTSet, b: SMTSet): Bool; /** @category RegularExpression */ InRe(seq: Seq | string, re: Re): Bool; /** @category RegularExpression */ Union>(...res: Re[]): Re; /** @category RegularExpression */ Intersect>(...res: Re[]): Re; /** @category RegularExpression */ ReConcat>(...res: Re[]): Re; /** @category RegularExpression */ Plus>(re: Re): Re; /** @category RegularExpression */ Star>(re: Re): Re; /** @category RegularExpression */ Option>(re: Re): Re; /** @category RegularExpression */ Complement>(re: Re): Re; /** @category RegularExpression */ Diff>(a: Re, b: Re): Re; /** @category RegularExpression */ Range>(lo: Seq | string, hi: Seq | string): Re; /** * Create a bounded repetition regex * @param re The regex to repeat * @param lo Minimum number of repetitions * @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo) * @category RegularExpression */ Loop>(re: Re, lo: number, hi?: number): Re; /** @category RegularExpression */ Power>(re: Re, n: number): Re; /** @category RegularExpression */ AllChar>(reSort: ReSort): Re; /** @category RegularExpression */ Empty>(reSort: ReSort): Re; /** @category RegularExpression */ Full>(reSort: ReSort): Re; /** * Create a partial order relation over a sort. * @param sort The sort of the relation * @param index The index of the relation * @category Operations */ mkPartialOrder(sort: Sort, index: number): FuncDecl; /** * Create the transitive closure of a binary relation. * The resulting relation is recursive. * @param f A binary relation represented as a function declaration * @category Operations */ mkTransitiveClosure(f: FuncDecl): FuncDecl; /** * Return the nonzero subresultants of p and q with respect to the "variable" x. * Note that any subterm that cannot be viewed as a polynomial is assumed to be a variable. * @param p Arithmetic term * @param q Arithmetic term * @param x Variable with respect to which subresultants are computed * @category Operations */ polynomialSubresultants(p: Arith, q: Arith, x: Arith): Promise>>; } export interface Ast { /** @hidden */ readonly __typename: 'Ast' | Sort['__typename'] | FuncDecl['__typename'] | Expr['__typename']; readonly ctx: Context; /** @hidden */ readonly ptr: Ptr; /** @virtual */ get ast(): Z3_ast; /** @virtual */ id(): number; eqIdentity(other: Ast): boolean; neqIdentity(other: Ast): boolean; sexpr(): string; hash(): number; } /** @hidden */ export interface SolverCtor { new (): Solver; } export interface Solver { /** @hidden */ readonly __typename: 'Solver'; readonly ctx: Context; readonly ptr: Z3_solver; set(key: string, value: any): void; push(): void; pop(num?: number): void; numScopes(): number; reset(): void; add(...exprs: (Bool | AstVector>)[]): void; addAndTrack(expr: Bool, constant: Bool | string): void; /** * Attach a simplifier to the solver for incremental pre-processing. * The solver will use the simplifier for incremental pre-processing of assertions. * @param simplifier - The simplifier to attach */ addSimplifier(simplifier: Simplifier): void; assertions(): AstVector>; fromString(s: string): void; /** * Check whether the assertions in the solver are consistent or not. * * Optionally, you can provide additional boolean expressions as assumptions. * These assumptions are temporary and only used for this check - they are not * permanently added to the solver. * * @param exprs - Optional assumptions to check in addition to the solver's assertions. * These are temporary and do not modify the solver state. * @returns A promise resolving to: * - `'sat'` if the assertions (plus assumptions) are satisfiable * - `'unsat'` if they are unsatisfiable * - `'unknown'` if Z3 cannot determine satisfiability * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * solver.add(x.gt(0)); * * // Check without assumptions * await solver.check(); // 'sat' * * // Check with temporary assumption (doesn't modify solver) * await solver.check(x.lt(0)); // 'unsat' * await solver.check(); // still 'sat' - assumption was temporary * ``` * * @see {@link unsatCore} - Retrieve unsat core after checking with assumptions */ check(...exprs: (Bool | AstVector>)[]): Promise; /** * Retrieve the unsat core after a check that returned `'unsat'`. * * The unsat core is a (typically small) subset of the assumptions that were * sufficient to determine unsatisfiability. This is useful for understanding * which assumptions are conflicting. * * Note: To use unsat cores effectively, you should call {@link check} with * assumptions (not just assertions added via {@link add}). * * @returns An AstVector containing the subset of assumptions that caused UNSAT * * @example * ```typescript * const solver = new Solver(); * const x = Bool.const('x'); * const y = Bool.const('y'); * const z = Bool.const('z'); * solver.add(x.or(y)); * solver.add(x.or(z)); * * const result = await solver.check(x.not(), y.not(), z.not()); * if (result === 'unsat') { * const core = solver.unsatCore(); * // core will contain a minimal set of conflicting assumptions * console.log('UNSAT core size:', core.length()); * } * ``` * * @see {@link check} - Check with assumptions to use with unsat core */ unsatCore(): AstVector>; model(): Model; /** * Retrieve statistics for the solver. * Returns performance metrics, memory usage, decision counts, and other diagnostic information. * * @returns A Statistics object containing solver metrics * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * solver.add(x.gt(0)); * await solver.check(); * const stats = solver.statistics(); * console.log('Statistics size:', stats.size()); * for (const entry of stats) { * console.log(`${entry.key}: ${entry.value}`); * } * ``` */ statistics(): Statistics; /** * Return a string describing why the last call to {@link check} returned `'unknown'`. * * @returns A string explaining the reason, or an empty string if the last check didn't return unknown * * @example * ```typescript * const result = await solver.check(); * if (result === 'unknown') { * console.log('Reason:', solver.reasonUnknown()); * } * ``` */ reasonUnknown(): string; /** * Retrieve the set of literals that were inferred by the solver as unit literals. * These are boolean literals that the solver has determined must be true in all models. * * @returns An AstVector containing the unit literals * * @example * ```typescript * const solver = new Solver(); * const x = Bool.const('x'); * solver.add(x.or(x)); // simplifies to x * await solver.check(); * const units = solver.units(); * console.log('Unit literals:', units.length()); * ``` */ units(): AstVector>; /** * Retrieve the set of tracked boolean literals that are not unit literals. * * @returns An AstVector containing the non-unit literals * * @example * ```typescript * const solver = new Solver(); * const x = Bool.const('x'); * const y = Bool.const('y'); * solver.add(x.or(y)); * await solver.check(); * const nonUnits = solver.nonUnits(); * ``` */ nonUnits(): AstVector>; /** * Retrieve the trail of boolean literals assigned by the solver during solving. * The trail represents the sequence of decisions and propagations made by the solver. * * @returns An AstVector containing the trail of assigned literals * * @example * ```typescript * const solver = new Solver(); * const x = Bool.const('x'); * const y = Bool.const('y'); * solver.add(x.implies(y)); * solver.add(x); * await solver.check(); * const trail = solver.trail(); * console.log('Trail length:', trail.length()); * ``` */ trail(): AstVector>; /** * Retrieve the root of the congruence class containing the given expression. * This is useful for understanding equality reasoning in the solver. * * Note: This works primarily with SimpleSolver and may not work with terms * eliminated during preprocessing. * * @param expr - The expression to find the congruence root for * @returns The root expression of the congruence class * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * const y = Int.const('y'); * solver.add(x.eq(y)); * await solver.check(); * const root = solver.congruenceRoot(x); * ``` */ congruenceRoot(expr: Expr): Expr; /** * Retrieve the next expression in the congruence class containing the given expression. * The congruence class forms a circular linked list. * * Note: This works primarily with SimpleSolver and may not work with terms * eliminated during preprocessing. * * @param expr - The expression to find the next congruent expression for * @returns The next expression in the congruence class * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * const y = Int.const('y'); * const z = Int.const('z'); * solver.add(x.eq(y)); * solver.add(y.eq(z)); * await solver.check(); * const next = solver.congruenceNext(x); * ``` */ congruenceNext(expr: Expr): Expr; /** * Explain why two expressions are congruent according to the solver's reasoning. * Returns a proof term explaining the congruence. * * Note: This works primarily with SimpleSolver and may not work with terms * eliminated during preprocessing. * * @param a - First expression * @param b - Second expression * @returns An expression representing the proof of congruence * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * const y = Int.const('y'); * solver.add(x.eq(y)); * await solver.check(); * const explanation = solver.congruenceExplain(x, y); * ``` */ congruenceExplain(a: Expr, b: Expr): Expr; /** * Load SMT-LIB2 format assertions from a file into the solver. * * @param filename - Path to the file containing SMT-LIB2 format assertions * * @example * ```typescript * const solver = new Solver(); * solver.fromFile('problem.smt2'); * const result = await solver.check(); * ``` */ fromFile(filename: string): void; /** * Convert the solver's assertions to SMT-LIB2 format as a benchmark. * * This exports the current set of assertions in the solver as an SMT-LIB2 string, * which can be used for bug reporting, sharing problems, or benchmarking. * * @param status - Status string such as "sat", "unsat", or "unknown" (default: "unknown") * @returns A string representation of the solver's assertions in SMT-LIB2 format * * @example * ```typescript * const solver = new Solver(); * const x = Int.const('x'); * const y = Int.const('y'); * solver.add(x.gt(0)); * solver.add(y.eq(x.add(1))); * const smtlib2 = solver.toSmtlib2('unknown'); * console.log(smtlib2); // Prints SMT-LIB2 formatted problem * ``` */ toSmtlib2(status?: string): string; /** * Manually decrease the reference count of the solver * This is automatically done when the solver is garbage collected, * but calling this eagerly can help release memory sooner. */ release(): void; } export interface Optimize { /** @hidden */ readonly __typename: 'Optimize'; readonly ctx: Context; readonly ptr: Z3_optimize; set(key: string, value: any): void; push(): void; pop(num?: number): void; add(...exprs: (Bool | AstVector>)[]): void; addSoft(expr: Bool, weight: number | bigint | string | CoercibleRational, id?: number | string): void; addAndTrack(expr: Bool, constant: Bool | string): void; assertions(): AstVector>; fromString(s: string): void; maximize(expr: Arith): void; minimize(expr: Arith): void; check(...exprs: (Bool | AstVector>)[]): Promise; model(): Model; statistics(): Statistics; /** * Manually decrease the reference count of the optimize * This is automatically done when the optimize is garbage collected, * but calling this eagerly can help release memory sooner. */ release(): void; } export interface Fixedpoint { /** @hidden */ readonly __typename: 'Fixedpoint'; readonly ctx: Context; readonly ptr: Z3_fixedpoint; /** * Set a configuration option for the fixedpoint solver. * @param key - Configuration parameter name * @param value - Configuration parameter value */ set(key: string, value: any): void; /** * Return a string describing all available options. */ help(): string; /** * Assert a constraint (or multiple) into the fixedpoint solver as background axioms. */ add(...constraints: Bool[]): void; /** * Register a predicate as a recursive relation. * @param pred - Function declaration to register as a recursive relation */ registerRelation(pred: FuncDecl): void; /** * Add a rule (Horn clause) to the fixedpoint solver. * @param rule - The rule as a Boolean expression (implication) * @param name - Optional name for the rule */ addRule(rule: Bool, name?: string): void; /** * Add a table fact to the fixedpoint solver. * @param pred - The predicate (function declaration) * @param args - Arguments to the predicate as integers */ addFact(pred: FuncDecl, ...args: number[]): void; /** * Update a named rule in the fixedpoint solver. * @param rule - The rule as a Boolean expression (implication) * @param name - Name of the rule to update */ updateRule(rule: Bool, name: string): void; /** * Query the fixedpoint solver to determine if the formula is derivable. * @param query - The query as a Boolean expression * @returns A promise that resolves to 'sat', 'unsat', or 'unknown' */ query(query: Bool): Promise; /** * Query the fixedpoint solver for a set of relations. * @param relations - Array of function declarations representing relations to query * @returns A promise that resolves to 'sat', 'unsat', or 'unknown' */ queryRelations(...relations: FuncDecl[]): Promise; /** * Retrieve the answer (satisfying instance or proof of unsatisfiability) from the last query. * @returns Expression containing the answer, or null if not available */ getAnswer(): Expr | null; /** * Retrieve the reason why the fixedpoint engine returned 'unknown'. * @returns A string explaining why the result was unknown */ getReasonUnknown(): string; /** * Retrieve the number of levels explored for a given predicate. * @param pred - The predicate function declaration * @returns The number of levels */ getNumLevels(pred: FuncDecl): number; /** * Retrieve the cover of a predicate at a given level. * @param level - The level to query * @param pred - The predicate function declaration * @returns Expression representing the cover, or null if not available */ getCoverDelta(level: number, pred: FuncDecl): Expr | null; /** * Add a property about the predicate at the given level. * @param level - The level to add the property at * @param pred - The predicate function declaration * @param property - The property as an expression */ addCover(level: number, pred: FuncDecl, property: Expr): void; /** * Retrieve set of rules added to the fixedpoint context. * @returns Vector of rules */ getRules(): AstVector>; /** * Retrieve set of assertions added to the fixedpoint context. * @returns Vector of assertions */ getAssertions(): AstVector>; /** * Set predicate representation for the Datalog engine. * @param pred - The predicate function declaration * @param kinds - Array of representation kinds */ setPredicateRepresentation(pred: FuncDecl, kinds: string[]): void; /** * Convert the fixedpoint context to a string. * @returns String representation of the fixedpoint context */ toString(): string; /** * Parse an SMT-LIB2 string with fixedpoint rules and add them to the context. * @param s - SMT-LIB2 string to parse * @returns Vector of queries from the parsed string */ fromString(s: string): AstVector>; /** * Parse an SMT-LIB2 file with fixedpoint rules and add them to the context. * @param file - Path to the file to parse * @returns Vector of queries from the parsed file */ fromFile(file: string): AstVector>; /** * Retrieve statistics for the fixedpoint solver. * Returns performance metrics and diagnostic information. * @returns A Statistics object containing solver metrics */ statistics(): Statistics; /** * Manually decrease the reference count of the fixedpoint * This is automatically done when the fixedpoint is garbage collected, * but calling this eagerly can help release memory sooner. */ release(): void; } /** @hidden */ export interface ModelCtor { new (): Model; } export interface Model extends Iterable> { /** @hidden */ readonly __typename: 'Model'; readonly ctx: Context; readonly ptr: Z3_model; length(): number; entries(): IterableIterator<[number, FuncDecl]>; keys(): IterableIterator; values(): IterableIterator>; decls(): FuncDecl[]; sexpr(): string; eval(expr: Bool, modelCompletion?: boolean): Bool; eval(expr: Arith, modelCompletion?: boolean): Arith; eval(expr: BitVec, modelCompletion?: boolean): BitVecNum; eval(expr: Expr, modelCompletion?: boolean): Expr; get(i: number): FuncDecl; get(from: number, to: number): FuncDecl[]; get(declaration: FuncDecl): FuncInterp | Expr; get(constant: Expr): Expr; get(sort: Sort): AstVector>; updateValue(decl: FuncDecl | Expr, a: Ast | FuncInterp): void; addFuncInterp[] = Sort[], RangeSort extends Sort = Sort>(decl: FuncDecl, defaultValue: CoercibleToMap, Name>): FuncInterp; /** * Return the number of uninterpreted sorts that have an interpretation in the model. * * @returns The number of uninterpreted sorts * * @example * ```typescript * 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()); * ``` */ numSorts(): number; /** * Return the uninterpreted sort at the given index. * * @param i - Index of the sort (must be less than numSorts()) * @returns The sort at the given index * * @example * ```typescript * const model = solver.model(); * for (let i = 0; i < model.numSorts(); i++) { * const sort = model.getSort(i); * console.log('Sort:', sort.toString()); * } * ``` */ getSort(i: number): Sort; /** * Return all uninterpreted sorts that have an interpretation in the model. * * @returns An array of all uninterpreted sorts * * @example * ```typescript * 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()); * } * ``` */ getSorts(): Sort[]; /** * Return the finite set of elements that represent the interpretation for the given sort. * This is only applicable to uninterpreted sorts with finite interpretations. * * @param sort - The sort to get the universe for * @returns An AstVector containing all elements in the sort's universe * * @example * ```typescript * 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()); * } * ``` */ sortUniverse(sort: Sort): AstVector>; /** * 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. */ release(): void; } /** * Statistics entry representing a single key-value pair from solver statistics */ export interface StatisticsEntry { /** @hidden */ readonly __typename: 'StatisticsEntry'; /** The key/name of this statistic */ readonly key: string; /** The numeric value of this statistic */ readonly value: number; /** True if this statistic is stored as an unsigned integer */ readonly isUint: boolean; /** True if this statistic is stored as a double */ readonly isDouble: boolean; } export interface StatisticsCtor { new (): Statistics; } /** * Statistics for solver operations * * Provides access to performance metrics, memory usage, decision counts, * and other diagnostic information from solver operations. */ export interface Statistics extends Iterable> { /** @hidden */ readonly __typename: 'Statistics'; readonly ctx: Context; readonly ptr: Z3_stats; /** * Return the number of statistical data points * @returns The number of statistics entries */ size(): number; /** * Return the keys of all statistical data * @returns Array of statistic keys */ keys(): string[]; /** * Return a specific statistic value by key * @param key - The key of the statistic to retrieve * @returns The numeric value of the statistic * @throws Error if the key doesn't exist */ get(key: string): number; /** * Return all statistics as an array of entries * @returns Array of all statistics entries */ entries(): StatisticsEntry[]; /** * Manually decrease the reference count of the statistics object * This is automatically done when the statistics is garbage collected, * but calling this eagerly can help release memory sooner. */ release(): void; } /** * Part of {@link Context}. Used to declare uninterpreted sorts * * ```typescript * const A = context.Sort.declare('A'); * const a = context.Const('a', A); * const b = context.const('b', A); * * a.sort.eqIdentity(A) * // true * b.sort.eqIdentity(A) * // true * a.eq(b) * // a == b * ``` */ export interface SortCreation { declare(name: string): Sort; } export interface Sort extends Ast { /** @hidden */ readonly __typename: 'Sort' | BoolSort['__typename'] | ArithSort['__typename'] | BitVecSort['__typename'] | SMTArraySort['__typename'] | DatatypeSort['__typename'] | FPSort['__typename'] | FPRMSort['__typename'] | SeqSort['__typename'] | ReSort['__typename']; kind(): Z3_sort_kind; /** @virtual */ subsort(other: Sort): boolean; /** @virtual */ cast(expr: CoercibleToExpr): Expr; name(): string | number; } /** * @category Functions */ export interface FuncEntry { /** @hidden */ readonly __typename: 'FuncEntry'; readonly ctx: Context; readonly ptr: Z3_func_entry; numArgs(): number; argValue(i: number): Expr; value(): Expr; } /** * @category Functions */ export interface FuncInterp { /** @hidden */ readonly __typename: 'FuncInterp'; readonly ctx: Context; readonly ptr: Z3_func_interp; elseValue(): Expr; numEntries(): number; arity(): number; entry(i: number): FuncEntry; addEntry(args: Expr[], value: Expr): void; } /** @hidden */ export type FuncDeclSignature = [Sort, Sort, ...Sort[]]; /** * Part of {@link Context}. Used to declare functions * @category Functions */ export interface FuncDeclCreation { /** * Declare a new function * * ```typescript * const f = ctx.Function.declare('f', ctx.Bool.sort(), ctx.Real.sort(), ctx.Int.sort()) * * f.call(true, "1/3").eq(5) * // f(true, 1/3) == 5 * ``` * @param name Name of the function * @param signature The domains, and last parameter - the range of the function */ declare[], RangeSort extends Sort>(name: string, ...signature: [...DomainSort, RangeSort]): FuncDecl; fresh[], RangeSort extends Sort>(...signature: [...DomainSort, RangeSort]): FuncDecl; } /** * @category Functions */ export interface RecFuncCreation { declare(name: string, ...signature: FuncDeclSignature): FuncDecl; addDefinition(f: FuncDecl, args: Expr[], body: Expr): void; } /** * @category Functions */ export interface FuncDecl[] = Sort[], RangeSort extends Sort = Sort> extends Ast { /** @hidden */ readonly __typename: 'FuncDecl'; name(): string | number; arity(): number; domain(i: T): DomainSort[T]; range(): RangeSort; kind(): Z3_decl_kind; params(): (number | string | Sort | Expr | FuncDecl)[]; call(...args: CoercibleToArrayIndexType): SortToExprMap; } export interface Expr = AnySort, Ptr = unknown> extends Ast { /** @hidden */ readonly __typename: 'Expr' | Bool['__typename'] | Arith['__typename'] | BitVec['__typename'] | FP['__typename'] | FPRM['__typename'] | Seq['__typename'] | Re['__typename'] | SMTArray['__typename'] | DatatypeExpr['__typename']; get sort(): S; eq(other: CoercibleToExpr): Bool; neq(other: CoercibleToExpr): Bool; params(): ReturnType['params']>; name(): ReturnType['name']>; decl(): FuncDecl; numArgs(): number; arg(i: number): AnyExpr; children(): AnyExpr[]; } /** @category Booleans */ export interface BoolSort extends Sort { /** @hidden */ readonly __typename: 'BoolSort'; cast(expr: Bool | boolean): Bool; cast(expr: CoercibleToExpr): never; } /** @category Booleans */ export interface BoolCreation { sort(): BoolSort; const(name: string): Bool; consts(names: string | string[]): Bool[]; vector(prefix: string, count: number): Bool[]; fresh(prefix?: string): Bool; val(value: boolean): Bool; } /** @category Booleans */ export interface Bool extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'Bool' | 'NonLambdaQuantifier'; not(): Bool; and(other: Bool | boolean): Bool; or(other: Bool | boolean): Bool; xor(other: Bool | boolean): Bool; implies(other: Bool | boolean): Bool; } /** @category Quantifiers */ export interface Pattern { /** @hidden */ readonly __typename: 'Pattern'; } /** * A Sort that represents Integers or Real numbers * @category Arithmetic */ export interface ArithSort extends Sort { /** @hidden */ readonly __typename: 'ArithSort'; cast(other: bigint | number | string): IntNum | RatNum; cast(other: CoercibleRational | RatNum): RatNum; cast(other: IntNum): IntNum; cast(other: bigint | number | string | Bool | Arith | CoercibleRational): Arith; cast(other: CoercibleToExpr | string): never; } /** @category Arithmetic */ export interface IntCreation { sort(): ArithSort; const(name: string): Arith; consts(names: string | string[]): Arith[]; vector(prefix: string, count: number): Arith[]; fresh(prefix?: string): Arith; val(value: bigint | number | string): IntNum; } /** @category Arithmetic */ export interface RealCreation { sort(): ArithSort; const(name: string): Arith; consts(names: string | string[]): Arith[]; vector(prefix: string, count: number): Arith[]; fresh(prefix?: string): Arith; val(value: number | string | bigint | CoercibleRational): RatNum; } /** * Represents Integer or Real number expression * @category Arithmetic */ export interface Arith extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'Arith' | IntNum['__typename'] | RatNum['__typename']; /** * Adds two numbers together */ add(other: CoercibleToArith): Arith; /** * Multiplies two numbers together */ mul(other: CoercibleToArith): Arith; /** * Subtract second number from the first one */ sub(other: CoercibleToArith): Arith; /** * Applies power to the number * * ```typescript * const x = Int.const('x'); * * await solve(x.pow(2).eq(4), x.lt(0)); // x**2 == 4, x < 0 * // x=-2 * ``` */ pow(exponent: CoercibleToArith): Arith; /** * Divides the number by the second one */ div(other: CoercibleToArith): Arith; /** * Returns a number modulo second one * * ```typescript * const x = Int.const('x'); * * await solve(x.mod(7).eq(1), x.gt(7)) // x % 7 == 1, x > 7 * // x=8 * ``` */ mod(other: CoercibleToArith): Arith; /** * Returns a negation of the number */ neg(): Arith; /** * Return whether the number is less or equal than the second one (`<=`) */ le(other: CoercibleToArith): Bool; /** * Returns whether the number is less than the second one (`<`) */ lt(other: CoercibleToArith): Bool; /** * Returns whether the number is greater than the second one (`>`) */ gt(other: CoercibleToArith): Bool; /** * Returns whether the number is greater or equal than the second one (`>=`) */ ge(other: CoercibleToArith): Bool; } /** * A constant Integer value expression * @category Arithmetic */ export interface IntNum extends Arith { /** @hidden */ readonly __typename: 'IntNum'; value(): bigint; asString(): string; asBinary(): string; } /** * A constant Rational value expression * * ```typescript * const num = Real.val('1/3'); * * num.asString() * // '1/3' * num.value * // { numerator: 1n, denominator: 3n } * num.asNumber() * // 0.3333333333333333 * ``` * @category Arithmetic */ export interface RatNum extends Arith { /** @hidden */ readonly __typename: 'RatNum'; value(): { numerator: bigint; denominator: bigint; }; numerator(): IntNum; denominator(): IntNum; asNumber(): number; asDecimal(prec?: number): string; asString(): string; } /** * A Real Closed Field (RCF) numeral. * * RCF numerals can represent: * - Rational numbers * - Algebraic numbers (roots of polynomials) * - Transcendental extensions (e.g., pi, e) * - Infinitesimal extensions * * ```typescript * const { RCFNum } = Context('main'); * * // Create pi * const pi = RCFNum.pi(); * console.log(pi.toDecimal(10)); // "3.1415926536" * * // Create a rational * const half = new RCFNum('1/2'); * * // Arithmetic * const sum = pi.add(half); * * // Check properties * console.log(pi.isTranscendental()); // true * console.log(half.isRational()); // true * ``` * @category Arithmetic */ export interface RCFNum { /** @hidden */ readonly __typename: 'RCFNum'; /** @hidden */ readonly ctx: Context; /** * Add two RCF numerals. * @param other - The RCF numeral to add * @returns this + other */ add(other: RCFNum): RCFNum; /** * Subtract two RCF numerals. * @param other - The RCF numeral to subtract * @returns this - other */ sub(other: RCFNum): RCFNum; /** * Multiply two RCF numerals. * @param other - The RCF numeral to multiply * @returns this * other */ mul(other: RCFNum): RCFNum; /** * Divide two RCF numerals. * @param other - The RCF numeral to divide by * @returns this / other */ div(other: RCFNum): RCFNum; /** * Negate this RCF numeral. * @returns -this */ neg(): RCFNum; /** * Compute the multiplicative inverse. * @returns 1/this */ inv(): RCFNum; /** * Raise this RCF numeral to a power. * @param k - The exponent * @returns this^k */ power(k: number): RCFNum; /** * Check if this RCF numeral is less than another. * @param other - The RCF numeral to compare with * @returns true if this < other */ lt(other: RCFNum): boolean; /** * Check if this RCF numeral is greater than another. * @param other - The RCF numeral to compare with * @returns true if this > other */ gt(other: RCFNum): boolean; /** * Check if this RCF numeral is less than or equal to another. * @param other - The RCF numeral to compare with * @returns true if this <= other */ le(other: RCFNum): boolean; /** * Check if this RCF numeral is greater than or equal to another. * @param other - The RCF numeral to compare with * @returns true if this >= other */ ge(other: RCFNum): boolean; /** * Check if this RCF numeral is equal to another. * @param other - The RCF numeral to compare with * @returns true if this == other */ eq(other: RCFNum): boolean; /** * Check if this RCF numeral is not equal to another. * @param other - The RCF numeral to compare with * @returns true if this != other */ neq(other: RCFNum): boolean; /** * Check if this RCF numeral is a rational number. * @returns true if this is rational */ isRational(): boolean; /** * Check if this RCF numeral is an algebraic number. * @returns true if this is algebraic */ isAlgebraic(): boolean; /** * Check if this RCF numeral is an infinitesimal. * @returns true if this is infinitesimal */ isInfinitesimal(): boolean; /** * Check if this RCF numeral is a transcendental number. * @returns true if this is transcendental */ isTranscendental(): boolean; /** * Convert this RCF numeral to a string. * @param compact - If true, use compact representation * @returns String representation */ toString(compact?: boolean): string; /** * Convert this RCF numeral to a decimal string. * @param precision - Number of decimal places * @returns Decimal string representation */ toDecimal(precision: number): string; } /** * Creation interface for RCF numerals * @category Arithmetic */ export interface RCFNumCreation { /** * Create an RCF numeral from a rational string. * @param value - String representation of a rational number (e.g., "3/2", "0.5", "42") */ (value: string): RCFNum; /** * Create an RCF numeral from a small integer. * @param value - Integer value */ (value: number): RCFNum; /** * Create an RCF numeral representing pi. */ pi(): RCFNum; /** * Create an RCF numeral representing e (Euler's constant). */ e(): RCFNum; /** * Create an RCF numeral representing an infinitesimal. */ infinitesimal(): RCFNum; /** * Find roots of a polynomial. * * The polynomial is a[n-1]*x^(n-1) + ... + a[1]*x + a[0]. * * @param coefficients - Polynomial coefficients (constant term first) * @returns Array of RCF numerals representing the roots */ roots(coefficients: RCFNum[]): RCFNum[]; } /** * A Sort representing Bit Vector numbers of specified {@link BitVecSort.size size} * * @typeParam Bits - A number representing amount of bits for this sort * @category Bit Vectors */ export interface BitVecSort extends Sort { /** @hidden */ readonly __typename: 'BitVecSort'; /** * The amount of bits inside the sort * * ```typescript * const x = BitVec.const('x', 32); * * console.log(x.sort.size) * // 32 * ``` */ size(): Bits; cast(other: CoercibleToBitVec): BitVec; cast(other: CoercibleToExpr): Expr; } /** @category Bit Vectors */ export interface BitVecCreation { sort(bits: Bits): BitVecSort; const(name: string, bits: Bits | BitVecSort): BitVec; consts(names: string | string[], bits: Bits | BitVecSort): BitVec[]; val(value: bigint | number | boolean, bits: Bits | BitVecSort): BitVecNum; } /** * Represents Bit Vector expression * @category Bit Vectors */ export interface BitVec extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'BitVec' | BitVecNum['__typename']; /** * The amount of bits of this BitVectors sort * * ```typescript * const x = BitVec.const('x', 32); * * x.size * // 32 * * const Y = BitVec.sort(8); * const y = BitVec.const('y', Y); * * y.size * // 8 * ``` */ size(): Bits; /** @category Arithmetic */ add(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ mul(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ sub(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ sdiv(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ udiv(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ smod(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ urem(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ srem(other: CoercibleToBitVec): BitVec; /** @category Arithmetic */ neg(): BitVec; /** * Creates a bitwise-or between two bitvectors * @category4 Bitwise */ or(other: CoercibleToBitVec): BitVec; /** * Creates a bitwise-and between two bitvectors * @category Bitwise */ and(other: CoercibleToBitVec): BitVec; /** * Creates a bitwise-not-and between two bitvectors * @category Bitwise */ nand(other: CoercibleToBitVec): BitVec; /** * Creates a bitwise-exclusive-or between two bitvectors * @category Bitwise */ xor(other: CoercibleToBitVec): BitVec; /** * Creates a bitwise-exclusive-not-or between two bitvectors * @category Bitwise */ xnor(other: CoercibleToBitVec): BitVec; /** * Creates an arithmetic shift right operation * @category Bitwise */ shr(count: CoercibleToBitVec): BitVec; /** * Creates a logical shift right operation * @category Bitwise */ lshr(count: CoercibleToBitVec): BitVec; /** * Creates a shift left operation * @category Bitwise */ shl(count: CoercibleToBitVec): BitVec; /** * Creates a rotate right operation * @category Bitwise */ rotateRight(count: CoercibleToBitVec): BitVec; /** * Creates a rotate left operation * @category Bitwise */ rotateLeft(count: CoercibleToBitVec): BitVec; /** * Creates a bitwise not operation * @category Bitwise */ not(): BitVec; /** * Creates an extraction operation. * Bits are indexed starting from 1 from the most right one (least significant) increasing to left (most significant) * * ```typescript * const x = BitVec.const('x', 8); * * x.extract(6, 2) * // Extract(6, 2, x) * x.extract(6, 2).sort * // BitVec(5) * ``` * @param high The most significant bit to be extracted * @param low The least significant bit to be extracted */ extract(high: number, low: number): BitVec; signExt(count: number): BitVec; zeroExt(count: number): BitVec; repeat(count: number): BitVec; /** * Creates a signed less-or-equal operation (`<=`) * @category Comparison */ sle(other: CoercibleToBitVec): Bool; /** * Creates an unsigned less-or-equal operation (`<=`) * @category Comparison */ ule(other: CoercibleToBitVec): Bool; /** * Creates a signed less-than operation (`<`) * @category Comparison */ slt(other: CoercibleToBitVec): Bool; /** * Creates an unsigned less-than operation (`<`) * @category Comparison */ ult(other: CoercibleToBitVec): Bool; /** * Creates a signed greater-or-equal operation (`>=`) * @category Comparison */ sge(other: CoercibleToBitVec): Bool; /** * Creates an unsigned greater-or-equal operation (`>=`) * @category Comparison */ uge(other: CoercibleToBitVec): Bool; /** * Creates a signed greater-than operation (`>`) * @category Comparison */ sgt(other: CoercibleToBitVec): Bool; /** * Creates an unsigned greater-than operation (`>`) * @category Comparison */ ugt(other: CoercibleToBitVec): Bool; /** * Creates a reduction-and operation */ redAnd(): BitVec; /** * Creates a reduction-or operation */ redOr(): BitVec; /** @category Boolean */ addNoOverflow(other: CoercibleToBitVec, isSigned: boolean): Bool; /** @category Boolean */ addNoUnderflow(other: CoercibleToBitVec): Bool; /** @category Boolean */ subNoOverflow(other: CoercibleToBitVec): Bool; /** @category Boolean */ subNoUnderflow(other: CoercibleToBitVec, isSigned: boolean): Bool; /** @category Boolean */ sdivNoOverflow(other: CoercibleToBitVec): Bool; /** @category Boolean */ mulNoOverflow(other: CoercibleToBitVec, isSigned: boolean): Bool; /** @category Boolean */ mulNoUnderflow(other: CoercibleToBitVec): Bool; /** @category Boolean */ negNoOverflow(): Bool; } /** * Represents Bit Vector constant value * @category Bit Vectors */ export interface BitVecNum extends BitVec { /** @hidden */ readonly __typename: 'BitVecNum'; value(): bigint; asSignedValue(): bigint; asString(): string; asBinaryString(): string; } /** * A Sort representing a SMT Array with range of sort {@link SMTArraySort.range range} * and a domain of sort {@link SMTArraySort.domain domain} * * @typeParam DomainSort The sort of the domain of the array (provided as an array of sorts) * @typeParam RangeSort The sort of the array range * @category Arrays */ export interface SMTArraySort = [Sort, ...Sort[]], RangeSort extends AnySort = AnySort> extends Sort { /** @hidden */ readonly __typename: 'ArraySort'; /** * The sort of the first dimension of the domain */ domain(): DomainSort[0]; /** * The sort of the i-th (0-indexed) dimension of the domain * * @param i index of the dimension of the domain being requested */ domain_n(i: T): DomainSort[T]; /** * The sort of the range */ range(): RangeSort; } /** @category Arrays */ export interface SMTArrayCreation { sort, RangeSort extends Sort>(...sig: [...DomainSort, RangeSort]): SMTArraySort; const, RangeSort extends Sort>(name: string, ...sig: [...DomainSort, RangeSort]): SMTArray; consts, RangeSort extends Sort>(names: string | string[], ...sig: [...DomainSort, RangeSort]): SMTArray[]; K, RangeSort extends AnySort>(domain: DomainSort, value: SortToExprMap): SMTArray; } export type NonEmptySortArray = [Sort, ...Array>]; export type ArrayIndexType[]> = [ ...{ [Key in keyof DomainSort]: DomainSort[Key] extends AnySort ? SortToExprMap : DomainSort[Key]; } ]; export type CoercibleToArrayIndexType[]> = [ ...{ [Key in keyof DomainSort]: DomainSort[Key] extends AnySort ? CoercibleToMap, Name> : DomainSort[Key]; } ]; /** * Represents Array expression * * @typeParam DomainSort The sort of the domain of the array (provided as an array of sorts) * @typeParam RangeSort The sort of the array range * @category Arrays */ export interface SMTArray = [Sort, ...Sort[]], RangeSort extends Sort = Sort> extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'Array' | 'Lambda'; domain(): DomainSort[0]; domain_n(i: T): DomainSort[T]; range(): RangeSort; select(...indices: CoercibleToArrayIndexType): SortToExprMap; /** * value should be coercible to RangeSort * * @param indicesAndValue (idx0, idx1, ..., idxN, value) */ store(...indicesAndValue: [ ...CoercibleToArrayIndexType, CoercibleToMap, Name> ]): SMTArray; /** * Access the array default value. * Produces the default range value, for arrays that can be represented as * finite maps with a default range value. */ default(): SortToExprMap; } /** * Set Implemented using Arrays * * @typeParam ElemSort The sort of the element of the set * @category Sets */ export type SMTSetSort = Sort> = SMTArraySort>; /** @category Sets*/ export interface SMTSetCreation { sort>(elemSort: ElemSort): SMTSetSort; const>(name: string, elemSort: ElemSort): SMTSet; consts>(names: string | string[], elemSort: ElemSort): SMTSet[]; empty>(sort: ElemSort): SMTSet; val>(values: CoercibleToMap, Name>[], sort: ElemSort): SMTSet; } /** * Represents Set expression * * @typeParam ElemSort The sort of the element of the set * @category Arrays */ export interface SMTSet = Sort> extends Expr, Z3_ast> { readonly __typename: 'Array'; elemSort(): ElemSort; union(...args: SMTSet[]): SMTSet; intersect(...args: SMTSet[]): SMTSet; diff(b: SMTSet): SMTSet; add(elem: CoercibleToMap, Name>): SMTSet; del(elem: CoercibleToMap, Name>): SMTSet; complement(): SMTSet; contains(elem: CoercibleToMap, Name>): Bool; subsetOf(b: SMTSet): Bool; } /** * Helper class for declaring Z3 datatypes. * * Follows the same pattern as Python Z3 API for declaring constructors * before creating the actual datatype sort. * * @example * ```typescript * const List = new ctx.Datatype('List'); * List.declare('cons', ['car', ctx.Int.sort()], ['cdr', List]); * List.declare('nil'); * const ListSort = List.create(); * ``` * * @category Datatypes */ export interface Datatype { readonly ctx: Context; readonly name: string; /** * Declare a constructor for this datatype. * * @param name Constructor name * @param fields Array of [field_name, field_sort] pairs */ declare(name: string, ...fields: Array<[string, AnySort | Datatype]>): this; /** * Create the actual datatype sort from the declared constructors. * For mutually recursive datatypes, use Context.createDatatypes instead. */ create(): DatatypeSort; } /** * @category Datatypes */ export interface DatatypeCreation { /** * Create a new datatype declaration helper. */ (name: string): Datatype; /** * Create mutually recursive datatypes. * * @param datatypes Array of Datatype declarations * @returns Array of created DatatypeSort instances */ createDatatypes(...datatypes: Datatype[]): DatatypeSort[]; } /** * A Sort representing an algebraic datatype. * * After creation, this sort will have constructor, recognizer, and accessor * functions dynamically attached based on the declared constructors. * * @category Datatypes */ export interface DatatypeSort extends Sort { /** @hidden */ readonly __typename: 'DatatypeSort'; /** * Number of constructors in this datatype */ numConstructors(): number; /** * Get the idx'th constructor function declaration */ constructorDecl(idx: number): FuncDecl; /** * Get the idx'th recognizer function declaration */ recognizer(idx: number): FuncDecl; /** * Get the accessor function declaration for the idx_a'th field of the idx_c'th constructor */ accessor(constructorIdx: number, accessorIdx: number): FuncDecl; cast(other: CoercibleToExpr): DatatypeExpr; cast(other: DatatypeExpr): DatatypeExpr; } /** * Represents expressions of datatype sorts. * * @category Datatypes */ export interface DatatypeExpr extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'DatatypeExpr'; } /** * Floating-point rounding mode sort * @category Floating-Point */ export interface FPRMSort extends Sort { /** @hidden */ readonly __typename: 'FPRMSort'; cast(other: FPRM): FPRM; cast(other: CoercibleToExpr): never; } /** * Floating-point sort (IEEE 754) * @category Floating-Point */ export interface FPSort extends Sort { /** @hidden */ readonly __typename: 'FPSort'; /** * Number of exponent bits */ ebits(): number; /** * Number of significand bits (including hidden bit) */ sbits(): number; cast(other: CoercibleToFP): FP; cast(other: CoercibleToExpr): Expr; } /** @category Floating-Point */ export interface FPCreation { /** * Create a floating-point sort with custom exponent and significand bit sizes * @param ebits Number of exponent bits * @param sbits Number of significand bits (including hidden bit) */ sort(ebits: number, sbits: number): FPSort; /** * IEEE 754 16-bit floating-point sort (half precision) */ sort16(): FPSort; /** * IEEE 754 32-bit floating-point sort (single precision) */ sort32(): FPSort; /** * IEEE 754 64-bit floating-point sort (double precision) */ sort64(): FPSort; /** * IEEE 754 128-bit floating-point sort (quadruple precision) */ sort128(): FPSort; /** * Create a floating-point constant */ const(name: string, sort: FPSort): FP; /** * Create multiple floating-point constants */ consts(names: string | string[], sort: FPSort): FP[]; /** * Create a floating-point value from a number */ val(value: number, sort: FPSort): FPNum; /** * Create floating-point NaN */ NaN(sort: FPSort): FPNum; /** * Create floating-point infinity * @param negative If true, creates negative infinity */ inf(sort: FPSort, negative?: boolean): FPNum; /** * Create floating-point zero * @param negative If true, creates negative zero */ zero(sort: FPSort, negative?: boolean): FPNum; } /** @category Floating-Point */ export interface FPRMCreation { /** * Get the floating-point rounding mode sort */ sort(): FPRMSort; /** * Round nearest, ties to even (default rounding mode) */ RNE(): FPRM; /** * Round nearest, ties to away */ RNA(): FPRM; /** * Round toward positive infinity */ RTP(): FPRM; /** * Round toward negative infinity */ RTN(): FPRM; /** * Round toward zero */ RTZ(): FPRM; } /** * Floating-point rounding mode expression * @category Floating-Point */ export interface FPRM extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'FPRM'; } /** * Floating-point expression (IEEE 754) * @category Floating-Point */ export interface FP extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'FP' | FPNum['__typename']; /** @category Arithmetic */ add(rm: FPRM, other: CoercibleToFP): FP; /** @category Arithmetic */ sub(rm: FPRM, other: CoercibleToFP): FP; /** @category Arithmetic */ mul(rm: FPRM, other: CoercibleToFP): FP; /** @category Arithmetic */ div(rm: FPRM, other: CoercibleToFP): FP; /** @category Arithmetic */ neg(): FP; /** @category Arithmetic */ abs(): FP; /** @category Arithmetic */ sqrt(rm: FPRM): FP; /** @category Arithmetic */ rem(other: CoercibleToFP): FP; /** @category Arithmetic */ fma(rm: FPRM, y: CoercibleToFP, z: CoercibleToFP): FP; /** @category Comparison */ lt(other: CoercibleToFP): Bool; /** @category Comparison */ gt(other: CoercibleToFP): Bool; /** @category Comparison */ le(other: CoercibleToFP): Bool; /** @category Comparison */ ge(other: CoercibleToFP): Bool; /** @category Predicates */ isNaN(): Bool; /** @category Predicates */ isInf(): Bool; /** @category Predicates */ isZero(): Bool; /** @category Predicates */ isNormal(): Bool; /** @category Predicates */ isSubnormal(): Bool; /** @category Predicates */ isNegative(): Bool; /** @category Predicates */ isPositive(): Bool; } /** * Floating-point numeral value * @category Floating-Point */ export interface FPNum extends FP { /** @hidden */ readonly __typename: 'FPNum'; /** * Get the floating-point value as a JavaScript number * Note: May lose precision for values outside JavaScript number range */ value(): number; } /** * Sequence sort (can be string or sequence of any element type) * @category String/Sequence */ export interface SeqSort = Sort> extends Sort { /** @hidden */ readonly __typename: 'SeqSort'; /** * Check if this is a string sort */ isString(): boolean; /** * Get the element sort of this sequence */ basis(): Sort; cast(other: Seq): Seq; cast(other: string): Seq; cast(other: CoercibleToExpr): Expr; } /** @category String/Sequence */ export interface StringCreation { /** * Create a string sort */ sort(): SeqSort; /** * Create a string constant */ const(name: string): Seq; /** * Create multiple string constants */ consts(names: string | string[]): Seq[]; /** * Create a string value */ val(value: string): Seq; } /** @category String/Sequence */ export interface SeqCreation { /** * Create a sequence sort over the given element sort */ sort>(elemSort: ElemSort): SeqSort; /** * Create an empty sequence */ empty>(elemSort: ElemSort): Seq; /** * Create a unit sequence (sequence with single element) */ unit>(elem: Expr): Seq; } /** * Sequence expression (includes strings) * @category String/Sequence */ export interface Seq = Sort> extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'Seq'; /** * Check if this is a string value */ isString(): boolean; /** * Get string value if this is a concrete string */ asString(): string; /** @category Operations */ concat(other: Seq | string): Seq; /** @category Operations */ length(): Arith; /** @category Operations */ at(index: Arith | number | bigint): Seq; /** @category Operations */ nth(index: Arith | number | bigint): Expr; /** @category Operations */ extract(offset: Arith | number | bigint, length: Arith | number | bigint): Seq; /** @category Operations */ indexOf(substr: Seq | string, offset?: Arith | number | bigint): Arith; /** @category Operations */ lastIndexOf(substr: Seq | string): Arith; /** @category Operations */ contains(substr: Seq | string): Bool; /** @category Operations */ prefixOf(s: Seq | string): Bool; /** @category Operations */ suffixOf(s: Seq | string): Bool; /** @category Operations */ replace(src: Seq | string, dst: Seq | string): Seq; /** @category Operations */ replaceAll(src: Seq | string, dst: Seq | string): Seq; } /** * Regular expression sort * @category RegularExpression */ export interface ReSort = SeqSort> extends Sort { /** @hidden */ readonly __typename: 'ReSort'; /** * Get the basis (underlying sequence sort) of this regular expression sort */ basis(): SeqSortRef; cast(other: Re): Re; cast(other: CoercibleToExpr): Expr; } /** @category RegularExpression */ export interface ReCreation { /** * Create a regular expression sort over the given sequence sort */ sort>(seqSort: SeqSortRef): ReSort; /** * Convert a sequence to a regular expression that accepts exactly that sequence */ toRe(seq: Seq | string): Re; } /** * Regular expression expression * @category RegularExpression */ export interface Re = SeqSort> extends Expr, Z3_ast> { /** @hidden */ readonly __typename: 'Re'; /** @category Operations */ plus(): Re; /** @category Operations */ star(): Re; /** @category Operations */ option(): Re; /** @category Operations */ complement(): Re; /** @category Operations */ union(other: Re): Re; /** @category Operations */ intersect(other: Re): Re; /** @category Operations */ diff(other: Re): Re; /** @category Operations */ concat(other: Re): Re; /** * Create a bounded repetition of this regex * @param lo Minimum number of repetitions * @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo) * @category Operations */ loop(lo: number, hi?: number): Re; /** @category Operations */ power(n: number): Re; } /** * Defines the expression type of the body of a quantifier expression * * @category Quantifiers */ export type BodyT = [Sort, ...Sort[]], QSort extends BoolSort | SMTArraySort = BoolSort | SMTArraySort> = QSort extends BoolSort ? Bool : QSort extends SMTArray ? SortToExprMap : never; /** @category Quantifiers */ export interface Quantifier = [Sort, ...Sort[]], QSort extends BoolSort | SMTArraySort = BoolSort | SMTArraySort> extends Expr { readonly __typename: 'NonLambdaQuantifier' | 'Lambda'; is_forall(): boolean; is_exists(): boolean; is_lambda(): boolean; weight(): number; num_patterns(): number; pattern(i: number): Pattern; num_no_patterns(): number; no_pattern(i: number): Expr; body(): BodyT; num_vars(): number; var_name(i: number): string | number; var_sort(i: T): QVarSorts[T]; children(): [BodyT]; } /** @hidden */ export interface GoalCtor { new (models?: boolean, unsat_cores?: boolean, proofs?: boolean): Goal; } /** * Goal is a collection of constraints we want to find a solution or show to be unsatisfiable. * Goals are processed using Tactics. A Tactic transforms a goal into a set of subgoals. * @category Tactics */ export interface Goal { /** @hidden */ readonly __typename: 'Goal'; readonly ctx: Context; readonly ptr: Z3_goal; /** * Add constraints to the goal. */ add(...constraints: (Bool | boolean)[]): void; /** * Return the number of constraints in the goal. */ size(): number; /** * Return a constraint from the goal at the given index. */ get(i: number): Bool; /** * Return the depth of the goal (number of tactics applied). */ depth(): number; /** * Return true if the goal contains the False constraint. */ inconsistent(): boolean; /** * Return the precision of the goal (precise, under-approximation, over-approximation). */ precision(): Z3_goal_prec; /** * Reset the goal to empty. */ reset(): void; /** * Return the number of expressions in the goal. */ numExprs(): number; /** * Return true if the goal is decided to be satisfiable. */ isDecidedSat(): boolean; /** * Return true if the goal is decided to be unsatisfiable. */ isDecidedUnsat(): boolean; /** * Convert a model for the goal to a model for the original goal. */ convertModel(model: Model): Model; /** * Convert the goal to a single Boolean expression (conjunction of all constraints). */ asExpr(): Bool; /** * Return a string representation of the goal. */ toString(): string; /** * Return a DIMACS string representation of the goal. */ dimacs(includeNames?: boolean): string; } /** * ApplyResult contains the subgoals produced by applying a tactic to a goal. * @category Tactics */ export interface ApplyResult { /** @hidden */ readonly __typename: 'ApplyResult'; readonly ctx: Context; readonly ptr: Z3_apply_result; /** * Return the number of subgoals in the result. */ length(): number; /** * Return a subgoal at the given index. */ getSubgoal(i: number): Goal; /** * Return a string representation of the apply result. */ toString(): string; /** * Get subgoal at index (alias for getSubgoal). */ [index: number]: Goal; } export interface Probe { /** @hidden */ readonly __typename: 'Probe'; readonly ctx: Context; readonly ptr: Z3_probe; /** * Apply the probe to a goal and return the result as a number. */ apply(goal: Goal): number; } /** @hidden */ export interface TacticCtor { new (name: string): Tactic; } export interface Tactic { /** @hidden */ readonly __typename: 'Tactic'; readonly ctx: Context; readonly ptr: Z3_tactic; /** * Apply the tactic to a goal and return the resulting subgoals. */ apply(goal: Goal | Bool): Promise>; /** * Create a solver from this tactic. * The solver will always solve each check() from scratch using this tactic. */ solver(): Solver; /** * Get help string describing the tactic. */ help(): string; /** * Get parameter descriptions for the tactic. * Returns a ParamDescrs object for introspecting available parameters. */ paramDescrs(): ParamDescrs; /** * Return a tactic that uses the given configuration parameters. * @param params - Parameters to configure the tactic */ usingParams(params: Params): Tactic; } /** * Params is a set of parameters used to configure Solvers, Tactics and Simplifiers in Z3. * @category Tactics */ export interface Params { /** @hidden */ readonly __typename: 'Params'; readonly ctx: Context; readonly ptr: Z3_params; /** * Set a parameter with the given name and value. * @param name - Parameter name * @param value - Parameter value (boolean, number, or string) */ set(name: string, value: boolean | number | string): void; /** * Validate the parameter set against a parameter description set. * @param descrs - Parameter descriptions to validate against */ validate(descrs: ParamDescrs): void; /** * Convert the parameter set to a string representation. */ toString(): string; } /** @hidden */ export interface ParamsCtor { new (): Params; } /** * ParamDescrs is a set of parameter descriptions for Solvers, Tactics and Simplifiers in Z3. * @category Tactics */ export interface ParamDescrs { /** @hidden */ readonly __typename: 'ParamDescrs'; readonly ctx: Context; readonly ptr: Z3_param_descrs; /** * Return the number of parameters in the description set. */ size(): number; /** * Return the name of the parameter at the given index. * @param i - Index of the parameter */ getName(i: number): string; /** * Return the kind (type) of the parameter with the given name. * @param name - Parameter name */ getKind(name: string): number; /** * Return the documentation string for the parameter with the given name. * @param name - Parameter name */ getDocumentation(name: string): string; /** * Convert the parameter description set to a string representation. */ toString(): string; } /** * Simplifiers act as pre-processing utilities for solvers. * Build a custom simplifier and add it to a solver for incremental preprocessing. * @category Tactics */ export interface Simplifier { /** @hidden */ readonly __typename: 'Simplifier'; readonly ctx: Context; readonly ptr: Z3_simplifier; /** * Return a string containing a description of parameters accepted by this simplifier. */ help(): string; /** * Return the parameter description set for this simplifier. */ paramDescrs(): ParamDescrs; /** * Return a simplifier that uses the given configuration parameters. * @param params - Parameters to configure the simplifier */ usingParams(params: Params): Simplifier; /** * Return a simplifier that applies this simplifier and then another simplifier. * @param other - The simplifier to apply after this one */ andThen(other: Simplifier): Simplifier; } /** @hidden */ export interface SimplifierCtor { new (name: string): Simplifier; } /** @hidden */ export interface AstVectorCtor { new = AnyAst>(): AstVector; } /** * Stores multiple {@link Ast} objects * * ```typescript * const vector = new AstVector(); * vector.push(Bool.val(5)); * vector.push(Bool.const('x')) * * vector.length * // 2 * vector.get(1) * // x * [...vector.values()] * // [2, x] * ``` */ export interface AstVector = AnyAst> extends Iterable { /** @hidden */ readonly __typename: 'AstVector'; readonly ctx: Context; readonly ptr: Z3_ast_vector; length(): number; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; get(i: number): Item; get(from: number, to: number): Item[]; set(i: number, v: Item): void; push(v: Item): void; resize(size: number): void; has(v: Item): boolean; sexpr(): string; } /** @hidden */ export interface AstMapCtor { new = AnyAst, Value extends Ast = AnyAst>(): AstMap; } /** * Stores a mapping between different {@link Ast} objects * * ```typescript * const map = new Map(); * const x = Int.const('x') * const y = Int.const('y') * map.set(x, Bool.val(true)) * map.Set(y, Bool.val(false)) * * map.size * // 2 * map.has(x) * // true * [...map.entries()] * // [[x, true], [y, false]] * map.clear() * map.size * // 0 * ``` */ export interface AstMap = AnyAst, Value extends Ast = AnyAst> extends Iterable<[Key, Value]> { /** @hidden */ readonly __typename: 'AstMap'; readonly ctx: Context; readonly ptr: Z3_ast_map; get size(): number; entries(): IterableIterator<[Key, Value]>; keys(): AstVector; values(): IterableIterator; get(key: Key): Value | undefined; set(key: Key, value: Value): void; delete(key: Key): void; clear(): void; has(key: Key): boolean; sexpr(): string; } /** * @category Global */ export interface Z3HighLevel { enableTrace(tag: string): void; disableTrace(tag: string): void; getVersion(): { major: number; minor: number; build_number: number; revision_number: number; }; getVersionString(): string; getFullVersion(): string; openLog(filename: string): boolean; appendLog(s: string): void; /** * Set a Z3 parameter * * ```typescript * setParam('pp.decimal', true); * ``` */ setParam(key: string, value: any): void; /** * Set multiple Z3 parameters at once * * ```typescript * setParam({ * 'pp.decimal': true, * 'pp.decimal_precision': 20 * }); * ``` */ setParam(key: Record): void; /** * Resets all Z3 parameters */ resetParams(): void; /** * Returns a global Z3 parameter */ getParam(name: string): string | null; /** * Use this to create new contexts * @see {@link Context} */ readonly Context: ContextCtor; }