Example #1
0
        private IEnumerable <Expr> DisjointnessExpr(Program program, IEnumerable <Variable> paramVars, HashSet <Variable> frame)
        {
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in paramVars.Union(frame))
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                yield return(linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName]));
            }
        }
Example #2
0
        private List <Requires> DisjointnessRequires(Program program, AtomicActionInfo first, AtomicActionInfo second, HashSet <Variable> frame)
        {
            List <Requires> requires = new List <Requires>();
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in frame)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            if (first != null)
            {
                foreach (Variable v in first.thatInParams)
                {
                    var domainName = linearTypeChecker.FindDomainName(v);
                    if (domainName == null)
                    {
                        continue;
                    }
                    if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                    {
                        continue;
                    }
                    domainNameToScope[domainName].Add(v);
                }
            }
            foreach (Variable v in second.thisInParams)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                if (!linearTypeChecker.linearDomains.ContainsKey(domainName))
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                requires.Add(new Requires(false, linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName])));
            }
            return(requires);
        }
Example #3
0
        private List <Requires> DisjointnessRequires(Program program, ActionInfo first, ActionInfo second)
        {
            List <Requires> requires = new List <Requires>();
            Dictionary <string, HashSet <Variable> > domainNameToScope = new Dictionary <string, HashSet <Variable> >();

            foreach (var domainName in linearTypeChecker.linearDomains.Keys)
            {
                domainNameToScope[domainName] = new HashSet <Variable>();
            }
            foreach (Variable v in program.GlobalVariables())
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            foreach (Variable v in first.thisInParams)
            {
                var domainName = linearTypeChecker.FindDomainName(v);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(v);
            }
            for (int i = 0; i < second.thatInParams.Count; i++)
            {
                var domainName = linearTypeChecker.FindDomainName(second.thisInParams[i]);
                if (domainName == null)
                {
                    continue;
                }
                domainNameToScope[domainName].Add(second.thatInParams[i]);
            }
            foreach (string domainName in domainNameToScope.Keys)
            {
                requires.Add(new Requires(false, linearTypeChecker.DisjointnessExpr(domainName, domainNameToScope[domainName])));
            }
            return(requires);
        }