spark-ada

Spark-Ada postcondition for array total

痞子三分冷 提交于 2021-02-10 05:52:30
问题 How does one write a Spark postcondition for a function that sums the elements of an array? (Spark 2014, but if someone shows me how to do it for an earlier Spark I should be able to adapt it.) So if I have: type Positive_Array is array (Positive range <>) of Positive; function Array_Total(The_Array: Positive_Array) return Positive with Post => Array_Total'Return = -- What goes here? is -- and so on I don't need to worry about overflow in my particular case (I know what the total was at

“Taking on a Challenge in SPARK Ada” - Sum ghost function in post-condition having unintended behavior

你离开我真会死。 提交于 2020-07-09 04:23:39
问题 I am writing a piece of software in SPARK Ada which requires the post-condition to verify that the function return value is equal to the summed values of an array. Upon proving the file where the function resides, I keep getting an error which doesn't quite add up, no pun intended (I will post screenshots of the code so as to allow a better look). The only acceptable values allowed in the array of size 10 are 0s or 1s. 回答1: In the example below (and opposed to the other answer), I separated