示例#1
0
 //Makes sure that a generated premise is the same as the show premise.
 public bool DDCheck(Premise a, Premise b)
 {
     if (a._Equals(b))
     {
         return(true);
     }
     return(false);
 }
示例#2
0
        //Generates a new premise as a result of performing Modus Ponens on the two input presmises.
        public Premise ModusPonens(Premise a, Premise b)
        {
            switch (a.type)
            {
            case 0:
            case 2:
            case 3:
            case 4:
            case 5:
                if (a._Equals(b.anti))
                {
                    return(b.cons);
                }
                else
                {
                    return(null);
                }

            case 1:
                if (b.type == 1 && a._Equals(b.anti))
                {
                    return(b.cons);
                }
                else if (b._Equals(a.anti))
                {
                    return(a.cons);
                }
                else
                {
                    return(null);
                }

            default:
                return(null);
            }
        }
示例#3
0
        //Makes sure that their is a proper contradiction.
        public bool IDCheck(Premise a, Premise b)
        {
            switch (a.type)
            {
            case 5:
                if (a.negated._Equals(b))
                {
                    return(true);
                }
                return(false);

            default:
                if (a._Equals(b.negated))
                {
                    return(true);
                }
                return(false);
            }
        }
示例#4
0
        public ProblemSet(int problemSet, string userID)
        {
            show = new Show(userID);
WorkingWithConditionals:
            while (stillRunning)
            {
                var solved = saveCloud.GetSolved(problemSet, userID, saveCloud.GetArgumentListLength(problemSet));

                Console.WriteLine("Choose an argument to derive:");

Loop1:
                var argumentDisplay = saveCloud.GetArgumentDisplay(problemSet);
                var upTo = argumentDisplay.Length - 1;
                for (var i = 0; i <= upTo; i++)
                {
                    if (problemSet == 2 && i == 1)
                    {
                        Console.WriteLine("Material Conditional 1: Solve the following derivation to unlock the MC1 rule.");
                    }
                    if (problemSet == 2 && i == 17)
                    {
                        Console.WriteLine("Material Conditional 2: Solve the following derivation to unlock the MC2 rule.");
                    }
                    if (solved[i] == true)
                    {
                        Console.WriteLine(i + ": " + argumentDisplay[i] + " (Solved)");
                    }
                    else
                    {
                        Console.WriteLine(i + ": " + argumentDisplay[i]);
                    }
                }
                Console.Write("Choice:");
                var choice    = Console.ReadLine();
                var choiceInt = 0;
                try
                {
                    choiceInt = Convert.ToInt32(choice);
                }
                catch (Exception)
                {
                    switch (choice)
                    {
                    case "help":
                        writer.ReadWholeFile("textFiles/helpShow.txt");
                        goto Loop1;

                    case "exit":
                        stillRunning = false;
                        goto Done;

                    //For constructing levels during development
                    case "make-argument":
                        Console.WriteLine("Into which problem Set?");
                        Console.Write("Choice:");
                        saveCloud.InsertArgument(Convert.ToInt32(Console.ReadLine()));
                        goto WorkingWithConditionals;

                    default:
                        Console.WriteLine("That is not a valid choice. Try again.");
                        //Console.WriteLine(e); //testing
                        goto Loop1;
                    }
                }

                problemConstructor = new ProblemConstructor(problemSet, choiceInt);
                currentArgument    = problemConstructor.argument;
                Console.WriteLine("Type 'help' at any time to read about commands.");
                Console.WriteLine("Type 'redo' to restart the derivation at any time.");
                Console.WriteLine("Type 'exit' at any time to exit.");
                Console.WriteLine(currentArgument.GetArgument());
                Console.Write("Command: ");
                string[] tokens  = Console.ReadLine().Split(' ');
                var      command = tokens[0];


                switch (command)
                {
                case "help":
                    writer.ReadWholeFile("textFiles/helpShow.txt");
                    break;

                case "exit":
                    break;

                case "Show":
Show:
                    if (!show.CheckTokenLength(tokens, 2))
                    {
                        Console.WriteLine("Show statement must be followed by one command.");
                        break;
                    }
                    switch (tokens[1])
                    {
                    case "C":
                    case "c":
Redo:
                        if (show.ShowPremise(currentArgument, currentArgument.conclusion, mainInventory))
                        {
                            Console.WriteLine("Solved!");
                            solved[Convert.ToInt32(choice)] = true;
                            saveCloud.MakeSolvedTrue(problemSet, userID, Convert.ToInt32(choice));
                            show.CheckRuleLocks();
                            mainInventory.Clear();
                            break;
                        }
                        else if (show.GetRedo())
                        {
                            goto Redo;
                        }
                        else
                        {
                            stillRunning = false;
                            break;
                        }

                    default:
                        Premise custom = problemConstructor.MakeCustom(tokens[1]);
                        if (custom == null)
                        {
                            Console.WriteLine("Bad Premise. Try again.");
                            break;
                        }
                        if (show.ShowPremise(currentArgument, custom, mainInventory))
                        {
                            if (custom._Equals(currentArgument.conclusion))
                            {
                                Console.WriteLine("Solved!");
                                solved[Convert.ToInt32(choice)] = true;
                                saveCloud.MakeSolvedTrue(problemSet, userID, Convert.ToInt32(choice));
                                show.CheckRuleLocks();
                                mainInventory.Clear();
                                break;
                            }
                            else
                            {
                                mainInventory.Add(custom);
                                Console.WriteLine(custom.GetPremise() + " " + currentArgument.conclusion.GetPremise());
                                break;
                            }
                        }
                        break;
                    }
                    break;

                default:
                    if (command.Equals("show", StringComparison.CurrentCultureIgnoreCase))
                    {
                        goto Show;
                    }
                    Console.WriteLine("Unrecognized input. type 'help' for more information.");
                    break;
                }
            }
            Done :;
        }