Skip to content

Commit a8d8866

Browse files
authored
Merge pull request #1817 from goblint/yaml-witness-certificates
Remove YAML witness 0.1 validation certificates
2 parents 66746b0 + 8c21f8b commit a8d8866

File tree

4 files changed

+25
-206
lines changed

4 files changed

+25
-206
lines changed

src/config/options.schema.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,8 +2813,6 @@
28132813
"loop_invariant",
28142814
"flow_insensitive_invariant",
28152815
"precondition_loop_invariant",
2816-
"loop_invariant_certificate",
2817-
"precondition_loop_invariant_certificate",
28182816
"invariant_set",
28192817
"violation_sequence",
28202818
"ghost_instrumentation"
@@ -2863,12 +2861,6 @@
28632861
"description": "YAML witness input path",
28642862
"type": "string",
28652863
"default": ""
2866-
},
2867-
"certificate": {
2868-
"title": "witness.yaml.certificate",
2869-
"description": "YAML witness certificate output path",
2870-
"type": "string",
2871-
"default": ""
28722864
}
28732865
},
28742866
"additionalProperties": false

src/witness/yamlWitness.ml

Lines changed: 25 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,6 @@ struct
121121
metadata = metadata ~task ();
122122
}
123123

124-
let target ~uuid ~type_ ~(file_name): Target.t = {
125-
uuid;
126-
type_;
127-
file_hash = sha256_file file_name;
128-
}
129-
130-
let certification verdict: Certification.t = {
131-
string = if verdict then "confirmed" else "rejected";
132-
type_ = "verdict";
133-
format = "confirmed | rejected";
134-
}
135-
136-
let loop_invariant_certificate ~target ~(certification): Entry.t = {
137-
entry_type = LoopInvariantCertificate {
138-
target;
139-
certification;
140-
};
141-
metadata = metadata ();
142-
}
143-
144-
let precondition_loop_invariant_certificate ~target ~(certification): Entry.t = {
145-
entry_type = PreconditionLoopInvariantCertificate {
146-
target;
147-
certification;
148-
};
149-
metadata = metadata ();
150-
}
151-
152124
let ghost_variable' ~variable ~type_ ~(initial): GhostInstrumentation.Variable.t = {
153125
name = variable;
154126
scope = "global";
@@ -743,11 +715,10 @@ struct
743715
cnt_error := 0;
744716
cnt_disabled := 0;
745717

746-
let validate_entry (entry: YamlWitnessType.Entry.t): YamlWitnessType.Entry.t option =
747-
let uuid = entry.metadata.uuid in
718+
let validate_entry (entry: YamlWitnessType.Entry.t): unit =
748719
let target_type = YamlWitnessType.EntryType.entry_type entry.entry_type in
749720

750-
let validate_lvars_invariant ~entry_certificate ~loc ~lvars inv =
721+
let validate_lvars_invariant ~loc ~lvars inv =
751722
let msgLoc: M.Location.t = CilLocation loc in
752723
match InvariantParser.parse_cabs inv with
753724
| Ok inv_cabs ->
@@ -773,86 +744,52 @@ struct
773744
begin match Option.get (VR.result_of_enum result) with
774745
| Confirmed ->
775746
incr cnt_confirmed;
776-
M.success ~category:Witness ~loc:msgLoc "invariant confirmed: %s" inv;
777-
Option.map (fun entry_certificate ->
778-
let target = Entry.target ~uuid ~type_:target_type ~file_name:loc.file in
779-
let certification = Entry.certification true in
780-
let certificate_entry = entry_certificate ~target ~certification in
781-
certificate_entry
782-
) entry_certificate
747+
M.success ~category:Witness ~loc:msgLoc "invariant confirmed: %s" inv
783748
| Unconfirmed ->
784749
incr cnt_unconfirmed;
785-
M.warn ~category:Witness ~loc:msgLoc "invariant unconfirmed: %s" inv;None
750+
M.warn ~category:Witness ~loc:msgLoc "invariant unconfirmed: %s" inv
786751
| Refuted ->
787752
incr cnt_refuted;
788-
M.error ~category:Witness ~loc:msgLoc "invariant refuted: %s" inv;
789-
Option.map (fun entry_certificate ->
790-
let target = Entry.target ~uuid ~type_:target_type ~file_name:loc.file in
791-
let certification = Entry.certification false in
792-
let certificate_entry = entry_certificate ~target ~certification in
793-
certificate_entry
794-
) entry_certificate
753+
M.error ~category:Witness ~loc:msgLoc "invariant refuted: %s" inv
795754
| ParseError ->
796755
incr cnt_error;
797756
M.error ~category:Witness ~loc:msgLoc "CIL couldn't parse invariant: %s" inv;
798-
M.info ~category:Witness ~loc:msgLoc "invariant has undefined variables or side effects: %s" inv;
799-
None
757+
M.info ~category:Witness ~loc:msgLoc "invariant has undefined variables or side effects: %s" inv
800758
end
801759
| Error e ->
802760
incr cnt_error;
803761
M.error ~category:Witness ~loc:msgLoc "Frontc couldn't parse invariant: %s" inv;
804-
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv;
805-
None
762+
M.info ~category:Witness ~loc:msgLoc "invariant has invalid syntax: %s" inv
806763
in
807764

