mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 19:52:29 +00:00 
			
		
		
		
	Added FreshFunction to Python bindings.
All other declarations can be done use appropriate Fresh*() call, or FreshConst() with a desired sort, except Functions. I've added the abillity to do that in Python bindings using already existing APIs
This commit is contained in:
		
							parent
							
								
									55f62fcaed
								
							
						
					
					
						commit
						876d7c92fb
					
				
					 1 changed files with 23 additions and 0 deletions
				
			
		|  | @ -818,6 +818,29 @@ def Function(name, *sig): | |||
|     ctx = rng.ctx | ||||
|     return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx) | ||||
| 
 | ||||
| def FreshFunction(*sig): | ||||
|     """Create a new fresh Z3 uninterpreted function with the given sorts. | ||||
| 
 | ||||
|     >>> f = FreshFunction(IntSort(), IntSort()) | ||||
|     >>> f(f(0)) | ||||
|     f!0(f!0(0)) | ||||
|     """ | ||||
|     sig = _get_args(sig) | ||||
|     if z3_debug(): | ||||
|         _z3_assert(len(sig) > 0, "At least two arguments expected") | ||||
|     arity = len(sig) - 1 | ||||
|     rng = sig[arity] | ||||
|     if z3_debug(): | ||||
|         _z3_assert(is_sort(rng), "Z3 sort expected") | ||||
|     dom = (z3.Sort * arity)() | ||||
|     for i in range(arity): | ||||
|         if z3_debug(): | ||||
|             _z3_assert(is_sort(sig[i]), "Z3 sort expected") | ||||
|         dom[i] = sig[i].ast | ||||
|     ctx = rng.ctx | ||||
|     return FuncDeclRef(Z3_mk_fresh_func_decl(ctx.ref(), 'f', arity, dom, rng.ast), ctx) | ||||
| 
 | ||||
| 
 | ||||
| def _to_func_decl_ref(a, ctx): | ||||
|     return FuncDeclRef(a, ctx) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue