Having probs with this assignment...
Prove using induction exp is determitive, n >= 0.
Incase my vocabulary fails: Prove that module exp stops(is right) with all n >= 0.
This is what I've got so far:
(i) exp(0) = 1
(ii) Assume exp(k) = true , k >= 0
exp(k+1) = true, k >= 0
Prove: If parameter n = 0 module returns 1, part (i), ending recursive calls. If n > 0 module calls itself recursively with parameter n-1. In recursive loop Lim n-1 = 0 so with every n >= 0 module exp will stop.
(iii) exp is true, n >= 0.
How ever I'm not very happy with the prove part. Can it be done more elegantly?
Code:
MODULE exp(n) RETURNS 2^n
IF n = 0 THEN
RETURN 1
ELSE
RETURN 2 * exp(n-1)
ENDIF
ENDMODULE
Prove using induction exp is determitive, n >= 0.
Incase my vocabulary fails: Prove that module exp stops(is right) with all n >= 0.
This is what I've got so far:
(i) exp(0) = 1
(ii) Assume exp(k) = true , k >= 0
exp(k+1) = true, k >= 0
Prove: If parameter n = 0 module returns 1, part (i), ending recursive calls. If n > 0 module calls itself recursively with parameter n-1. In recursive loop Lim n-1 = 0 so with every n >= 0 module exp will stop.
(iii) exp is true, n >= 0.
How ever I'm not very happy with the prove part. Can it be done more elegantly?