예제 #1
0
        /// <summary>
        /// Generates a test file
        /// </summary>
        static void GenerateExamples()
        {
            FileStream   fs = new FileStream("examples.hl", FileMode.Create);
            StreamWriter w  = new StreamWriter(fs);

            Random rnd = new Random(2);

            // Dependencies
            w.WriteLine("needs \"test_explicit.hl\"");
            w.WriteLine("let test = [");

            for (int k = 0; k < 300; k++)
            {
                List <decimal> cs   = new List <decimal>();
                List <string>  vars = new List <string>();

                int i = rnd.Next(100);
                while (i >= 0)
                {
                    vars.Add('x'.ToString() + "_" + String.Format("{0:000}", i));
                    cs.Add(rnd.Next(1000000000));

                    i -= rnd.Next(10) + 1;
                }

                LinearFunction f = new LinearFunction(cs, vars);
                w.Write(f.ToHOLExplicit(5, null));
                //                w.Write("`" + f.ToHOLString(5) + "`");
                w.WriteLine(";");
            }

            w.WriteLine("];;");
            w.Flush();
            fs.Close();
        }
예제 #2
0
        /// <summary>
        /// Converts to a HOL term
        /// </summary>
        /// <param name="precision"></param>
        /// <returns></returns>
        public string ToHOLExplicit(int precision, VariableCollection vars)
        {
            StringBuilder str = new StringBuilder();

            switch (type)
            {
            case IneqType.Eq:
                // Eq becomes Le
                str.Append("mk_le_ineq ");
                break;

            case IneqType.Le:
                str.Append("mk_le_ineq ");
                break;

            case IneqType.Ge:
                str.Append("mk_ge_ineq ");
                break;
            }

            str.Append(lhs.ToHOLExplicit(precision, vars));
            str.Append(rhs.ToHOLExplicit(precision));

            return(str.ToString());
        }