張竣傑
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Turing Machine Turing machine was proposed by **Alan Turing** in 1936. Used as automata in computational issues: * Decidabililty of problems * Time/Space complexity analysis of problems * Algorithms design and analysis A Turing machine can: 1. Read a symbol from the tape, but the symbol is not erased! 2. **Write** a symbol on the tape. 3. Move the head left or right. 4. Change its state. ## Components * An infinite input tape. * A state register. * A control unit. * A read/write head ## Mathematical Model A Turing machine is defined by: $$ M = (K, \Sigma, \delta, s, H) $$ Where: * $K$: A fintie set of states. * $\Sigma$: The alphabet. * $s$: Initial state. * $H$: The set of **halting** states, it is a subset of $K$. * $\delta$: The transition function. Transition function defines actions of $M$: * $\delta(q, a) \rightarrow (p, b)$: changing state and tape. * $\delta(q, a) \rightarrow (p, \rightarrow)$: move right. * $\delta(q, a) \rightarrow (p, \leftarrow)$: move left. ## Acceptance The machine **stops** when it enters a halting(final) state. The machine leaves the **result** in the tape. > If the transition function is not carefully designed, the machine may loop forever. ## Language of Turing Machine Recognition process of an input string: * Keep the input sting $w$ in the tape. * The TM processes $w$ according to its transition function. * The TM has 2 halting states, $H = {y, n}$ * If halting in $y$-state, it accepts the input string. * If halting in $n$-state, it reejects the string. ### Recursive Language Definition: A language is **recursive**, if it is **decidable** by some Turing machine. #### Compare with Context Free A PDA can always be simulated by using a Turing machine, so context free language is a proper subset of **recursive language class**. ### Recursively Enumerable Languages Definition: A language is **recursively enumerable**, if it is **semi-decidable** by some Turing machine. > Recursively Enumerable > Recursive #### Semi-Decidable A language $L$ is **semi-decidable** by Turing machine if: * For any string $w$ in $L$, $M$ enters the halting state, $h$, at the end of the computation. * For any string $w$ NOT in $L$: $M$ loops forever. > Compared with decidable carefully, "Decidable" means that Turning machine always halt in **y** or **n** state; "Semi-decidable" means halting or loop-forever. ### Semi-deciable vs Decidable Theorem: **Recursive language** class is a proper subset of **recursively enumerable language** class. > Because decidability is a proper subset of semi-decidability,所以說 Semi-decidable 會比 Decidable 強大。 ## Turing Computable Functions ### Numerical Computation Turing machines can be used to compute (numerical) functions. * The input (if any) is kept in the tape. * The results are left on the tape. ### Basic Functions Definition: Functions which are directly computable by using Turing machine. * The Turing machine are designed by using **mathematical definition** or **machine schema**. Key basic functions ($x$ and $y$ are binary number): * Minus 1: $x = x - 1$ * Add 1: $x = x + 1$ * Test zero: $x = 0 ?$ * 1's or 2's complement: $-x$ * Addition and subtraction: $x+y$, $x-y$. ### Recursive Function A function which is **computable** by Turing machine is called by a **recursive function**. Turing machine can compute functions of $n$ parameters. ### Function Classes Function classes: * Basic functions * Primitive recursive functions * Partial recursive functions ## Non-determinstic Turing Machine Definition: If the transition functions is replaced by a transition relation, the Turing machine becomes a non-deterministic Turing machine. A NTM may: 1. Hang on the current configuration since no action can be taken. 2. It may have multiple chocies for this configuration. ### Acceptance * If $w \in L$: There are **some** computations leading the machine into acceptance configurations. * If $w \notin L$: The machine always rejects the string. ### Decidable by NTM If the language $L$ is decidable by an non-determinsitc Turing machine $M$, then $L$ is still a recursive language. ### Semi-decidable by NTM If the language $L$ is **semi-decidable** by an non-determinsitc Turing machine $M$, then $L$ is still a **recursively enumerable language**. ## Determinstic Turing Machine Definition: For each configuration, a deterministic Turing machine has exactly only one operation to perform. ### Non-determinstic vs Determinstic Theorem: Every DTM is an NTM. Non-deterministic Turing machine can be converted into deterministic Turing machines. 非常重要!!! In the aspect of **computational power**: **non-deterministic Turing machines = deterministic Turing machines.** **Theorem: Every DTM is an NTM.** * Transition functions are special cases of transition relations. * Therefore, DTM are NTM by definition. * DTM $\leq$ NTM Theoerm: Non-deterministic Turing machines can be converted into deterministic Turing machines. Conclusion: * NTM $\geq$ DTM. * NTM $\leq$ DTM. * Totally, NTM $=$ DTM. ![](https://i.imgur.com/WddL3Ml.png) ## Extensions We can add the following facilities to a Turing machines: 1. Multiple tapes. 2. Multiple heads. 3. Two-way tape. 4. Random access memory. 5. Two-dimensional memory. 6. A stack, multiple Turing machines in a Turing machine. These extensions may increase the efficiency of Turing machine, However, none of these facilities will increase the power of Turning mahcines. ## Church-Turing Thesis Turing machines are the **ultimate** computational devices. Turing machines = algorithms. Never be proved or denied. Any Turing machine solvable problems can be solved by using modern computers. Any Tuting machine sovlable problems can be solved by using algorithms. If a problem is unsolvable by using Turing machine, it's unsolvable for modern computer either. Therefore, no algorithm for solving such problem. ## Design Turing Machine Define a Turing machine by using the mathematical model is inconvenient. Understanding a Turing machine via its formal definition is not easy. Design Turing machine by using **machine schema**. ## Turing Equivalence A computational device which can simulate Turing machine is called **Turing Equivalence** or **Turing Complete**. # Machine Schema For finite automata, transition diagrams are easier to understand than formal models of finite automata, We can use a similar methodology to design Turing machine. * Represent Turing machine operations as basic instructions. * Code more instructions using these basic instructions. * Create complex instructions by using the available instructions. * Program advanced Turing machine by using this instructions set. * Draw flowcharts to represent Turing machine. Design Turing machine by using the following method: * Represent instructions by using symbols. * Create subroutines to form complex instructions. * Draw Turing machine by using flowcharts (Directed Graphs) * **Vertices**: symbols of instructions and subroutines. * **Arcs**: conditional / unconditional branches or loops. ## Basic Machines Use simple Turing machine as basic instruction, for example: * Writing an `a` in the tape $\rightarrow$ represented by the symbol 'a'. * Moving right, $\rightarrow$ represented by 'R'. * Moving left, $\rightarrow$ represented by 'L'. R a R: Means move right, write an 'a' and move right. * Conditional branches: if encounter an `a` move right: $\xrightarrow{a}R$ * Unconditional branches: just jump to there, and move right: $\rightarrow R$ * until encountering a certain symbol: $L_{\#}$: move left until encountering a '#'. $R_{\overline{\#}}$: move right until encounter a non-'#' symbol ### Example Copy machine: copy the string $w$ in the input tape and stop at the '#' between the two strings. $\#w\# \rightarrow \#w\#w\#$ ![](https://i.imgur.com/bRJvp5g.png) ## Multiple Tape We can use multiple tapes to keep the input, intermediate results, or results. Multiple tapes simplify Turing machine design. Use **superscripts** to indicate tape indices. * $R^1, a^2$ // Move right in tape 1, write an 'a' in tape 2. * $L^{1,2}, \#^2\#^1$ // Move left in tape 1 and 2, write a '#' in tape 1 and 2. # Functions 如果有一個 Function 可以被 Turing machine 計算,就稱之為 **Recursive Functions**。 Turing machines can be used to compute functions. However, not all functions are computable by Turing machines! Computable functions are divided into 3 classes: * Basic functions * Primitive recursive functions * $\mu$-recursive functions (partial recursive functions) Theorem: a function is $\mu$-recursive if and only if it is computable by Turing machines. > Partial recursive functions = Recursive functions > Primitive recursive,Primitive recursive 是 Recursive functions 的一種特例。 ## K-ary Basic Functions A k-ary function takes k arguments and produce one result. ## Basic Functions Some functions are so basic that we can design Turing machine computing them directly. ## Complicated Functions More complicated functions can be defined by using functional operators. * These functional operators are Turing machine computable! Functional operators: 1. function composition 2. recursive definition 3. definition by cases 4. minimalization ## Primitive Recursive Functions Definition: The primitive recursive function class includes: * Basic functions * Functions defined by using function **composition** * Functions defined by using **recursive definition** ### Primitive Recursive Predicates A function can be not only numerical but also logical. Definition: a primitive recursive function which return 1 or 0 is a primitive recursive predicate. ## Partial Recursive Functions Definition: The partial recursive functions class includes: * Basic functions * Functions defined by using function composition * Functions defined by using recursive definition * Functions defined by using **minimalization** # Unrestricted Grammar ## Definition $$ G = (V, \Sigma, R, S) $$ * $V$ is an alphabet. (Variables + Terminals) * $\Sigma$ is a subset of $V$, the set of terminals * $R$ is the set of grammar rules: $V^\star (V-\Sigma) V^\star \rightarrow V^\star$ * $S$ is a start **variable**. ### Unrestricted and Context Free Grammars Their definitions are very similar. However, only **one non-terminal** appears at the left hand sides of Context Free Grammar rules: $(V-\Sigma) \rightarrow V^\star$ ### Derivation String To derive a string: * Strarting with the initial symbol, a non-terminal. * Applying a grammar rule to replace a substring of the current string with another sub-string in each step. ### Grammar and CFG * Every Context-Free Grammar is a simplified grammar. * A grammar is not necessarily a Context-Free Grammar. * So **Grammar > Context-Free Grammar** ### Grammar and Turing Machines * Theorem: Unrestricted grammars are equivalent to Turing machines. * **Grammer**: language generators * **Turing Machine**: language recognizers. ### Recursively Enumerable Languages Theorem: The languages generated by unrestricted grammars are **recursively enumerable languages**. * $L$ is generated by a grammar if and only if $L$ is **semi-decidable** by a Turing machine. # Closure Properties ###### tags: `計算理論`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully