Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Computer Science 101 Theory of Computing Computer Science is . . . • The study of algorithms, with respect to – their formal properties – their linguistic realizations (in programming languages, from Python down to machine code) – their hardware realizations (machine architecture, logic circuits, transistors) Things to Desire in an Algorithm • Correctness • Maintainability • Efficiency Wait, can it be solved? • There are problems that do not have any algorithmic solution! • Algorithms are carried out by computing agents • What can these agents do, and what can’t they do? What is a model? • Models – Capture the essence of the real thing – Probably differ in scale from the real thing – Omit some of the details of the real thing – Lack the full functionality of the real thing A Model of a Computing Agent • Computing agent should be able to: – Accept input – Store information in and retrieve it from memory – Take actions according to algorithmic instructions – Produce output The Turing Machine • Developed by Alan Turing to demonstrate theoretical properties of computation • 1935, before real computers • Still the theoretical basis of computing The Turing Machine • Developed by Alan Turing to demonstrate theoretical properties of computation • 1935, before real computers • Still the theoretical basis of computing Components of a TM • Memory – a paper tape to which symbols can be written or from which they can be read • States – a set of descriptions of actions to be performed (reading, writing, and moving the read/write head on the tape) • Alphabet – a set of symbols to be input or output The TM Tape Consists of squares in which symbols are written Extends an infinite distance in both directions (can always buy more tape) Can read or write a symbol from/to one square at a time The Read/Write Head and States At startup, the read/write head (the arrow) is placed next to a square on the tape State 1 says “if the tape symbol is a 0, write a 1, move one square to the right, and go into state 2” The Read/Write Head and a State The change from one state to the next one is called a transition On each transition, an input symbol is read, an output symbol is written, the read/right head moves left or right, and the machine goes into the next state The Read/Write Head and a State Sometimes, the current state and the next state are the same (like a loop) Sometimes, the input and output symbols are the same The alphabet can contain any symbols What Can a TM Do? • Can execute a whole sequence of instructions • Can accept input • Can store information in and retrieve it from memory • Can take actions according to algorithm instructions • Can produce output A Model of an Algorithm • An algorithm must: – Be a well-ordered collection – Consist of unambiguous and effectively computable operations – Halt in a finite amount of time – Produce a result Turing Machine Examples • Turing machine – Must begin in state 1 on the leftmost nonblank cell – Machine state 1 must be a state in which 0s are changed to 1s and 1s are changed to 0s Bit Inverter • State diagram – Visual representation of a Turing machine algorithm – Circles represent states, and arrows represent transitions from one state to another Invert the Bits This TM needs another transition, which reads a blank, writes a blank, moves left, and goes into State 2 State 2 then has no transitions (no actions), so it’s the halt state Tuple Representation of States A state can also be represented as a set of tuples Each tuple has the form IN OUT NEXT DIR States for the bit inverter TM: State 1 IN OUT NEXT DIR 0 1 1 R 1 0 1 R b b 2 L State 2 (halt state)