So, for one of my university courses, I have to analyse an algorithm on one of my assignments and identify a loop invariant that would allow for a formal proof of algorithmic correctness.
I believe that I identified it in the form of a sum of all of the elements of an array A that have positive values, ranging from 0 to i (where i is the number of time the algorithm has iterated).
I know how to annotate most of that - you write a capital sigma with “k=0” as a subscript and i as a superscript, followed by A[k] but I’m not sure how to specify that I’m only summing the positive elements, so the kth element of A is only added to the sun if it has a positive value.
The lecturer has assured me that that’s not a problem since I can just explain my answer in words, but I still sort of want to know how to do it properly.