您好,我正在尝试从此函数编写证明注释..这是使用 Spark 编程语言编写的
function Read_Sensor_Majority return Sensor_Type is
count1:Integer:=0;
count2:Integer:=0;
count3:Integer:=0;
overall:Sensor_Type;
begin
for index in Integer range 1..3 loop
if State(index) = Proceed then
count1:=count1+1;
elsif State (index) = Caution then
count2:=count2+1;
elsif State (index)=Danger then
count3:=count3+1;
end if;
end loop;
if count1>=2 then
overall:=Proceed;
elsif count2>=2 then
overall:=Caution;
elsif count3>=2 then
overall:=Danger;
else
overall:=Undef;
end if;
return overall;
end Read_Sensor_Majority;
begin -- initialization
State:= Sensordata'(Sensor_Index_Type => Undef);
end Sensors;
这是 .ads 文件
package Sensors
--# own State;
--# initializes State;
is
type Sensor_Type is (Proceed, Caution, Danger, Undef);
subtype Sensor_Index_Type is Integer range 1..3;
procedure Write_Sensors(Value_1, Value_2, Value_3: in Sensor_Type);
--# global in out State;
--# derives State from State ,Value_1, Value_2, Value_3;
function Read_Sensor(Sensor_Index: in Sensor_Index_Type) return Sensor_Type;
--# global in State;
function Read_Sensor_Majority return Sensor_Type;
--# global in State;
--# return overall => (count1>=2 -> overall=Proceed) and
--# (count2>=2 -> overall=Caution) and
--# (count3>=2 -> overall=Danger);
end Sensors;
这些是我使用 spark 检查器检查文件后遇到的错误
Examiner Semantic Error 1 - The identifier count1 is either undeclared or not visible at this point. <b>34:27</b> Semantic Error 1 - The identifier count1 is either undeclared or not visible at this point. Examiner
Sensors.ads:34:27
Semantic Error 1 - The identifier count1 is either undeclared or not visible at this point.