@@ -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"
0 commit comments