640 likes | 653 Views
B. B. 1. 0. B. NECSI Summer School 2008 Week 3: Methods for the Study of Complex Systems Computation Theory. Hiroki Sayama sayama@ binghamton.edu. Four approaches to complexity. Nonlinear Dynamics Complexity = No closed-form solution, Chaos. Information Complexity =
E N D
B B 1 0 B NECSI Summer School 2008Week 3: Methods for the Study of Complex SystemsComputation Theory Hiroki Sayama sayama@binghamton.edu
Four approaches to complexity Nonlinear Dynamics Complexity = No closed-form solution, Chaos Information Complexity = Length of description, Entropy Computation Complexity = Computational time/space, Algorithmic complexity Collective Behavior Complexity = Multi-scale patterns, Emergence
Computation? A sequence of rewritings applied to a symbolic representation of something • Rewriting rules are predefined and fixed so that: • Process of computation is efficient • Final result is accurate and useful
Proposition • A logical statement that is either true or false • “A human is an animal.” (true) • “An animal is a human.” (false) • These are both valid propositions
Propositional variables Propositional variables • “A human is an animal.” (true) • “An animal is a human.” (false) A = true (1), B = false (0) Propositional logic is about truth values only; no semantics involved → A → B Truth value
Logical operators • NOT (negation) ¬A, A • OR (disjunction) A∨B, A+B • AND (conjunction) A∧B, AB
A B A∨B 0 0 0 0 1 1 1 0 1 1 1 1 A B A∧B 0 0 0 0 1 0 1 0 0 1 1 1 A ¬A 0 1 1 0 Truth table
Logical formula • Symbolic expressions made of propositional variables and logical operators ¬B∧C (A∧B)∨(B∧¬C) • They are also propositions, and their truth values will be determined if truth values of all variables are given
Truth table of logical formula • X = (A∧B)∨(B∧¬C) A B C X 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1
Exercise • Create truth tables of the following logical formulae: ¬(A∨B)∨¬A (A∧¬B)∧(A∨C)
Equivalence of logical formulae • Two logical formulae are equivalent if they have exactly the same truth table ¬(A∨B)∨¬A ⇔ ¬A
A B A→B 0 0 1 0 1 1 1 0 0 1 1 1 Logical operator for “implication” A → B • This expresses that “B must be true if A is true” ?
A B A⇔B 0 0 1 0 1 0 1 0 0 1 1 1 Logical operator for “equivalence” A ⇔ B • This expresses that “A and B are logically equivalent”
Complete set of operators • A set of logical operators with which any logical formula can be equivalently expressed • Examples: • { NAND } • { NOR } • { NOT, AND } • { NOT, OR }
Proof in propositional logic • Premises: A, B, C, … • Conclusion derived from premises: X • Proof in propositional logic is to show that (A∧B∧C∧…) → X is ALWAYS true
Method of proof (1) • Complete the truth table exhaustively and show that the formula is always true regardless of situations • Trivial, mechanistic method • Impractical if many variables are involved (due to explosion of possibility space)
Exercise • Prove “If A→(B→C), then (A→B)→(A→C)” by creating a truth table of this proposition
Method of proof (2) • Starting from unquestionably true “axioms”, keep modifying formulae based on logically sound inference rules until you reach what you want • Non-trivial, heuristic method • Potentially capable of proving complicated propositions through exploration • What humans usually do in math, physics • Reachable formulae are called “theorems”
Example: Hilbert-Bernays system • Made of 15 basic axioms and just 1 inference rule • The only inference rule: If A and A→B are both theorems, then B is also a theorem
Hilbert-Bernays axioms (1) I. Implication (1)A→(B→A) (2)(A→(A→B))→(A→B) (3)(A→B)→((B→C)→(A→C))
Hilbert-Bernays axioms (2) II. Conjunction (1)A∧B→A (2)A∧B→B (3)(A→B)→((A→C)→(A→B∧C))
Hilbert-Bernays axioms (3) III. Disjunction (1)A→A∨B (2)B→A∨B (3)(A→C)→((B→C)→(A∨B→C))
Hilbert-Bernays axioms (4) IV. Equivalence (1)(A⇔B)→(A→B) (2)(A⇔B)→(B→A) (3)(A→B)→((B→A)→(A⇔B))
Hilbert-Bernays axioms (5) V. Negation (1)(A→B)→(¬B→¬A) (2)A→¬¬A (3) ¬¬A→A
Hilbert-Bernays axioms (6) • Any formula that can be obtained by replacing A, B, and/or C in the basic axioms with other expressions is also an axiom • Example: A→(B→A) is an axiom, therefore (A→B)→(C→(A→B)) is also an axiom
Example of proof in HB system • Proving A∨A→A: Replace B in basic axiom I-(1) by A A→(A→A) Replace B in basic axiom I-(2) by A (A→(A→A))→(A→A) Apply inference rule to the above two formulae A→A Replace B and C in basic axiomIII-(3) by A (A→A)→((A→A)→(A∨A→A)) Apply inference rule to the above two formulae ((A→A)→(A∨A→A)) Apply inference rule to the above and A→A A∨A→A
Exercise • Prove A∧B→A∨B in the HB system
Consistency, soundness, completeness • An axiomatic system is: • Consistent if it doesn’t prove any theorems that contradict to each other • Sound if its inference rules never produce false formula from true premises • Complete if it can prove or disprove all possible logical formula • HB system is known to be consistent, sound and complete within prop. logic
Logic vs. computation • Logic is a static description • It describes relationships between facts • It illustrates potential pathways leading to truth, but doesn’t tell where to go • Computation is a dynamic process • It executes specific operations in order • Computer (either machine or human) has its own internal states, I/Os, etc.
Automaton • A formal representation of dynamic, autonomous behaviors of machines • Has internal states • Changes its states and produces outputs over time according to predefined rules that refer to its own states and inputs received • States and time are usually discrete
Example • Parity checker • Tells whether the number of 1’s included in an input (bit string) is even or odd Initial state 1 Even Odd 1 0 0
Formal languages and automata • Formal language: An infinite set of strings that are grammatically valid • There are several distinct classes of grammatical complexity • Computational power of an automaton is often characterized by the class of languages it can recognize • After “hearing” a string, the automaton’s internal state tells whether that string is in the language or not
Chomsky’s hierarchy • Finite state automata • Can recognize regular languages • Pushdown automata • Can recognize context-free languages • Linear bounded automata • Can recognize context-sensitive languages • Turing machines • Can recognize recursively enumerable languages
Examples of languages • Regular languages: • { (01)n }, { bit strings in which 0’s and 1’s exist in even number each } • Context-free languages: • { 0n1n }, { bit strings in which 0’s and 1’s exist in the same number }, most programming languages • Context-sensitive languages: • { 0n1n2n }, most natural languages (weakly context-sensitive)
Finite state automaton • Has only finite number of states • Has no infinite memory • Therefore, all physically built computational systems are in this class in principle • Can recognize regular languages • Often used in complex systems modeling • E.g. cellular automata
Pushdown automaton • Finite state automaton with an infinitely long pushdown stack • Has infinite LIFO memory • Non-deterministic PDA can recognize context-free languages • Can handle nested structures inputs FSA Pushdown stack 1 0
Linear bounded automaton • (Non-deterministic) Turing machine whose tape length is a linear function of the length of input • Has infinite memory but its accessible range is bounded according to input size • Can recognize context-sensitive languages
Turing machine (TM) • Finite state automata with an infinitely long memory tape • Has a read/write head that can move on the tape left and right B B 1 0 B FSA
Mathematical definition • Turing machine M: M=<S, S, f, q0, H> S: A finite set of states S: A finite set of tape symbols - Includes “B” for blank f: State-transition function - S x S→ S x S × {R, L, N} (motion of head) q0: Initial state (in S) H: A set of halting states (subset of S)
Rule table f: State-transition function - S x S→ S x S × {R, L, N} (motion of head) Often written as a set of “sss’s’m” • s: Current state of FSA • s: Symbol read from the tape • s’: Next state of FSA • s’: Symbol to be written to the tape • m: Direction of motion of the head
B B B B 1 0 0 1 B B q0 halt Computation by a Turing machine • Input: Initial contents of the tape • Output: Contents of the tape when the TM halts • TM halts when the FSA reaches one of its halting states Input Output Computation (state transition)
a/1, → 1/1, → q0 B/B, ← h B a 1 a B B 1 B 1 B 1 B 1 1 a B 1 a B 1 1 B 1 1 B q0 q0 q0 q0 h Example S = { q0, h },S = { B, a, 1 } f = { q0aq01R, q01q01R, q0BhBL } H = { h } Writing 1’s over non-blank symbols moving rightward until it reaches a “B”
Exercise • Design a Turing machine that moves its head rightward and keeps inverting bits written in its tape until its head reaches a blank symbol
Exercise • Figure out what the following TM does: S = { q0, e, o, h } S = { B, 1, E, O } f = { q01o1R, q0BhEN, e1o1R, eBhEN, o1e1R, oBhON } H = { h }
Computational universality of TMs • Church–Turing thesis: “Every mathematical function that is naturally regarded as computable is computable by a Turing machine” • Not a rigorous theorem or hypothesis, but an empirical “thesis” widely accepted TMs are considered “computationally universal”