本文整理汇总了C#中Microsoft.Z3.Context.MkRealSort方法的典型用法代码示例。如果您正苦于以下问题:C# Context.MkRealSort方法的具体用法?C# Context.MkRealSort怎么用?C# Context.MkRealSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Z3.Context
的用法示例。
在下文中一共展示了Context.MkRealSort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrAddMemberAccessFunction
internal static FuncDecl GetOrAddMemberAccessFunction(Context context, Environment environment, MemberInfo memberInfo)
{
FuncDecl memberFunc;
if (!environment.Members.TryGetValue(memberInfo, out memberFunc))
{
Sort memberTypeSort;
if (!environment.Types.TryGetValue(memberInfo.DeclaringType, out memberTypeSort))
{
throw new KeyNotFoundException(memberInfo.DeclaringType + " could not be found at environment.Types");
}
Sort memberReturnTypeEnumSort;
var propertyType = ((PropertyInfo)memberInfo).PropertyType;
if (propertyType == typeof(bool))
memberReturnTypeEnumSort = context.MkBoolSort();
else if (propertyType == typeof(int))
memberReturnTypeEnumSort = context.MkIntSort();
else if (propertyType == typeof(long))
memberReturnTypeEnumSort = context.MkRealSort();
else if (propertyType == typeof(string))
memberReturnTypeEnumSort = environment.PossibleStringValues;
else
{
if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
var listItemType = propertyType.GenericTypeArguments[0];
var listSort = context.MkSetSort(environment.Types[listItemType]);
memberReturnTypeEnumSort = listSort;
// TODO: add TryGetValue
environment.Types.Add(propertyType, listSort);
}
else if (propertyType.IsEnum)
{
EnumSort enumSort = context.MkEnumSort(propertyType.Name, Enum.GetNames(propertyType));
memberReturnTypeEnumSort = enumSort;
// TODO: add TryGetValue
environment.Types.Add(propertyType, enumSort);
}
else
{
// TODO throw exception if type is not supported
memberReturnTypeEnumSort = environment.Types[propertyType];
}
}
memberFunc = context.MkFuncDecl(memberInfo.Name, memberTypeSort, memberReturnTypeEnumSort);
environment.Members.Add(memberInfo, memberFunc);
}
return memberFunc;
}
示例2: ModelConverterTest
static void ModelConverterTest(Context ctx)
{
Console.WriteLine("ModelConverterTest");
ArithExpr xr = (ArithExpr)ctx.MkConst(ctx.MkSymbol("x"), ctx.MkRealSort());
ArithExpr yr = (ArithExpr)ctx.MkConst(ctx.MkSymbol("y"), ctx.MkRealSort());
Goal g4 = ctx.MkGoal(true);
g4.Assert(ctx.MkGt(xr, ctx.MkReal(10, 1)));
g4.Assert(ctx.MkEq(yr, ctx.MkAdd(xr, ctx.MkReal(1, 1))));
g4.Assert(ctx.MkGt(yr, ctx.MkReal(1, 1)));
ApplyResult ar = ApplyTactic(ctx, ctx.MkTactic("simplify"), g4);
if (ar.NumSubgoals == 1 && (ar.Subgoals[0].IsDecidedSat || ar.Subgoals[0].IsDecidedUnsat))
throw new TestFailedException();
ar = ApplyTactic(ctx, ctx.AndThen(ctx.MkTactic("simplify"), ctx.MkTactic("solve-eqs")), g4);
if (ar.NumSubgoals == 1 && (ar.Subgoals[0].IsDecidedSat || ar.Subgoals[0].IsDecidedUnsat))
throw new TestFailedException();
Solver s = ctx.MkSolver();
foreach (BoolExpr e in ar.Subgoals[0].Formulas)
s.Assert(e);
Status q = s.Check();
Console.WriteLine("Solver says: " + q);
Console.WriteLine("Model: \n" + s.Model);
Console.WriteLine("Converted Model: \n" + ar.ConvertModel(0, s.Model));
if (q != Status.SATISFIABLE)
throw new TestFailedException();
}