1 def recmin(A):
2 if len(A) == 1:
3 return A[0]
4 else:
5 m = len(A) // 2
6 min1 = recmin(A[0..m-1])
7 min2 = recmin(A[m..len(A)-1])
8 return min(min1, min2)
I'm trying to prove the partial correctness of this function, I figured out a predicate of p(i)
:for the array A=[0..i]
, len(A)=i+1
and when recmin[A]is called,then this call terminates and returns some t such that 0<=t<=i A[t]
is the min value
But I feel like this predicate is wrong and how would i prove that the postcondition where A[0]
is min value