Abstract Machines (bephpug)

A4b95be2145cc46f891707b6db9dd82d?s=47 Igor Wiedler
February 04, 2014

Abstract Machines (bephpug)

A4b95be2145cc46f891707b6db9dd82d?s=128

Igor Wiedler

February 04, 2014
Tweet

Transcript

  1. 3.
  2. 5.
  3. 6.

    • Link between our universe and computational universe • Cellular

    automata are self-replicating abstract machines • Humans are self-replicating biological machines (down to the cellular level) • Or is the entire universe a single machine?
  4. 9.
  5. 10.

    • if alive • 2 or 3 neighbours to survive

    • if dead • exactly 3 neighbours to spawn • else • cell is dead
  6. 11.
  7. 12.

    1 1 2 1 3 5 2 2 1 2

    2 2 2 3 2 1
  8. 13.

    1 1 2 1 3 5 2 2 1 2

    2 2 2 3 2 1
  9. 14.
  10. 15.
  11. 16.
  12. 17.
  13. 18.
  14. 19.
  15. 20.
  16. 21.
  17. 22.
  18. 23.
  19. 26.

    • Other cellular automata • Codd’s automaton (8 states) •

    Langton’s loops (8 states) • Wireworld (4 states)
  20. 29.
  21. 35.
  22. 36.
  23. 37.
  24. 38.
  25. 39.
  26. 40.
  27. 41.

    234

  28. 42.

    34

  29. 43.

    4

  30. 44.
  31. 45.
  32. 46.

    • M = (Q, Σ, δ, q0, F) • Rule

    δ = (qi, a → qi1) • Can accept regular languages
  33. 47.
  34. 48.

    $rules = [ 0 => ['c' => 1, 'f' =>

    7, 'r' => 9], 1 => ['l' => 2], 2 => ['o' => 3], ... ]; ! $tokens = ['f', 'i', 'x', 'e', 's', ' ', '#', '1', '2', '3', '4', 'EOF']; ! foreach ($tokens as $token) { if (!isset($rules[$state][$token])) { throw new NoTransitionException(); } ! $state = $rules[$state][$token]; } ! $accepted = in_array($state, $accept_states);
  35. 50.

    baz

  36. 51.

    baz

  37. 52.

    az

  38. 53.

    z

  39. 54.
  40. 55.
  41. 56.
  42. 57.

    • Does not add computational power • Can be compiled

    to a DFA • Previous DFA example already showed this • Basic quantum physics
  43. 58.
  44. 61.
  45. 62.
  46. 70.
  47. 71.
  48. 72.
  49. 73.

    e

  50. 74.

    e

  51. 75.

    • M = (Q, Σ, Γ, δ, q0, Zo, F)

    • Rule δ = (qi, a, sj → qi1, sj1) • Can accept context-free languages
  52. 78.
  53. 79.
  54. 80.
  55. 81.
  56. 82.
  57. 83.
  58. 84.
  59. 85.
  60. 86.
  61. 87.
  62. 88.
  63. 89.
  64. 90.
  65. 91.
  66. 92.
  67. 93.
  68. 94.
  69. 95.
  70. 96.
  71. 97.
  72. 98.

    • M = (Q, Σ, Γ, δ, q0, b, F)

    • Rule δ = (qi, aj → qi1, aj1, dk) • Can accept recursively enumerable languages • Or loop forever
  73. 99.

    while (!in_array($state, $accept_states)) { $read_val = isset($tape[$position]) ? $tape[$position] :

    '_'; ! if (!isset($rules[$state][$read_val])) { throw new NoTransitionException(); } ! list($write_val, $move_dir, $new_state) = $rules[$state][$read_val]; ! $tape[$position] = $write_val; ! if ('l' === $move_dir) { $position--; if ($position < 0) { $position++; array_unshift($tape, '_'); } } else if ('r' === $move_dir) { $position++; if ($position >= count($tape)) { array_push($tape, '_'); } } ! $state = $new_state; }
  74. 107.

    U M

  75. 108.
  76. 111.

    • System capable of emulating a turing machine • Unbounded

    storage • Conditional branching • Recursion
  77. 113.

    • If PHP can only do as much as a

    turing machine, why bother? • Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy. • Epigrams on Programming by Alan Perlis
  78. 114.

    • Is our universe really turing complete? • Or are

    the possible paths finite and pre- determined? • Do even stronger forces exist?
  79. 116.

    <?php $data = <<<'DATA' $program = <<<PROGRAM <?php \$data =

    <<<'DATA'\n$data\nDATA; $data ! PROGRAM; echo $program; DATA; $program = <<<PROGRAM <?php \$data = <<<'DATA'\n$data\nDATA; $data ! PROGRAM; echo $program;
  80. 117.
  81. 118.
  82. 121.
  83. 123.

    • Let R be the set of all sets that

    do not contain themselves • Does R contain itself? • If yes, then R’s definition is incorrect • If no, R is not in the set, so it must contain itself
  84. 124.

    • Liar paradox: “This sentence is false.” • Type theory

    • Hierarchy of types avoids self-reference
  85. 126.

    • David Hilbert asks for an algorithm that decides if

    a statement in first-order logic is universally valid • Halting problem can be reduced to Entscheidungsproblem • Machine that determines if another machine will halt
  86. 127.
  87. 131.
  88. 142.
  89. 143.
  90. 146.
  91. 148.