コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
        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);
            }
        }
コード例 #3
0
ファイル: Rule.cs プロジェクト: OlliSaarikivi/Automata
        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);
            }
        }
コード例 #4
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 internal abstract BranchingRule <TERM> ApplyInp(TERM pred, IContextCore <TERM> solver, TERM x, TERM t);
コード例 #5
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 /// <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));
 }
コード例 #6
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 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);
コード例 #7
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 /// <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));
 }
コード例 #8
0
 public RepositoriesFactoryBase(IContextCore contextCore)
 {
     _contextCore         = contextCore;
     _genericRepositories = new Dictionary <Type, object>();
 }
コード例 #9
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 internal override BranchingRule <TERM> ApplyInp(TERM pred, IContextCore <TERM> solver, TERM x, TERM input)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 public override TERM ExctractRaiseCondition(IContextCore <TERM> solver, TERM guard)
 {
     return(solver.False);
 }
コード例 #11
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 internal override BranchingRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst)
 {
     return(this);
 }
コード例 #12
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 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);
 }
コード例 #13
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 public override IEnumerable <Move <Rule <TERM> > > EnumerateMoves(IContextCore <TERM> solver, int source, TERM guard)
 {
     yield break;
 }
コード例 #14
0
 public RepositoryBaseReadWrite(IContextCore context) : base(context)
 {
     //
 }
コード例 #15
0
 /// <summary>
 /// Método construtor
 /// </summary>
 public UnitOfWork(IContextCore contextCore)
 {
     this.contextCore = contextCore;
     transaction      = null;
 }
コード例 #16
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 internal abstract BranchingRule <TERM> Subst1(TERM path, IContextCore <TERM> solver, Dictionary <TERM, TERM> subst);
コード例 #17
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 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())));
 }
コード例 #18
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 /// <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);
コード例 #19
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
        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);
        }
コード例 #20
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
 /// <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);
コード例 #21
0
 public RepositoryBaseRead(IContextCore context)
 {
     _context      = context;
     _dbContextSet = _context.Set <TEntity>();
 }
コード例 #22
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
        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());
            }
        }