This expression may be written in AMPL in the same way as shown in your question:
sum {j in 0..J} (a[j] * x[j] * sum {jj in j-k..j} x[jj])
To prevent jj from taking negative values, you can replace "j-k" in the above expression by "max(0,j-k)" or by "j less k". (The little-known AMPL operation "a less b" gives a-b if a is greater than b, or 0 otherwise; so it's just a shorthand for max(0,a-b).)
Bob Fourer
4...@ampl.com