Codificación maquinas de turing

download Codificación maquinas de turing

of 27

Transcript of Codificación maquinas de turing

  • 8/17/2019 Codificación maquinas de turing

    1/27

    UNIVERSIDAD MICHOACANA DE SAN NICOLÁSDE HIDALGO

    FACULTAD DE INGENIERÍA ELÉCTRICA

    EJERCICIOS

    CODIFICACIÓN MAQUINAS DE TURING

      TEORÍA DE LA COMPUTACIÓN

    Por:

      JOSÉ DE JESÚS HERNÁNDEZ ONCHI

  • 8/17/2019 Codificación maquinas de turing

    2/27

    1.- CODIFICACIÓN DE LAS MAQUINAS DE TURING

    1.1.- 0n1n  

    M=({   q1 , q2 , q3 , q4 , q5 },{0,1},{0,1,B,X,Y},δ,   q1 ,B,{   q2 })

    E!"#$%

    q1⇒ estadoinicial

    q2⇒estado de aceptacion

    S&'$$%

     x1

    =0 x

    2=1

     x3=B

     x4= X 

     x5=Y 

    D*+*/%

     D1=

     L

     D2= R 

    #$/# δ:

    δ(   q1 , 0 )=(   q3, X , R ) = 010100010000100

    δ(   q1 , Y  )=(   q5 ,Y ,R ) = 0100000100000100000100

    δ(   q3 , 0 )=(   q3,0, R ) = 00010100010100

    δ(   q3

    , Y  )=(   q3, Y , R ) = 0001000001000100000100

    δ(   q3 , 1 )=(   q4 ,Y , L ) = 0001001000010000010

    δ(   q4 ,0 )=(   q4 , 0, L ) = 000010100001010

    δ(   q4 ,Y  )=(   q4 ,Y , L ) = 00001000001000010000010

  • 8/17/2019 Codificación maquinas de turing

    3/27

    δ(   q4 , X  )=(   q1 , X , R ) = 0000100001010000100

    δ(   q5

    , Y  )=(   q5, Y , R ) = 00000100000100000100000100

    δ(   q5 , B )=(   q2,B ,R ) = 0000010001001000100

    Codifcación:

    010100010000100 11 0100000100000100000100 11 00010100010100

    11 0001000001000100000100 11 0001001000010000010 11 000010100001010

    11 00001000001000010000010 11 0000100001010000100

    11 00000100000100000100000100 11 0000010001001000100

    1.2.- 0n1

    n0

    n  

    M=({   q1, q2 , q3 , q4 , q5 , q6 , q7 , q8 },{0,1},{0,1,B,X,Y,Z},δ,   q1 ,B,{   q2 })

    E!"#$%

    q1⇒ estadoinicial

    q2⇒estado de aceptacion

    S&'$$%

     x1=0

     x2=1

     x3=B

     x4= X 

     x5=Y 

     x6=Z 

    D*+*/%

     D1=

     L

     D2=

     R 

    donde δ:

  • 8/17/2019 Codificación maquinas de turing

    4/27

    δ(   q1 , 0 )=(   q3, X , R ) = 010100010000100

    δ(   q3 , 0 )=(   q3,0, R ) = 00010100010100

    δ(   q3 , Y  )=(   q3, Y , R ) = 0001000001000100000100

    δ(   q3 , 1 )=(   q4 , Y , R ) = 00010010000100000100

    δ(   q4 ,1 )=(   q4 ,1, R ) = 000010010000100100

    δ(   q4 , Z  )=(   q4 , Z , R ) = 00001000000100001000000100

    δ(   q4 ,0 )=(   q5, Z , L ) = 000010100000100000010

    δ(   q5 , Z  )=(   q5 , Z , L ) = 000001000000100000100000010

    δ(   q5

    , Y  )=(   q5, Y , L ) = 0000010000010000010000010

    δ(   q5 , 1 )=(   q5, 1, L ) = 0000010010000010010

    δ(   q5 , 0 )=(   q5 , 0, L ) = 00000101000001010

    δ(   q5 , X  )=(   q1, X , R ) = 00000100001010000100

    δ(   q1 , Y  )=(   q6, Y , R ) = 01000001000000100000100

    δ(   q6

    , Y  )=(   q6

    ,Y ,R ) = 0000001000001000000100000100

    δ(   q6 , Z  )=(   q7, Z , R ) = 0000001000000100000001000000100

    δ(   q7 , Z  )=(   q7, Z , R ) = 00000001000000100000001000000100

    δ(   q7 , B )=(   q2 ,B ,R ) = 000000010001001000100

    C$#**"*/%

    010100010000100 11 00010100010100 11 0001000001000100000100

    11 00010010000100000100 11 000010010000100100

    11 00001000000100001000000100 11 000010100000100000010

  • 8/17/2019 Codificación maquinas de turing

    5/27

    11 000001000000100000100000010 11 0000010000010000010000010

    11 0000010010000010010 11 00000101000001010 11 00000100001010000100

    11 01000001000000100000100 11 0000001000001000000100000100

    11 0000001000000100000001000000100 1100000001000000100000001000000100 11 000000010001001000100

    1.3.- 0n12n

    M=({   q1, q2 , q3 , q4 , q5 , q6 },{0,1},{0,1,B,X,Y},δ,   q1 ,B,{   q2 })

    E!"#$%

    q1⇒ estadoinicial

    q2⇒estado de aceptacion

    S&'$$%

     x1=0

     x2=1

     x3=B

     x4= X  x5=Y 

    D*+*/%

     D1= L

     D2= R

     

    donde δ:

    δ(   q1 , 0 )=(   q3, X , R ) = 010100010000100

    δ(   q3 , 0 )=(   q3,0, R ) = 00010100010100

    δ(   q3

    , Y  )=(   q3, Y , R ) = 0001000001000100000100

  • 8/17/2019 Codificación maquinas de turing

    6/27

    δ(   q3 , 1 )=(   q4 , Y , R ) = 00010010000100000100

    δ(   q4 ,1 )=(   q5 ,Y ,L ) = 000010010000010000010

    δ(   q5 , 0 )=(   q5 , 0, L ) = 00000101000001010

    δ(   q5 , Y  )=(   q5, Y , L ) = 0000010000010000010000010

    δ(   q5 , X  )=(   q1, X , R ) = 00000100001010000100

    δ(   q1 , Y  )=(   q6, Y , R ) = 01000001000000100000100

    δ(   q6 , Y  )=(   q6 ,Y ,R ) = 0000001000001000000100000100

    δ(   q6 , B )=(   q2 ,B ,R ) = 00000010001001000100

    Codifcación:

     010100010000100 11 00010100010100 11 0001000001000100000100

    11 00010010000100000100 11 000010010000010000010

    11 00000101000001010 11 0000010000010000010000010

    11 00000100001010000100 11 01000001000000100000100

    11 0000001000001000000100000100 11 00000010001001000100

    1.4 ww

    M=({   q1, q2 , q3 , q4 , q5 , q6 , q7 , q8 ,q 9 , q10 ,q 11 , q12 , q13 ,q14 },{0,1},{0,1,B,X,,!},δ,   q1 ,B,

    {   q2 })

    E!"#$%

    q1⇒ estadoinicial

    q2⇒estado de aceptacion

    S&'$$%

  • 8/17/2019 Codificación maquinas de turing

    7/27

     x1=0 x2=1 x3=B x4= X  x5=@

     x5=$

    D*+*/%

     D1=

     L

     D2=

     R 

    donde δ:

    Desplazamiento una casilla a la derecha

    δ(   q1 , 0 )=(   q3, @ , R ) = 0101000100000100

    δ(   q1 , 1 )=(   q3 , $ , R ) = 010010001000000100

    δ(   q3 , 0 )=(   q3,0, R ) = 00010100010100

    δ(   q3 , 1 )=(   q3, 1, R ) = 0001001000100100

    δ(   q3 , B )=(   q4 , B , L ) = 000100010000100010

    δ(   q4

    ,0 )=(   q5, X , R ) = 00001010000010000100

    δ(   q5 , B )=(   q6, 0, L ) = 00000100010000001010

    δ(   q4 ,1 )=(   q7 , X , R ) = 00001001000000010000100

    δ(   q7 , B )=(   q6 , 1, L ) = 00000001000100000010010

    δ(   q6 , X  )=(   q4 , B , L ) = 0000001000010000100010

    δ(   q4 ,@ )=(   q8 , B , R ) = 00001000001000000001000100

  • 8/17/2019 Codificación maquinas de turing

    8/27

    δ(   q4

    , $ )=(   q9, B , R ) = 0000100000010000000001000100

    δ(   q8

    , B )=(   q10 , 0, L ) = 000000001000100000000001010

    δ(   q9 , B )=(   q10,1, L ) = 00000000010001000000000010010

    δ(   q10 , B )=(   q11, B , R ) = 000000000010001000000000001000100

    Comparar ww

    δ(   q 11 , X  )=(   q11 , X , R ) = 000000000001000010000000000010000100

    δ(   q 11 ,0 )=(   q12 , X , R ) = 0000000000010100000000000010000100

    δ(   q 12 , X  )=(   q12, X , R ) = 00000000000010000100000000000010000100

    δ(   q 12 ,1 )=(   q12, 1, R ) = 0000000000001001000000000000100100

    δ(   q12 ,0 )=(   q13, X , L ) = 00000000000010100000000000001000010

    δ(   q13 ,0 )=(   q13,0, L ) = 000000000000010100000000000001010

    δ(   q13 ,1 )=(   q13, 1, L ) = 00000000000001001000000000000010010

    δ(   q13 , X  )=(   q13, X , L ) = 000000000000010000100000000000001000010

    δ(   q13 , B )=(   q11 , B , R ) = 000000000000010001000000000001000100

    δ(   q 11 ,1 )=(   q14, X , R ) = 0000000000010010000000000000010000100

    δ(   q14 , X  )=(   q14 , X , R ) = 000000000000001000010000000000000010000100

    δ(   q14 ,0 )=(   q14 , 0, R ) = 000000000000001010000000000000010100

    δ(   q14 ,1 )=(   q13 , X , L ) = 00000000000000100100000000000001000010

    δ(   q11 , B )=(   q2, B , L ) = 000000000001000100100010

  • 8/17/2019 Codificación maquinas de turing

    9/27

    Codifcación:

      0101000100000100 11 010010001000000100 11 00010100010100 11

    0001001000100100 11 000100010000100010 11 00001010000010000100

    11 00000100010000001010 11 00001001000000010000100

    11 00000001000100000010010 11 0000001000010000100010

    11 00001000001000000001000100 11 0000100000010000000001000100

    11 000000001000100000000001010 11 00000000010001000000000010010

    11 000000000010001000000000001000100

    11 000000000001000010000000000010000100

    11 0000000000010100000000000010000100

    11 00000000000010000100000000000010000100

    11 0000000000001001000000000000100100

    11 00000000000010100000000000001000010

    11 000000000000010100000000000001010

    11 00000000000001001000000000000010010

    11 000000000000010000100000000000001000010

    11 000000000000010001000000000001000100

    11 0000000000010010000000000000010000100

    11 000000000000001000010000000000000010000100

    11 000000000000001010000000000000010100

    11 00000000000000100100000000000001000010

    11 000000000001000100100010

  • 8/17/2019 Codificación maquinas de turing

    10/27

    2.- "#a$%a& e'&eione 3-C*+

    2.1.- Códio de$ &o&aa.

    #include#include

    #include

    #include

    #define CNF 3

    struct variable{

    int signo;

    int subindice;

    };

    typedef struct variable variable;

    int **Crearabla!erdad"int filas int columnas$%

    &oid 'lenarabla!erdad"int **matriz int filas int columnas$%

    &ariable **Crear()presion"int filas int columnas$%

    &oid at"int **tabla!erdad&ariable **e)presionint n&ariables int nterminos$%

    int main"int argc char **arg&$+

    &ariable **e)presion,N-''%

    char cadena/001%

    char *p,N-''%

    char subindice201%

    int tam%int n&ariables,0%

    int nterminos,0%

    int i,0%

    int ,0%

  • 8/17/2019 Codificación maquinas de turing

    11/27

    int r,0%

    int t,0%

    int **tabla!erdad,N-''%

    F4'( *ptr,N-''%ptr,fopen"arg&516r6$%

    if"ptr,,N-''$+

    printf"6(rror al abrir el archi&o7n6$%

    e)it"5$%

    8

     while"fgets"cadena/00ptr$$+

    p,strto"cadena6 "$&97t7n6$%

    n&ariables,atoi"p$%

    p,strto"N-''6 "$&97t7n6$%

    nterminos,atoi"p$%

    e)presion,Crear()presion"nterminosCNF$%

    for"i,0%i

  • 8/17/2019 Codificación maquinas de turing

    12/27

    t::%

    8

    subindicet1,;70;%

    e)presioni11.signo,=5%e)presioni11.subindice,"int$atoi"subindice$%

    8

    else+

    for"r,5%r

  • 8/17/2019 Codificación maquinas de turing

    13/27

    int i%

    matriz , calloc"altosizeof"int *$$%

    for"i,0%i

  • 8/17/2019 Codificación maquinas de turing

    14/27

    8

    &ariable **Crear()presion"int alto int ancho$+

    &ariable **e)presion,N-''%

    int i%e)presion , calloc"altosizeof"&ariable *$$%

    for"i,0%i

  • 8/17/2019 Codificación maquinas de turing

    15/27

    if"and$+

    printf"6(s satisfactible con7n6$%

    for"l,0%l

  • 8/17/2019 Codificación maquinas de turing

    16/27

    (ecucin del programa

  • 8/17/2019 Codificación maquinas de turing

    17/27

  • 8/17/2019 Codificación maquinas de turing

    18/27

    ...- S83/#$ 2'5$ " " 75+*/ 

    ( x1∨¬ x2∨ x3)∧(¬ x1∨¬ x2∨¬ x3)∧(¬ x1∨¬ x2∨ x3)∧(¬ x1∨ x2∨¬ x3)∧( x1∨ x2∨ x3)¿∧(¬ x

    1∨ x

    2∨ x

    3)∧( x

    1∨ x

    2∨¬ x

    3)

    Irchi&o de te)to

    (ecucin del programa

    ..9.- E2'5$ 9% E6"3"+ " 75+*/

    ( x2∨ x4∨ x9)∧( x8∨¬ x10∨ x5)∧(¬ x6∨¬ x8∨¬ x10)∧( x2∨¬ x4∨¬ x9)∧¿(¬ x

    9∨¬ x

    3∨ x

    6)∧( x

    10∨ x

    5∨ x

    7)∧(¬ x

    7∨ x

    1∨¬ x

    2)∧( x

    2∨¬ x

    4∨ x

    9)∧( x

    3∨ x

    6∨¬ x

    8)

    ¿∧(¬ x5∨ x

    7∨ x

    1)∧(¬ x

    2∨¬ x

    4∨¬ x

    9)∧( x

    2∨ x

    4∨¬ x

    9)∧(¬ x

    1∨¬ x

    2∨ x

    4)∧( x

    2∨¬ x

    4∨ x

    9)

     

    Irchi&o de te)to

    (ecucin del programa

  • 8/17/2019 Codificación maquinas de turing

    19/27

  • 8/17/2019 Codificación maquinas de turing

    20/27

  • 8/17/2019 Codificación maquinas de turing

    21/27

  • 8/17/2019 Codificación maquinas de turing

    22/27

  • 8/17/2019 Codificación maquinas de turing

    23/27

  • 8/17/2019 Codificación maquinas de turing

    24/27

  • 8/17/2019 Codificación maquinas de turing

    25/27

  • 8/17/2019 Codificación maquinas de turing

    26/27

  • 8/17/2019 Codificación maquinas de turing

    27/27