本文整理汇总了C#中CharSetSolver.MkCharConstraint方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.MkCharConstraint方法的具体用法?C# CharSetSolver.MkCharConstraint怎么用?C# CharSetSolver.MkCharConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.MkCharConstraint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyTest
public void MyTest()
{
PDLEnumerator pdlEnumerator = new PDLEnumerator();
var solver = new CharSetSolver(BitWidth.BV64);
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 1, a));
moves.Add(new Move<BDD>(0, 3, b));
moves.Add(new Move<BDD>(1,2, b));
moves.Add(new Move<BDD>(2, 1, a));
moves.Add(new Move<BDD>(1, 1, a));
moves.Add(new Move<BDD>(2, 2, b));
moves.Add(new Move<BDD>(3, 4, a));
moves.Add(new Move<BDD>(4, 3, b));
moves.Add(new Move<BDD>(3, 3, b));
moves.Add(new Move<BDD>(4, 4, a));
var dfa1 = Automaton<BDD>.Create(0, new int[] { 0,1,3 }, moves).Determinize(solver).Minimize(solver);
foreach (var v in pdlEnumerator.SynthesizePDL(al, dfa1, solver, new StringBuilder(), 5000))
{
Console.WriteLine(PDLUtil.ToEnglishString(v));
break;
}
}
示例2: DileepTest1
public void DileepTest1()
{
PDLEnumerator pdlEnumerator = new PDLEnumerator();
var solver = new CharSetSolver(BitWidth.BV64);
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
PDLPred phi = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1);
phi = new PDLAnd(new PDLStartsWith("a"), phi);
var dfa1 = phi.GetDFA(al, solver);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 0, a));
moves.Add(new Move<BDD>(0, 5, a));
moves.Add(new Move<BDD>(5, 0, a));
moves.Add(new Move<BDD>(5, 5, b));
var dfa2 = Automaton<BDD>.Create(0, new int[] { 5 }, moves);
var feedbackGrade = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Solution, true, false, false);
var feedString = "<ul>";
foreach (var feed in feedbackGrade.Second)
feedString += string.Format("<li>{0}</li>", feed);
feedString += "</ul>";
Console.Write( string.Format("<div>Grade: {0} <br /> Feedback: {1}</div>", feedbackGrade.First, feedString));
}
示例3: TextP48
public void TextP48()
{
var solver = new CharSetSolver(CharacterEncoding.Unicode);
var alph = new List<char> { 'a', 'b' };
var al = new HashSet<char>(alph);
var moves = new List<Move<CharSet>>();
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
moves.Add(new Move<CharSet>(0, 1, a));
moves.Add(new Move<CharSet>(0, 4, b));
moves.Add(new Move<CharSet>(1, 4, a));
moves.Add(new Move<CharSet>(1, 2, b));
moves.Add(new Move<CharSet>(2, 3, a));
moves.Add(new Move<CharSet>(2, 3, b));
moves.Add(new Move<CharSet>(3, 2, a));
moves.Add(new Move<CharSet>(3, 2, b));
moves.Add(new Move<CharSet>(4, 4, a));
moves.Add(new Move<CharSet>(4, 4, b));
var dfa = Automaton<CharSet>.Create(0, new int[] { 2 }, moves).Determinize(solver).Minimize(solver);
var sb = new StringBuilder();
DFAUtilities.printDFA(dfa, al, sb);
System.Console.WriteLine(sb);
}
示例4: Feedback2
public void Feedback2()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV64);
var al = new HashSet<char>(new char[] { 'a', 'b' });
var dfa1 = new PDLModSetEq(new PDLIndicesOf("a"), 2, 1).GetDFA(al, solver);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var movescorrect = new List<Move<BDD>>();
movescorrect.Add(new Move<BDD>(0, 0, b));
movescorrect.Add(new Move<BDD>(0, 1, a));
movescorrect.Add(new Move<BDD>(1, 0, a));
movescorrect.Add(new Move<BDD>(1, 0, b));
var dfa2 = Automaton<BDD>.Create(0, new int[] { 1 }, movescorrect);
var v4 = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Hint);
Console.WriteLine("Grade: {0}", v4.First);
foreach (var v in v4.Second)
Console.WriteLine("Feedback: {0}", v);
}
示例5: parseDFAFromString
public static Pair<HashSet<char>, Automaton<BDD>> parseDFAFromString(string str, CharSetSolver solver)
{
var lines = Regex.Split(str, "\r\n|\r|\n");
HashSet<char> al = new HashSet<char>();
var line = lines[0];
var tokens = line.Split(new char[] { ' ' });
for (int i = 1; i < tokens.Length; i++)
al.Add(tokens[i].ToCharArray()[0]);
var finalStates = new List<int>();
line = lines[2];
tokens = line.Split(new char[] { ' ' });
for (int i = 2; i < tokens.Length; i++)
finalStates.Add(Convert.ToInt32(tokens[i]));
var moves = new List<Move<BDD>>();
for (int i = 3; i < lines.Length; i++)
{
tokens = lines[i].Split(new char[] { ',' });
if (tokens.Length > 1)
moves.Add(new Move<BDD>(Convert.ToInt32(tokens[0]), Convert.ToInt32(tokens[1]), solver.MkCharConstraint(false, tokens[2].ToCharArray()[0])));
}
return new Pair<HashSet<char>, Automaton<BDD>>(al, Automaton<BDD>.Create(0, finalStates, moves));
}
示例6: getDFA
public Automaton<BDD> getDFA(HashSet<char> alphabet, CharSetSolver solver)
{
//Predicate representing the alphabet
var alphPred = solver.False;
foreach (var ch in alphabet)
alphPred = solver.MkOr(solver.MkCharConstraint(false, ch), alphPred);
var dfa1 = this.Normalize(solver).PushQuantifiers().getDFA(new List<string>(), alphPred, solver);
var moves = new List<Move<BDD>>();
foreach (var move in dfa1.GetMoves())
foreach (var ch in solver.GenerateAllCharacters(solver.MkAnd(move.Label,alphPred),false))
moves.Add(new Move<BDD>(move.SourceState,move.TargetState,solver.MkCharConstraint(false,ch)));
return Automaton<BDD>.Create(dfa1.InitialState,dfa1.GetFinalStates(),moves,true,true).Determinize(solver).Minimize(solver);
}
示例7: GradingTest1
public void GradingTest1()
{
var solver = new CharSetSolver(BitWidth.BV64);
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 0, a));
moves.Add(new Move<BDD>(0, 1, b));
moves.Add(new Move<BDD>(1, 1, b));
moves.Add(new Move<BDD>(1, 2, a));
moves.Add(new Move<BDD>(2, 2, a));
moves.Add(new Move<BDD>(2, 3, b));
moves.Add(new Move<BDD>(3, 3, b));
moves.Add(new Move<BDD>(3, 4, a));
moves.Add(new Move<BDD>(4, 4, a));
moves.Add(new Move<BDD>(4, 5, b));
moves.Add(new Move<BDD>(5, 6, a));
moves.Add(new Move<BDD>(5, 5, b));
moves.Add(new Move<BDD>(6, 6, a));
moves.Add(new Move<BDD>(6, 6, b));
var dfa1 = Automaton<BDD>.Create(0, new int[] { 4,5 }, moves);
var moves1 = new List<Move<BDD>>();
moves1.Add(new Move<BDD>(0, 0, a));
moves1.Add(new Move<BDD>(0, 1, b));
moves1.Add(new Move<BDD>(1, 1, b));
moves1.Add(new Move<BDD>(1, 2, a));
moves1.Add(new Move<BDD>(2, 2, a));
moves1.Add(new Move<BDD>(2, 3, b));
moves1.Add(new Move<BDD>(3, 3, b));
moves1.Add(new Move<BDD>(3, 4, a));
moves1.Add(new Move<BDD>(4, 4, a));
moves1.Add(new Move<BDD>(4, 4, b));
var dfa2 = Automaton<BDD>.Create(0, new int[] { 4 }, moves1);
var v1 = DFAGrading.GetGrade(dfa1, dfa2, al, solver, timeout, 10, FeedbackLevel.Hint);
Console.WriteLine("grade0: {0}, ", v1);
}
示例8: parseNFAFromXML
public static Pair<HashSet<char>, Automaton<BDD>> parseNFAFromXML(XElement Automaton1, CharSetSolver solver)
{
HashSet<char> al = new HashSet<char>();
var moves = new List<Move<BDD>>();
var finalStates = new List<int>();
int start = 0;
XElement Automaton = XElement.Parse(RemoveAllNamespaces(Automaton1.ToString()));
XElement xmlAlphabet = Automaton.Element("alphabet");
foreach (XElement child in xmlAlphabet.Elements())
{
char element = Convert.ToChar(child.Value);
if (element != 'ε' && element != '?')
al.Add(element);
}
XElement trans = Automaton.Element("transitionSet");
foreach (XElement child in trans.Elements())
{
if (child.Name == "transition")
{
char element = Convert.ToChar(child.Element("read").Value);
if (element != 'ε' && element != '?')
moves.Add(new Move<BDD>(Convert.ToInt32(child.Element("from").Value), Convert.ToInt32(child.Element("to").Value),
solver.MkCharConstraint(false, element)));
else
moves.Add(Move<BDD>.Epsilon(Convert.ToInt32(child.Element("from").Value), Convert.ToInt32(child.Element("to").Value)));
}
}
XElement acc = Automaton.Element("acceptingSet");
foreach (XElement child in acc.Elements())
{
if (child.Name == "state")
{
finalStates.Add((int)child.Attribute("sid"));
}
}
XElement states = Automaton.Element("initState");
foreach (XElement child in states.Elements())
{
if (child.Name == "state")
{
start = (int)child.Attribute("sid");
}
}
return new Pair<HashSet<char>, Automaton<BDD>>(al, Automaton<BDD>.Create(start, finalStates, moves));
}
示例9: TestIgnoreCaseTransformer
public void TestIgnoreCaseTransformer()
{
CharSetSolver solver = new CharSetSolver();
int t = System.Environment.TickCount;
IgnoreCaseTransformer ic = new IgnoreCaseTransformer(solver);
//simple test first:
BDD a2c = solver.MkRangeConstraint('a', 'c');
BDD a2cA2C = ic.Apply(a2c);
BDD a2cA2C_expected = a2c.Or(solver.MkRangeConstraint('A', 'C'));
Assert.AreEqual<BDD>(a2cA2C, a2cA2C_expected);
//
//comprehensive test:
//
//test that the whole array is correct:
// Microsoft.Automata.Internal.Generated.IgnoreCaseRelation.ignorecase
// (generated by:)
//
// IgnoreCaseRelationGenerator.Generate(
// "Microsoft.Automata.Internal.Generated",
// "IgnoreCaseRelation",
// @"C:\GitHub\AutomataDotNet\Automata\src\Automata\Internal\Generated");
//
//test that all characters in it are truly equivalent wrt the igore-case option of regex
//
for (int i = 0; i <= 0xFFFF; i++)
{
char c = (char)i;
if (ic.IsInDomain(c))
{
BDD cC = ic.Apply(solver.MkCharConstraint(c));
foreach (char d in solver.GenerateAllCharacters(cC))
{
Assert.IsTrue(Regex.IsMatch(d.ToString(), "^(?i:" + StringUtility.Escape(c) + ")$"));
}
}
}
//
//second, test that all characters outside the domain are only equivalent (up-to-case) to themsevles
//
// for some reson this does not succeed, ??? some characters, e.g. '\xF7', are
// equivalent to some other characters in the below test, but not when tested individually
// there is a bug in Regex.IsMatch with ignore-case combined with intervals
//
//for (int i = 2; i <= 0xFFFD; i++)
//{
// char c = (char)i;
// if (!ic.IsInDomain(c))
// {
// if (Regex.IsMatch(c.ToString(), @"^([\0-" + StringUtility.Escape((char)(i - 1)) + StringUtility.Escape((char)(i + 1)) + @"-\uFFFF])$", RegexOptions.IgnoreCase))
// Console.WriteLine(StringUtility.Escape(c));
// }
//}
}
示例10: TestMoveCharToggling1
public void TestMoveCharToggling1()
{
var solver = new CharSetSolver(BitWidth.BV64);
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
var a = solver.MkCharConstraint(false, 'a');
var b = solver.MkCharConstraint(false, 'b');
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 0, a));
moves.Add(new Move<BDD>(0, 1, b));
moves.Add(new Move<BDD>(1, 1, a));
moves.Add(new Move<BDD>(1, 2, b));
moves.Add(new Move<BDD>(2, 2, a));
moves.Add(new Move<BDD>(2, 3, b));
moves.Add(new Move<BDD>(3, 3, a));
moves.Add(new Move<BDD>(3, 3, b));
var nfa1 = Automaton<BDD>.Create(0, new int[] { 0, 3 }, moves);
var moves3 = new List<Move<BDD>>();
moves3.Add(new Move<BDD>(0, 1, b));
moves3.Add(new Move<BDD>(1, 1, a));
moves3.Add(new Move<BDD>(1, 2, b));
moves3.Add(new Move<BDD>(2, 2, a));
moves3.Add(new Move<BDD>(3, 3, a));
moves3.Add(new Move<BDD>(3, 3, b));
var nfa3 = Automaton<BDD>.Create(0, new int[] { 0, 3 }, moves3);
var sb = new StringBuilder();
NFAEditDistanceProvider nfaedp = new NFAEditDistanceProvider(nfa1, al, solver, timeout);
var distanceNfa1Nfa3 = nfaedp.GetNFAOptimalEdit(nfa3);
Assert.IsTrue(distanceNfa1Nfa3.GetCost() == 2);
}
示例11: parseDFAFromXML
public static Pair<HashSet<char>, Automaton<BDD>> parseDFAFromXML(XElement Automaton1, CharSetSolver solver)
{
HashSet<char> al = new HashSet<char>();
//XElement Automaton = XElement.Parse(xmlString);
//All DFAs in problem set on automata tutor are over a,b
var moves = new List<Move<BDD>>();
var finalStates = new List<int>();
int start = 0;
XElement Automaton = XElement.Parse(RemoveAllNamespaces(Automaton1.ToString()));
XElement trans = Automaton.Element("transitionSet");
foreach (XElement child in trans.Elements())
{
if (child.Name == "transition")
{
moves.Add(new Move<BDD>(Convert.ToInt32(child.Element("from").Value), Convert.ToInt32(child.Element("to").Value),
solver.MkCharConstraint(false, Convert.ToChar(child.Element("read").Value))));
al.Add(Convert.ToChar(child.Element("read").Value));
}
}
XElement acc = Automaton.Element("acceptingSet");
foreach (XElement child in acc.Elements())
{
if (child.Name == "state")
{
finalStates.Add((int)child.Attribute("sid"));
}
}
XElement states = Automaton.Element("initState");
foreach (XElement child in states.Elements())
{
if (child.Name == "state")
{
start = (int)child.Attribute("sid");
}
}
return new Pair<HashSet<char>, Automaton<BDD>>(al, Automaton<BDD>.Create(start, finalStates, moves));
}
示例12: CheckEquivalence
public void CheckEquivalence()
{
CharSetSolver solver = new CharSetSolver();
var moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 1, solver.True));
moves.Add(new Move<BDD>(1, 2, solver.True));
var sfa1 = ThreeAutomaton<BDD>.Create(solver, 0, new int[] { 0 }, new int[] { 2 }, moves);
var c = solver.MkCharConstraint('c');
moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 1, c));
moves.Add(new Move<BDD>(1, 2, solver.True));
moves.Add(new Move<BDD>(0, 3, solver.MkNot(c)));
moves.Add(new Move<BDD>(3, 2, solver.True));
var sfa2 = ThreeAutomaton<BDD>.Create(solver, 0, new int[] { 0 }, new int[] { 2 }, moves);
Assert.IsTrue(sfa1.IsEquivalentWith(sfa2,solver));
}
示例13: WS1SLabelTest
public void WS1SLabelTest()
{
var solver = new CharSetSolver(BitWidth.BV64); //new solver using ASCII encoding
List<char> alph = new List<char> { 'a', 'b' };
HashSet<char> al = new HashSet<char>(alph);
WS1SFormula f = new WS1SUnaryPred("X", solver.MkCharConstraint(false, 'a'));
WS1SFormula phi = new WS1SExists("X", f);
var dfa = phi.getDFA(al, solver);
var test = solver.Convert(@"^(a|b)*$").Determinize(solver).Minimize(solver);
string file = "../../../MSOZ3Test/DotFiles/sigmastar";
solver.SaveAsDot(dfa, "aut", file); //extension .dot is added automatically when missing
Assert.IsTrue(dfa.IsEquivalentWith(test, solver));
}
示例14: CheckDeMorgan
public void CheckDeMorgan()
{
CharSetSolver solver = new CharSetSolver();
var moves = new List<Move<BDD>>();
var c = solver.MkCharConstraint('a');
moves.Add(new Move<BDD>(0, 1, c));
moves.Add(new Move<BDD>(1, 2, solver.True));
var sfa1 = ThreeAutomaton<BDD>.Create(solver, 0, new int[] { 0 }, new int[] { 2 }, moves);
moves = new List<Move<BDD>>();
moves.Add(new Move<BDD>(0, 1, c));
moves.Add(new Move<BDD>(1, 2, solver.True));
moves.Add(new Move<BDD>(0, 3, solver.MkNot(c)));
moves.Add(new Move<BDD>(3, 2, solver.True));
var sfa2 = ThreeAutomaton<BDD>.Create(solver, 0, new int[] { 0 }, new int[] { 2 }, moves);
var inters = sfa1.Intersect(sfa2,solver);
var union = sfa1.Union(sfa2, solver);
var u2 = sfa1.MkComplement().Intersect(sfa1.MkComplement(), solver).MkComplement();
}
示例15: TestNFA2
public void TestNFA2()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV7);
var a = solver.MkCharConstraint('a');
var na = solver.MkNot(a);
var nfa = Automaton<BDD>.Create(solver, 0, new int[] { 1 }, new Move<BDD>[] { new Move<BDD>(0, 1, solver.True), new Move<BDD>(0, 2, solver.True), new Move<BDD>(2, 1, solver.True), new Move<BDD>(1, 1, a), new Move<BDD>(1, 2, na) });
var min_nfa = nfa.Minimize();
nfa.isDeterministic = true; //pretend that nfa is equivalent, causes the deterministic version to be executed that provides the wrong result
var min_nfa_wrong = nfa.Minimize();
nfa.isDeterministic = false;
min_nfa_wrong.isDeterministic = false;
//min_nfa.ShowGraph("min_nfa");
//min_nfa_wrong.ShowGraph("min_nfa_wrong");
//min_nfa.Determinize().Minimize().ShowGraph("min_nfa1");
//nfa.Determinize().Minimize().ShowGraph("dfa");
//nfa.ShowGraph("nfa");
//min_nfa_wrong.Determinize().Minimize().ShowGraph("min_nfa2");
Assert.IsFalse(min_nfa.IsEquivalentWith(min_nfa_wrong));
Assert.IsTrue(min_nfa.IsEquivalentWith(nfa));
//concrete witness "abab" distinguishes nfa from min_nfa_wrong
Assert.IsTrue(solver.Convert("^abab$").Intersect(nfa).IsEmpty);
Assert.IsFalse(solver.Convert("^abab$").Intersect(min_nfa_wrong).IsEmpty);
}