Ejemplo n.º 1
0
 void CollectWithoutShareTriggers(TriggersCollector triggersCollector)
 {
     foreach (var q in quantifiers)
     {
         var candidates = triggersCollector.CollectTriggers(q.quantifier).Deduplicate(TriggerTerm.Eq);
         q.CandidateTerms = candidates; // The list of candidate terms is immutable
         q.Candidates     = TriggerUtils.AllNonEmptySubsets(candidates, SubsetGenerationPredicate, q.quantifier.BoundVars).Select(set => set.ToTriggerCandidate()).ToList();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Collect triggers from the body of each quantifier, and share them
        /// between all quantifiers. This method assumes that all quantifiers
        /// actually come from the same context, and were the result of a split that
        /// gave them all the same variables.
        /// </summary>
        /// <param name="triggersCollector"></param>
        void CollectAndShareTriggers(TriggersCollector triggersCollector)
        {
            List <TriggerTerm> pool = new List <TriggerTerm>();

            foreach (var q in quantifiers)
            {
                var candidates = triggersCollector.CollectTriggers(q.quantifier).Deduplicate(TriggerTerm.Eq);
                // filter out the candidates that was "second-class"
                var filtered = TriggerUtils.Filter(candidates, tr => tr, (tr, _) => !tr.IsTranslatedToFunctionCall(), (tr, _) => { }).ToList();
                // if there are only "second-class" candidates, add them back.
                if (filtered.Count == 0)
                {
                    filtered = candidates;
                }
                pool.AddRange(filtered);
            }
            var distinctPool = pool.Deduplicate(TriggerTerm.Eq);

            foreach (var q in quantifiers)
            {
                q.CandidateTerms = distinctPool; // The list of candidate terms is immutable
                q.Candidates     = TriggerUtils.AllNonEmptySubsets(distinctPool, SubsetGenerationPredicate, q.quantifier.BoundVars).Select(set => set.ToTriggerCandidate()).ToList();
            }
        }