Randomness in Computing
Chapter overview: Randomness can be used as a computational resource. This chapter distinguishes true randomness, algorithmic complexity, pseudorandomness, and cryptographic randomness, emphasizing why unpredictability is important.
10.1 Randomness
Introduction / Definition
Randomness describes outcomes that are not predictable from the information available to the observer under the chosen model. In probability theory, a random variable X assigns outcomes to probabilities P(X=x). Computing systems can use randomness for sampling, randomized algorithms, simulations, and security.
Syntax / Structure / Formula
0 ≤ P(A) ≤ 1
Σ_x P(X=x)=1 for a discrete random variable
Detailed Explanation
For a fair bit, P(0)=P(1)=1/2. Repeated independent bits form a simple random bit stream.
Example
X ∈ {0,1}
P(X=0)=1/2
P(X=1)=1/2
Output / Result
Each outcome has probability one-half under the fair-bit model.
Important Points / Notes
- Randomness is modeled probabilistically.
- Randomized algorithms can have probabilistic performance.
- Security applications require stronger unpredictability than ordinary simulation.
Mini Practice Question
Why is a fair coin modeled with probability 1/2 for each outcome?
10.2 Complexity
Introduction / Definition
Randomness can change the way computational complexity is analyzed. Randomized algorithms use random choices during execution and can sometimes obtain simpler or faster expected behavior than deterministic approaches. Complexity analysis may consider expected time, error probability, worst-case time, or success probability.
Syntax / Structure / Formula
- Expected time: E[T] = Σ_t t·P(T=t)
Detailed Explanation
A randomized algorithm may have a small probability of failure but a high probability of correctness. For example, repeated randomized trials can reduce the probability that an error persists.
Example
If one trial fails with probability 1/2, independent repetition k times gives failure probability (1/2)^k.
Output / Result
For k=10, failure probability = 1/1024.
Important Points / Notes
- Expected complexity is not the same as worst-case complexity.
- Error probability can often be reduced through repetition.
- Randomness can simplify some algorithms.
Mini Practice Question
If an independent randomized test has error probability 1/4 per run, what is the probability of error in four repeated runs if all must fail?
10.3 Pseudorandomness
Introduction / Definition
Pseudorandomness refers to sequences generated deterministically that appear random according to specified tests or computational observers. A pseudorandom generator expands a short random seed into a longer sequence. Good pseudorandom generators aim to make the output difficult to distinguish from true randomness for a specified class of tests.
Syntax / Structure / Formula
G(seed) → long bit string
|seed| ≪ |G(seed)|
Detailed Explanation
A simple linear congruential generator can be written x_{n+1}=(a x_n+c) mod m. Such generators are useful for simulation but are generally not suitable for cryptographic security without additional guarantees.
Example
x₀=1, a=5, c=3, m=16
x₁=(5·1+3) mod 16=8
Output / Result
The next generated value is 8; repeated application produces a deterministic sequence.
Important Points / Notes
- Same seed produces the same sequence.
- Simulation and cryptography have different requirements.
- Cryptographic PRGs require strong unpredictability properties.
Mini Practice Question
Why is a deterministic pseudorandom generator useful in simulations?
10.4 Cryptography
Introduction / Definition
Cryptography uses mathematical techniques to protect information against unauthorized parties. Major goals include confidentiality, integrity, authentication, and sometimes non-repudiation. Modern cryptography relies on carefully defined security assumptions and computational hardness rather than merely hiding an algorithm.
Syntax / Structure / Formula
Encryption: C = Enc_k(M)
Decryption: M = Dec_k(C)
Security often depends on computational hardness.
Detailed Explanation
In symmetric encryption, the same secret key is used for encryption and decryption. In public-key cryptography, a public key and private key are used for related operations. Cryptographic systems also use hashes, digital signatures, and secure random number generation.
Example
Message M → Enc(secret key) → Ciphertext C
C → Dec(secret key) → M
Output / Result
The original message is recovered only with the appropriate decryption capability.
Important Points / Notes
- Cryptographic randomness must be unpredictable to attackers.
- Keys must be protected.
- Modern cryptography uses published algorithms with secret keys rather than secret algorithms.
- Security claims must be evaluated against realistic threat models.
Mini Practice Question
Why is ordinary pseudorandomness not necessarily sufficient for cryptographic key generation?
Quick Revision Sheet
Concept
Key Idea
Combinational machine
Output depends only on current input; no persistent state.
FSM
Finite-state computational model; recognizes regular languages.
DFA
Exactly one transition for each state/input pair.
NFA
May have multiple possible transitions; same regular-language power as DFA.
Regular expression
Formal notation for regular languages.
PDA
Finite control plus stack; recognizes context-free languages.
CFG
Grammar G=(V,Σ,P,S) for recursively structured syntax.
Recursive function
Function defined using base cases and smaller instances.
Turing machine
Finite control + unbounded tape + read/write head.
RAM model
Abstract random-access machine used for algorithmic cost analysis.
Lambda calculus
Functions, application, and substitution as a model of computation.
Computability equivalence
Different formalisms can express the same class of computable functions.
Recursive set
Membership is decidable by a total halting algorithm.
Enumerable/RE set
Members can be recognized; nonmembers may cause nontermination.
Recognizer
Accepts members; may not halt on nonmembers.
Universal TM
Simulates an encoded Turing machine on an encoded input.
Diagonalization
Constructs an object differing from every item in a proposed list.
Uncomputability
No algorithm can solve all instances with guaranteed termination.
Gödel incompleteness
Sufficiently expressive consistent formal systems have limitations on provability.
Complexity
Study of resources required as input size grows.
Deterministic
One computation path for a given configuration.
Nondeterministic
Multiple possible branches; acceptance if one branch accepts.
Formalization
Precisely specifies inputs, outputs, constraints, and correctness.
Church-Turing thesis
Effective calculability corresponds to Turing computability.
Pseudorandomness
Deterministic output designed to look random to specified observers.
Cryptography
Mathematical methods for secure communication and data protection.
Important Formulas and Notation
- M=(Q,Σ,δ,q₀,F) — standard DFA notation.
- δ: Q×Σ→Q — DFA transition function.
- G=(V,Σ,P,S) — context-free grammar.
- δ(q,a,X)→(p,γ) — typical PDA transition notation.
- δ(q,a)=(p,b,D) — typical Turing-machine transition form.
- β-reduction: (λx.E)A → E[x:=A].
- χ_L(x)=1 if x∈L and 0 otherwise for a recursive language.
- T(n)=number of computational steps as a function of input size n.
- O(n), O(n²), etc. describe asymptotic growth.
- E[T]=Σ_t tP(T=t) — expected running time.
- P(A)∈[0,1] and ΣP(x)=1 for a discrete probability distribution.
- Simple linear congruential generator: x_{n+1}=(ax_n+c) mod m.
- Symmetric encryption/decryption: C=Enc_k(M), M=Dec_k(C).
Final Practice Set
- Explain why a combinational machine cannot naturally recognize arbitrary 0^n1^n.
- Define a DFA formally and explain each component.
- Give a regular expression for strings ending in 01.
- Explain why a PDA is stronger than an FSM for nested structures.
- Construct a CFG for balanced parentheses.
- Define recursion and identify the base case in a factorial function.
- Explain the main components of a Turing machine.
- Differentiate computability from complexity.
- Explain recursive versus recursively enumerable languages.
- Describe the idea of a universal Turing machine.
- Explain diagonalization in simple terms.
- Why is the halting problem uncomputable?
- State the basic idea of Gödel's first incompleteness theorem.
- Differentiate deterministic and nondeterministic computation.
- Explain why formalization is necessary before designing an algorithm.
- State the Church-Turing thesis and explain why it is a thesis.
- Differentiate true randomness and pseudorandomness.
- Why do cryptographic systems require unpredictable random values?
End of Notes
These notes provide a complete textbook-style foundation for CS-553 — Foundations of Computing, covering formal machines, automata, grammars, computability, universal computation, undecidability, complexity, the Church-Turing thesis, randomness, pseudorandomness, and cryptography.