Exemplo n.º 1
0
        public void Step(MonitoredState state)
        {
            if (currentNegative == null | currentPositive == null)
                return;

            var successors = positiveNFA.Post (currentPositive, (l, t) => state.Evaluate (l.LiteralSet));
            if (successors.Count () == 1) {
                currentPositive = successors.Single ();

            } else if (successors.Count () == 0) {
                // There is no way to satisfy the formula
                currentPositive = null;
                Status = MonitorStatus.False;
                return;

            } else {
                throw new NotImplementedException ("Non deterministic automaton not supported.");
            }

            successors = negativeNFA.Post (currentNegative,(l, t) => state.Evaluate (l.LiteralSet));
            if (successors.Count () == 1) {
                currentNegative = successors.Single ();

            } else if (successors.Count () == 0) {
                // There is no way to dissatisfy the formula
                currentNegative = null;
                Status = MonitorStatus.True;
                return;

            } else {
                throw new NotImplementedException ("Non deterministic automaton not supported.");
            }

            UpdateStatus ();
        }
Exemplo n.º 2
0
        public void Consume(MonitoredState state)
        {
            foreach (var current in currentPositive.ToList ()) {
                var successors = positiveNFA.Post (current, (l, t) => state.Evaluate (l.LiteralSet));
                currentPositive.Remove (current);
                foreach (var nt in successors) {
                    currentPositive.Add (nt);
                }
            }

            foreach (var current in currentNegative.ToList ()) {
                var successors = negativeNFA.Post (current, (l, t) => state.Evaluate (l.LiteralSet));
                currentNegative.Remove (current);
                foreach (var nt in successors) {
                    currentNegative.Add (nt);
                }
            }

            var negativeAcceptance = currentNegative.All (t => !negativeNFA.AcceptingNodes.Contains (t));
            var positiveAcceptance = currentPositive.All (t => !positiveNFA.AcceptingNodes.Contains (t));

            Status = MonitorStatus.Inconclusive;
            if (negativeAcceptance | currentPositive.Count == 0)
                Status = MonitorStatus.False;
            if (positiveAcceptance | currentNegative.Count == 0)
                Status = MonitorStatus.True;
        }