Esempio n. 1
0
        public override PDLPred ToPDL(List <MonaMacro> macros, Dictionary <string, string> sub)
        {
            switch (q)
            {
            case MonaQuantifier.ExistsFO:
            {
                var ret = phi.ToPDL(macros, sub);
                foreach (var v in vars)
                {
                    return(ret = new PDLExistsFO(v, ret));
                }
                return(ret);
            }

            case MonaQuantifier.ExistsSO:
            {
                var ret = phi.ToPDL(macros, sub);
                foreach (var v in vars)
                {
                    return(ret = new PDLExistsSO(v, ret));
                }
                return(ret);
            }

            case MonaQuantifier.ForallFO:
            {
                var ret = phi.ToPDL(macros, sub);
                foreach (var v in vars)
                {
                    return(ret = new PDLForallFO(v, ret));
                }
                return(ret);
            }

            case MonaQuantifier.ForallSO:
            {
                var ret = phi.ToPDL(macros, sub);
                foreach (var v in vars)
                {
                    return(ret = new PDLForallSO(v, ret));
                }
                return(ret);
            }

            default: throw new MonaException("Quantifier undefined");
            }
        }
Esempio n. 2
0
        public static Testcase createTestcase11()
        {
            PDLPred xInA     = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("A"));
            PDLPred xInB     = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("B"));
            PDLPred xInC     = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("C"));
            PDLPred yInA     = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("A"));
            PDLPred yInB     = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("B"));
            PDLPred yInC     = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("C"));
            PDLPred zInA     = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("A"));
            PDLPred zInB     = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("B"));
            PDLPred zInC     = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("C"));
            PDLPred xOnlyInA = new PDLAnd(xInA, new PDLAnd(new PDLNot(xInB), new PDLNot(xInC)));
            PDLPred xOnlyInB = new PDLAnd(new PDLNot(xInA), new PDLAnd(xInB, new PDLNot(xInC)));
            PDLPred xOnlyInC = new PDLAnd(new PDLNot(xInA), new PDLAnd(new PDLNot(xInB), xInC));

            PDLPred problem = new PDLForallSO("A", new PDLForallSO("B", new PDLForallSO("C",
                                                                                        new PDLIf(
                                                                                            new PDLForallFO("x",
                                                                                                            new PDLAnd(
                                                                                                                new PDLIf(new PDLAtPos('a', new PDLPosVar("x")), xOnlyInA),
                                                                                                                new PDLAnd(
                                                                                                                    new PDLIf(new PDLAtPos('b', new PDLPosVar("x")), xOnlyInB),
                                                                                                                    new PDLIf(new PDLAtPos('c', new PDLPosVar("x")), xOnlyInC)
                                                                                                                    ))
                                                                                                            ),
                                                                                            new PDLForallFO("x", new PDLForallFO("y",
                                                                                                                                 new PDLAnd(
                                                                                                                                     new PDLIf(new PDLAnd(xInA, yInB), new PDLPosLe(new PDLPosVar("x"), new PDLPosVar("y"))),
                                                                                                                                     new PDLIf(new PDLAnd(xInB, yInC), new PDLPosLe(new PDLPosVar("x"), new PDLPosVar("y")))
                                                                                                                                     )
                                                                                                                                 ))
                                                                                            )
                                                                                        )));

            return(new Testcase(11, new char[] { 'a', 'b', 'c' }, problem));
        }
        public static Testcase createTestFormula12()
        {
            PDLPred xInA = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("A"));
            PDLPred xInB = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("B"));
            PDLPred xInC = new PDLBelongs(new PDLPosVar("x"), new PDLSetVar("C"));
            PDLPred yInA = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("A"));
            PDLPred yInB = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("B"));
            PDLPred yInC = new PDLBelongs(new PDLPosVar("y"), new PDLSetVar("C"));
            PDLPred zInA = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("A"));
            PDLPred zInB = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("B"));
            PDLPred zInC = new PDLBelongs(new PDLPosVar("z"), new PDLSetVar("C"));
            PDLPred xOnlyInA = new PDLAnd(xInA, new PDLAnd(new PDLNot(xInB), new PDLNot(xInC)));
            PDLPred xOnlyInB = new PDLAnd(new PDLNot(xInA), new PDLAnd(xInB, new PDLNot(xInC)));
            PDLPred xOnlyInC = new PDLAnd(new PDLNot(xInA), new PDLAnd(new PDLNot(xInB), xInC));

            PDLPred problem = new PDLForallSO("A", new PDLForallSO("B", new PDLForallSO("C",
                new PDLIf(
                    new PDLForallFO("x",
                        new PDLAnd(
                            new PDLIf(new PDLAtPos('a', new PDLPosVar("x")), xOnlyInA),
                        new PDLAnd(
                            new PDLIf(new PDLAtPos('b', new PDLPosVar("x")), xOnlyInB),
                            new PDLIf(new PDLAtPos('c', new PDLPosVar("x")), xOnlyInC)
                        ) )
                    ),
                    new PDLForallFO("x", new PDLForallFO("y", 
                        new PDLAnd(
                            new PDLIf(new PDLAnd(xInA, yInB), new PDLPosLe(new PDLPosVar("x"), new PDLPosVar("y"))),
                            new PDLIf(new PDLAnd(xInB, yInC), new PDLPosLe(new PDLPosVar("x"), new PDLPosVar("y")))
                        )
                    ) )
                )
            ) ) );
            return new Testcase(12,new char[] { 'a','b','c' }, problem);
        }
 public override PDLPred ToPDL(List<MonaMacro> macros, Dictionary<string, string> sub)
 {
     switch (q)
     {
         case MonaQuantifier.ExistsFO:
             {
                 var ret = phi.ToPDL(macros, sub);
                 foreach(var v in vars)
                     return ret =  new PDLExistsFO(v, ret);
                 return ret;
             }
         case MonaQuantifier.ExistsSO:
             {
                 var ret = phi.ToPDL(macros, sub);
                 foreach (var v in vars)
                     return ret = new PDLExistsSO(v, ret);
                 return ret;
             }
         case MonaQuantifier.ForallFO:
             {
                 var ret = phi.ToPDL(macros, sub);
                 foreach (var v in vars)
                     return ret = new PDLForallFO(v, ret);
                 return ret;
             }
         case MonaQuantifier.ForallSO:
             {
                 var ret = phi.ToPDL(macros, sub);
                 foreach (var v in vars)
                     return ret = new PDLForallSO(v, ret);
                 return ret;
             }
         default: throw new MonaException("Quantifier undefined");
     }
 }