Computabilidad · Lenguajes formales

Los conceptos de la computación, explicados visualmente.

Explora pilas, autómatas finitos y la máquina de Turing con simuladores interactivos. Nada de teoría abstracta: toca, ejecuta y observa cómo funciona cada modelo.

LIFO / FIFO

El orden de llegada importa: pilas y colas estructuran datos.

Estados

Los autómatas deciden si una cadena pertenece a un lenguaje.

Cómputo universal

Turing define el límite de lo calculable.

Guía de repaso

Del símbolo al límite

Una ruta completa para entender cómo los modelos de computación leen, recuerdan, transforman y deciden sobre la información.

Σ

Alphabet, string and language

An alphabet Σ is a finite set of symbols. A string is a finite sequence of symbols; a language is a set of strings over Σ.

Σ = {0, 1}
w = 0101  →  |w| = 4
L = { w ∈ Σ* : w termina en 01 }

The central question is always: does w belong to L?

Operations that appear in exams

  • uv concatenates u and v; order matters.
  • ε is the empty string and |ε| = 0.
  • Σ* contains every finite string, including ε.
  • Lᶜ contains the strings in Σ* that are not in L.
  • L* allows concatenating zero or more strings from L.
?

Recognizing is not generating

A model recognizes a language when it receives a string and answers yes/no. A generator describes how to produce valid strings. The same idea can be expressed as an automaton, a regular expression or a grammar.

Input
string w
Output
accept / reject

Which model do I need?

DFAIt only needs to remember a finite number of situations.
PDAIt needs to count or nest without knowing the size in advance.
TMIt needs rewritable memory and movement in both directions.

Key idea: do not choose a model by the problem's name; choose it by the memory the solution needs.

Submission checklist

  1. 01Define Σ, the language and what acceptance means.
  2. 02State the initial state, stack or configuration.
  3. 03Write at least one accepted and one rejected trace.
  4. 04Justify with an invariant, not only a diagram.
  5. 05Check ε, short strings, unexpected symbols and cost.

Rule of thumb: a trace shows what happened for one input; an invariant explains why the model keeps working for every input.

Estructura de datos

