Mathematical Foundations of Computing
Computability Theory
-
Turing Machine
- Church–Turing thesis: a Turing machine can simulate every effective form of computation.
- In other words, no computation can be more effective than a Turing machine.
- Terminology
- (accepts, rejects, loops) on a string
- halts - accepts or rejects (does not loop)
- does not accept - rejects or loops
- Decider - will always halt, never loops
- Definitely accepts w when w∈L and rejects w when w∈L
- mn always decides (never loops)
- R - set of all languages that have a decider for it
- Recognizer - always accepts w∈L. Either rejects or loops on w when w∈L
- a Turing machine is a recognizer for L ↔ (it will eventually accept an string s ↔ s∈L)
- mn always recognizes (always accepts when it should)
- A Turing machine M recognizes (or is a recognizer for) a language L if:
- If s∈L, M eventually accepts s
- If s∈/L, M either rejects s or loops forever
- Formally, ∀w∈Σ∗.(w∈L↔M accepts w)
- Annoyingly, if you don't know if w∈L and the TM is still running, you can't tell if it loops or just needs more time
- RE - set of all languages that have a recognizer for it
-
Falsifiability -
-
Myhill–Nerode Theorem - if L is a language and S is a distinguishing set of L with infinitely many strings then L is nonregular
-
Distinguishability - two strings x and y in Σ⋆ are distinguishable (x≡Ly) if xw∈L and yw∈L (e.g., x=aa, y=aaaa, and w=bb) for some string w
- Formally, ∃w∈Σ⋆.(xw∈L↔yw∈L)
- Layman: Distinguishable if there is a string w you can add to one that will make it accepting but adding w to the other will make it rejected
- Distinguishing set - set where each item is distinguishable from each other item
- Constructing NFAs
- Have the NFA guess the information you want and deterministically check if it is true (guess-and-check technique)
- Regular languages
- Regular languages are problems that can be solved with finite memory. Nonregular languages correspond to languages that cannot be solved with finite memory, such as {anbn∣n∈N}.
- The following are equivalent: L is a regular language, there exists an NFA or DFA or regex called X such that L(X)=L (the language of X is L)
- Kleene closure/star of a language L is L*, which is the set of all strings that can be formed by concatenating any number of strings in L (e.g., L={a,b} means L*={ε, a, b, aa, ab, ba, bb, aaa, ...})
- Formally, L⋆={w∈Σ⋆ ∣ ∃n∈N.w∈Ln }
- Closure properties of languages. If L1 and L2 are regular languages, so are these: L1,L1∪L2,L1∩L2,L1L2,L1∗
- Language concatenation L1L2 is the language {xy ∣ x∈L1∧y∈L2}
- xy is the strings x and y concatenated
- Finite automaton - collection of states joined by transitions, has a start state
- Some states are accepting states. If automaton ends at accepting state, it accepts the input else rejects the input
- DFA (Deterministic Finite Automaton) - exactly 1 transition at each state for each symbol in Σ
- NFA (nondeterministic finite automaton) - each state has 0 or multiple transitions
- If there is one path that works, NFA accepts
- Path dies if cannot move at a certain symbol
- ε-transition - transition that doesn't consume input
- Works by perfect positive guessing or massive parallelism
- the term
nondeterministic
means the automaton has a finite number of choices (possibly 0) to make at a given point
- Subset construction (AKA powerset construction) is a method for turning an NFA into a DFA
- A language is regular if there is a DFA D (or NFA) such that L(D)=L, in which case D
recognizes
L
- Language - string[]
string - character[]
alphabet - set<character>
- (formal) language - set of strings
- language over Σ if is set of strings each over Σ
- Σ∗ is the set of all strings composed from letters in Σ
- String
- empty string - ε
- String over Σ - finite sequence of characters from Σ (such as aaaabbaba for Σ={a,b})
- Alphabet Σ - set of characters
- Characters
- Automaton - mathematical model of a computer (abstraction of real computer)
- states linked by transitions
Discrete Math
- Induction
- P(0) is true - basis/base case
- P(k) → P(k+1) - inductive step
- P(k) - inductive hypothesis
- To prove
- Pigeonhole principle
- if n items are put into m containers, with n>m , then at least one container must contain more than one item
- Generalized pigeonhole principle (AKA strong pigeonhole principle)
- For p pigeons and h holes,
- some crowded hole will have at least ⌈hp⌉ pigeons in it
- not all holes can have more than ⌊hp⌋ pigeons in them
- some hole will have ⌊hp⌋ or fewer pigeons
- GC is the graph complement of G. All edges are turned into not edges and all not edges are turned into edges in GC.
- subset symbols
- ⊊ - proper/strict subset. Cannot be itself.
- ⊆ - subset or equal
- includes the improper subset case in which a set is the (improper) subset of itself
- ⊂ is ambiguous (could mean ⊆ or ⊊ in different textbooks)
- Generalized pigeonhole principle
- For p pigeons and h holes,
- some hole will have at least ⌈hp⌉ pigeons in it
- some hole will have at most ⌊hp⌋ pigeons in it
- The "composition of f and g" is g∘f
- Translating first-order logic to English in a proof:
- Functions
- domain - function defined for every element of domain
- codomain - output is always in codomain. Not all els in codomain must have an associated output of the f tho
- f:A→B means f has domain A and codomain B
- Involution: a function f is an involution if ∀a∈A.f(f(a))=a
- Layman: apply twice gives same thing back. f is an involution if f(f(x))=x
- Surjective: ∀b∈B.∃a∈A.(f(a)=b)
- Layman: all outputs have an input that points to it
- Injective: ∀a1∈A.∀a2∈A.(a1=a2→f(a1)=f(a2))
- Equivalently ∀a1∈A.∀a2∈A.(f(a1)=f(a2)→a1=a2)
- Layman: one-to-one function. No no output maps to two inputs. Every output maps to 1 or 0 inputs.
- one-to-one function (not every codomain element needs to be used)
- horizontal line test in y=f(x) tells you if a function is injective
- Said differently, surjective associates each codomain element with at least one domain element and injective associates each codomain element with at most one domain element
- bijective - injective and surjective, one-to-one correspondence (ever codomain element used)
- Function needs to be:
- ∀a∈A.∃b∈B.(f(a)=b) - total
- Defined on every element in domain, as opposed to partial, which means that f(a) is undefined for some a in the domain
- Partial - ∃a∈A.f(a) is undefined
- ∀a1∈A.∀a2∈A.(a1=a2→f(a1)=f(a2)) - deterministic (same input always produces same output)
- Proof explains why theorem is true
Disproof explains why claim is false (such as through a counterexample)
- Transformations
- ¬∀x.A
∃x.¬A
- ¬∃x.A
∀x.¬A
- ¬(A∧B)−2 ways
¬A∨¬B (De Morgan's Law)
A→¬B
- ¬(A∨B)
¬A∧¬B (De Morgan's Law)
- ¬(A→B)
A∧¬B
- ¬(A↔B)
¬A↔B
A↔¬B
- Mnemonics
- "Pushing" ¬ inward and flipping between operators (or vice versa):
- ∧ to →
- ∀ to ∃
- De Morgan's Law is like distributing the ¬ and flipping the operator (from ∧ to ∨ or vice versa)
- When applying ¬ to the biconditional (↔) negate either side and keep the operator same
- p→q is the same as ¬(p∧¬q)
- only false when p is true and q is false
- Others
- p→b→r same as p∧q→r
- The Aristotelian Forms
- All As are Bs: ∀x.(A(x)→B(x))
- No As are Bs: ∀x.(A(x)→¬B(x))
- Some As are Bs: ∃x.(A(x)∧B(x))
- Some As aren't Bs: ∃x.(A(x)∧¬B(x))
- First-order logic
- Terms
- Functions - object → object
Predicate - object → bool
- Connective - bool(s) → bool
- conjunction - ∧ (binary)
- disjunction - ∨
- implication - →
- biconditional - ↔
- negation - ¬ (unary)
- truth - ⊤ (nullary)
- falsity - ⊥
- Quantifier - bool → bool
- Examples
- = operates on objects, ↔ operates on predicates
- Some P is a Q translates to ∃x.(P(x)∧Q(x))
- All Ps are Qs translates to ∀x.(P(x)→Q(x))
- Try to pair ∃ with ∧ and ∀ with →
- Precedence (highest to lowest)
- ¬
- ∀ and ∃
- ∧ (and before or)
- ∨
- →
- → is right-associative so a→b→c is a→(b→c). Most operators like ∧ are left-associative.
- ↔
- Propositional logic
- Propositional variable
- Propositional connectives
- Universal statement - for all x, some [property] holds for x (mn works on x universally)
- Existential statement - there is some x where [property] holds for x (mn some x exists for it to work)
- Proof types
- Implication: If antecedent, then consequent.
- Assume step: assume the antecedent is true
- Want-to-show steps
- demonstrate that the consequent is true
- Reiterate what you wanted to show□
Derivations
Myhill-Nerode Theorem
Myhill–Nerode Theorem: if L is a language and S is a distinguishing set for L that contains infinitely many strings then L is nonregular.
Proof: Pick an arbitrary language L and a distinguishing set for L that contains infinitely many strings. We want to show that L is nonregular. To do so, assume for the sake of contradiction that L is regular. This means that there exists a DFA D such that L(D)=L. Let k be the number of states in D. Pick k+1 strings from S. Since we picked k+1 strings and there are k states in the DFA, there must be one state with 2 strings sm and sn. Since S is a distinguishing set, sm and sn cannot map to the same state of a DFA. We have reached a contradiction, so our earlier assumption must have been false. Therefore, L is nonregular.
p→q≡¬p∨q
De Morgan's Laws
(A∨B)↔(¬A→B)↔(¬B→A)
