コード例 #1
0
ファイル: Rule.cs プロジェクト: teodorov/Automata-1
        public override string ToString()
        {
            var condStr = Condition.ToString();
            var fStr    = FalseCase.ToString();
            var tStr    = TrueCase.ToString();

            return(string.Format("(if {0} then {1} else {2})", condStr, tStr, fStr));
        }
コード例 #2
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());
            }
        }
コード例 #3
0
ファイル: Expression.cs プロジェクト: yongaru/uno
 public bool ValueEquals(ConditionalExpression other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Condition.ValueEquals(other.Condition) && TrueCase.ValueEquals(other.TrueCase) && FalseCase.ValueEquals(other.FalseCase));
 }