Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Properties
UserPropagator Class Reference

Propagator context for .Net. More...

+ Inheritance diagram for UserPropagator:

Public Member Functions

delegate void FixedEh (Expr term, Expr value)
 Delegate type for fixed callback Note that the life-time of the term and value only applies within the scope of the callback. That means the term and value cannot be stored in an array, dictionary or similar and accessed after the callback has returned. Use the functionality Dup on expressions to create a duplicate copy that extends the lifetime.
 
delegate void EqEh (Expr term, Expr value)
 Delegate type for equality or disequality callback.
 
delegate void CreatedEh (Expr term)
 Delegate type for when a new term using a registered function symbol is created internally.
 
delegate void DecideEh (Expr term, uint idx, bool phase)
 Delegate type for callback into solver's branching. The values can be overridden by calling NextSplit.
 
delegate bool OnBindingEh (Expr q, Expr inst)
 Delegate type for callback when a quantifier is bound to an instance.
 
 UserPropagator (Solver s)
 Propagator constructor from a solver class.
 
 UserPropagator (Context _ctx)
 Propagator constructor from a context. It is used from inside of Fresh.
 
virtual void Dispose ()
 Must be called. The object will not be garbage collected automatically even if the context is disposed.
 
virtual void Push ()
 Virtual method for push. It must be overwritten by inherited class.
 
virtual void Pop (uint n)
 Virtual method for pop. It must be overwritten by inherited class.
 
virtual UserPropagator Fresh (Context ctx)
 Virtual method for fresh. It can be overwritten by inherited class.
 
void Conflict (params Expr[] terms)
 Declare combination of assigned expressions a conflict.
 
void Conflict (IEnumerable< Expr > terms)
 Declare combination of assigned expressions a conflict.
 
bool Propagate (IEnumerable< Expr > terms, Expr conseq)
 Propagate consequence

Returns
true if the propagated expression is new for the solver; false if the propagation was ignored

 
bool Propagate (IEnumerable< Expr > terms, EqualityPairs equalities, Expr conseq)
 Propagate consequence

Returns
true if the propagated expression is new for the solver; false if the propagation was ignored

 
bool NextSplit (Expr e, uint idx, int phase)
 Set the next decision

Parameters
eA bit-vector or Boolean used for branching. Use null to clear
idxIf the term is a bit-vector, then an index into the bit-vector being branched on
phaseThe tentative truth-value (-1/false, 1/true, 0/let Z3 decide)

 
void Register (Expr term)
 Track assignments to a term.
 

Properties

FixedEh Fixed [set]
 Set fixed callback.
 
Action Final [set]
 Set final callback.
 
EqEh Eq [set]
 Set equality event callback.
 
EqEh Diseq [set]
 Set disequality event callback.
 
CreatedEh Created [set]
 Set created callback.
 
DecideEh Decide [set]
 Set decision callback.
 
OnBindingEh OnBinding [set]
 Set binding callback.
 

Detailed Description

Propagator context for .Net.


Definition at line 40 of file UserPropagator.cs.

Constructor & Destructor Documentation

◆ UserPropagator() [1/2]

UserPropagator ( Solver  s)
inline

Propagator constructor from a solver class.


Definition at line 204 of file UserPropagator.cs.

205 {
206 gch = GCHandle.Alloc(this);
207 solver = s;
208 ctx = solver.Context;
209 push_eh = _push;
210 pop_eh = _pop;
211 fresh_eh = _fresh;
212 Native.Z3_solver_propagate_init(ctx.nCtx, solver.NativeObject, GCHandle.ToIntPtr(gch), push_eh, pop_eh, fresh_eh);
213 }
Context Context
Access Context object.
Definition Z3Object.cs:111

◆ UserPropagator() [2/2]

UserPropagator ( Context  _ctx)
inline

Propagator constructor from a context. It is used from inside of Fresh.


Definition at line 218 of file UserPropagator.cs.

219 {
220 gch = GCHandle.Alloc(this);
221 solver = null;
222 ctx = _ctx;
223 }

Member Function Documentation

◆ Conflict() [1/2]

void Conflict ( IEnumerable< Expr terms)
inline

Declare combination of assigned expressions a conflict.

Definition at line 271 of file UserPropagator.cs.

