Beispiel #1
0
        public MSOFormula <BDD> ToMSO()
        {
            if (header == MonaHeader.M2LTREE || header == MonaHeader.WS2S)
            {
                throw new NotSupportedException("unsopprted header " + header);
            }

            foreach (var d in declarations)
            {
                if (d.kind != Mona.MonaDeclKind.formula &&
                    d.kind != Mona.MonaDeclKind.var1 &&
                    d.kind != Mona.MonaDeclKind.var2 &&
                    d.kind != Mona.MonaDeclKind.constant &&
                    d.kind != Mona.MonaDeclKind.pred &&
                    d.kind != Mona.MonaDeclKind.macro)
                {
                    throw new NotImplementedException("declaration: " + d.ToString());
                }
                MonaVarDecl vd = d as MonaVarDecl;
                if (vd != null && (vd.univs != null || vd.varwhere.where != null))
                {
                    throw new NotImplementedException("var declaration (with universe or where condition): " + vd.ToString());
                }
            }

            int fvcount = vars1.Count + vars2.Count;

            MSOFormula <BDD> psi = null;

            foreach (var decl in declarations)
            {
                if (decl.kind == MonaDeclKind.formula)
                {
                    var phi = ConvertFormula(((MonaFormulaDecl)decl).formula, MapStack <string, MonaParam> .Empty);
                    if (psi == null)
                    {
                        psi = phi;
                    }
                    else
                    {
                        psi = psi & phi;
                    }
                }
                else if (decl.kind == MonaDeclKind.pred || decl.kind == MonaDeclKind.macro)
                {
                    var pd = decl as MonaPredDecl;
                    predMap[pd.name.text] = ConvertFormula(pd.formula, MapStack <string, MonaParam> .Empty.Push(pd.pmap));
                }
            }

            if (psi == null)
            {
                throw new ArgumentException("formula is missing from the mona program");
            }

            return(psi);
        }
Beispiel #2
0
        MonaVarDecls MkTreeDecl(object vars, object univs)
        {
            var vars_  = (Cons <MonaVarWhere>)vars;
            var univs_ = (univs == null ? null : (Cons <Token>)univs);

            foreach (var vw in vars_)
            {
                if (GlobalDecls.ContainsKey(vw.name))
                {
                    throw new MonaParseException(MonaParseExceptionKind.DuplicateDeclaration, vw.token.Location, string.Format("name '{0}' is already declared", vw.name));
                }
                else
                {
                    var vd = new MonaVarDecl(MonaDeclKind.tree, univs_, vw);
                    GlobalDecls[vw.name] = vd;
                    varsT.Add(vd);
                }
            }
            return(new MonaVarDecls(MonaDeclKind.tree, univs_, vars_));
        }