コード例 #1
0
 public override void isSatiesfied <T>(TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
 {
     sat = new HashSet <T>();
 }
コード例 #2
0
        public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }

            HashSet <T> sat_1;

            left.isSatiesfied <T>(transition_system, states, out sat_1, ref factory);
            HashSet <T> sat_2;

            right.isSatiesfied <T>(transition_system, states, out sat_2, ref factory);

            sat_1.IntersectWith(sat_2);

            factory.prop_sats.Add(this, sat_1);

            sat = sat_1;
        }
コード例 #3
0
 public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
 {
     if (b)
     {
         var res = new HashSet <T>();
         foreach (var entry in states)
         {
             res.Add(entry);
         }
         sat = res;
     }
     else
     {
         sat = new HashSet <T>();
     }
 }
コード例 #4
0
        public override void isSatiesfied <T>(TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }


            HashSet <T> res = new HashSet <T>();

            foreach (var entry in states)
            {
                T    state     = entry;
                bool satisfied = transition_system.HasAtomicProposition(ref state, atomic.PropositionIndex);

                if (satisfied)
                {
                    res.Add(state);
                }
            }

            //Console.WriteLine("atomic");

            factory.prop_sats.Add(this, res);


            sat = res;
        }
コード例 #5
0
        public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }


            //Console.WriteLine("Until start");
            HashSet <T> t;                                                                    //Sat(right)

            right.isSatiesfied <T>(transition_system, states, out t, ref factory);
            List <T>    e;                                                                   //Sat(right) <-- still to be expanded
            HashSet <T> temp;

            right.isSatiesfied <T>(transition_system, states, out temp, ref factory);
            e = temp.ToList <T>();
            Queue <T> e_queue = new Queue <T>();

            HashSet <T> left_sat;                                                              //Sat(left)

            left.isSatiesfied <T>(transition_system, states, out left_sat, ref factory);

            left_sat.ExceptWith(t);

            foreach (var entry in e)
            {
                e_queue.Enqueue(entry);
            }

            //HashSet<T> x;



            int e_queue_size = e_queue.Count;

            //Console.WriteLine("59");

            while (e_queue_size > 0)
            {
                var s_prime = e_queue.Dequeue();
                //Console.WriteLine("pre start");
                HashSet <T> pre = factory.getPreSet(ref s_prime);
                //Console.WriteLine("pre stop");
                //left_sat.ExceptWith(t);

                foreach (var s in pre)
                {
                    if (left_sat.Contains(s))
                    {
                        t.Add(s);
                        left_sat.ExceptWith(t);

                        e_queue.Enqueue(s);
                    }
                }
                e_queue_size = e_queue.Count;
            }

            factory.prop_sats.Add(this, t);

            sat = t;

            //Console.WriteLine("Until stop");
        }
コード例 #6
0
        public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }


            //Console.WriteLine("Always start");
            HashSet <T> v;                                                                        //Sat(operand)

            operand.isSatiesfied <T>(transition_system, states, out v, ref factory);
            HashSet <T> e = new HashSet <T>();                                                    //S\V

            foreach (var entry in states)
            {
                e.Add(entry);
            }

            e.ExceptWith(v);

            Queue <T> e_queue = new Queue <T>();

            foreach (var entry in e)
            {
                e_queue.Enqueue(entry);
            }

            Dictionary <T, int> state_c = new Dictionary <T, int>();



            // Initialize c[s] for every state in Sat(operand)
            foreach (var entry in v)
            {
                var         temp = entry;
                HashSet <T> post = factory.getPostSet(ref temp);

                state_c.Add(temp, post.Count);
            }

            int e_queue_size = e_queue.Count;

            while (e_queue_size > 0)
            {
                var         s_prime     = e_queue.Dequeue();
                HashSet <T> pre_s_prime = factory.getPreSet(ref s_prime);

                foreach (var s in pre_s_prime)
                {
                    if (v.Contains(s))
                    {
                        int current_c;
                        state_c.TryGetValue(s, out current_c);
                        state_c.Remove(s);

                        current_c--;

                        state_c.Add(s, current_c);

                        if (current_c == 0)
                        {
                            v.Remove(s);
                            e_queue.Enqueue(s);
                        }
                    }
                }

                e_queue_size = e_queue.Count;
            }

            factory.prop_sats.Add(this, v);

            sat = v;

            //Console.WriteLine("Always stop");
        }
コード例 #7
0
        public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }

            HashSet <T> positive_sat;

            state.isSatiesfied <T>(transition_system, states, out positive_sat, ref factory);

            HashSet <T> res = new HashSet <T>();

            /*
             * foreach (var entry in states)
             * {
             *  if (positive_sat.Contains(entry))
             *      continue;
             *
             *  res.Add(entry);
             * }
             */

            foreach (var entry in states)
            {
                res.Add(entry);
            }

            res.ExceptWith(positive_sat);

            factory.prop_sats.Add(this, res);

            sat = res;
        }
コード例 #8
0
        public override void isSatiesfied <T>(Modest.Teaching.TransitionSystem <T> transition_system, LinkedList <T> states, out HashSet <T> sat, ref Pre_Compute_Factory <T> factory)
        {
            if (factory.prop_sats.ContainsKey(this))
            {
                factory.prop_sats.TryGetValue(this, out sat);
                return;
            }

            HashSet <T> operand_sat;

            operand.isSatiesfied <T>(transition_system, states, out operand_sat, ref factory);
            HashSet <T> res = new HashSet <T>();

            foreach (var entry in states)
            {
                HashSet <T> post  = new HashSet <T>();
                var         state = entry;
                T           successor;
                foreach (var transition in transition_system.GetTransitions(ref state))
                {
                    transition_system.GetTargetState(ref state, transition, out successor);
                    post.Add(successor);
                }

                post.IntersectWith(operand_sat);

                if (post.Count > 0)
                {
                    res.Add(entry);
                }
            }

            factory.prop_sats.Add(this, res);

            sat = res;
        }