try's notebooks

  • Formal Definition of a NFA - /try/formal-definition-of-a-nfa
    Last edited 5 years ago
    // the five tuples const Q = states = new Set(['q1', 'q2', 'q3', 'q4']) const Sigma = alphabet = new Set(['0', '1']) const delta = transitionFunction = (state, symbol) => { const table = { 'q1': { '0': new Set(['q1']), '1': new Set(['q1', 'q2']), 'e': new Set() }, 'q2': { '0': new Set(['q3']), '1': new Set(), 'e': new Set(['q3']) }, 'q3': { '0': new Set(), '1': new Set(['q4']), 'e': new Set() }, 'q4': { '0': new Set(['q4']), '1': new Set(['q4']), 'e': new Set() } } return table[state][symbol] } const q0 = startState = 'q1' const F = finalStates = new Set(['q4'])
  • Finite Automaton P34 - /try/finite-automaton-p34
    Last edited 5 years ago
    // states, P34 const states = ['q1', 'q2', 'q3'] const startState = 'q1' const endState = 'q2' // rules const q1 = (input) => { switch (input) { case '0': return 'q1' case '1': return 'q2' } } const q2 = (input) => { switch (input) { case '0': return 'q3' case '1': return 'q2' } } const q3 = (input) => { switch (input) { case '0': case '1': return 'q2' } } // machine business const check = (string) => { let arr = string.split("") let currState = startState for (let i = 0; i < arr.length; i++ ) { currState = eval(currState)(arr[i]) } return currState == endState ? 'accept' : "reject" }
  • Formal Definition of a Finite Automaton - /try/formal-definition-of-a-finite-automaton
    Last edited 5 years ago
    // the five tuples const Q = states = new Set(['q1', 'q2', 'q3']) const Sigma = alphabet = new Set(['0', '1']) const delta = transitionFunction = (state, symbol) => { const table = { 'q1': { '0': 'q1', '1': 'q2' }, 'q2': { '1': 'q2', '0': 'q3' }, 'q3': { '1': 'q2', '0': 'q2' } } return table[state][symbol] } const q0 = startState = 'q1' const F = finalStates = new Set(['q2'])
  • Automatic Door - /try/automatic-door
    Last edited 5 years ago
    From book Introduction of the theory of computation Page 31