Guest User

Untitled

a guest
Jan 5th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. /* CORRECT*- */
  2. #include <stdio.h>
  3.  
  4. int nondet_int (void)
  5. {
  6. int nd;
  7. return nd;
  8. }
  9.  
  10.  
  11. #define OLEV 600 /* in feets/minute */
  12. #define MAXALTDIFF 600 /* max altitude difference in feet */
  13. #define MINSEP 300 /* min separation in feet */
  14. #define NOZCROSS 100 /* in feet */
  15. /* variables */
  16.  
  17. typedef int bool;
  18.  
  19. int Cur_Vertical_Sep;
  20. int High_Confidence;
  21. bool Two_of_Three_Reports_Valid;
  22. int Own_Tracked_Alt;
  23. int Own_Tracked_Alt_Rate;
  24. int Other_Tracked_Alt;
  25. int Alt_Layer_Value; /* 0, 1, 2, 3 */
  26. int Positive_RA_Alt_Thresh_0;
  27. int Positive_RA_Alt_Thresh_1;
  28. int Positive_RA_Alt_Thresh_2;
  29. int Positive_RA_Alt_Thresh_3;
  30. int Up_Separation;
  31. int Down_Separation;
  32.  
  33. /* state variables */
  34. int Other_RAC; /* NO_INTENT, DO_NOT_CLIMB, DO_NOT_DESCEND */
  35. #define NO_INTENT 0
  36. #define DO_NOT_CLIMB 1
  37. #define DO_NOT_DESCEND 2
  38.  
  39. int Other_Capability; /* TCAS_TA, OTHER */
  40. #define TCAS_TA 1
  41. #define OTHER 2
  42.  
  43. int Climb_Inhibit; /* true/false */
  44.  
  45. #define UNRESOLVED 0
  46. #define UPWARD_RA 1
  47. #define DOWNWARD_RA 2
  48.  
  49. void initialize()
  50. {
  51. Positive_RA_Alt_Thresh_0 = 400;
  52. Positive_RA_Alt_Thresh_1 = 500;
  53. Positive_RA_Alt_Thresh_2 = 640;
  54. Positive_RA_Alt_Thresh_3 = 740;
  55. }
  56.  
  57. int Positive_RA_Alt_Thresh(int Alt)
  58. {
  59. int res = 0;
  60. if( Alt == 0 )
  61. { res = Positive_RA_Alt_Thresh_0; }
  62. if( Alt == 1 )
  63. { res = Positive_RA_Alt_Thresh_1; }
  64. if( Alt == 2 )
  65. { res = Positive_RA_Alt_Thresh_2; }
  66. if( Alt == 3 )
  67. { res = Positive_RA_Alt_Thresh_3; }
  68. return(res);
  69. }
  70.  
  71. int ALIM ()
  72. {
  73. return Positive_RA_Alt_Thresh(Alt_Layer_Value);
  74. }
  75.  
  76. int Inhibit_Biased_Climb ()
  77. {
  78. return (Climb_Inhibit ? Up_Separation + 100 : Up_Separation);
  79. }
  80.  
  81. bool Non_Crossing_Biased_Climb()
  82. {
  83. int upward_preferred;
  84. int upward_crossing_situation;
  85. bool result;
  86.  
  87. upward_preferred = Inhibit_Biased_Climb() > Down_Separation;
  88. if (upward_preferred)
  89. {
  90. result = !(Own_Below_Threat()) || ((Own_Below_Threat()) && (!(Down_Separation > ALIM()))); /* opertor mutation */
  91. }
  92. else
  93. {
  94. result = Own_Above_Threat() && (Cur_Vertical_Sep >= 300) && (Up_Separation >= ALIM());
  95. }
  96. return result;
  97. }
  98.  
  99. bool Non_Crossing_Biased_Descend()
  100. {
  101. int upward_preferred;
  102. int upward_crossing_situation;
  103. bool result;
  104.  
  105. upward_preferred = Inhibit_Biased_Climb() > Down_Separation;
  106. if (upward_preferred)
  107. {
  108. result = Own_Below_Threat() && (Cur_Vertical_Sep >= 300) && (Down_Separation >= ALIM());
  109. }
  110. else
  111. {
  112. result = !(Own_Above_Threat()) || ((Own_Above_Threat()) && (Up_Separation >= ALIM()));
  113. }
  114. return result;
  115. }
  116.  
  117. bool Own_Below_Threat()
  118. {
  119. return (Own_Tracked_Alt < Other_Tracked_Alt);
  120. }
  121.  
  122. bool Own_Above_Threat()
  123. {
  124. return (Other_Tracked_Alt < Own_Tracked_Alt);
  125. }
  126.  
  127. int alt_sep_test()
  128. {
  129. bool enabled, tcas_equipped, intent_not_known;
  130. bool need_upward_RA, need_downward_RA;
  131. int alt_sep;
  132.  
  133. enabled = High_Confidence && (Own_Tracked_Alt_Rate <= 600) && (Cur_Vertical_Sep > 600);
  134. tcas_equipped = Other_Capability == 1;
  135. intent_not_known = Two_of_Three_Reports_Valid && Other_RAC == 0;
  136.  
  137. alt_sep = 0;
  138.  
  139. if (enabled && ((tcas_equipped && intent_not_known) || !tcas_equipped))
  140. {
  141. need_upward_RA = Non_Crossing_Biased_Climb() && Own_Below_Threat();
  142. need_downward_RA = Non_Crossing_Biased_Descend() && Own_Above_Threat();
  143. if (need_upward_RA && need_downward_RA)
  144. alt_sep = 0;
  145. else if (need_upward_RA)
  146. alt_sep = 1;
  147. else if (need_downward_RA)
  148. alt_sep = 2;
  149. else
  150. alt_sep = 0;
  151. }
  152.  
  153.  
  154. /*If P1b is satisfied; ensures alt_step != upward_RA */
  155. if(alt_sep == 1) __VERIFIER_error();
  156. return alt_sep;
  157. }
  158.  
  159. int main()
  160. {
  161. int res;
  162. initialize();
  163. Cur_Vertical_Sep = 46766;
  164. High_Confidence = 1;
  165. Two_of_Three_Reports_Valid = 1;
  166. Own_Tracked_Alt_Rate = 574;
  167. Own_Tracked_Alt = 2000;
  168. Other_Tracked_Alt = 4000;
  169. Alt_Layer_Value = 2;
  170. Up_Separation = 600;
  171. Down_Separation = 640;
  172. Other_RAC = 0;
  173. Other_Capability = 0;
  174. Climb_Inhibit = 1;
  175.  
  176. res = alt_sep_test();
  177.  
  178. return 0;
  179. }
Add Comment
Please, Sign In to add comment