本文整理汇总了C#中CharSetSolver.MkNot方法的典型用法代码示例。如果您正苦于以下问题:C# CharSetSolver.MkNot方法的具体用法?C# CharSetSolver.MkNot怎么用?C# CharSetSolver.MkNot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharSetSolver
的用法示例。
在下文中一共展示了CharSetSolver.MkNot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: 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();
}
示例3: 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);
}
示例4: TestRanges3
public void TestRanges3()
{
CharSetSolver solver = new CharSetSolver(BitWidth.BV16);
BDD cond = solver.MkCharSetFromRegexCharClass(@"\d");
int cnt = cond.CountNodes();
Pair<uint, uint>[] ranges = solver.ToRanges(cond);
BDD set = solver.MkCharSetFromRanges(ranges);
int nodes = set.CountNodes();
var ranges2 = new List<Pair<uint, uint>>(ranges);
ranges2.Reverse();
BDD set2 = solver.MkCharSetFromRanges(ranges2);
int nodes2 = set.CountNodes();
var ranges3 = solver.ToRanges(set2);
BDD set3 = solver.MkCharSetFromRanges(ranges3);
int cnt2 = set2.CountNodes();
int cnt3 = set3.CountNodes();
Assert.IsTrue(set2 == set3);
Assert.AreEqual<int>(nodes, nodes2);
Assert.AreSame(set,set2);
set.ToDot("digits.dot");
//check equivalence
bool equiv = solver.MkOr(solver.MkAnd(cond, solver.MkNot(set)), solver.MkAnd(set, solver.MkNot(cond))) == solver.False;
Assert.AreEqual<int>(31, ranges.Length);
}
示例5: GetDFAEditScriptTimeout
// looks for an edit at depth "depth"
// returns false and null in bestScript if no edit is found at depth "depth"
// returns false and not null in bestScript if found
// returns true if timeout
internal static bool GetDFAEditScriptTimeout(
Automaton<BDD> dfa1, Automaton<BDD> dfa2,
HashSet<char> al, CharSetSolver solver,
List<long> editScriptHash, List<DFAEdit> editList,
int depth, long timeout, Stopwatch sw,
Pair<IEnumerable<string>, IEnumerable<string>> tests,
double dfa1density,
int totalCost,
DFAEditScript bestScript, Dictionary<int, int> stateNamesMapping)
{
// check timer
if (sw.ElapsedMilliseconds > timeout)
return true;
//Compute worst case distance, call finalScript with this value?
int dist = (dfa1.StateCount + dfa2.StateCount) * (al.Count + 1);
//Stop if no more moves left
if (depth == 0)
{
if (DFAUtilities.ApproximateMNEquivalent(tests, dfa1density, dfa2, al, solver) && dfa2.IsEquivalentWith(dfa1, solver))
//check if totalCost < finalScript cost and replace if needed
if (bestScript.script == null || totalCost < bestScript.GetCost())
bestScript.script = ObjectCopier.Clone<List<DFAEdit>>(editList);
return false;
}
DFAEdit edit = null;
#region Flip one move target state
foreach (var move in dfa2.GetMoves())
{
//Creaty copy of the moves without current move
var movesWithoutCurrMove = dfa2.GetMoves().ToList();
movesWithoutCurrMove.Remove(move);
//Redirect every ch belonging to move condition
foreach (var c in solver.GenerateAllCharacters(move.Label, false))
{
long hash = IntegerUtil.PairToInt(move.SourceState, c - 97) + dfa2.StateCount;
if (CanAdd(hash, editScriptHash))
{
editScriptHash.Insert(0, hash);
//Local copy of moves
var newMoves = movesWithoutCurrMove.ToList();
var newMoveCondition = solver.MkCharConstraint(false, c);
#region Remove ch from current move
var andCond = solver.MkAnd(move.Label, solver.MkNot(newMoveCondition));
//add back move without ch iff satisfiable
if (solver.IsSatisfiable(andCond))
newMoves.Add(new Move<BDD>(move.SourceState, move.TargetState, andCond));
#endregion
#region Redirect c to a different state
foreach (var state in dfa2.States)
if (state != move.TargetState)
{
var newMovesComplete = newMoves.ToList();
newMovesComplete.Add(new Move<BDD>(move.SourceState, state, newMoveCondition));
var dfa2new = Automaton<BDD>.Create(dfa2.InitialState, dfa2.GetFinalStates(), newMovesComplete);
edit = new DFAEditMove(stateNamesMapping[move.SourceState], stateNamesMapping[state], c);
editList.Insert(0, edit);
if (GetDFAEditScriptTimeout(dfa1, dfa2new, al, solver, editScriptHash, editList, depth - 1, timeout, sw, tests, dfa1density, totalCost + edit.GetCost(), bestScript, stateNamesMapping))
return true;
editList.RemoveAt(0);
}
#endregion
editScriptHash.RemoveAt(0);
}
}
}
#endregion
#region Flip one state from fin to non fin
foreach (var state in dfa2.States)
{
if (CanAdd(state, editScriptHash))
{
//flip its final non final status
editScriptHash.Insert(0, state);
var newFinalStates = new HashSet<int>(dfa2.GetFinalStates());
Automaton<BDD> dfa2new = null;
if (dfa2.GetFinalStates().Contains(state))
{
edit = new DFAEditState(stateNamesMapping[state], false);
editList.Insert(0, edit);
newFinalStates.Remove(state);
dfa2new = Automaton<BDD>.Create(dfa2.InitialState, newFinalStates, dfa2.GetMoves());
}
//.........这里部分代码省略.........
示例6: Normalize
public override WS1SFormula Normalize(CharSetSolver solver)
{
if (phi is WS1SNot)
{
return (phi as WS1SNot).phi.Normalize(solver);
}
if (phi is WS1SUnaryPred)
{
var cphi = phi as WS1SUnaryPred;
return new WS1SUnaryPred(cphi.set, solver.MkNot(cphi.pred));
}
return new WS1SNot(phi.Normalize(solver)); ;
}