Ejemplo n.º 1
0
        private void ConvertErrorModel(StringBuilder m) {
            if (Parent.options.Solver == SolverKind.Z3) {
                // Datatype declarations are not returned by Z3, so parse common
                // instead. This is not very efficient, but currently not an issue,
                // as this not the normal way of interfacing with Z3.
                var ms = new MemoryStream(Encoding.ASCII.GetBytes(Parent.common.ToString()));
                var sr = new StreamReader(ms);
                SExpr.Parser p = new MyFileParser(sr, null);
                var sexprs = p.ParseSExprs(false);
                foreach (var e in sexprs) {
                    switch (e.Name) {
                    case "declare-datatypes":
                        ExtractDataType(e);
                        break;
                    }
                }
            }

            while (ErrorModelTodo.Count > 0) {
                var e = ErrorModelTodo[0];
                ErrorModelTodo.RemoveAt(0);

                switch (e.Name) {
                case "define-fun":
                    ConstructDefine(e, m);
                    break;
                case "declare-sort":
                    SortSet[e[0].Name] = System.Convert.ToInt32(e[1].Name);
                    break;
                case "declare-datatypes":
                    ExtractDataType(e);
                    break;
                case "declare-fun":
                    if (e[1].Name != "" || e[1].ArgCount > 0 || e[2].ArgCount > 0 ||
                        e[2].Name == "Bool" || e[2].Name == "Int") {
                        Parent.HandleProverError("Unexpected top level model element: " + e.Name);
                        throw new BadExprFromProver ();
                    }
                    Functions[e[0].Name] = e[2];
                    break;
                case "forall":
                    // ignore
                    break;
                default:
                    Parent.HandleProverError("Unexpected top level model element: " + e.Name);
                    throw new BadExprFromProver ();
                }
            }
        }
Ejemplo n.º 2
0
    void ReadConjectures(string filename)
    {
        try
        {
            System.IO.StreamReader sr = new StreamReader(filename + ".tmp");
            SExpr.Parser p = new MyFileParser(sr, this);
            var sexps = p.ParseSExprs(false);
            Dictionary<string, RPFP.Node> pmap = GetNodeMap();
            foreach (var e in sexps)
            {
                string pname;
                RPFP.Transformer annot;
                GetDefun(e, out pname, out annot);

                if (pmap.ContainsKey(pname))
                {
                    var c = new RPFP.Conjecture();
                    c.node = pmap[pname];
                    c.bound = annot;
                    rpfp.conjectures.Add(c);
                }
                else if (pname[0] != '@')
                { // if not an internal symbol
                    HandleProverError("Prover error: got unknown predicate:" + pname);
                    throw new BadExprFromProver();
                }
            }
            sr.Close();
        }
        catch (Exception)
        {
            HandleProverError("No conjecture file from prover");
            throw new BadExprFromProver();
        }
    }