272 {
273 Propagate(terms, ctx.MkFalse());
274 }
BoolExpr MkFalse()
The false Term.
Definition Context.cs:926
bool Propagate(IEnumerable< Expr > terms, Expr conseq)
Propagate consequence true if the propagated expression is new for the solver; false if the propagati...

◆ Conflict() [2/2]

void Conflict ( params Expr[]  terms)
inline

Declare combination of assigned expressions a conflict.

Definition at line 263 of file UserPropagator.cs.

264 {
265 Propagate(terms, ctx.MkFalse());
266 }

◆ CreatedEh()

delegate void CreatedEh ( Expr  term)

Delegate type for when a new term using a registered function symbol is created internally.


Referenced by UserPropagator.OnBindingEh().

◆ DecideEh()

delegate void DecideEh ( Expr  term,
uint  idx,
bool  phase 
)

Delegate type for callback into solver's branching. The values can be overridden by calling NextSplit.

Parameters
termA bit-vector or Boolean used for branching
idxIf the term is a bit-vector, then an index into the bit-vector being branched on
phaseThe tentative truth-value

Referenced by UserPropagator.OnBindingEh().

◆ Dispose()

virtual void Dispose ( )
inlinevirtual

Must be called. The object will not be garbage collected automatically even if the context is disposed.

Definition at line 236 of file UserPropagator.cs.

237 {
238 if (!gch.IsAllocated)
239 return;
240 gch.Free();
241 if (solver == null)
242 ctx.Dispose();
243 }
void Dispose()
Disposes of the context.
Definition Context.cs:4992

◆ EqEh()

delegate void EqEh ( Expr  term,
Expr  value 
)

Delegate type for equality or disequality callback.


Referenced by UserPropagator.OnBindingEh().

◆ FixedEh()

delegate void FixedEh ( Expr  term,
Expr  value 
)

Delegate type for fixed callback Note that the life-time of the term and value only applies within the scope of the callback. That means the term and value cannot be stored in an array, dictionary or similar and accessed after the callback has returned. Use the functionality Dup on expressions to create a duplicate copy that extends the lifetime.


Referenced by UserPropagator.OnBindingEh().

◆ Fresh()

virtual UserPropagator Fresh ( Context  ctx)
inlinevirtual

Virtual method for fresh. It can be overwritten by inherited class.

Definition at line 258 of file UserPropagator.cs.

258{ return new UserPropagator(ctx); }
UserPropagator(Solver s)
Propagator constructor from a solver class.

◆ NextSplit()

bool NextSplit ( Expr  e,
uint  idx,
int  phase 
)
inline

Set the next decision

Parameters
eA bit-vector or Boolean used for branching. Use null to clear
idxIf the term is a bit-vector, then an index into the bit-vector being branched on
phaseThe tentative truth-value (-1/false, 1/true, 0/let Z3 decide)

Returns
true in case the value was successfully set; false if the next split could not be set

Definition at line 413 of file UserPropagator.cs.

414 {
415 return Native.Z3_solver_next_split(ctx.nCtx, this.callback, e?.NativeObject ?? IntPtr.Zero, idx, phase) != 0;
416 }

◆ OnBindingEh()

delegate bool OnBindingEh ( Expr  q,
Expr  inst 
)

Delegate type for callback when a quantifier is bound to an instance.

Parameters
qQuantifier
instInstance
Returns
true if binding is allowed to take effect in the solver, false if blocked by callback

Referenced by UserPropagator.OnBindingEh().

◆ Pop()

virtual void Pop ( uint  n)
inlinevirtual

Virtual method for pop. It must be overwritten by inherited class.


Definition at line 253 of file UserPropagator.cs.

253{ throw new Z3Exception("Pop method should be overwritten"); }

◆ Propagate() [1/2]

bool Propagate ( IEnumerable< Expr terms,
EqualityPairs  equalities,
Expr  conseq 
)
inline

Propagate consequence

Returns
true if the propagated expression is new for the solver; false if the propagation was ignored

Definition at line 295 of file UserPropagator.cs.

