Exemple #1
0
 /// <summary>
 /// Pushes a new element to the top of the stack.
 /// </summary>
 /// <param name="elem">element to be pushed</param>
 public void Push(E elem)
 {
     elems = new ConsList <E>(elem, elems);
 }
Exemple #2
0
 /// <summary>
 /// Make a new list whose first element is first and whose rest is rest (rest may be null)
 /// </summary>
 public ConsList(E first, ConsList <E> rest)
 {
     this.first = first;
     this.rest  = rest;
 }
Exemple #3
0
 internal SimpleListEnumerator(ConsList <E1> tl)
 {
     this.tl = tl;
 }
Exemple #4
0
 public void Dispose()
 {
     tl = null;
 }
Exemple #5
0
        private STbRule <TERM> EvalB_Rule(STbRule <TERM> ruleB, int qA, TERM regA, TERM pathCond, ConsList <TERM> inputs, TERM regB, Func <int, int, int> stateComposer, Sequence <TERM> outputFromB, bool isFinal)
        {
            if (ruleB == null)
            {
                return(UndefRule <TERM> .Default);
            }

            if (ruleB is SwitchRule <TERM> )
            {
                throw new NotImplementedException(ruleB.ToString());
            }

            var br = ruleB as BaseRule <TERM>;

            if (br != null)
            {
                var yields = br.Yields.ConvertAll(y => Simpl(Subst(y, B.InputVar, inputs.First, B.RegVar, regB)));
                var reg    = Simpl(Subst(br.Register, B.InputVar, inputs.First, B.RegVar, regB));
                var outp   = outputFromB.Append(yields);
                var res    = EvalB(inputs.Rest, qA, regA, pathCond, br.State, reg, stateComposer, outp, isFinal);
                return(res);
            }
            else
            {
                var ite = ruleB as IteRule <TERM>;
                if (ite != null)
                {
                    var condLifted          = Subst(ite.Condition, B.InputVar, inputs.First, B.RegVar, regB);
                    var path_and_condLifted = solver.MkAnd(pathCond, condLifted);
                    if (!solver.IsSatisfiable(path_and_condLifted))
                    {
                        //path ==> !condLifted, the true-branch is unreachable
                        var res = EvalB_Rule(ite.FalseCase, qA, regA, pathCond, inputs, regB, stateComposer, outputFromB, isFinal);
                        return(res);
                    }
                    else
                    {
                        var path_and_not_condLifted = solver.MkAnd(pathCond, solver.MkNot(condLifted));
                        if (!solver.IsSatisfiable(path_and_not_condLifted))
                        {
                            //path ==> condLifted, the false-branch is unreachable
                            var res = EvalB_Rule(ite.TrueCase, qA, regA, pathCond, inputs, regB, stateComposer, outputFromB, isFinal);
                            return(res);
                        }
                        else
                        {
                            var t = EvalB_Rule(ite.TrueCase, qA, regA, path_and_condLifted, inputs, regB, stateComposer, outputFromB, isFinal);
                            var f = EvalB_Rule(ite.FalseCase, qA, regA, path_and_not_condLifted, inputs, regB, stateComposer, outputFromB, isFinal);
                            if (t is UndefRule <TERM> && f is UndefRule <TERM> )
                            {
                                return(UndefRule <TERM> .Default);
                            }

                            return(new IteRule <TERM>(condLifted, t, f));
                        }
                    }
                }
                else
                {
                    return(UndefRule <TERM> .Default);
                }
            }
        }