Unit 6 Computable Function
Unit 6 Computable Function
(W-22)
Partial Function
A partial function is not defined for every input.
It gives output only for some inputs.
For other inputs, the result is undefined.
Example:
f(x) = 1/x
Not defined when x = 0 → So it is a partial function.
Constant Function
A constant function always gives the same output.
No matter what input you give, the output doesn’t change.
Example:
f(x) = 5
f(1) = 5, f(100) = 5 → Always same.
Total Function
A total function is defined for every input in the domain.
It gives a valid result for all inputs.
Example:
f(x) = x + 2
It works for all values of x → So it's a total function.
Example:
factorial(n) = n * factorial(n-1)
Base case:
factorial(0) = 1
What is Computable?
A function is computable if we can write a step-by-step algorithm (or program) that gives an
answer for every valid input in finite time.
Recursive Case
add(x, y+1) = add(x, y) + 1
(Add 1 step by step using previous result)
Example: add(2, 3)
add(2, 3) = add(2, 2) + 1
add(2, 2) = add(2, 1) + 1
add(2, 1) = add(2, 0) + 1
add(2, 0) = 2 (base case)
add(2, 1) = 2 + 1 = 3
add(2, 2) = 3 + 1 = 4
add(2, 3) = 4 + 1 = 5
Key Features
Can express all computable functions.
May run forever (not always guaranteed to stop).
Built using:
o Basic functions
o Composition
o Primitive recursion
o Minimization (μ-operator)
It is written as:
Here, μ denotes the smallest y for which the predicate holds true within the bound z.
mP(x₁, ..., xₙ, z) = smallest y ≤ z such that P(x₁, ..., xₙ, y) is true
Bounded Quantification means putting a limit (bound) on the types or values a variable can
take in a quantified statement (like "for all" or "there exists").
Pointwise Explanation:
true."