Esempio n. 1
0
        private void btnGoal_Click(object sender, EventArgs e)
        {
            string    Goal  = tbxGoal.Text;
            ParseFact parse = new ParseFact(Goal);
            Fact      F     = parse.GetFact();

            if (F == null)
            {
                MessageBox.Show("Ошибка при задании цели", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Logic  L = new Logic(KB);
                string Out;
                if (L.CheckFact(F))
                {
                    Out = "Цель " + Goal + " успешно доказана";
                }
                else
                {
                    Out = "Цель " + Goal + " не доказана";
                }
                lvwResults.Items.Add(Out);

                /*if ((Out.Length * 5) > cmnGoals.Width)
                 *  cmnGoals.Width = Out.Length * 5;*/
            }
        }
Esempio n. 2
0
        public Rule GetRule()
        {
            OPERATION Operation = CheckCorrectness();

            if (Operation == OPERATION.NON_DEF)
            {
                return(null);
            }
            string Pattern = @"^(.+\))\s*:\s*(.+)*\.$";
            Match  M       = Regex.Match(Input, Pattern);

            GroupCollection gc     = M.Groups;
            List <string>   Result = new List <string>();

            Result.Add(gc[1].Value + ".");

            string Pattern2 = @"^([a-z][a-z|0-9]*\(\s*[a-z|A-Z|0-9|_]+(?:,\s*[a-zA-Z0-9_]+)*\))(?:\s*[&\|]\s*([a-z][a-z|0-9]*\(\s*[a-z|A-Z|0-9|_]+(?:,\s*[a-zA-Z0-9_]+)*\)))*$";
            string Params   = gc[2].Value;

            M  = Regex.Match(Params, Pattern2);
            gc = M.Groups;
            if (gc[0].Value == "")
            {
                return(null);
            }
            foreach (Group Gr in gc)
            {
                if (Gr.Value == Params)
                {
                    continue;
                }
                Result.Add(Gr.Value + ".");
            }

            Fact[] facts;
            facts = new Fact[Result.Count];
            for (int i = 0; i < Result.Count; ++i)
            {
                ParseFact parseFact = new ParseFact(Result[i]);
                if ((facts[i] = parseFact.GetFact()) == null)
                {
                    return(null);
                }
            }

            Rule R = new Rule(facts, Operation);

            return(R);
        }
Esempio n. 3
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (ofdRequests.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         lbRequests.Items.Clear();
         string[] Requests = File.ReadAllLines(ofdRequests.FileName);
         foreach (string Request in Requests)
         {
             ParseFact Parse = new ParseFact(Request);
             Fact      F     = Parse.GetFact();
             if (F != null)
             {
                 KB.AddFact(F);
                 lbRequests.Items.Add(Request);
             }
         }
     }
 }
Esempio n. 4
0
        private void btnAddFact_Click(object sender, EventArgs e)
        {
            string    In    = tbxFacts.Text;
            ParseFact Parse = new ParseFact(In);
            Fact      F     = Parse.GetFact();

            if (F != null)
            {
                KB.AddFact(F);
                lvwFacts.Items.Add(In);

                /*if ((In.Length * 5) > cmnFacts.Width)
                 *  cmnFacts.Width = In.Length * 5;*/
            }
            else
            {
                MessageBox.Show("Невозможно распознать введенный факт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 5
0
        private void ofdFacts_FileOk(object sender, CancelEventArgs e)
        {
            lvwFacts.Items.Clear();
            StreamReader SR = new StreamReader(File.OpenRead(ofdFacts.FileName));

            //int FactCount = Convert.ToInt32(SR.ReadLine());
            while (!SR.EndOfStream)
            {
                string    In    = SR.ReadLine();
                ParseFact Parse = new ParseFact(In);
                Fact      F     = Parse.GetFact();
                if (F != null)
                {
                    KB.AddFact(F);
                    lvwFacts.Items.Add(In);

                    /* if ((In.Length * 5) > cmnFacts.Width)
                     *   cmnFacts.Width = In.Length * 5;*/
                }
            }
        }