public override TERM ExctractRaiseCondition(IContextCore <TERM> solver, TERM guard) { TERM cond = solver.False; TERM defaultcond = solver.True; foreach (var c in cases) { var set = solver.MkEq(input, c.Key); TERM guard1 = And(solver, guard, set); TERM cond1 = c.Value.ExctractRaiseCondition(solver, guard1); cond = Or(solver, cond, cond1); defaultcond = And(solver, defaultcond, solver.MkNot(set)); } cond = Or(solver, cond, defaultcase.ExctractRaiseCondition(solver, And(solver, guard, defaultcond))); return(cond); }
public override IEnumerable <Move <Rule <TERM> > > EnumerateMoves(IContextCore <TERM> solver, int source, TERM guard) { TERM defaultcond = solver.True; foreach (var c in cases) { var set = solver.MkEq(input, c.Key); defaultcond = And(solver, defaultcond, solver.MkNot(set)); foreach (var m in c.Value.EnumerateMoves(solver, source, And(solver, guard, set))) { yield return(m); } } foreach (var m in defaultcase.EnumerateMoves(solver, source, And(solver, guard, defaultcond))) { yield return(m); } }
public STbRule <TERM> CollapseRedundantITEs(IContextCore <TERM> solver) { switch (this.RuleKind) { case STbRuleKind.Ite: { var t = this.TrueCase.CollapseRedundantITEs(solver); var f = this.FalseCase.CollapseRedundantITEs(solver); if (t.RuleKind == STbRuleKind.Undef && f.RuleKind == STbRuleKind.Undef) { return(t); } else if (t.RuleKind == STbRuleKind.Base && f.RuleKind == STbRuleKind.Base) { var tb = t as BaseRule <TERM>; var fb = f as BaseRule <TERM>; if (tb.State == fb.State && tb.Yields.Length == fb.Yields.Length && !solver.IsSatisfiable(solver.MkOr(GetBaseRuleNonequivalences(solver, tb, fb)))) { return(tb); } } if (f == this.FalseCase && t == this.TrueCase) { return(this); } else { return(new IteRule <TERM>(this.Condition, t, f)); } } default: return(this); } }
internal abstract BranchingRule <TERM> ApplyInp(TERM pred, IContextCore <TERM> solver, TERM x, TERM t);
/// <summary> /// Create an instance of the rule by replacing the input variable x with the new input term t /// </summary> public BranchingRule <TERM> ApplyInput(IContextCore <TERM> solver, TERM x, TERM t) { return(ApplyInp(solver.True, solver, x, t)); }
internal abstract BranchingRule <TERM> Concretize1(TERM path, IContextCore <TERM> solver, Func <TERM, TERM> fBP, Func <TERM, TERM> fNBP, Func <int, TERM, int> stateMap, TERM newReg, TERM inputVar);
/// <summary> /// Concretize the rule with respect to the given values. /// </summary> public BranchingRule <TERM> Concretize(IContextCore <TERM> solver, Func <TERM, TERM> fBP, Func <TERM, TERM> fNBP, Func <int, TERM, int> stateMap, TERM newReg, TERM inputVar) { return(Concretize1(solver.True, solver, fBP, fNBP, stateMap, newReg, inputVar)); }
public RepositoriesFactoryBase(IContextCore contextCore) { _contextCore = contextCore; _genericRepositories = new Dictionary <Type, object>(); }
internal override BranchingRule <TERM> ApplyInp(TERM pred, IContextCore <TERM> solver, TERM x, TERM input) { throw new NotImplementedException(); }
public override TERM ExctractRaiseCondition(IContextCore <TERM> solver, TERM guard) { return(solver.False); }
internal override BranchingRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst) { return(this); }
internal override BranchingRule <TERM> Concretize1(TERM path, IContextCore <TERM> solver, Func <TERM, TERM> fBP, Func <TERM, TERM> fNBP, Func <int, TERM, int> stateMap, TERM newReg, TERM inputVar) { return(this); }
public override IEnumerable <Move <Rule <TERM> > > EnumerateMoves(IContextCore <TERM> solver, int source, TERM guard) { yield break; }
public RepositoryBaseReadWrite(IContextCore context) : base(context) { // }
/// <summary> /// Método construtor /// </summary> public UnitOfWork(IContextCore contextCore) { this.contextCore = contextCore; transaction = null; }
internal abstract BranchingRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst);
public override IEnumerable <Move <Rule <TERM> > > EnumerateMoves(IContextCore <TERM> solver, int source, TERM guard) { yield return(Move <Rule <TERM> > .Create(source, state, Rule <TERM> .Mk(guard, register, yields.ToArray()))); }
/// <summary> /// Enumerates the underlying branches as moves from the give source state and guard. /// Excludes all raise rules. /// </summary> /// <param name="solver">solver for composing conditions</param> /// <param name="source">source states of the moves</param> /// <param name="guard">initial guard of the moves</param> /// <returns></returns> public abstract IEnumerable <Move <Rule <TERM> > > EnumerateMoves(IContextCore <TERM> solver, int source, TERM guard);
public BranchingRule <TERM> Compose(int q, BranchingRule <TERM> rule, TERM y1, TERM y2, TERM y, TERM predicate, IContextCore <TERM> solver, Func <int, int, int> stateComposer) { if (rule is UndefRule <TERM> ) { return(rule); } if (this.yields.Length == 0) { int pq = stateComposer(state, q); var register1 = solver.ApplySubstitution(register, y1, solver.MkProj(0, y)); var register2 = solver.MkProj(1, y); var newreg = solver.MkTuple(register1, register2); var res = new BaseRule <TERM>(Sequence <TERM> .Empty, newreg, pq); return(res); } else { var y_1 = solver.MkProj(0, y); foreach (var o in yields) { var o1 = solver.ApplySubstitution(o, y1, y_1); //var rule1 = rule.Subst(solver, y2) } } return(null); }
/// <summary> /// Extracts the condition under which the rule raises an exception. /// </summary> /// <param name="solver">solver for composing conditions</param> /// <param name="guard">initial guard of the moves</param> /// <returns></returns> public abstract TERM ExctractRaiseCondition(IContextCore <TERM> solver, TERM guard);
public RepositoryBaseRead(IContextCore context) { _context = context; _dbContextSet = _context.Set <TEntity>(); }
public bool TryGetGuardAndUpdate(IContextCore <TERM> solver, int targetState, out TERM guard, out TERM update) { switch (RuleKind) { case BranchingRuleKind.Base: { if (State == targetState) { guard = solver.True; update = Register; return(true); } else { guard = default(TERM); update = default(TERM); return(false); } } case BranchingRuleKind.Undef: { guard = default(TERM); update = default(TERM); return(false); } case BranchingRuleKind.Ite: { TERM t_guard; TERM t; bool t_ok = TrueCase.TryGetGuardAndUpdate(solver, targetState, out t_guard, out t); TERM f_guard; TERM f; bool f_ok = FalseCase.TryGetGuardAndUpdate(solver, targetState, out f_guard, out f); if (t_ok && f_ok) { if (t_guard.Equals(solver.True) && f_guard.Equals(solver.True)) { guard = solver.True; } else { guard = solver.MkIte(Condition, t_guard, f_guard); } if (object.Equals(t, f)) { update = t; } else { update = solver.MkIte(Condition, t, f); } return(true); } else if (t_ok) { guard = And(solver, t_guard, Condition); update = t; return(true); } else if (f_ok) { guard = And(solver, f_guard, Not(solver, Condition)); update = f; return(true); } else { guard = default(TERM); update = default(TERM); return(false); } } default: throw new NotImplementedException(BranchingRuleKind.Switch.ToString()); } }