Пример #1
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();
        }
Пример #2
0
        private void miroirMI_Click(object sender, EventArgs e)
        {
            if (Selected.Automate != null)
            {
                PGfa UserPGfa = new PGfa();

                UserPGfa = ((Automata)Selected.Automate).getMirror();
                UserPGfa.Name = "Automate" + Automates_list.Count;
                Auto UserAuto = new Auto(UserPGfa);
                UserAuto.type = Automata.TYPE.PGfa;
                AjouterPGfa(UserAuto);
            }
        }
Пример #3
0
 /// <summary>
 /// Obtenir l'automate du language Iteration positive
 /// </summary>
 /// <returns>Un automate partiellement generalisé</returns>
 public PGfa getIterationPositive()
 {
     PGfa temp = this.toPGfa();
     int s0 = temp.S0;
     temp = new PGfa(temp.X, temp.S + 1, temp.S, temp.F, (ArrayList[,])temp.getInstructionTable());
     temp.AddInstruction(temp.S - 1, EPSILON, s0);
     foreach (int Fi in temp.F)
         temp.AddInstruction(Fi, EPSILON, s0);
     return temp;
 }
Пример #4
0
    /// <summary>
    /// Obtenir l'automate de language miroire 
    /// </summary>
    /// <returns>Un automate de type PGfa</returns>
    public virtual PGfa getMirror()
    {
        PGfa Pgfa = new PGfa();
        Pgfa.X = (ArrayList)this.X.Clone();

        if (!Pgfa.X.Contains(PGfa.EPSILON))
            Pgfa.X.Insert(0, PGfa.EPSILON);
        Pgfa.S = this.S + 1;
        Pgfa.F.Add(this.S0);
        Pgfa.S0 = this.S;
        Pgfa.InitI();
        for (int i = 0; i < this.S; i++)
            foreach (char car in this.X)
                if (this.getType() == TYPE.Dfa)
                {
                    if (((Dfa)this).getInstruction(i, car) != -1)
                        Pgfa.AddInstruction(((Dfa)this).getInstruction(i, car), car, i);
                }
                else
                    foreach (int j in this.getInstruction(i, car))
                        Pgfa.AddInstruction(j, car, i);
        foreach (int s in this.F)
            Pgfa.AddInstruction(Pgfa.S0, PGfa.EPSILON, s);
        return Pgfa;
    }
Пример #5
0
 /// <summary>
 /// Obtenir  l'automate qui defini l'union des deux languages definis par A et B
 /// </summary>
 /// <returns>Un automate de type PGfa</returns>
 public static PGfa Union(Automata A, Automata B)
 {
     PGfa a = A.toPGfa();
     PGfa b = B.toPGfa();
     PGfa aUb = new PGfa(arrayListUnion(a.X, b.X), a.S + b.S + 1);
     aUb.S0 = 0;
     foreach (int Fi in a.F)
         aUb.AddFinalState(Fi + 1);
     foreach (int Fi in b.F)
         aUb.AddFinalState(Fi + a.S + 1);
     for (int i = 0; i < a.S; i++)
         foreach (char car in a.X)
             foreach (int j in a.getInstruction(i, car))
                 aUb.AddInstruction(i + 1, car, j + 1);
     for (int i = 0; i < b.S; i++)
         foreach (char car in b.X)
             foreach (int j in b.getInstruction(i, car))
                 aUb.AddInstruction(i + a.S + 1, car, j + b.S + 1);
     aUb.AddInstruction(aUb.S0, EPSILON, new ArrayList { a.S0 + 1, b.S0 + a.S + 1 });
     return aUb;
 }
Пример #6
0
 /// <summary>
 /// Obtenir l'automate qui defini la concatenation de deux laguages definis par A et B
 /// </summary>
 /// <returns>Un automate de type PGfa</returns>
 public static PGfa Concatenation(Automata A, Automata B)
 {
     PGfa a = A.toPGfa();
     PGfa b = B.toPGfa();
     ArrayList f = new ArrayList();
     foreach (int Fi in b.F)
         f.Add(Fi + a.S);
     PGfa aCb = new PGfa(arrayListUnion(a.X, b.X), a.S + b.S, a.S0, f, (ArrayList[,])a.getInstructionTable());
     for (int i = 0; i < b.S; i++)
         foreach (char car in b.X)
             foreach (int j in b.getInstruction(i, car))
                 aCb.AddInstruction(i + a.S, car, j + b.S);
     foreach (int Fi in a.F)
         aCb.AddInstruction(Fi, EPSILON, b.S0 + a.S);
     return aCb;
 }
Пример #7
0
        public override PGfa toPGfa()
        {
            if (isConverted)
                return this.PGfa_CV;
            if (this.X.Count == this.Read.Count)
            {
                PGfa_CV = new PGfa(this.X, this.S, this.S0, this.F, this.I);
                return PGfa_CV;
            }

            int s = this.X.Count;

            for (int i = this.X.Count; i < this.Read.Count; i++)
                s += ((String) this.Read[i].ToString()).Length - 1;

            PGfa_CV = new PGfa(this.X, s, this.S0, this.F, this.I);
            if (!PGfa_CV.X.Contains(Automata.EPSILON))
                PGfa_CV.X.Add(Automata.EPSILON);
            s = this.S;
            for (int i = 0; i < this.S; i++)
            {
                for (int j = this.X.Count; (i < PGfa_CV.S) && (j < Read.Count) && (((String)Read[j].ToString()).Length > 0); j++)
                {
                    String temp = (String)Read[j].ToString();

                    if (getInstruction(i, temp).Count > 0)
                    {
                        PGfa_CV.AddInstruction(i, temp[0], s++);
                        for (int k = 1; (k < temp.Length - 1) && (s <= PGfa_CV.S); k++)
                            PGfa_CV.AddInstruction(s - 1, temp[k], s++);
                        if (s <= PGfa_CV.S)
                            PGfa_CV.AddInstruction((s - 1), temp[temp.Length - 1], getInstruction(i, temp));

                    }
                }
            }
            isConverted = true;
            return PGfa_CV;
        }
Пример #8
0
 /// <summary>
 /// retourner un automate deterministe reduit à partir de l'automate patiellement généralisé
 /// </summary>
 /// <returns></returns>
 public override Dfa toReduced()
 {
     if (!isConverted)
         toNfa();
     PGfa temp = new PGfa(this.X, this.S, this.S0, this.F, (ArrayList[,])this.getInstructionTable());
     return temp.toDfa().toReduced();
 }
Пример #9
0
 public override PGfa toPGfa()
 {
     PGfa temp = new PGfa(this.X, this.S, this.S0, this.F, (ArrayList[,])this.getInstructionTable());
     return temp;
 }