296 {
297 var nTerms = Z3Object.ArrayToNative(terms.ToArray());
298 var nLHS = Z3Object.ArrayToNative(equalities.LHS.ToArray());
299 var nRHS = Z3Object.ArrayToNative(equalities.RHS.ToArray());
300 return Native.Z3_solver_propagate_consequence(ctx.nCtx, this.callback, (uint)nTerms.Length, nTerms, (uint)equalities.Count, nLHS, nRHS, conseq.NativeObject) != 0;
301 }

◆ Propagate() [2/2]

bool Propagate ( IEnumerable< Expr terms,
Expr  conseq 
)
inline

Propagate consequence

Returns
true if the propagated expression is new for the solver; false if the propagation was ignored

Definition at line 283 of file UserPropagator.cs.

284 {
285 return Propagate(terms, new EqualityPairs(), conseq);
286 }

Referenced by UserPropagator.Conflict(), UserPropagator.Conflict(), and UserPropagator.Propagate().

◆ Push()

virtual void Push ( )
inlinevirtual

Virtual method for push. It must be overwritten by inherited class.


Definition at line 248 of file UserPropagator.cs.

248{ throw new Z3Exception("Push method should be overwritten"); }

◆ Register()

void Register ( Expr  term)
inline

Track assignments to a term.

Definition at line 423 of file UserPropagator.cs.

424 {
425 if (this.callback != IntPtr.Zero)
426 {
427 Native.Z3_solver_propagate_register_cb(ctx.nCtx, callback, term.NativeObject);
428 }
429 else
430 {
431 Native.Z3_solver_propagate_register(ctx.nCtx, solver.NativeObject, term.NativeObject);
432 }
433 }

Property Documentation

◆ Created

CreatedEh Created
set

Set created callback.

Definition at line 363 of file UserPropagator.cs.

364 {
365 set
366 {
367 this.created_wrapper = _created;
368 this.created_eh = value;
369 if (solver != null)
370 Native.Z3_solver_propagate_created(ctx.nCtx, solver.NativeObject, created_wrapper);
371 }
372 }

◆ Decide

DecideEh Decide
set

Set decision callback.

Definition at line 377 of file UserPropagator.cs.

378 {
379 set
380 {
381 this.decide_wrapper = _decide;
382 this.decide_eh = value;
383 if (solver != null)
384 Native.Z3_solver_propagate_decide(ctx.nCtx, solver.NativeObject, decide_wrapper);
385 }
386 }

◆ Diseq

EqEh Diseq
set

Set disequality event callback.

Definition at line 349 of file UserPropagator.cs.

350 {
351 set
352 {
353 this.diseq_wrapper = _diseq;
354 this.diseq_eh = value;
355 if (solver != null)
356 Native.Z3_solver_propagate_diseq(ctx.nCtx, solver.NativeObject, diseq_wrapper);
357 }
358 }

◆ Eq

EqEh Eq
set

Set equality event callback.

Definition at line 335 of file UserPropagator.cs.

336 {
337 set
338 {
339 this.eq_wrapper = _eq;
340 this.eq_eh = value;
341 if (solver != null)
342 Native.Z3_solver_propagate_eq(ctx.nCtx, solver.NativeObject, eq_wrapper);
343 }
344 }

◆ Final

Action Final
set

Set final callback.

Definition at line 321 of file UserPropagator.cs.

322 {
323 set
324 {
325 this.final_wrapper = _final;
326 this.final_eh = value;
327 if (solver != null)
328 Native.Z3_solver_propagate_final(ctx.nCtx, solver.NativeObject, final_wrapper);
329 }
330 }

◆ Fixed

FixedEh Fixed
set

Set fixed callback.

Definition at line 307 of file UserPropagator.cs.

308 {
309 set
310 {
311 this.fixed_wrapper = _fixed;
312 this.fixed_eh = value;
313 if (solver != null)
314 Native.Z3_solver_propagate_fixed(ctx.nCtx, solver.NativeObject, fixed_wrapper);
315 }
316 }

◆ OnBinding

OnBindingEh OnBinding
set

Set binding callback.

Definition at line 391 of file UserPropagator.cs.

392 {
393 set
394 {
395 this.on_binding_wrapper = _on_binding;
396 this.on_binding_eh = value;
397 if (solver != null)
398 Native.Z3_solver_propagate_on_binding(ctx.nCtx, solver.NativeObject, on_binding_wrapper);
399 }
400 }