Pilas (Stack)

    simulador-pila
    size: 0

     

    Exploración en 3D

    La pila, en tres dimensiones

    Los mismos datos del simulador anterior, renderizados como bloques 3D. Arrastra para orbitar y usa la rueda para acercarte: cada push hace caer un bloque nuevo desde arriba.

    Modelos de cómputo

    Autómatas finitos (AFD)

    Un autómata finito determinista lee una cadena símbolo a símbolo y salta entre estados según transiciones fijas. Si al terminar está en un estado de aceptación (doble círculo), la cadena pertenece al lenguaje.

    1 0 0 1 1 0, 1 q₀ q₁ q₂

    L = cadenas binarias que terminan en «01» · q₂ es estado de aceptación (doble círculo)

    Simulador

    estado actual q₀

     

    Quiz: ¿acepta o rechaza?

    0 0 / 0

     

    Logros

    El puente: estados + memoria

    Autómata con pila (PDA)

    Un AFD no puede recordar cuántas «a» leyó. Un autómata con pila añade una pila como memoria auxiliar, y de repente lenguajes como aⁿbⁿ se vuelven reconocibles: apila una ficha por cada «a» y desapila una por cada «b». Si la pila queda vacía justo al terminar, la cadena es válida.

    a · apilar b · desapilar b · desapilar q₀ q₁

    L = aⁿbⁿ · aceptación: estado q₁ con pila vacía (solo el fondo Z)

    estado actual q₀

     

    Memoria auxiliar

    Z₀
    Pensar como diseñador

    Cómo resolver un ejercicio de computabilidad

    La teoría deja de parecer una colección de dibujos cuando sigues siempre la misma secuencia: especificar, elegir memoria, ejecutar y demostrar.

    The five-step method

    1

    Specify the language

    Write the alphabet and a mathematical definition of L. Avoid ambiguous phrases such as “valid strings”.

    2

    Identify the required memory

    If a finite summary is enough, use a DFA. If you must match or nest, think about a stack.

    3

    Define the configuration

    State the head position, current state and the symbols left to read or stored in memory.

    4

    Trace boundary cases

    Test ε, the shortest valid string, a near miss and a string that breaks the rule at the first symbol.

    5

    Justify with an invariant

    Explain what each state or memory symbol represents after every prefix has been read.

    Example A / DFA

    Strings ending in 01

    For w = 1101, the trace is:

    q₀ —1→ q₀ —1→ q₀ —0→ q₁ —1→ q₂

    It ends in q₂, so it accepts. The automaton only needs to remember the most relevant recent symbols.

    Example B / PDA

    The aⁿbⁿ invariant

    After reading aⁱbʲ, the stack contains exactly Aⁱ⁻ʲ. If an a appears after a b, the language's shape has already been broken.

    For aabb: push A, A; pop A, A; only Z₀ remains, so the string is accepted.

    Common mistakes to avoid

    Confusing acceptance with halting: a TM may halt and reject; halting does not mean accepting.

    Counting with a DFA: an arbitrary count cannot fit in finite memory.

    Forgetting ε: the empty string may belong to the language and should be tested separately.

    Drawing without an invariant: a nice diagram does not prove that it covers every string.

    Proof toolkit

    Induction: prove a base case and show that each step preserves the property.

    Pumping lemma: use it to show that a language cannot be regular or context-free.

    Closure: if a family is closed under union, complement or intersection, you can build new languages.

    Reduction: transform a known problem into the one you are analyzing; if the first is impossible, so is the second.

    Power and cost are different

    DFAreads n symbols in O(n) and uses constant memory.
    Stackpush, pop and peek cost O(1); traversing costs O(n).
    TMcan solve more, but runtime depends on the program and may not halt.

    More memory expands the class of languages you can recognize; it does not guarantee a fast algorithm.

    Construye el tuyo

    Editor de autómatas

    Crea estados, conéctalos con transiciones 0/1, marca el inicial (doble clic) y los de aceptación. Tu autómata se guarda automáticamente y puedes exportarlo o importarlo como JSON.

    clic para crear estados · arrastra para mover

     

    doble clic sobre un estado → marcarlo como inicial · clic en la etiqueta de una transición (modo borrar) para eliminarla

    El modelo fundacional · 1936

    Máquina de Turing

    Una cinta infinita, un cabezal que lee/escribe y un conjunto de reglas. Con solo eso, cualquier problema computable puede resolverse — y también quedan definidos los problemas indecidibles, como el problema de la parada.

    Estado

    q₀

    Paso

    0

    Regla aplicada

    Resultado

    en espera

    Programa cargado

    Esta máquina incrementa un número binario en 1. Recorre la cinta hasta el final y suma con acarreo hacia la izquierda.

    ¿Por qué importa?

    La tesis de Church-Turing sostiene que nada que sea «computable» supera a esta máquina simple. Todo tu ordenador es, en esencia, una máquina de Turing muy rápida.

    Panorama

    Jerarquía de Chomsky

    Cada tipo de gramática tiene su autómata asociado. A más potencia, más coste de cómputo.

    Tipo Gramática Autómata Ejemplo de lenguaje
    Type 3 Regular AFD / AFN a*b | (ab)*
    Type 2 Context-free Pushdown automaton aⁿbⁿ
    Type 1 Context-sensitive Linear bounded automaton aⁿbⁿcⁿ
    Type 0 Unrestricted Turing machine todo lo decidible… y más

    El límite existe: hay problemas que ninguna máquina de Turing puede resolver — como decidir si un programa arbitrario termina (problema de la parada, Alan Turing, 1936). No es falta de velocidad ni memoria: es una imposibilidad matemática.

    Consulta rápida

    Glosario de bolsillo

    Las palabras que aparecen una y otra vez en teoría de la computación, explicadas en una línea para que puedas volver a ellas mientras resuelves.

    Σ · alphabet

    Finite set of symbols allowed as input.

    Σ* · closure

    Every finite string over Σ, including the empty string ε.

    ε · empty string

    A string with no symbols; its length is 0, but it is still a string.

    L · language

    Subset of Σ*. The recognition problem asks whether w ∈ L.

    δ · transition

    Rule that gives the next state or configuration after reading a symbol.

    State

    Summary of the information the model keeps at a given moment.

    Determinism

    From a given configuration and symbol, there is at most one next action.

    Invariant

    Property that remains true after every execution step.

    Decidable

    A machine exists that always halts and answers yes or no correctly.

    Recognizable

    A machine accepts the language's strings, although it may not halt outside the language.

    Closure

    Property of a language family that remains in the family after an operation.

    Reduction

    Transformation showing that solving one problem would let us solve another.

    Guided practice

    Banco de ejercicios razonados

    Intenta responder antes de abrir la solución. La explicación importa tanto como el resultado.

    expandable solutions
    01Does 0101 belong to the language of strings ending in 01?

    Yes. The string ends in 01 and the DFA trace ends in q₂. Its length and earlier symbols do not change that condition.

    02Does aabbb belong to {aⁿbⁿ : n ≥ 0}?

    No. It has two a symbols and three b symbols. The PDA runs out of stack tokens before reading the last b; the counts must match.

    03Design a DFA for strings with an even number of 1s.

    Use two states: q_even (initial and accepting) and q_odd. On 0, stay in the same state; on 1, switch between them.

    04What does the stack represent after reading aaabb?

    A remains above the bottom marker Z₀: three tokens were pushed and two were popped. The string is not accepted yet because one b is missing.

    05What does the TM produce when incrementing 111?

    1000. The machine changes each 1 to 0 while carrying left; when it reaches the blank, it writes a 1.

    06What is the cost of push, pop and peek?

    In a correctly implemented stack, all three operations are O(1). Traversing or copying the entire stack costs O(n).

    Suggested 60-minute route

    1. 15 min · Read the basics and write three languages with their alphabets.
    2. 15 min · Run one accepted and one rejected string in each simulator.
    3. 15 min · Build a DFA in the editor and test boundary cases.
    4. 15 min · Solve two exercises without looking at the solution and explain the invariant.

    Go deeper

    Once this page feels familiar, compare your solutions with reference texts: Introduction to the Theory of Computation by Michael Sipser, Introduction to Automata Theory, Languages, and Computation by Hopcroft, Motwani and Ullman, or An Introduction to Formal Languages and Automata by Peter Linz.

    Community tip: share the trace and reasoning, not only the final answer.

    Ponte a prueba

    Retos con verificación

    Tres desafíos que cruzan todo lo aprendido. Tu progreso se guarda y completarlos todos desbloquea logros.

    Progreso0 / 3
    AFD

    Cadena aceptada larga

    Escribe una cadena de longitud ≥ 5 que termine en q₂ (es decir, que sea aceptada).

    MT

    Incremento binario

    ¿Qué número produce la máquina al incrementar 1011? Escribe el resultado en binario.

    PDA

    Equilibrio perfecto

    Escribe una cadena aceptada por el autómata con pila con exactamente n a seguidas de n b, donde n ≥ 2.

    clase en curso