3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-15 13:21:50 +00:00

Add missing API methods across language bindings (#8150)

* Initial plan

* Add API coherence improvements for C#, Python, C++, and TypeScript

- C#: Add SubstituteFuns method to Expr class
- Python: Add update method to ExprRef class
- C++: Add update method to expr class
- TypeScript: Add complete Statistics API with Statistics interface, StatisticsEntry interface, StatisticsImpl class, and statistics() methods for Solver, Optimize, and Fixedpoint

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add Z3_stats import and Statistics types to TypeScript bindings

- Add Z3_stats to imports in types.ts and high-level.ts
- Add Statistics and StatisticsEntry to type imports in high-level.ts
- Fixes missing type references identified in code review

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-11 10:01:04 -08:00 committed by GitHub
parent 6c90b7ec3f
commit 319db5dbb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 258 additions and 0 deletions

View file

@ -159,6 +159,28 @@ namespace Microsoft.Z3
return Expr.Create(Context, Native.Z3_substitute_vars(Context.nCtx, NativeObject, (uint)to.Length, Expr.ArrayToNative(to)));
}
/// <summary>
/// Substitute functions in <paramref name="from"/> with the expressions in <paramref name="to"/>.
/// </summary>
/// <remarks>
/// The expressions in <paramref name="to"/> can have free variables. The free variable in <c>to[i]</c> at de-Bruijn index 0
/// refers to the first argument of <c>from[i]</c>, the free variable at index 1 corresponds to the second argument, and so on.
/// The arrays <paramref name="from"/> and <paramref name="to"/> must have the same size.
/// </remarks>
public Expr SubstituteFuns(FuncDecl[] from, Expr[] to)
{
Debug.Assert(from != null);
Debug.Assert(to != null);
Debug.Assert(from.All(f => f != null));
Debug.Assert(to.All(t => t != null));
Context.CheckContextMatch<FuncDecl>(from);
Context.CheckContextMatch<Expr>(to);
if (from.Length != to.Length)
throw new Z3Exception("Arrays 'from' and 'to' must have the same length");
return Expr.Create(Context, Native.Z3_substitute_funs(Context.nCtx, NativeObject, (uint)from.Length, FuncDecl.ArrayToNative(from), Expr.ArrayToNative(to)));
}
/// <summary>
/// Translates (copies) the term to the Context <paramref name="ctx"/>.
/// </summary>