Exemplo n.º 1
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;
    }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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;
        }