808765
let validate_location_invariant (location_invariant: YamlWitnessType.LocationInvariant.t) =
809766
let loc = loc_of_location location_invariant.location in
810767
let inv = location_invariant.location_invariant.string in
811-
let entry_certificate = (* TODO: Wrong, because there's no location_invariant_certificate, but this is the closest thing for now. *)
812-
if entry_type_enabled YamlWitnessType.LoopInvariantCertificate.entry_type then
813-
Some Entry.loop_invariant_certificate
814-
else
815-
None
816-
in
817768

818769
match Locator.find_opt location_locator loc with
819770
| Some lvars ->
820-
validate_lvars_invariant ~entry_certificate ~loc ~lvars inv
771+
validate_lvars_invariant ~loc ~lvars inv
821772
| None ->
822773
incr cnt_error;
823-
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv;
824-
None
774+
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv
825775
in
826776

827777
let validate_loop_invariant (loop_invariant: YamlWitnessType.LoopInvariant.t) =
828778
let loc = loc_of_location loop_invariant.location in
829779
let inv = loop_invariant.loop_invariant.string in
830-
let entry_certificate =
831-
if entry_type_enabled YamlWitnessType.LoopInvariantCertificate.entry_type then
832-
Some Entry.loop_invariant_certificate
833-
else
834-
None
835-
in
836780

837781
match Locator.find_opt loop_locator loc with
838782
| Some lvars ->
839-
validate_lvars_invariant ~entry_certificate ~loc ~lvars inv
783+
validate_lvars_invariant ~loc ~lvars inv
840784
| None ->
841785
incr cnt_error;
842-
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv;
843-
None
786+
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv
844787
in
845788

846789
let validate_precondition_loop_invariant (precondition_loop_invariant: YamlWitnessType.PreconditionLoopInvariant.t) =
847790
let loc = loc_of_location precondition_loop_invariant.location in
848791
let pre = precondition_loop_invariant.precondition.string in
849792
let inv = precondition_loop_invariant.loop_invariant.string in
850-
let entry_certificate =
851-
if entry_type_enabled YamlWitnessType.PreconditionLoopInvariantCertificate.entry_type then
852-
Some Entry.precondition_loop_invariant_certificate
853-
else
854-
None
855-
in
856793
let msgLoc: M.Location.t = CilLocation loc in
857794

858795
match Locator.find_opt loop_locator loc with
@@ -880,21 +817,18 @@ struct
880817
let lvars = LvarS.filter precondition_holds lvars in
881818
if LvarS.is_empty lvars then (
882819
incr cnt_unchecked;
883-
M.warn ~category:Witness ~loc:msgLoc "precondition never definitely holds: %s" pre;
884-
None
820+
M.warn ~category:Witness ~loc:msgLoc "precondition never definitely holds: %s" pre
885821
)
886822
else
887-
validate_lvars_invariant ~entry_certificate ~loc ~lvars inv
823+
validate_lvars_invariant ~loc ~lvars inv
888824
| Error e ->
889825
incr cnt_error;
890826
M.error ~category:Witness ~loc:msgLoc "Frontc couldn't parse precondition: %s" pre;
891-
M.info ~category:Witness ~loc:msgLoc "precondition has invalid syntax: %s" pre;
892-
None
827+
M.info ~category:Witness ~loc:msgLoc "precondition has invalid syntax: %s" pre
893828
end
894829
| None ->
895830
incr cnt_error;
896-
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv;
897-
None
831+
M.warn ~category:Witness ~loc:msgLoc "couldn't locate invariant: %s" inv
898832
in
899833

900834
let validate_invariant_set (invariant_set: YamlWitnessType.InvariantSet.t) =
@@ -905,7 +839,7 @@ struct
905839

906840
match Locator.find_opt location_locator loc with
907841
| Some lvars ->
908-
ignore (validate_lvars_invariant ~entry_certificate:None ~loc ~lvars inv)
842+
validate_lvars_invariant ~loc ~lvars inv
909843
| None ->
910844
incr cnt_error;
911845
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv;
@@ -917,7 +851,7 @@ struct
917851

918852
match Locator.find_opt loop_locator loc with
919853
| Some lvars ->
920-
ignore (validate_lvars_invariant ~entry_certificate:None ~loc ~lvars inv)
854+
validate_lvars_invariant ~loc ~lvars inv
921855
| None ->
922856
incr cnt_error;
923857
M.warn ~category:Witness ~loc:(CilLocation loc) "couldn't locate invariant: %s" inv;
@@ -935,8 +869,7 @@ struct
935869
M.info_noloc ~category:Witness "disabled invariant of type %s" target_type;
936870
in
937871

938-
List.iter validate_invariant invariant_set.content;
939-
None
872+
List.iter validate_invariant invariant_set.content
940873
in
941874

942875
let validate_violation_sequence (violation_sequence: YamlWitnessType.ViolationSequence.t) =
@@ -945,7 +878,7 @@ struct
945878
If program is correct and we can prove it, we output true, which counts as refutation of violation witness.
946879
If program is correct and we cannot prove it, we output unknown.
947880
If program is incorrect, we output unknown. *)
948-
None
881+
()
949882
in
950883

