本文整理汇总了C#中Microsoft.Z3.FuncDecl类的典型用法代码示例。如果您正苦于以下问题:C# FuncDecl类的具体用法?C# FuncDecl怎么用?C# FuncDecl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FuncDecl类属于Microsoft.Z3命名空间,在下文中一共展示了FuncDecl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AcceptorBase
internal AcceptorBase(FuncDecl symbol, Expr guard, ExprSet[] lookahead)
{
this.symbol = symbol;
this.guard = guard;
this.lookahead = lookahead;
this.lhs = new Pair<FuncDecl, Sequence<ExprSet>>(symbol, new Sequence<ExprSet>(lookahead));
}
示例2: RegisterRelation
/// <summary>
/// Register predicate as recursive relation.
/// </summary>
public void RegisterRelation(FuncDecl f)
{
Contract.Requires(f != null);
Context.CheckContextMatch(f);
Native.Z3_fixedpoint_register_relation(Context.nCtx, NativeObject, f.NativeObject);
}
示例3: AddFuncDecl
internal void AddFuncDecl(FuncDecl funcDecl, string name, params object[] keys)
{
object[] objs = new object[keys.Length + 1];
objs[0] = name;
Array.Copy(keys, 0, objs, 1, keys.Length);
var s = new Sequence<object>(objs);
funcDecls.Add(new Sequence<object>(objs), funcDecl);
}
示例4: BinaryTreeInfo
public BinaryTreeInfo(FuncDecl mkTree, FuncDecl mkLeaf,
FuncDecl getLeafValue, FuncDecl isTree, FuncDecl isLeaf,
FuncDecl getLeft, FuncDecl getRight)
{
this.MkTree = mkTree;
this.GetLeft = getLeft;
this.GetRight = getRight;
this.MkLeaf = mkLeaf;
this.GetLeafValue = getLeafValue;
this.IsTree = isTree;
this.IsLeaf = isLeaf;
}
示例5: InjAxiom
/// <summary>
/// Create axiom: function f is injective in the i-th argument.
/// </summary>
/// <remarks>
/// The following axiom is produced:
/// <c>
/// forall (x_0, ..., x_n) finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i
/// </c>
/// Where, <code>finv</code>is a fresh function declaration.
/// </summary>
public static BoolExpr InjAxiom(Context ctx, FuncDecl f, int i)
{
Sort[] domain = f.Domain;
uint sz = f.DomainSize;
if (i >= sz)
{
Console.WriteLine("failed to create inj axiom");
return null;
}
/* declare the i-th inverse of f: finv */
Sort finv_domain = f.Range;
Sort finv_range = domain[i];
FuncDecl finv = ctx.MkFuncDecl("f_fresh", finv_domain, finv_range);
/* allocate temporary arrays */
Expr[] xs = new Expr[sz];
Symbol[] names = new Symbol[sz];
Sort[] types = new Sort[sz];
/* fill types, names and xs */
for (uint j = 0; j < sz; j++)
{
types[j] = domain[j];
names[j] = ctx.MkSymbol(String.Format("x_{0}", j));
xs[j] = ctx.MkBound(j, types[j]);
}
Expr x_i = xs[i];
/* create f(x_0, ..., x_i, ..., x_{n-1}) */
Expr fxs = f[xs];
/* create f_inv(f(x_0, ..., x_i, ..., x_{n-1})) */
Expr finv_fxs = finv[fxs];
/* create finv(f(x_0, ..., x_i, ..., x_{n-1})) = x_i */
Expr eq = ctx.MkEq(finv_fxs, x_i);
/* use f(x_0, ..., x_i, ..., x_{n-1}) as the pattern for the quantifier */
Pattern p = ctx.MkPattern(new Expr[] { fxs });
/* create & assert quantifier */
BoolExpr q = ctx.MkForall(
types, /* types of quantified variables */
names, /* names of quantified variables */
eq,
1,
new Pattern[] { p } /* patterns */);
return q;
}
示例6: TryGetFuncDecl
internal bool TryGetFuncDecl(out FuncDecl funcDecl, string name, params object[] keys)
{
object[] objs = new object[keys.Length + 1];
objs[0] = name;
Array.Copy(keys, 0, objs, 1, keys.Length);
Sequence<object> s = new Sequence<object>(objs);
if (funcDecls.TryGetValue(s, out funcDecl))
return true;
funcDecl = null;
return false;
}
示例7: ConstInterp
/// <summary>
/// Retrieves the interpretation (the assignment) of <paramref name="f"/> in the model.
/// </summary>
/// <param name="f">A function declaration of zero arity</param>
/// <returns>An expression if the function has an interpretation in the model, null otherwise.</returns>
public Expr ConstInterp(FuncDecl f)
{
Contract.Requires(f != null);
Context.CheckContextMatch(f);
if (f.Arity != 0 ||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f.NativeObject)) == (uint)Z3_sort_kind.Z3_ARRAY_SORT)
throw new Z3Exception("Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp.");
IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject);
if (n == IntPtr.Zero)
return null;
else
return Expr.Create(Context, n);
}
示例8: RankedAlphabet
internal RankedAlphabet(
TreeTheory tt,
string[] symbols,
Dictionary<string, int> idMap,
Sort alphabetSort,
Sort nodeSort,
int[] ranks,
FuncDecl[] constructors,
FuncDecl[][] accessors,
FuncDecl[] testers,
FuncDecl acceptor,
Expr[] vars
)
{
this.tt = tt;
this.symbols = new List<string>(symbols).AsReadOnly();
this.idMap = idMap;
this.alphabetSort = alphabetSort;
this.nodeSort = nodeSort;
this.ranks = ranks;
this.constructors = constructors;
this.accessors = accessors;
this.testers = testers;
this.acceptor = acceptor;
this.vars = vars;
this.trans = tt.GetTrans(alphabetSort, alphabetSort);
this.emptyAcceptor = TreeTransducer.MkEmpty(this);
this.fullAcceptor = TreeTransducer.MkFull(this);
this.idAut = TreeTransducer.MkId(this);
this.symbolsOfRank = new Dictionary<int, List<FuncDecl>>();
for (int i = 0; i < ranks.Length; i++)
{
var r = ranks[i];
if (!symbolsOfRank.ContainsKey(r))
symbolsOfRank[r] = new List<FuncDecl>();
symbolsOfRank[r].Add(constructors[i]);
}
var attrDomain = tt.Z.MkFreshFuncDecl("_", new Sort[] { nodeSort }, tt.Z.BoolSort);
this.attrExpr = tt.Z.MkApp(attrDomain, vars[0]);
tt.Z.AssertAxiom(this.attrExpr, tt.Z.True, vars[0]);
}
示例9: UnrankedTreeInfo
public UnrankedTreeInfo(Sort treeListSort, FuncDecl getNodeValue, FuncDecl getSubtrees, FuncDecl mkNode,
FuncDecl mkLeaf, FuncDecl getLeafValue, FuncDecl isNode, FuncDecl isLeaf,
Expr empty, FuncDecl first, FuncDecl rest,
FuncDecl cons, FuncDecl isEmpty, FuncDecl isCons)
{
this.TreeListSort = treeListSort;
this.GetNodeLabel = getNodeValue;
this.GetNodeSubtrees = getSubtrees;
this.MkNode = mkNode;
this.EmptyTreeList = empty;
this.GetFirst = first;
this.GetRest = rest;
this.MkCons = cons;
this.IsEmpty = isEmpty;
this.IsCons = isCons;
this.MkLeaf = mkLeaf;
this.GetLeafValue = getLeafValue;
this.IsNode = isNode;
this.IsLeaf = isLeaf;
}
示例10: FuncInterp
/// <summary>
/// Retrieves the interpretation (the assignment) of a non-constant <paramref name="f"/> in the model.
/// </summary>
/// <param name="f">A function declaration of non-zero arity</param>
/// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns>
public FuncInterp FuncInterp(FuncDecl f)
{
Contract.Requires(f != null);
Context.CheckContextMatch(f);
Z3_sort_kind sk = (Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_range(Context.nCtx, f.NativeObject));
if (f.Arity == 0)
{
IntPtr n = Native.Z3_model_get_const_interp(Context.nCtx, NativeObject, f.NativeObject);
if (sk == Z3_sort_kind.Z3_ARRAY_SORT)
{
if (n == IntPtr.Zero)
return null;
else
{
if (Native.Z3_is_as_array(Context.nCtx, n) == 0)
throw new Z3Exception("Argument was not an array constant");
IntPtr fd = Native.Z3_get_as_array_func_decl(Context.nCtx, n);
return FuncInterp(new FuncDecl(Context, fd));
}
}
else
{
throw new Z3Exception("Constant functions do not have a function interpretation; use ConstInterp");
}
}
else
{
IntPtr n = Native.Z3_model_get_func_interp(Context.nCtx, NativeObject, f.NativeObject);
if (n == IntPtr.Zero)
return null;
else
return new FuncInterp(Context, n);
}
}
示例11: Parameter
internal Parameter(Z3_parameter_kind k, FuncDecl fd)
{
this.kind = k;
this.fd = fd;
}
示例12: MkApp
/// <summary>
/// Create a new function application.
/// </summary>
public Expr MkApp(FuncDecl f, IEnumerable<Expr> args)
{
Contract.Requires(f != null);
Contract.Requires(args == null || Contract.ForAll(args, a => a != null));
Contract.Ensures(Contract.Result<Expr>() != null);
CheckContextMatch(f);
CheckContextMatch(args);
return Expr.Create(this, f, args.ToArray());
}
示例13: AddCover
/// <summary>
/// Add <tt>property</tt> about the <tt>predicate</tt>.
/// The property is added at <tt>level</tt>.
/// </summary>
public void AddCover(int level, FuncDecl predicate, Expr property)
{
Native.Z3_fixedpoint_add_cover(Context.nCtx, NativeObject, level, predicate.NativeObject, property.NativeObject);
}
示例14: SetPredicateRepresentation
/// <summary>
/// Instrument the Datalog engine on which table representation to use for recursive predicate.
/// </summary>
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds)
{
Contract.Requires(f != null);
Native.Z3_fixedpoint_set_predicate_representation(Context.nCtx, NativeObject,
f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds));
}
示例15: Query
/// <summary>
/// Query the fixedpoint solver.
/// A query is an array of relations.
/// The query is satisfiable if there is an instance of some relation that is non-empty.
/// The query is unsatisfiable if there are no derivations satisfying any of the relations.
/// </summary>
public Status Query(FuncDecl[] relations)
{
Contract.Requires(relations != null);
Contract.Requires(Contract.ForAll(0, relations.Length, i => relations[i] != null));
Context.CheckContextMatch(relations);
Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query_relations(Context.nCtx, NativeObject,
AST.ArrayLength(relations), AST.ArrayToNative(relations));
switch (r)
{
case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
default: return Status.UNKNOWN;
}
}