本文整理汇总了C#中Z3Provider.GetCharValue方法的典型用法代码示例。如果您正苦于以下问题:C# Z3Provider.GetCharValue方法的具体用法?C# Z3Provider.GetCharValue怎么用?C# Z3Provider.GetCharValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Z3Provider
的用法示例。
在下文中一共展示了Z3Provider.GetCharValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LDiffExperimentZ3
private static void LDiffExperimentZ3(BitWidth encoding)
{
List<string> regexes = new List<string>(SampleRegexes.regexes);
regexes.RemoveRange(2, regexes.Count - 2); //just consider the first 5 cases
long timeout = 5 * Microsoft.Automata.Internal.Utilities.HighTimer.Frequency; //5 sec
for (int i = 0; i < regexes.Count; i++)
for (int j = 0; j < regexes.Count; j++)
{
string regexA = regexes[i];
string regexB = regexes[j];
var z3p = new Z3Provider(encoding);
z3p.MainSolver.Push();
var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);
//A.ShowGraph();
try
{
List<Expr> witness;
var AmB = Automaton<Expr>.MkDifference(A, B, (int)timeout).Determinize().Minimize();
//AmB.ShowGraph();
bool isNonempty = Automaton<Expr>.CheckDifference(A, B, (int)timeout, out witness);
if (isNonempty)
{
string s = new String(Array.ConvertAll(witness.ToArray(), c => z3p.GetCharValue(z3p.MainSolver.FindOneMember(c).Value)));
Assert.IsTrue(Regex.IsMatch(s, regexA), s + " must match " + regexA);
Assert.IsFalse(Regex.IsMatch(s, regexB), s + " must not match " + regexB);
}
}
catch (TimeoutException)
{
Console.WriteLine("Timeout {0},{1}", i, j);
}
z3p.MainSolver.Pop();
}
}
示例2: LProdExperimentZ3
private void LProdExperimentZ3(BitWidth encoding)
{
List<string> regexes = new List<string>(SampleRegexes.regexes);
regexes.RemoveRange(6, regexes.Count - 6); //just consider the first 100 cases
int nonemptyCount = 0;
for (int i = 0; i < regexes.Count; i++)
for (int j = 0; j < regexes.Count; j++)
{
string regexA = regexes[i];
string regexB = regexes[j];
var z3p = new Z3Provider(encoding);
z3p.MainSolver.Push();
var A = z3p.RegexConverter.Convert(regexA, System.Text.RegularExpressions.RegexOptions.None);
var B = z3p.RegexConverter.Convert(regexB, System.Text.RegularExpressions.RegexOptions.None);
List<Expr> witness;
bool C = Automaton<Expr>.CheckProduct(A, B, 0, out witness);
if (i == j)
Assert.IsTrue(C, "product must me nonempty");
if (C)
{
nonemptyCount += 1;
string s = new String(Array.ConvertAll(witness.ToArray(), cs => { return z3p.GetCharValue(z3p.MainSolver.FindOneMember(cs).Value); }));
Assert.IsTrue(Regex.IsMatch(s, regexA, RegexOptions.None), "regex mismatch");
Assert.IsTrue(Regex.IsMatch(s, regexB, RegexOptions.None), "regex mismatch");
}
z3p.MainSolver.Pop();
}
Assert.AreEqual<int>(10, nonemptyCount, "wrong number of empty intersections");
}
示例3: GetMember
static string GetMember(Z3Provider z3p, Automaton<Expr> C)
{
//z3p.Chooser.RandomSeed = 123;
var sExpr = new List<Expr>(C.ChoosePathToSomeFinalState(z3p.Chooser)).ToArray();
string s = new String(Array.ConvertAll(sExpr, m => z3p.GetCharValue(z3p.MainSolver.FindOneMember(m).Value)));
return s;
}