951884
match entry_type_enabled target_type, entry.entry_type with
@@ -961,26 +894,20 @@ struct
961894
validate_violation_sequence x
962895
| false, (LocationInvariant _ | LoopInvariant _ | PreconditionLoopInvariant _ | InvariantSet _ | ViolationSequence _) ->
963896
incr cnt_disabled;
964-
M.info_noloc ~category:Witness "disabled entry of type %s" target_type;
965-
None
897+
M.info_noloc ~category:Witness "disabled entry of type %s" target_type
966898
| _ ->
967899
incr cnt_unsupported;
968-
M.warn_noloc ~category:Witness "cannot validate entry of type %s" target_type;
969-
None
900+
M.warn_noloc ~category:Witness "cannot validate entry of type %s" target_type
970901
in
971902

972-
let yaml_entries' = List.fold_left (fun yaml_entries' yaml_entry ->
903+
List.iter (fun yaml_entry ->
973904
match YamlWitnessType.Entry.of_yaml yaml_entry with
974905
| Ok entry ->
975-
let certificate_entry = validate_entry entry in
976-
let yaml_certificate_entry = Option.map YamlWitnessType.Entry.to_yaml certificate_entry in
977-
Option.to_list yaml_certificate_entry @ yaml_entry :: yaml_entries'
906+
validate_entry entry
978907
| Error (`Msg e) ->
979908
incr cnt_error;
980-
M.error_noloc ~category:Witness "couldn't parse entry: %s" e;
981-
yaml_entry :: yaml_entries'
982-
) [] yaml_entries
983-
in
909+
M.error_noloc ~category:Witness "couldn't parse entry: %s" e
910+
) yaml_entries;
984911

985912
M.msg_group Info ~category:Witness "witness validation summary" [
986913
(Pretty.dprintf "confirmed: %d" !cnt_confirmed, None);
@@ -993,10 +920,6 @@ struct
993920
(Pretty.dprintf "total validation entries: %d" (!cnt_confirmed + !cnt_unconfirmed + !cnt_refuted + !cnt_unchecked + !cnt_unsupported + !cnt_error + !cnt_disabled), None);
994921
];
995922

996-
let certificate_path = GobConfig.get_string "witness.yaml.certificate" in
997-
if certificate_path <> "" then
998-
yaml_entries_to_file (List.rev yaml_entries') (Fpath.v certificate_path);
999-
1000923
match GobConfig.get_bool "witness.yaml.strict" with
1001924
| true when !cnt_error > 0 ->
1002925
Error "witness error"

src/witness/yamlWitnessType.ml

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -368,83 +368,6 @@ struct
368368
{content}
369369
end
370370

371-
module Target =
372-
struct
373-
type t = {
374-
uuid: string;
375-
type_: string;
376-
file_hash: string;
377-
}
378-
[@@deriving eq, ord, hash]
379-
380-
let to_yaml {uuid; type_; file_hash} =
381-
`O [
382-
("uuid", `String uuid);
383-
("type", `String type_);
384-
("file_hash", `String file_hash);
385-
]
386-
387-
let of_yaml y =
388-
let open GobYaml in
389-
let+ uuid = y |> find "uuid" >>= to_string
390-
and+ type_ = y |> find "type" >>= to_string
391-
and+ file_hash = y |> find "file_hash" >>= to_string in
392-
{uuid; type_; file_hash}
393-
end
394-
395-
module Certification =
396-
struct
397-
type t = {
398-
string: string;
399-
type_: string;
400-
format: string;
401-
}
402-
[@@deriving eq, ord, hash]
403-
404-
let to_yaml {string; type_; format} =
405-
`O [
406-
("string", `String string);
407-
("type", `String type_);
408-
("format", `String format);
409-
]
410-
411-
let of_yaml y =
412-
let open GobYaml in
413-
let+ string = y |> find "string" >>= to_string
414-
and+ type_ = y |> find "type" >>= to_string
415-
and+ format = y |> find "format" >>= to_string in
416-
{string; type_; format}
417-
end
418-
419-
module LoopInvariantCertificate =
420-
struct
421-
type t = {
422-
target: Target.t;
423-
certification: Certification.t;
424-
}
425-
[@@deriving eq, ord, hash]
426-
427-
let entry_type = "loop_invariant_certificate"
428-
429-
let to_yaml' {target; certification} =
430-
[
431-
("target", Target.to_yaml target);
432-
("certification", Certification.to_yaml certification);
433-
]
434-
435-
let of_yaml y =
436-
let open GobYaml in
437-
let+ target = y |> find "target" >>= Target.of_yaml
438-
and+ certification = y |> find "certification" >>= Certification.of_yaml in
439-
{target; certification}
440-
end
441-
442-
module PreconditionLoopInvariantCertificate =
443-
struct
444-
include LoopInvariantCertificate
445-
let entry_type = "precondition_loop_invariant_certificate"
446-
end
447-
448371
module ViolationSequence =
449372
struct
450373

@@ -791,8 +714,6 @@ struct
791714
| LoopInvariant of LoopInvariant.t
792715
| FlowInsensitiveInvariant of FlowInsensitiveInvariant.t
793716
| PreconditionLoopInvariant of PreconditionLoopInvariant.t
794-
| LoopInvariantCertificate of LoopInvariantCertificate.t
795-
| PreconditionLoopInvariantCertificate of PreconditionLoopInvariantCertificate.t
796717
| InvariantSet of InvariantSet.t
797718
| ViolationSequence of ViolationSequence.t
798719
| GhostInstrumentation of GhostInstrumentation.t
@@ -803,8 +724,6 @@ struct
803724
| LoopInvariant _ -> LoopInvariant.entry_type
804725
| FlowInsensitiveInvariant _ -> FlowInsensitiveInvariant.entry_type
805726
| PreconditionLoopInvariant _ -> PreconditionLoopInvariant.entry_type
806-
| LoopInvariantCertificate _ -> LoopInvariantCertificate.entry_type
807-
| PreconditionLoopInvariantCertificate _ -> PreconditionLoopInvariantCertificate.entry_type
808727
| InvariantSet _ -> InvariantSet.entry_type
809728
| ViolationSequence _ -> ViolationSequence.entry_type
810729
| GhostInstrumentation _ -> GhostInstrumentation.entry_type
@@ -814,8 +733,6 @@ struct
814733
| LoopInvariant x -> LoopInvariant.to_yaml' x
815734
| FlowInsensitiveInvariant x -> FlowInsensitiveInvariant.to_yaml' x
816735
| PreconditionLoopInvariant x -> PreconditionLoopInvariant.to_yaml' x
817-
| LoopInvariantCertificate x -> LoopInvariantCertificate.to_yaml' x
818-
| PreconditionLoopInvariantCertificate x -> PreconditionLoopInvariantCertificate.to_yaml' x
819736
| InvariantSet x -> InvariantSet.to_yaml' x
820737
| ViolationSequence x -> ViolationSequence.to_yaml' x
821738
| GhostInstrumentation x -> GhostInstrumentation.to_yaml' x
@@ -835,12 +752,6 @@ struct
835752
else if entry_type = PreconditionLoopInvariant.entry_type then
836753
let+ x = y |> PreconditionLoopInvariant.of_yaml in
837754
PreconditionLoopInvariant x
838-
else if entry_type = LoopInvariantCertificate.entry_type then
839-
let+ x = y |> LoopInvariantCertificate.of_yaml in
840-
LoopInvariantCertificate x
841-
else if entry_type = PreconditionLoopInvariantCertificate.entry_type then
842-
let+ x = y |> PreconditionLoopInvariantCertificate.of_yaml in
843-
PreconditionLoopInvariantCertificate x
844755
else if entry_type = InvariantSet.entry_type then
845756
let+ x = y |> InvariantSet.of_yaml in
846757
InvariantSet x

0 commit comments

Comments
 (0)