@@ -165,6 +165,10 @@ struct
165165
166166 let invariant_type = " loop_invariant"
167167
168+ let min_version = function
169+ | {labels = Some _ ; _} -> YamlWitnessVersion. V2_1
170+ | _ -> YamlWitnessVersion. V2_0
171+
168172 let to_yaml' {location; value; format; labels} =
169173 [
170174 (" location" , Location. to_yaml location);
@@ -197,13 +201,15 @@ struct
197201 include LoopInvariant
198202
199203 let invariant_type = " loop_transition_invariant"
204+ let min_version _ = YamlWitnessVersion. V2_1
200205 end
201206
202207 module LocationTransitionInvariant =
203208 struct
204209 include LoopTransitionInvariant
205210
206211 let invariant_type = " location_transition_invariant"
212+ let min_version _ = YamlWitnessVersion. V2_1
207213 end
208214
209215 module FlowInsensitiveInvariant =
@@ -215,6 +221,7 @@ struct
215221 [@@ deriving eq , ord , hash ]
216222
217223 let invariant_type = " flow_insensitive_invariant"
224+ let min_version _ = YamlWitnessVersion. V2_1_Goblint
218225
219226 let to_yaml' {value; format} =
220227 [
@@ -247,6 +254,13 @@ struct
247254 | LocationTransitionInvariant _ -> LocationTransitionInvariant. invariant_type
248255 | FlowInsensitiveInvariant _ -> FlowInsensitiveInvariant. invariant_type
249256
257+ let min_version = function
258+ | LocationInvariant x -> LocationInvariant. min_version x
259+ | LoopInvariant x -> LoopInvariant. min_version x
260+ | LoopTransitionInvariant x -> LoopTransitionInvariant. min_version x
261+ | LocationTransitionInvariant x -> LocationTransitionInvariant. min_version x
262+ | FlowInsensitiveInvariant x -> FlowInsensitiveInvariant. min_version x
263+
250264 let to_yaml' = function
251265 | LocationInvariant x -> LocationInvariant. to_yaml' x
252266 | LoopInvariant x -> LoopInvariant. to_yaml' x
@@ -285,6 +299,8 @@ struct
285299
286300 let invariant_kind = " invariant"
287301
302+ let min_version {invariant_type} = InvariantType. min_version invariant_type
303+
288304 let to_yaml {invariant_type} =
289305 `O [
290306 (" invariant" , `O ([
@@ -311,6 +327,7 @@ struct
311327 [@@ deriving eq , ord , hash ]
312328
313329 let contract_type = " function_contract"
330+ let min_version _ = YamlWitnessVersion. V2_1
314331
315332 let to_yaml' {location; requires; ensures; format; labels} =
316333 [
@@ -344,6 +361,9 @@ struct
344361 let contract_type = function
345362 | FunctionContract _ -> FunctionContract. contract_type
346363
364+ let min_version = function
365+ | FunctionContract x -> FunctionContract. min_version x
366+
347367 let to_yaml' = function
348368 | FunctionContract x -> FunctionContract. to_yaml' x
349369
@@ -366,6 +386,8 @@ struct
366386
367387 let invariant_kind = " contract"
368388
389+ let min_version {contract_type} = ContractType. min_version contract_type
390+
369391 let to_yaml {contract_type} =
370392 `O [
371393 (" contract" , `O ([
@@ -391,6 +413,10 @@ struct
391413 | Invariant _ -> Invariant. invariant_kind
392414 | Contract _ -> Contract. invariant_kind
393415
416+ let min_version = function
417+ | Invariant x -> Invariant. min_version x
418+ | Contract x -> Contract. min_version x
419+
394420 let to_yaml = function
395421 | Invariant x -> Invariant. to_yaml x
396422 | Contract x -> Contract. to_yaml x
@@ -419,6 +445,11 @@ struct
419445
420446 let entry_type = " invariant_set"
421447
448+ let min_version {content} =
449+ List. to_seq content
450+ |> Seq. map InvariantKind. min_version
451+ |> Seq. fold_left YamlWitnessVersion. max YamlWitnessVersion. V2_0
452+
422453 let to_yaml' {content} =
423454 [(" content" , `A (List. map InvariantKind. to_yaml content))]
424455
@@ -636,6 +667,7 @@ struct
636667 [@@ deriving eq , ord , hash ]
637668
638669 let entry_type = " violation_sequence"
670+ let min_version _ = YamlWitnessVersion. V2_0
639671
640672 let to_yaml' {content} =
641673 [(" content" , `A (List. map Segment. to_yaml content))]
@@ -749,6 +781,7 @@ struct
749781 [@@ deriving eq , ord , hash ]
750782
751783 let entry_type = " ghost_instrumentation"
784+ let min_version _ = YamlWitnessVersion. V2_1
752785
753786 let to_yaml' {ghost_variables; ghost_updates} =
754787 [(" content" ,
@@ -780,6 +813,11 @@ struct
780813 | ViolationSequence _ -> ViolationSequence. entry_type
781814 | GhostInstrumentation _ -> GhostInstrumentation. entry_type
782815
816+ let min_version = function
817+ | InvariantSet x -> InvariantSet. min_version x
818+ | ViolationSequence x -> ViolationSequence. min_version x
819+ | GhostInstrumentation x -> GhostInstrumentation. min_version x
820+
783821 let to_yaml' = function
784822 | InvariantSet x -> InvariantSet. to_yaml' x
785823 | ViolationSequence x -> ViolationSequence. to_yaml' x
0 commit comments