예제 #1
0
        //Returns a string containing the full argument.
        public string GetArgument()
        {
            var _out  = "";
            var count = 1;

            for (var i = 0; i < premises.Count; i++)
            {
                _out = _out + "PR" + Convert.ToString(count) + ":" + premises[i].GetPremise() + " ";
                count++;
            }
            _out = _out + "∴" + conclusion.GetPremise();
            return(_out);
        }
예제 #2
0
파일: Show.cs 프로젝트: Fizzizist/Logic2018
 //Prints the Show statement with a list of currently generated premises at the users disposal.
 public void ListSheet(Premise Prem)
 {
     Console.WriteLine("Show: " + Prem.GetPremise());
     for (var i = 0; i < inventory.Count; i++)
     {
         Console.WriteLine(Convert.ToString(i) + ": " + inventory[i].GetPremise());
     }
 }
예제 #3
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 :;
        }
예제 #4
0
        //Returns a string containing the contents of the premise.
        //0:atomic 1:conditional 2:biconditional 3:and 4:or 5:negation
        public string GetPremise()
        {
            switch (type)
            {
            case 0:
                return(atomic);

            case 1:
                if (anti.type != 0 && cons.type != 0 && anti.type != 5 && cons.type != 5)
                {
                    return("(" + anti.GetPremise() + ")" + "→" + "(" + cons.GetPremise() + ")");
                }
                else if (anti.type != 0 && anti.type != 5)
                {
                    return("(" + anti.GetPremise() + ")" + "→" + cons.GetPremise());
                }
                else if (cons.type != 0 && cons.type != 5)
                {
                    return(anti.GetPremise() + "→" + "(" + cons.GetPremise() + ")");
                }
                return(anti.GetPremise() + "→" + cons.GetPremise());

            case 2:
                if (child1.type != 0 && child2.type != 0 && child1.type != 5 && child2.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "↔" + "(" + child2.GetPremise() + ")");
                }
                if (child1.type != 0 && child1.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "↔" + child2.GetPremise());
                }
                if (child2.type != 0 && child2.type != 5)
                {
                    return(child1.GetPremise() + "↔" + "(" + child2.GetPremise() + ")");
                }
                return(child1.GetPremise() + "↔" + child2.GetPremise());

            case 3:
                if (child1.type != 0 && child2.type != 0 && child1.type != 5 && child2.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "^" + "(" + child2.GetPremise() + ")");
                }
                if (child1.type != 0 && child1.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "^" + child2.GetPremise());
                }
                if (child2.type != 0 && child2.type != 5)
                {
                    return(child1.GetPremise() + "^" + "(" + child2.GetPremise() + ")");
                }
                return(child1.GetPremise() + "^" + child2.GetPremise());

            case 4:

                if (child1.type != 0 && child2.type != 0 && child1.type != 5 && child2.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "v" + "(" + child2.GetPremise() + ")");
                }
                if (child1.type != 0 && child1.type != 5)
                {
                    return("(" + child1.GetPremise() + ")" + "v" + child2.GetPremise());
                }
                if (child2.type != 0 && child2.type != 5)
                {
                    return(child1.GetPremise() + "v" + "(" + child2.GetPremise() + ")");
                }
                return(child1.GetPremise() + "∨" + child2.GetPremise());

            case 5:
                if (negated.type == 0 || negated.type == 5)
                {
                    return("~" + negated.GetPremise());
                }
                return("~" + "(" + negated.GetPremise() + ")");

            default:
                return("");
            }
        }