Esempio n. 1
0
 private void validateAlphaState_Click(object sender, EventArgs e)
 {
     if (Alphabet.Items.Count > 0)
     {
         AlphabetCreation.Enabled = StateCreation.Enabled = validateAlphaState.Enabled = false;
         group.Enabled = true;
         myNfa = new Nfa();
         myNfa.S0 = (int)States.Items.IndexOf(InitialState.SelectedItem);
         for (int i = 0; i < Alphabet.Items.Count; i++)
         {
             myNfa.X.Add((char)Alphabet.Items[i]);
             stXI.Items.Add(Alphabet.Items[i]);
         }
         myNfa.S = States.Items.Count;
         for (int i = 0; i < States.CheckedItems.Count; i++)
             myNfa.F.Add(States.Items.IndexOf(States.CheckedItems[i]));
         int j = 0;
         for (; j < States.Items.Count; j++)
         {
             stSI.Items.Add(States.Items[j]);
             stSJ.Items.Add(States.Items[j]);
         }
     }
     else MessageBox.Show("The Alphabet must contain at least one letter!");
 }
Esempio n. 2
0
 public override Nfa toNfa()
 {
     Nfa temp = new Nfa(this.X, this.S, this.S0, this.F, (ArrayList[,])this.getInstructionTable());
     return temp;
 }
Esempio n. 3
0
        public void AjouterDfa(Auto UserAuto)
        {
            if (UserAuto.Automate == null) return;
            Selected = UserAuto;

            Automates_list.Add(UserAuto);

            // l'automate Dfa
            Dfa UserDfa_ = new Dfa();
            UserDfa_ = ((Dfa)UserAuto.Automate).toDfa();
            UserDfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Dfa]";

            Auto UserAuto_Dfa_ = new Auto(UserDfa_);
            UserAuto_Dfa_.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_Dfa_);

            // l'automate Nfa
            Nfa UserNfa_ = new Nfa();
            UserNfa_ = ((Dfa)UserAuto.Automate).toNfa();
            UserNfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Nfa]";

            Auto UserAuto_Nfa_ = new Auto(UserNfa_);
            UserAuto_Nfa_.type = Automata.TYPE.Nfa;
            Automates_list.Add(UserAuto_Nfa_);

            // l'automate PGfa
            PGfa UserPGfa = new PGfa();
            UserPGfa = ((Dfa)UserAuto.Automate).toPGfa();
            UserPGfa.Name = ((Dfa)UserAuto.Automate).Name + "[PGfa]";

            Auto UserAuto_PGfa = new Auto(UserPGfa);
            UserAuto_PGfa.type = Automata.TYPE.PGfa;
            Automates_list.Add(UserAuto_PGfa);

            // l'automate Gfa
            Gfa UserGfa = new Gfa();
            UserGfa = ((Dfa)UserAuto.Automate).toGfa();
            UserGfa.Name = ((Dfa)UserAuto.Automate).Name + "[Gfa]";

            Auto UserAuto_Gfa = new Auto(UserGfa);
            UserAuto_Gfa.type = Automata.TYPE.Gfa;
            Automates_list.Add(UserAuto_Gfa);

            // l'automate reduit
            Dfa UserDfa_reduit = new Dfa();
            UserDfa_reduit = ((Dfa)UserAuto.Automate).toReduced();
            UserDfa_reduit.Name = ((Dfa)UserAuto.Automate).Name + "[Reduit]";

            Auto UserAuto_DfaReduit = new Auto(UserDfa_reduit);
            UserAuto_DfaReduit.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaReduit);

            // l'automate complet
            Dfa UserDfa_complet = new Dfa();
            UserDfa_complet = ((Dfa)UserAuto.Automate).toComplete();
            UserDfa_complet.Name = ((Dfa)UserAuto.Automate).Name + "[Complet]";

            Auto UserAuto_DfaComplet = new Auto(UserDfa_complet);
            UserAuto_DfaComplet.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaComplet);

            TreeNode node_automate = new TreeNode(UserAuto.ToString());
            TreeNode node_automate_Dfa = new TreeNode(UserAuto_Dfa_.ToString());
            TreeNode node_automate_Nfa = new TreeNode(UserAuto_Nfa_.ToString());
            TreeNode node_automate_PGfa = new TreeNode(UserAuto_PGfa.ToString());
            TreeNode node_automate_Gfa = new TreeNode(UserAuto_Gfa.ToString());
            TreeNode node_automate_DfaReduit = new TreeNode(UserAuto_DfaReduit.ToString());
            TreeNode node_automate_DfaComplet = new TreeNode(UserAuto_DfaComplet.ToString());

            node_automate.ContextMenuStrip = RightMenu;
            node_automate_Dfa.ContextMenuStrip = RightMenu;
            node_automate_Nfa.ContextMenuStrip = RightMenu;
            node_automate_PGfa.ContextMenuStrip = RightMenu;
            node_automate_Gfa.ContextMenuStrip = RightMenu;
            node_automate_DfaReduit.ContextMenuStrip = RightMenu;
            node_automate_DfaComplet.ContextMenuStrip = RightMenu;

            node_automate.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto.type);
            node_automate_Dfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Dfa_.type);
            node_automate_Nfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Nfa_.type);
            node_automate_PGfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_PGfa.type);
            node_automate_Gfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Gfa.type);
            node_automate_DfaReduit.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaReduit.type);
            node_automate_DfaComplet.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaComplet.type);

            node_automate.Nodes.Add(node_automate_Dfa);
            node_automate.Nodes.Add(node_automate_Nfa);
            node_automate.Nodes.Add(node_automate_PGfa);
            node_automate.Nodes.Add(node_automate_Gfa);
            node_automate.Nodes.Add(node_automate_DfaReduit);
            node_automate.Nodes.Add(node_automate_DfaComplet);
            Automates_tree.Nodes.Add(node_automate);

            //node_automate.Nodes.Add(node_automate);
            node_automate.Expand();

            ((Dfa)UserAuto.Automate).Draw(Drawpanel, true);
            ((Dfa)UserAuto.Automate).Afficher_grid(transition_Grid);
            Type_label.Text = "L'automate : " + ((Automata)Selected.Automate).Name + "  de type : " + Selected.type.ToString();
            Drawpanel.Refresh();
        }
Esempio n. 4
0
        /// <summary>
        /// retourner un automate non deterministe à partir de l'automate patiellement généralisé
        /// </summary>
        /// <returns></returns>
        public override Nfa toNfa()
        {
            if (isConverted)
                return Nfa_CV;
            ArrayList x = (ArrayList)this.X.Clone();
            x.Remove(EPSILON);
            Nfa_CV = new Nfa(x, this.S, this.S0, this.F, new ArrayList[this.S, this.X.Count - 1]);

            for (int i = 0; i < this.S; i++)
                foreach (char car in Nfa_CV.X)
                {
                    Nfa_CV.AddInstruction(i, car, new ArrayList(this.getInstruction(i, car)));
                }
            for (int i = 0; i < this.S; i++)
            {
                foreach (int state in this.getInstruction(i, EPSILON))
                    foreach (char car in Nfa_CV.X)
                        Nfa_CV.AddInstruction(i, car, getInstruction(state, car));
                if (Intersect(this.getInstruction(i, EPSILON), Nfa_CV.F) && (!Nfa_CV.F.Contains(i)))
                    Nfa_CV.F.Add(i);
            }
            isConverted = true;
            return Nfa_CV;
        }