本文整理汇总了C#中Z3Provider.GetNumeralInt方法的典型用法代码示例。如果您正苦于以下问题:C# Z3Provider.GetNumeralInt方法的具体用法?C# Z3Provider.GetNumeralInt怎么用?C# Z3Provider.GetNumeralInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Z3Provider
的用法示例。
在下文中一共展示了Z3Provider.GetNumeralInt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HexProjTest
public void HexProjTest()
{
Z3Provider z3p = new Z3Provider();
//Sort bv64 = z3p.MkBitVecSort(64);
Sort sort = z3p.MkBitVecSort(64);
Expr _0x654321 = z3p.MkNumeral((uint)0x654321, sort);
Expr _5 = z3p.MkHexProj(4, _0x654321, sort).Simplify();
Expr _4 = z3p.MkHexProj(3, _0x654321, sort).Simplify();
Expr _3 = z3p.MkHexProj(2, _0x654321, sort).Simplify();
Expr _2 = z3p.MkHexProj(1, _0x654321, sort).Simplify();
Expr _1 = z3p.MkHexProj(0, _0x654321, sort).Simplify();
int _5v = (int)z3p.GetNumeralInt(_5);
int _4v = (int)z3p.GetNumeralInt(_4);
int _3v = (int)z3p.GetNumeralInt(_3);
int _2v = (int)z3p.GetNumeralInt(_2);
int _1v = (int)z3p.GetNumeralInt(_1);
Assert.AreEqual<int>(5, _5v);
Assert.AreEqual<int>(4, _4v);
Assert.AreEqual<int>(3, _3v);
Assert.AreEqual<int>(2, _2v);
Assert.AreEqual<int>(1, _1v);
}
示例2: GetDTAMINFormatString
public static string GetDTAMINFormatString(TreeTransducer aut)
{
Z3Provider Z = new Z3Provider();
StringBuilder sb = new StringBuilder();
var transition = aut.GetRules();
foreach (var rule in transition)
{
sb.Append(Z.GetNumeralInt(rule.State) + 1);
sb.Append(" ");
sb.Append(rule.Symbol.Name.ToString());
for (int j = 1; j <= rule.Rank; j++)
{
var args_j = rule.Lookahead(j - 1);
if (args_j.ToList().Count > 1)
throw new Exception("Some i has more than one state");
foreach (var rlastate in args_j)
{
sb.Append(" ");
sb.Append(Z.GetNumeralInt(rlastate)+1);
}
}
sb.AppendLine();
}
int c = 0;
foreach (var st in aut.roots)
{
if(c==aut.roots.Count-1)
sb.Append("0 " + (Z.GetNumeralInt(st) + 1));
else
sb.AppendLine("0 " + (Z.GetNumeralInt(st) + 1));
c++;
}
return sb.ToString();
}
示例3: TestPositionConflictMiddle
public void TestPositionConflictMiddle()
{
string bek1 = @"
program decode(input) {
return iter(c in input)[pc := 0;]{
case ((pc == 0) && (c == 'a')) :
pc := 1;
yield (c,c+1);
case ((pc == 1) && ((c == 'b') || (c == 'd'))) :
pc := 1;
yield (c,c);
case ((pc == 1) && (c == 'a')) :
pc := 2;
yield (c);
case (true):
raise Error;
} end {
case (pc == 2):
yield ('a');
case (true):
raise Error;
};
}
";
string bek2 = @"
program decode(input) {
return iter(c in input)[pc := 0;]{
case ((pc == 0) && (c == 'a')) :
pc := 1;
yield (c);
case ((pc == 1) && ((c == 'b') || (c == 'd'))) :
pc := 1;
yield (c,c);
case ((pc == 1) && (c == 'a')) :
pc := 2;
yield (c+1,c);
case (true):
raise Error;
} end {
case (pc == 2):
yield ('a');
case (true):
raise Error;
};
}
";
Z3Provider solver = new Z3Provider(BitWidth.BV16);
Func<IEnumerable<Expr>, string> GetString = w =>
{
return new String(Array.ConvertAll(new List<Expr>(w).ToArray(), x => (char)solver.GetNumeralInt(x)));
};
var A = BekConverter.BekToSTb(solver, bek1).ExploreBools().ToST().Explore();
var B = BekConverter.BekToSTb(solver, bek2).ExploreBools().ToST().Explore();
var witness = A.Neq1(B);
Assert.IsFalse(witness == null);
var inp = GetString(witness);
var out1 = GetString(A.Apply(witness));
var out2 = GetString(B.Apply(witness));
Assert.AreNotEqual<string>(out1, out2);
}
示例4: TestPositionConflict2
public void TestPositionConflict2()
{
string bek1 = @"
program decode(input){
replace {
""&"" ==> ""&"";
""<"" ==> ""<"";
"">"" ==> "">"";
@""&\d{3}$"" ==> [(#1|#2)|#3];
else ==> [#0];
}
}
";
string bek2 = @"
program decode(input){
replace {
""&"" ==> ""&"";
""<"" ==> ""<"";
"">"" ==> "">"";
@""&[0-9]{3}$"" ==> [(#1|#2)|#3];
else ==> [#0];
}
}
";
Tuple<int, string> foo = Tuple.Create(34, "abc");
Tuple<int, string> bar = Tuple.Create(34, "ab" + "c");
bool b = foo.Equals(bar);
Z3Provider solver = new Z3Provider(BitWidth.BV16);
var d1 = BekConverter.BekToSTb(solver, bek1).ToST();
var d2 = BekConverter.BekToSTb(solver, bek2).ToST();
var witness = d1.Neq1(d2);
Assert.IsFalse(witness == null);
var inp = new String(Array.ConvertAll(witness.ToArray(), x => (char)solver.GetNumeralInt(x)));
var out1 = new String(Array.ConvertAll(new List<Expr>(d1.Apply(witness)).ToArray(), x => (char)solver.GetNumeralInt(x)));
var out2 = new String(Array.ConvertAll(new List<Expr>(d2.Apply(witness)).ToArray(), x => (char)solver.GetNumeralInt(x)));
solver.Dispose();
Assert.AreNotEqual<string>(out1, out2);
}
示例5: TestPositionConflict
public void TestPositionConflict()
{
string bek1 = @"
program decode(input){
replace {
""&"" ==> ""&"";
""<"" ==> ""<"";
"">"" ==> "">"";
else ==> [#0];
}
}
";
string bek2 = @"
program decode(input){
replace {
""&"" ==> ""&"";
""<"" ==> ""<"";
"">"" ==> "")"";
else ==> [#0];
}
}
";
Z3Provider solver = new Z3Provider(BitWidth.BV16);
var test1 = BekConverter.BekToSTb(solver, bek1).ExploreBools();
//test1.ShowGraph();
var meth1 = test1.Compile();
var test2 = BekConverter.BekToSTb(solver, bek2).ExploreBools();
//test1.ShowGraph();
var meth2 = test2.Compile();
//just test on couple of samples
Assert.AreEqual<string>("<", meth1.Apply("<"));
Assert.AreEqual<string>(">", meth1.Apply(">"));
Assert.AreEqual<string>("&g>", meth1.Apply("&g>"));
Assert.AreEqual<string>("&g>", meth1.Apply("&g>"));
var d1 = test1.ToST().Explore();
var d2 = test2.ToST().Explore();
var witness = d1.Neq1(d2);
Assert.IsFalse(witness == null);
var inp = new String(Array.ConvertAll(witness.ToArray(), x => (char)solver.GetNumeralInt(x)));
var out1 = meth1.Apply(inp);
var out2 = meth2.Apply(inp);
Assert.AreNotEqual<string>(out1, out2);
}
示例6: TestLengthConflict
public void TestLengthConflict()
{
string bek = @"
program decode(input){
replace {
""&"" ==> ""&"";
""<"" ==> ""<"";
"">"" ==> "">"";
else ==> [#0];
}
}
";
Z3Provider solver = new Z3Provider(BitWidth.BV16);
var test = BekConverter.BekToSTb(solver, bek);
var test1 = test.ExploreBools();
//test1.ShowGraph();
//var meth = test1.Compile();
//just test on couple of samples
//Assert.AreEqual<string>("<", meth.Apply("<"));
//Assert.AreEqual<string>(">", meth.Apply(">"));
//Assert.AreEqual<string>("&g>", meth.Apply("&g>"));
//Assert.AreEqual<string>("&g>", meth.Apply("&g>"));
var dec = test.ToST();
var d = dec.Explore();
var dd = d.Compose(d);
//var ddmeth = dd.ToSTb().Compile();
var witness = d.Neq1(dd);
Assert.IsFalse(witness == null);
var inp = new String(Array.ConvertAll(witness.ToArray(), x => (char)solver.GetNumeralInt(x)));
//var out1 = meth.Apply(inp);
//var out2 = ddmeth.Apply(inp);
var out1b = new String(Array.ConvertAll(new List<Expr>(dec.Apply(witness)).ToArray(), x => ((char)solver.GetNumeralInt(x))));
var out2b = new String(Array.ConvertAll(new List<Expr>(dd.Apply(witness)).ToArray(), x => ((char)solver.GetNumeralInt(x))));
//Assert.AreEqual<string>(out1, out1b);
//Assert.AreEqual<string>(out2, out2b);
Assert.AreNotEqual<string>(out1b, out2b);
}
示例7: GetVataFormatString
public static string GetVataFormatString(TreeTransducer aut)
{
Z3Provider Z = new Z3Provider();
StringBuilder sb = new StringBuilder();
sb.Append("Ops");
var alph = aut.InputAlphabet;
foreach (var constructor in alph.constructors)
{
sb.AppendFormat(" {0}:{1}", constructor.Name, constructor.Arity - 1);
}
sb.AppendLine();
sb.AppendLine();
sb.AppendLine("Automaton a");
sb.AppendLine();
sb.Append("States");
var states = aut.GetStates();
foreach (var state in states)
{
sb.AppendFormat(" q{0}", int.Parse(state.ToString()));
}
sb.AppendLine();
sb.Append("Final States");
var finalStates = aut.roots;
foreach (var state in finalStates)
{
sb.AppendFormat(" q{0}", int.Parse(state.ToString()));
}
sb.AppendLine();
sb.AppendLine("Transitions");
var transition = aut.GetRules();
foreach (var rule in transition)
{
sb.Append(rule.Symbol.Name.ToString());
sb.Append("(");
for (int j = 1; j <= rule.Rank; j++)
{
var args_j = rule.Lookahead(j - 1);
if (args_j.ToList().Count > 1)
throw new Exception("Some i has more than one state");
foreach (var rlastate in args_j)
{
if (j > 1)
sb.Append(",");
sb.Append("q" + Z.GetNumeralInt(rlastate));
}
}
sb.Append(") -> ");
sb.AppendLine("q" + Z.GetNumeralInt(rule.State));
}
sb.AppendLine();
return sb.ToString();
}