From aeca05b7df71467c923d25383f50fd38c8d671a4 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Wed, 30 Oct 2024 19:48:24 +0100 Subject: [PATCH 01/35] Add prefix to names --- engine/backends/coq/coq/coq_backend.ml | 21 ++++++++++++- .../toolchain__literals into-coq.snap | 30 +++++++++---------- .../toolchain__reordering into-coq.snap | 4 +-- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 0e03029fc..29b1cb2a8 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -64,10 +64,27 @@ struct let metadata = Phase_utils.Metadata.make (Reject (NotInBackendLang backend)) end +(* module CoqNamePolicy = Concrete_ident.DefaultNamePolicy *) +module CoqNamePolicy = struct + (* include Concrete_ident.DefaultNamePolicy *) + + let reserved_words : string Hash_set.t = Hash_set.of_list (module String) ["Definition"; "Inductive"; "match"; "if"; "then"; "else"; "as"; "into"; "end"; "Record"; "Arguments"; "Type"] (* TODO: Make complete *) + (** List of all words that have a special meaning in the target + language, and that should thus be escaped. *) + + let index_field_transform x : string = x (* tuple struct, field `0` *) + (** Transformation applied to indexes fields name (i.e. [x.1]) *) + + let field_name_transform : struct_name:string -> string -> string = fun ~struct_name x -> + struct_name ^ "_" ^ x + + let enum_constructor_name_transform : enum_name:string -> string -> string = fun ~enum_name x -> x + let struct_constructor_name_transform : string -> string = fun x -> x +end + module AST = Ast.Make (InputLanguage) module BackendOptions = Backend.UnitBackendOptions open Ast -module CoqNamePolicy = Concrete_ident.DefaultNamePolicy module U = Ast_utils.MakeWithNamePolicy (InputLanguage) (CoqNamePolicy) open AST @@ -128,6 +145,8 @@ struct object (self) inherit BasePrinter.base + val concrete_ident_view = (module U.Concrete_ident_view : Concrete_ident.VIEW_API) + method private primitive_to_string (id : primitive_ident) : document = match id with | Deref -> default_document_for "(TODO: Deref)" diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index f2da7be00..4375f38c0 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -47,13 +47,13 @@ Export Hax_lib (t_int). Record t_Foo : Type := { - f_field : t_u8; + Foo_f_field : t_u8; }. Arguments t_Foo:clear implicits. Arguments t_Foo. Arguments Build_t_Foo. #[export] Instance settable_t_Foo : Settable _ := - settable! (@Build_t_Foo) . + settable! (@Build_t_Foo) . (* NotImplementedYet *) @@ -76,18 +76,18 @@ Definition fn_pointer_cast (_ : unit) : unit := x in tt. -Definition math_integers (x : t_Int) `{andb (f_gt (x) (impl__Int___unsafe_from_str ("0"%string))) (f_lt (x) (impl__Int___unsafe_from_str ("16"%string))) = true} : t_u8 := - let _ : t_Int := f_lift (3) in - let _ := f_gt (impl__Int___unsafe_from_str ("-340282366920938463463374607431768211455000"%string)) (impl__Int___unsafe_from_str ("340282366920938463463374607431768211455000"%string)) in - let _ := f_lt (x) (x) in - let _ := f_ge (x) (x) in - let _ := f_le (x) (x) in - let _ := f_ne (x) (x) in - let _ := f_eq (x) (x) in - let _ := f_add (x) (x) in - let _ := f_sub (x) (x) in - let _ := f_mul (x) (x) in - let _ := f_div (x) (x) in +Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___unsafe_from_str ("0"%string))) (PartialOrd_f_lt (x) (impl__Int___unsafe_from_str ("16"%string))) = true} : t_u8 := + let _ : t_Int := Abstraction_f_lift (3) in + let _ := PartialOrd_f_gt (impl__Int___unsafe_from_str ("-340282366920938463463374607431768211455000"%string)) (impl__Int___unsafe_from_str ("340282366920938463463374607431768211455000"%string)) in + let _ := PartialOrd_f_lt (x) (x) in + let _ := PartialOrd_f_ge (x) (x) in + let _ := PartialOrd_f_le (x) (x) in + let _ := PartialEq_f_ne (x) (x) in + let _ := PartialEq_f_eq (x) (x) in + let _ := Add_f_add (x) (x) in + let _ := Sub_f_sub (x) (x) in + let _ := Mul_f_mul (x) (x) in + let _ := Div_f_div (x) (x) in let _ : t_i16 := impl__Int__to_i16 (x) in let _ : t_i32 := impl__Int__to_i32 (x) in let _ : t_i64 := impl__Int__to_i64 (x) in @@ -98,7 +98,7 @@ Definition math_integers (x : t_Int) `{andb (f_gt (x) (impl__Int___unsafe_from_s let _ : t_u64 := impl__Int__to_u64 (x) in let _ : t_u128 := impl__Int__to_u128 (x) in let _ : t_usize := impl__Int__to_usize (x) in - impl__Int__to_u8 (f_add (x) (f_mul (x) (x))). + impl__Int__to_u8 (Add_f_add (x) (Mul_f_mul (x) (x))). Definition null : ascii := "\000"%char. diff --git a/test-harness/src/snapshots/toolchain__reordering into-coq.snap b/test-harness/src/snapshots/toolchain__reordering into-coq.snap index d3b0567d8..aafff19ec 100644 --- a/test-harness/src/snapshots/toolchain__reordering into-coq.snap +++ b/test-harness/src/snapshots/toolchain__reordering into-coq.snap @@ -49,13 +49,13 @@ Arguments t_Foo. Record t_Bar : Type := { - 0 : t_Foo; + Bar_0 : t_Foo; }. Arguments t_Bar:clear implicits. Arguments t_Bar. Arguments Build_t_Bar. #[export] Instance settable_t_Bar : Settable _ := - settable! (@Build_t_Bar) <0>. + settable! (@Build_t_Bar) . Definition t_Foo_cast_to_repr (x : t_Foo) : t_isize := match x with From 16b34729ede0472051983153c070ae5df3e55dcb Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 4 Nov 2024 16:30:19 +0100 Subject: [PATCH 02/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 29b1cb2a8..ea2ecb04d 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -68,17 +68,36 @@ end module CoqNamePolicy = struct (* include Concrete_ident.DefaultNamePolicy *) - let reserved_words : string Hash_set.t = Hash_set.of_list (module String) ["Definition"; "Inductive"; "match"; "if"; "then"; "else"; "as"; "into"; "end"; "Record"; "Arguments"; "Type"] (* TODO: Make complete *) (** List of all words that have a special meaning in the target language, and that should thus be escaped. *) + let reserved_words : string Hash_set.t = + Hash_set.of_list + (module String) + [ + "Definition"; + "Inductive"; + "match"; + "if"; + "then"; + "else"; + "as"; + "into"; + "end"; + "Record"; + "Arguments"; + "Type"; + ] + (* TODO: Make complete *) - let index_field_transform x : string = x (* tuple struct, field `0` *) (** Transformation applied to indexes fields name (i.e. [x.1]) *) + let index_field_transform x : string = x (* tuple struct, field `0` *) - let field_name_transform : struct_name:string -> string -> string = fun ~struct_name x -> - struct_name ^ "_" ^ x + let field_name_transform : struct_name:string -> string -> string = + fun ~struct_name x -> struct_name ^ "_" ^ x + + let enum_constructor_name_transform : enum_name:string -> string -> string = + fun ~enum_name x -> x - let enum_constructor_name_transform : enum_name:string -> string -> string = fun ~enum_name x -> x let struct_constructor_name_transform : string -> string = fun x -> x end @@ -145,8 +164,9 @@ struct object (self) inherit BasePrinter.base - val concrete_ident_view = (module U.Concrete_ident_view : Concrete_ident.VIEW_API) - + val concrete_ident_view : (module Concrete_ident.VIEW_API) = + (module U.Concrete_ident_view) + method private primitive_to_string (id : primitive_ident) : document = match id with | Deref -> default_document_for "(TODO: Deref)" From b9727e5d690fb98eb87e8c7f9a7ebebe00e9a1ba Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 4 Nov 2024 16:21:44 +0100 Subject: [PATCH 03/35] Minor fixes --- engine/backends/coq/coq/coq_backend.ml | 82 +++++++++++++++----------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index ea2ecb04d..f63e3691f 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -120,6 +120,12 @@ let hardcoded_coq_headers = From RecordUpdate Require Import RecordSet.\n\ Import RecordSetNotations.\n" +let dummy_lib = + "Definition t_usize := Z.\n\ + Class t_Sized (T : Type) := { }.\n\ + Definition t_Array T (x : t_usize) := list T.\n\ + Definition t_u8 := Z.\n" + module BasePrinter = Generic_printer.Make (InputLanguage) module Make @@ -133,17 +139,22 @@ struct let default_string_for s = "TODO: please implement the method `" ^ s ^ "`" let default_document_for = default_string_for >> string + let concat_with ?(pre=empty) ?(post=empty) l = concat_map (fun x -> pre ^^ x ^^ post) l + let concat_map_with ?(pre=empty) ?(post=empty) f l = concat_map (fun x -> pre ^^ f x ^^ post) l + + let concat_spaced_doc l = concat_map_with ~pre:space (fun x -> x#p) l + module CoqNotation = struct let definition_struct keyword n name generics params typ body = keyword ^^ space ^^ name ^^ generics - ^^ concat_map (fun x -> space ^^ x) params + ^^ concat_with ~pre:space params ^^ space ^^ colon ^^ space ^^ typ ^^ space ^^ string ":=" ^^ nest n (break 1 ^^ body) ^^ dot let proof_struct keyword name generics params statement = keyword ^^ space ^^ name ^^ generics - ^^ concat_map (fun x -> space ^^ x) params + ^^ concat_with ~pre:space params ^^ space ^^ colon ^^ nest 2 (break 1 ^^ statement ^^ dot) ^^ break 1 ^^ string "Proof" ^^ dot ^^ space ^^ string "Admitted" ^^ dot @@ -155,6 +166,9 @@ struct let instance = definition_struct (string "Instance") 2 let class_ = definition_struct (string "Class") 2 let lemma = proof_struct (string "Lemma") + + let arguments name (explicivity : bool list) = + !^"Arguments" ^^ space ^^ name ^^ concat_map_with ~pre:space (function | true -> string "(_)" | false -> string "{_}") explicivity ^^ dot end type ('get_span_data, 'a) object_type = @@ -202,7 +216,7 @@ struct match witness with _ -> . method expr'_App_application ~super:_ ~f ~args ~generics:_ = - f#p ^^ concat_map (fun x -> space ^^ parens x#p) args + f#p ^^ concat_map_with ~pre:space (fun x -> parens x#p) args method expr'_App_constant ~super:_ ~constant ~generics:_ = constant#p @@ -229,7 +243,7 @@ struct method expr'_Closure ~super:_ ~params ~body ~captures:_ = !^"fun" - ^^ concat_map (fun x -> space ^^ x#p) params + ^^ concat_spaced_doc params ^^ space ^^ !^"=>" ^^ space ^^ nest 2 (break 1 ^^ body#p) @@ -301,7 +315,7 @@ struct method expr'_Match ~super:_ ~scrutinee ~arms = string "match" ^^ space ^^ scrutinee#p ^^ space ^^ string "with" ^^ break 1 - ^^ concat_map (fun x -> string "|" ^^ space ^^ x#p ^^ break 1) arms + ^^ concat_map_with ~pre:(string "|" ^^ space) ~post:(break 1) (fun x -> x#p) arms ^^ string "end" method expr'_QuestionMark ~super:_ ~e:_ ~return_typ:_ ~witness = @@ -339,9 +353,8 @@ struct method generic_value_GType x1 = parens x1#p method generics ~params ~constraints = - let params_document = concat_map (fun x -> space ^^ x#p) params in - let constraints_document = - concat_map (fun x -> space ^^ x#p) constraints + let params_document = concat_spaced_doc params in + let constraints_document = concat_spaced_doc constraints in params_document ^^ constraints_document @@ -382,7 +395,7 @@ struct if List.length params == 0 then body#p else string "fun" ^^ space - ^^ concat_map (fun x -> x#p ^^ space) params + ^^ concat_spaced_doc params ^^ string "=>" ^^ nest 2 (break 1 ^^ body#p) @@ -449,10 +462,10 @@ struct CoqNotation.instance (name#p ^^ string "_" ^^ string (Int.to_string ([%hash: item] super))) generics#p [] - (name#p ^^ concat_map (fun x -> space ^^ parens x#p) args) + (name#p ^^ concat_map_with ~pre:space (fun x -> parens x#p) args) (braces (nest 2 - (concat_map (fun x -> break 1 ^^ name#p ^^ !^"_" ^^ x#p) items) + (concat_map_with ~pre:(break 1 ^^ name#p ^^ !^"_") (fun x -> x#p) items) ^^ break 1)) method item'_NotImplementedYet = string "(* NotImplementedYet *)" @@ -465,12 +478,8 @@ struct CoqNotation.class_ name#p generics#p [] !^"Type" (braces (nest 2 (concat_map (fun x -> break 1 ^^ x#p) items) ^^ break 1)) - ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon - ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space - ^^ name#p - ^^ concat_map (fun _ -> space ^^ !^"(_)") params - ^^ concat_map (fun _ -> space ^^ !^"{_}") constraints - ^^ dot + ^^ break 1 + ^^ CoqNotation.arguments name#p (List.map ~f:(fun _ -> true) params @ List.map ~f:(fun _ -> false) constraints) method item'_TyAlias ~super:_ ~name ~generics:_ ~ty = string "Notation" ^^ space ^^ string "\"'" ^^ name#p ^^ string "'\"" @@ -478,6 +487,12 @@ struct method item'_Type_struct ~super:_ ~name ~generics ~tuple_struct:_ ~arguments = + let arguments_explicity_with_ty = + (List.map ~f:(fun _ -> true) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) + in + let arguments_explicity_without_ty = + (List.map ~f:(fun _ -> false) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) + in CoqNotation.record name#p generics#p [] (string "Type") (braces (nest 2 @@ -487,25 +502,22 @@ struct ^^ semi) arguments) ^^ break 1)) - ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon - ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space - ^^ name#p - ^^ concat_map (fun _ -> space ^^ !^"(_)") generics#v.params - ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints - ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space ^^ !^"Build_" ^^ name#p - ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.params - ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints - ^^ dot ^^ break 1 ^^ !^"#[export]" ^^ space - ^^ CoqNotation.instance - (string "settable" ^^ string "_" ^^ name#p) - generics#p [] - (!^"Settable" ^^ space ^^ !^"_") - (string "settable!" ^^ space - ^^ parens (!^"@" ^^ !^"Build_" ^^ name#p ^^ generics#p) + ^^ break 1 ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) arguments_explicity_with_ty + ^^ concat_map_with ~pre:(break 1) (fun (ident, typ, attr) -> CoqNotation.arguments ident#p arguments_explicity_without_ty) arguments + ^^ break 1 ^^ !^"#[export]" ^^ space + ^^ if List.is_empty arguments + then empty + else + CoqNotation.instance + (string "settable" ^^ string "_" ^^ name#p) + generics#p [] + (!^"Settable" ^^ space ^^ !^"_") + (string "settable!" ^^ space + ^^ parens (!^"Build_" ^^ name#p ^^ (concat_map_with ~pre:space (fun (x : generic_param) -> match x with | { ident; _ } -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics ident)#p) generics#v.params)) ^^ space ^^ string "<" ^^ separate_map (semi ^^ space) - (fun (ident, typ, attr) -> ident#p) - arguments + (fun (ident, typ, attr) -> ident#p) + arguments ^^ string ">") method item'_Type_enum ~super:_ ~name ~generics ~variants = @@ -809,7 +821,7 @@ let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = let sourcemap, contents = let annotated = my_printer#entrypoint_modul items in let open Generic_printer.AnnotatedString in - let header = pure (hardcoded_coq_headers ^ "\n") in + let header = pure (hardcoded_coq_headers ^ "\n" ^ dummy_lib) in let annotated = concat header annotated in (to_sourcemap annotated, to_string annotated) in From 37fb5ced560f8e1faa98db5430acb9f6e919a246 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 4 Nov 2024 22:31:23 +0100 Subject: [PATCH 04/35] Update concrete ident for record --- engine/backends/coq/coq/coq_backend.ml | 86 +++++++++++-------- engine/lib/concrete_ident/concrete_ident.ml | 6 +- .../lib/concrete_ident/concrete_ident_sig.ml | 1 + 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index f63e3691f..85cb33d8f 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -90,15 +90,16 @@ module CoqNamePolicy = struct (* TODO: Make complete *) (** Transformation applied to indexes fields name (i.e. [x.1]) *) - let index_field_transform x : string = x (* tuple struct, field `0` *) + let index_field_transform x = x - let field_name_transform : struct_name:string -> string -> string = - fun ~struct_name x -> struct_name ^ "_" ^ x + let field_name_transform ~struct_name x = + struct_name ^ "_" ^ x - let enum_constructor_name_transform : enum_name:string -> string -> string = - fun ~enum_name x -> x + let enum_constructor_name_transform ~enum_name x = x + let struct_constructor_name_transform x : string = + "Build_t_" ^ x - let struct_constructor_name_transform : string -> string = fun x -> x + let constructor_prefix = "" end module AST = Ast.Make (InputLanguage) @@ -124,7 +125,8 @@ let dummy_lib = "Definition t_usize := Z.\n\ Class t_Sized (T : Type) := { }.\n\ Definition t_Array T (x : t_usize) := list T.\n\ - Definition t_u8 := Z.\n" + Definition t_u8 := Z.\n\ + Definition t_i32 := Z.\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -169,6 +171,13 @@ struct let arguments name (explicivity : bool list) = !^"Arguments" ^^ space ^^ name ^^ concat_map_with ~pre:space (function | true -> string "(_)" | false -> string "{_}") explicivity ^^ dot + + let notation pattern value = + !^"Notation" ^^ space ^^ string "\"" ^^ pattern ^^ string "\"" ^^ space ^^ !^":=" ^^ space ^^ value ^^ dot + + let notation_name name value = + notation (string "'" ^^ name ^^ string "'") value + end type ('get_span_data, 'a) object_type = @@ -218,7 +227,8 @@ struct method expr'_App_application ~super:_ ~f ~args ~generics:_ = f#p ^^ concat_map_with ~pre:space (fun x -> parens x#p) args - method expr'_App_constant ~super:_ ~constant ~generics:_ = constant#p + method expr'_App_constant ~super:_ ~constant ~generics:_ = + constant#p method expr'_App_field_projection ~super:_ ~field ~e = field#p ^^ space ^^ e#p @@ -253,16 +263,15 @@ struct if List.is_empty fields then empty else add_space - ^^ parens - (separate_map (comma ^^ space) (fun x -> (snd x)#p) fields) + ^^ separate_map space (fun x -> (snd x)#p) fields in if is_record && is_struct then match base with | Some x -> string "Build_" ^^ x#p ^^ fields_or_empty space - | None -> string "Build_t_" ^^ constructor#p ^^ fields_or_empty space + | None -> constructor#p ^^ fields_or_empty space else if not is_record then if is_struct then - string "Build_t_" ^^ constructor#p ^^ fields_or_empty space + constructor#p ^^ fields_or_empty space else constructor#p ^^ fields_or_empty space else default_document_for @@ -403,8 +412,9 @@ struct method item ~v ~span:_ ~ident:_ ~attrs:_ = v#p ^^ break 1 method item'_Alias ~super:_ ~name ~item = - string "Notation" ^^ space ^^ string "\"'" ^^ name#p ^^ string "'\"" - ^^ space ^^ string ":=" ^^ space ^^ parens item#p ^^ dot + CoqNotation.notation_name + (name#p) + (parens item#p) method item'_Fn ~super ~name ~generics ~body ~params ~safety:_ = (* TODO: Why is type not available here ? *) @@ -482,10 +492,11 @@ struct ^^ CoqNotation.arguments name#p (List.map ~f:(fun _ -> true) params @ List.map ~f:(fun _ -> false) constraints) method item'_TyAlias ~super:_ ~name ~generics:_ ~ty = - string "Notation" ^^ space ^^ string "\"'" ^^ name#p ^^ string "'\"" - ^^ space ^^ string ":=" ^^ space ^^ ty#p ^^ dot + CoqNotation.notation_name + (name#p) + ty#p - method item'_Type_struct ~super:_ ~name ~generics ~tuple_struct:_ + method item'_Type_struct ~super:_ ~name ~generics ~tuple_struct ~arguments = let arguments_explicity_with_ty = (List.map ~f:(fun _ -> true) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) @@ -505,20 +516,26 @@ struct ^^ break 1 ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) arguments_explicity_with_ty ^^ concat_map_with ~pre:(break 1) (fun (ident, typ, attr) -> CoqNotation.arguments ident#p arguments_explicity_without_ty) arguments ^^ break 1 ^^ !^"#[export]" ^^ space - ^^ if List.is_empty arguments - then empty - else - CoqNotation.instance - (string "settable" ^^ string "_" ^^ name#p) - generics#p [] - (!^"Settable" ^^ space ^^ !^"_") - (string "settable!" ^^ space - ^^ parens (!^"Build_" ^^ name#p ^^ (concat_map_with ~pre:space (fun (x : generic_param) -> match x with | { ident; _ } -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics ident)#p) generics#v.params)) - ^^ space ^^ string "<" - ^^ separate_map (semi ^^ space) - (fun (ident, typ, attr) -> ident#p) - arguments - ^^ string ">") + ^^ + (if List.is_empty arguments + then empty + else + CoqNotation.instance + (string "settable" ^^ string "_" ^^ name#p) + generics#p [] + (!^"Settable" ^^ space ^^ !^"_") + (string "settable!" ^^ space + ^^ parens (!^"Build_" ^^ name#p ^^ (concat_map_with ~pre:space (fun (x : generic_param) -> match x with | { ident; _ } -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics ident)#p) generics#v.params)) + ^^ space ^^ string "<" + ^^ separate_map (semi ^^ space) + (fun (ident, typ, attr) -> ident#p) + arguments + ^^ string ">")) + ^^ + (if tuple_struct + then break 1 ^^ + (CoqNotation.notation_name (string (String.drop_prefix (U.Concrete_ident_view.to_definition_name name#v) 2 )) (!^"Build_" ^^ name#p)) + else empty) method item'_Type_enum ~super:_ ~name ~generics ~variants = CoqNotation.inductive name#p generics#p [] (string "Type") @@ -631,9 +648,10 @@ struct (fun field_pat -> (snd field_pat)#p) fields) else - (if is_struct then string "Build_t_" else empty) - ^^ constructor#p - ^^ concat_map (fun (ident, exp) -> space ^^ parens exp#p) fields + (* constructor#p ^^ *) + string "{|" ^^ + separate_map (semi ^^ space) (fun (ident, exp) -> ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) fields + ^^ string "|}" method pat'_PConstruct_tuple ~super:_ ~components = (* TODO: Only add `'` if you are a top-level pattern *) diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index b0d0cc160..ced38d163 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -473,7 +473,8 @@ module MakeViewAPI (NP : NAME_POLICY) : VIEW_API = struct else escape name | Constructor { is_struct } -> let name = - if start_lowercase name || is_reserved_word name then "C_" ^ name + if start_lowercase name || is_reserved_word name + then NP.constructor_prefix ^ name else escape name in if is_struct then NP.struct_constructor_name_transform name @@ -481,7 +482,7 @@ module MakeViewAPI (NP : NAME_POLICY) : VIEW_API = struct let enum_name = type_name |> Option.value_exn in NP.enum_constructor_name_transform ~enum_name name | Field | AssociatedItem _ -> - let struct_name = type_name |> Option.value_exn in + let struct_name = type_name |> Option.value_exn in NP.field_name_transform ~struct_name (match Stdlib.int_of_string_opt name with | Some _ -> NP.index_field_transform name @@ -565,6 +566,7 @@ module DefaultNamePolicy = struct let field_name_transform ~struct_name:_ = Fn.id let enum_constructor_name_transform ~enum_name:_ = Fn.id let struct_constructor_name_transform = Fn.id + let constructor_prefix = "C_" end let matches_namespace (ns : Types.namespace) (did : t) : bool = diff --git a/engine/lib/concrete_ident/concrete_ident_sig.ml b/engine/lib/concrete_ident/concrete_ident_sig.ml index 09af4797a..13df71853 100644 --- a/engine/lib/concrete_ident/concrete_ident_sig.ml +++ b/engine/lib/concrete_ident/concrete_ident_sig.ml @@ -18,6 +18,7 @@ struct val field_name_transform : struct_name:string -> string -> string val enum_constructor_name_transform : enum_name:string -> string -> string val struct_constructor_name_transform : string -> string + val constructor_prefix : string end module type VIEW_API = sig From 49feac44a8bf12cd1e9ea04c10b5ee1936b90673 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 5 Nov 2024 19:51:45 +0100 Subject: [PATCH 05/35] Improved enum and records --- engine/backends/coq/coq/coq_backend.ml | 95 +++++++++++++------ engine/lib/generic_printer/generic_printer.ml | 2 +- 2 files changed, 65 insertions(+), 32 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 85cb33d8f..c877faf55 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -126,7 +126,10 @@ let dummy_lib = Class t_Sized (T : Type) := { }.\n\ Definition t_Array T (x : t_usize) := list T.\n\ Definition t_u8 := Z.\n\ - Definition t_i32 := Z.\n" + Definition t_i32 := Z.\n\ + Definition t_isize := Z.\n\ + Definition t_String := string.\n\ + Definition ToString_f_to_string (x : string) := x.\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -263,20 +266,23 @@ struct if List.is_empty fields then empty else add_space - ^^ separate_map space (fun x -> (snd x)#p) fields + ^^ separate_map space (fun x -> parens((snd x)#p)) fields in if is_record && is_struct then match base with - | Some x -> string "Build_" ^^ x#p ^^ fields_or_empty space - | None -> constructor#p ^^ fields_or_empty space - else if not is_record then - if is_struct then + | Some x -> + (* Update fields *) + x#p ^^ concat_map_with ~pre:space (fun x -> string "<|" ^^ (fst x)#p ^^ space ^^ !^":=" ^^ space ^^ (snd x)#p ^^ space ^^ string "|>") fields + | None -> constructor#p ^^ fields_or_empty space + else if not is_record then + if is_struct + then constructor#p ^^ fields_or_empty space else constructor#p ^^ fields_or_empty space else - default_document_for - "expr'_Construct_inductive [is_record=true, is_struct = false] \ - todo record" + constructor#p ^^ space ^^ string "{|" ^^ space ^^ + separate_map (semi ^^ space) (fun (ident, exp) -> ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) fields + ^^ space ^^ string "|}" method expr'_Construct_tuple ~super:_ ~components = if List.length components == 0 then !^"tt" @@ -346,7 +352,7 @@ struct method generic_constraint_GCType x1 = string "`" ^^ braces x1#p method generic_param ~ident ~span:_ ~attrs:_ ~kind = - string "`" ^^ braces (ident#p ^^ space ^^ colon ^^ space ^^ kind#p) + ident#p ^^ space ^^ colon ^^ space ^^ kind#p method generic_param_kind_GPConst ~typ = typ#p @@ -362,7 +368,7 @@ struct method generic_value_GType x1 = parens x1#p method generics ~params ~constraints = - let params_document = concat_spaced_doc params in + let params_document = concat_map_with ~pre:space (fun x -> string "`" ^^ braces (x#p)) params in let constraints_document = concat_spaced_doc constraints in params_document ^^ constraints_document @@ -487,7 +493,7 @@ struct let _, params, constraints = generics#v in CoqNotation.class_ name#p generics#p [] !^"Type" (braces - (nest 2 (concat_map (fun x -> break 1 ^^ x#p) items) ^^ break 1)) + (nest 2 (concat_map_with ~pre:(break 1) (fun x -> x#p) items) ^^ break 1)) ^^ break 1 ^^ CoqNotation.arguments name#p (List.map ~f:(fun _ -> true) params @ List.map ~f:(fun _ -> false) constraints) @@ -504,7 +510,7 @@ struct let arguments_explicity_without_ty = (List.map ~f:(fun _ -> false) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) in - CoqNotation.record name#p generics#p [] (string "Type") + CoqNotation.record name#p ((concat_map_with ~pre:space (fun x -> parens( self#entrypoint_generic_param x )) generics#v.params) ^^ (concat_map_with ~pre:space (fun x -> self#entrypoint_generic_constraint x ) generics#v.constraints)) [] (string "Type") (braces (nest 2 (concat_map @@ -537,17 +543,38 @@ struct (CoqNotation.notation_name (string (String.drop_prefix (U.Concrete_ident_view.to_definition_name name#v) 2 )) (!^"Build_" ^^ name#p)) else empty) - method item'_Type_enum ~super:_ ~name ~generics ~variants = + (* map_def_path_item_string (fun x -> x) x#v.name *) + + method item'_Type_enum ~super ~name ~generics ~variants = + concat_map_with ~post:(break 1) (fun x -> + (self#item'_Type_struct ~super ~name:( + self#_do_not_override_lazy_of_concrete_ident + AstPos_variant__arguments ( + Concrete_ident.Create.map_last ~f:(fun x -> x ^ "_record") x#v.name + )) ~generics ~tuple_struct:false ~arguments:(List.map + ~f:(fun (ident, typ, attrs) -> + ( self#_do_not_override_lazy_of_concrete_ident + AstPos_variant__arguments ident, + self#_do_not_override_lazy_of_ty AstPos_variant__arguments + typ, + self#_do_not_override_lazy_of_attrs AstPos_variant__attrs + attrs )) + x#v.arguments)) + ) (List.filter ~f:(fun x -> x#v.is_record) variants) ^^ CoqNotation.inductive name#p generics#p [] (string "Type") (separate_map (break 1) - (fun x -> string "|" ^^ space ^^ x#p) + (fun x -> string "|" ^^ space ^^ x#p ^^ + (if x#v.is_record + then + (concat_map_with ~pre:space (fun (x : generic_param) -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics x.ident)#p) generics#v.params) ^^ space ^^ !^"->" ^^ space ^^ !^"_" + else empty)) variants) - ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon - ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space - ^^ name#p - ^^ concat_map (fun _ -> space ^^ !^"(_)") generics#v.params - ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints - ^^ dot + (* ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon *) + (* ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space *) + (* ^^ name#p *) + (* ^^ concat_map (fun _ -> space ^^ !^"(_)") generics#v.params *) + (* ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints *) + (* ^^ dot *) method item'_Use ~super:_ ~path ~is_external ~rename:_ = if List.length path == 0 || is_external then empty @@ -641,17 +668,22 @@ struct method pat'_PConstruct_inductive ~super:_ ~constructor ~is_record ~is_struct ~fields = - if is_record then + if is_record + then constructor#p ^^ space ^^ parens (separate_map (comma ^^ space) (fun field_pat -> (snd field_pat)#p) fields) else + if is_record + then (* constructor#p ^^ *) string "{|" ^^ separate_map (semi ^^ space) (fun (ident, exp) -> ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) fields ^^ string "|}" + else + constructor#p ^^ concat_map_with ~pre:space (fun (ident, exp) -> exp#p) fields method pat'_PConstruct_tuple ~super:_ ~components = (* TODO: Only add `'` if you are a top-level pattern *) @@ -775,18 +807,19 @@ struct method item'_Enum_Variant ~name ~arguments ~is_record ~attrs:_ = if is_record then - concat_map - (fun (ident, typ, attr) -> - ident#p ^^ space ^^ colon ^^ space ^^ typ#p) - arguments - ^^ semi - else if List.length arguments == 0 then name#p + name#p ^^ space ^^ colon ^^ space ^^ name#p ^^ !^"_record" ^^ space + (* concat_map *) + (* (fun (ident, typ, attr) -> *) + (* ident#p ^^ space ^^ colon ^^ space ^^ typ#p) *) + (* arguments *) + else + if List.length arguments == 0 then name#p else name#p ^^ space ^^ colon ^^ space ^^ separate_map - (space ^^ string "->" ^^ space) - (fun (ident, typ, attr) -> typ#p) - arguments + (space ^^ string "->" ^^ space) + (fun (ident, typ, attr) -> typ#p) + arguments ^^ space ^^ string "->" ^^ space ^^ string "_" method module_path_separator = "." diff --git a/engine/lib/generic_printer/generic_printer.ml b/engine/lib/generic_printer/generic_printer.ml index 811051c0e..ee5f7079f 100644 --- a/engine/lib/generic_printer/generic_printer.ml +++ b/engine/lib/generic_printer/generic_printer.ml @@ -618,7 +618,7 @@ module Make (F : Features.T) = struct lazy_doc (fun (id : global_ident) -> match id with - | `Concrete cid -> + | `Concrete cid | `Projector (`Concrete cid) -> (self#_do_not_override_lazy_of_concrete_ident ast_position cid) #p | _ -> From 8d53378378e744e6dc5c070a329952204d0cad29 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 7 Nov 2024 17:07:03 +0100 Subject: [PATCH 06/35] Test coq implementation / coverage tests --- engine/backends/coq/coq/coq_backend.ml | 63 ++++++-- examples/coverage/Cargo.toml | 6 + .../coverage/proofs/coq/extraction/Coverage.v | 48 ++++++ .../coq/extraction/Coverage_Test_closures.v | 44 ++++++ .../coq/extraction/Coverage_Test_enum.v | 118 ++++++++++++++ .../coq/extraction/Coverage_Test_enum_Test.v | 41 +++++ .../coq/extraction/Coverage_Test_functions.v | 50 ++++++ .../coq/extraction/Coverage_Test_primitives.v | 53 +++++++ .../coq/extraction/Coverage_Test_sequence.v | 45 ++++++ .../coq/extraction/Coverage_Test_struct.v | 149 ++++++++++++++++++ .../proofs/coq/extraction/_CoqProject | 11 ++ examples/coverage/src/lib.rs | 9 ++ examples/coverage/src/test_closures.rs | 14 ++ examples/coverage/src/test_enum.rs | 52 ++++++ examples/coverage/src/test_functions.rs | 25 +++ examples/coverage/src/test_primitives.rs | 30 ++++ examples/coverage/src/test_primtives.rs | 0 examples/coverage/src/test_sequence.rs | 17 ++ examples/coverage/src/test_struct.rs | 55 +++++++ examples/coverage/src/test_struct_unit.rs | 13 ++ 20 files changed, 831 insertions(+), 12 deletions(-) create mode 100644 examples/coverage/Cargo.toml create mode 100644 examples/coverage/proofs/coq/extraction/Coverage.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v create mode 100644 examples/coverage/proofs/coq/extraction/_CoqProject create mode 100644 examples/coverage/src/lib.rs create mode 100644 examples/coverage/src/test_closures.rs create mode 100644 examples/coverage/src/test_enum.rs create mode 100644 examples/coverage/src/test_functions.rs create mode 100644 examples/coverage/src/test_primitives.rs create mode 100644 examples/coverage/src/test_primtives.rs create mode 100644 examples/coverage/src/test_sequence.rs create mode 100644 examples/coverage/src/test_struct.rs create mode 100644 examples/coverage/src/test_struct_unit.rs diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index c877faf55..44160dddf 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -119,17 +119,28 @@ let hardcoded_coq_headers = Require Import String.\n\ Require Import Coq.Floats.Floats.\n\ From RecordUpdate Require Import RecordSet.\n\ - Import RecordSetNotations.\n" + Import RecordSetNotations.\n\n\ + From Core Require Import Core.\n" let dummy_lib = - "Definition t_usize := Z.\n\ - Class t_Sized (T : Type) := { }.\n\ - Definition t_Array T (x : t_usize) := list T.\n\ + "Class t_Sized (T : Type) := { }.\n\ Definition t_u8 := Z.\n\ + Definition t_u16 := Z.\n\ + Definition t_u32 := Z.\n\ + Definition t_u64 := Z.\n\ + Definition t_u128 := Z.\n\ + Definition t_usize := Z.\n\ + Definition t_i8 := Z.\n\ + Definition t_i16 := Z.\n\ Definition t_i32 := Z.\n\ + Definition t_i64 := Z.\n\ + Definition t_i128 := Z.\n\ Definition t_isize := Z.\n\ + Definition t_Array T (x : t_usize) := list T.\n\ Definition t_String := string.\n\ - Definition ToString_f_to_string (x : string) := x.\n" + Definition ToString_f_to_string (x : string) := x.\n\ + Instance Sized_any : forall {t_A}, t_Sized t_A := {}.\n\ + Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}.\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -236,8 +247,22 @@ struct method expr'_App_field_projection ~super:_ ~field ~e = field#p ^^ space ^^ e#p - method expr'_App_tuple_projection ~super:_ ~size:_ ~nth:_ ~e:_ = - default_document_for "expr'_App_tuple_projection" + method expr'_App_tuple_projection ~super:_ ~size ~nth ~e = + let size = match e#v.e with + | Construct { + constructor; + is_record; + is_struct; + fields; + base; + } -> + List.length fields + | _ -> size (* TODO: Size argument incorrect? *) + in + List.fold_right ~init:(e#p) + ~f:(fun x y -> parens(x ^^ y)) + ((if Stdlib.(nth != 0) then [ string "snd" ] else []) + @ List.init (size - 1 - nth) ~f:(fun _ -> string "fst")) method expr'_Ascription ~super:_ ~e ~typ = e#p ^^ space ^^ colon ^^ space ^^ typ#p @@ -433,6 +458,18 @@ struct self#_do_not_override_lazy_of_ty AstPos_item'_Fn_body body#v.typ in + let params = + List.map ~f:(fun x -> match x#v with + | { pat = { p = PBinding { + mut; + mode; + var; + typ = _; + subpat; + }; span : span; typ = _ }; typ; typ_span; attrs } -> x#p + | _ -> string "'" ^^ x#p) params + in + let get_expr_of kind f : document option = Attrs.associated_expr kind super.attrs |> Option.map ~f:(self#entrypoint_expr >> f) @@ -445,23 +482,22 @@ struct get_expr_of Ensures (fun x -> x ^^ space ^^ string "=" ^^ space ^^ string "true") in - let is_lemma = Attrs.lemma super.attrs in if is_lemma then CoqNotation.lemma name#p generics#p - (List.map ~f:(fun x -> x#p) params) + params (Option.value ~default:empty requires ^^ space ^^ !^"->" ^^ break 1 ^^ Option.value ~default:empty ensures) else if is_rec then CoqNotation.fixpoint name#p generics#p - (List.map ~f:(fun x -> x#p) params + (params @ Option.value ~default:[] (Option.map ~f:(fun x -> [ string "`" ^^ braces x ]) requires)) typ#p body#p (* ^^ TODO: ensures? *) else CoqNotation.definition name#p generics#p - (List.map ~f:(fun x -> x#p) params + (params @ Option.value ~default:[] (Option.map ~f:(fun x -> [ string "`" ^^ braces x ]) requires)) typ#p body#p (* ^^ TODO: ensures? *) @@ -630,7 +666,10 @@ struct string "\"" ^^ string (Char.escaped x1) ^^ string "\"" ^^ string "%char" method literal_Float ~value ~negative ~kind:_ = - (if negative then !^"-" else empty) ^^ string value ^^ string "%float" + (if negative + then parens(!^"-" ^^ string value) + else string value) + ^^ string "%float" method literal_Int ~value ~negative ~kind:_ = (if negative then !^"-" else empty) ^^ string value diff --git a/examples/coverage/Cargo.toml b/examples/coverage/Cargo.toml new file mode 100644 index 000000000..055dab5dd --- /dev/null +++ b/examples/coverage/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "coverage" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/examples/coverage/proofs/coq/extraction/Coverage.v b/examples/coverage/proofs/coq/extraction/Coverage.v new file mode 100644 index 000000000..73677f973 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage.v @@ -0,0 +1,48 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + + + +(* NotImplementedYet *) + +(* NotImplementedYet *) + +(* NotImplementedYet *) + +(* NotImplementedYet *) + +(* NotImplementedYet *) + +(* NotImplementedYet *) + +(* NotImplementedYet *) diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v new file mode 100644 index 000000000..a085ed82d --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v @@ -0,0 +1,44 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +(* Class t_Sized (T : Type) := { }. *) +(* Definition t_u8 := Z. *) +(* Definition t_u16 := Z. *) +(* Definition t_u32 := Z. *) +(* Definition t_u64 := Z. *) +(* Definition t_u128 := Z. *) +(* Definition t_usize := Z. *) +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +(* Definition test__f `{v_F : Type} `{t_Sized (v_F)} `{t_FnOnce (v_F) (unit)} `{_.(t_FnOnce_f_Output) = t_u8} (g : v_F) : t_u8 := *) +(* t_Add_f_add (t_Add := _) (t_FnOnce_f_call_once (t_FnOnce := _) (g) (tt)) (Build_t_u8 (Build_t_U8 2)). *) + +(* Definition test '(_ : unit) : unit := *) +(* let add : t_i32 -> t_i32 -> t_i32 := fun x y => *) +(* t_Add_f_add (x) (y) in *) +(* let _ := Fn_f_call (fun x => *) +(* Add_f_add (x) (x)) ((2)) in *) +(* let _ := test__f (fun _ => *) +(* 23) in *) +(* tt. *) diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v new file mode 100644 index 000000000..d32fd0595 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v @@ -0,0 +1,118 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +Record Foo_Qux_record (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := + { + Qux_f_x : v_T; + Qux_f_y : t_Array (v_T) (v_N); + Qux_f_z : t_u8; + }. +Arguments Build_Foo_Qux_record (_) (_) {_}. +Arguments Qux_f_x {_} {_} {_}. +Arguments Qux_f_y {_} {_} {_}. +Arguments Qux_f_z {_} {_} {_}. +#[export] Instance settable_Foo_Qux_record `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := + settable! (Build_Foo_Qux_record v_T v_N) . +Inductive t_Foo `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Type := +| Foo_Bar : t_u8 -> _ +| Foo_Baz +| Foo_Qux : Foo_Qux_record v_T v_N -> _. + +Inductive t_test__AnimalA : Type := +| test__AnimalA_Dog +| test__AnimalA_Cat. + +Definition t_test__AnimalA_cast_to_repr (x : t_test__AnimalA) : t_isize := + match x with + | test__AnimalA_Dog => + 0 + | test__AnimalA_Cat => + 1 + end. + +Record test__AnimalB_Cat_record : Type := + { + Cat_f_name : t_String; + Cat_f_weight : float; + }. +Arguments Build_test__AnimalB_Cat_record. +Arguments Cat_f_name. +Arguments Cat_f_weight. +#[export] Instance settable_test__AnimalB_Cat_record : Settable _ := + settable! (Build_test__AnimalB_Cat_record) . +Inductive t_test__AnimalB : Type := +| test__AnimalB_Dog : t_String -> float -> _ +| test__AnimalB_Cat : test__AnimalB_Cat_record -> _. + +Record test__Enum_Struct_record : Type := + { + Struct_f_a : t_u8; + Struct_f_b : t_u16; + }. +Arguments Build_test__Enum_Struct_record. +Arguments Struct_f_a. +Arguments Struct_f_b. +#[export] Instance settable_test__Enum_Struct_record : Settable _ := + settable! (Build_test__Enum_Struct_record) . +Inductive t_test__Enum : Type := +| test__Enum_Unit +| test__Enum_Tuple : t_u16 -> _ +| test__Enum_Struct : test__Enum_Struct_record -> _. + +Record test__Examples_StructLike_record : Type := + { + StructLike_f_value : t_i32; + }. +Arguments Build_test__Examples_StructLike_record. +Arguments StructLike_f_value. +#[export] Instance settable_test__Examples_StructLike_record : Settable _ := + settable! (Build_test__Examples_StructLike_record) . +Inductive t_test__Examples : Type := +| test__Examples_UnitLike +| test__Examples_TupleLike : t_i32 -> _ +| test__Examples_StructLike : test__Examples_StructLike_record -> _. + +Definition test '(_ : unit) : unit := + let a : t_test__AnimalA := test__AnimalA_Dog in + let a := test__AnimalA_Cat in + let _ := tt in + let a : t_test__AnimalB := test__AnimalB_Dog (ToString_f_to_string ("Cocoa"%string)) (37.2%float) in + let a := test__AnimalB_Cat {| Cat_f_name := (ToString_f_to_string ("Spotty"%string)); Cat_f_weight := (2.7%float) |} in + let _ := tt in + let x := test__Examples_UnitLike in + let x := test__Examples_UnitLike in + let y := test__Examples_TupleLike (123) in + let y := test__Examples_TupleLike (123) in + let z := test__Examples_StructLike {| StructLike_f_value := (123) |} in + let _ := tt in + tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v new file mode 100644 index 000000000..d2c30d4c9 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v @@ -0,0 +1,41 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +From Coverage Require Import Examples. +Export Examples. + +Definition discriminant_test__Enum_Struct : t_u8 := + 1. + +Definition discriminant_test__Enum_Unit : t_u8 := + 3. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v new file mode 100644 index 000000000..6b18c8c9e --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v @@ -0,0 +1,50 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +Definition first `{v_A : Type} `{v_B : Type} `{t_Sized (v_A)} `{t_Sized (v_B)} `{t_Clone (v_B)} '((value,_) : (v_A*t_i32)) (y : v_B) : v_A := + value. + +Definition foo1 `{v_A : Type} `{v_B : Type} `{t_Sized (v_A)} `{t_Sized (v_B)} (x : v_A) (y : v_B) : unit := + tt. + +Definition foo2 `{v_T : Type} `{t_Sized (v_T)} `{t_Clone (v_T)} (x : t_Slice v_T) (y : t_Array (v_T) (1)) : unit := + tt. + +Definition foo3 '(_ : unit) : unit := + tt. + +Definition test '(_ : unit) : unit := + let x := [1] in + let _ := foo2 (unsize (x)) (x) in + let _ := foo2 (unsize ([1; 2])) (x) in + tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v new file mode 100644 index 000000000..4aa5c8a02 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v @@ -0,0 +1,53 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +Definition test '(_ : unit) : unit := + let _ : bool := false in + let _ : bool := true in + let _ : t_u8 := 12 in + let _ : t_u16 := 123 in + let _ : t_u32 := 1234 in + let _ : t_u64 := 12345 in + let _ : t_u128 := 123456 in + let _ : t_usize := 32 in + let _ : t_i8 := -12 in + let _ : t_i16 := 123 in + let _ : t_i32 := -1234 in + let _ : t_i64 := 12345 in + let _ : t_i128 := 123456 in + let _ : t_isize := -32 in + let _ : float := 1.2%float in + let _ : float := (-1.23)%float in + let _ : ascii := "c"%char in + let _ : string := "hello world"%string in + tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v new file mode 100644 index 000000000..dd8ecb148 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v @@ -0,0 +1,45 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +Definition test '(_ : unit) : unit := + let _ : unit := tt in + let _ : (t_u8*t_u16*t_i8) := (1,2,3) in + let _ : t_u8 := (fst(1,2)) in + let _ : t_u8 := (1) in + let _ : t_u8 := (snd(fst(1,2,3,4,5))) in + let _ : t_Array (t_u8) (0) := [] in + let _ : t_Array (string) (3) := ["23"%string; "a"%string; "hllo"%string] in + let _ : t_Array (t_u8) (14) := repeat (2) (14) in + let _ : t_Slice t_u8 := unsize ([1; 2; 3; 4]) in + let _ : t_Slice string := unsize ([]) in + tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v new file mode 100644 index 000000000..984908e8b --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v @@ -0,0 +1,149 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +From Core Require Import Core. + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. + +Record t_foo (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := + { + foo_f_bar : v_T; + foo_f_baz : t_Array (v_T) (v_N); + foo_f_qux : t_u8; + }. +Arguments Build_t_foo (_) (_) {_}. +Arguments foo_f_bar {_} {_} {_}. +Arguments foo_f_baz {_} {_} {_}. +Arguments foo_f_qux {_} {_} {_}. +#[export] Instance settable_t_foo `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := + settable! (Build_t_foo v_T v_N) . + +Record t_test__Color : Type := + { + test__Color_0 : t_u8; + test__Color_1 : t_u8; + test__Color_2 : t_u8; + }. +Arguments Build_t_test__Color. +Arguments test__Color_0. +Arguments test__Color_1. +Arguments test__Color_2. +#[export] Instance settable_t_test__Color : Settable _ := + settable! (Build_t_test__Color) . +Notation "'test__Color'" := Build_t_test__Color. + +Record t_test__Cookie : Type := + { + }. +Arguments Build_t_test__Cookie. +#[export] +Notation "'test__Cookie'" := Build_t_test__Cookie. + +Record t_test__CookieA : Type := + { + }. +Arguments Build_t_test__CookieA. +#[export] +Notation "'test__CookieA'" := Build_t_test__CookieA. + +Record t_test__Gamma : Type := + { + }. +Arguments Build_t_test__Gamma. +#[export] +Notation "'test__Gamma'" := Build_t_test__Gamma. + +Record t_test__PointA : Type := + { + test__PointA_f_x : t_i32; + test__PointA_f_y : t_i32; + }. +Arguments Build_t_test__PointA. +Arguments test__PointA_f_x. +Arguments test__PointA_f_y. +#[export] Instance settable_t_test__PointA : Settable _ := + settable! (Build_t_test__PointA) . + +Record t_test__PointB : Type := + { + test__PointB_0 : t_i32; + test__PointB_1 : t_i32; + }. +Arguments Build_t_test__PointB. +Arguments test__PointB_0. +Arguments test__PointB_1. +#[export] Instance settable_t_test__PointB : Settable _ := + settable! (Build_t_test__PointB) . +Notation "'test__PointB'" := Build_t_test__PointB. + +Record t_test__Position : Type := + { + test__Position_0 : t_i32; + test__Position_1 : t_i32; + test__Position_2 : t_i32; + }. +Arguments Build_t_test__Position. +Arguments test__Position_0. +Arguments test__Position_1. +Arguments test__Position_2. +#[export] Instance settable_t_test__Position : Settable _ := + settable! (Build_t_test__Position) . +Notation "'test__Position'" := Build_t_test__Position. + +Definition test__Cookie : t_test__Cookie := + Build_t_test__Cookie. + +Definition test '(_ : unit) : unit := + let a := Build_t_test__Gamma in + let b := Build_t_test__Gamma in + let _ := tt in + let _ := Build_t_test__Position (0) (0) (0) in + let c := Build_t_test__Position in + let pos := test__Position (8) (6) (7) in + let _ := tt in + let c1 := Build_t_test__Color (0) (0) (0) in + let c2 := Build_t_test__Color (255) (127) (0) in + let c3 := Build_t_test__Color (0) in + let _ := tt in + let p := Build_t_test__PointA (10) (11) in + let px : t_i32 := test__PointA_f_x p in + let p2 := Build_t_test__PointA (10) (11) in + let p2 := p2 <|test__PointA_f_x := 10 |> in + let p2 := p2 <|test__PointA_f_y := 14 |> in + let _ := tt in + let p := Build_t_test__PointB (10) (11) in + let px : t_i32 := match p with + | Build_t_test__PointB x _ => + x + end in + let _ := tt in + let c := [Build_t_test__CookieA; Build_t_test__CookieA; Build_t_test__CookieA; Build_t_test__CookieA] in + let _ := tt in + let c := [test__Cookie; Build_t_test__Cookie; test__Cookie; Build_t_test__Cookie] in + tt. diff --git a/examples/coverage/proofs/coq/extraction/_CoqProject b/examples/coverage/proofs/coq/extraction/_CoqProject new file mode 100644 index 000000000..636260f7a --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/_CoqProject @@ -0,0 +1,11 @@ +-R ./ Core +-arg -w +-arg all + +./Coverage_Test_closures.v +./Coverage_Test_enum.v +./Coverage_Test_functions.v +./Coverage_Test_primitives.v +./Coverage_Test_sequence.v +./Coverage_Test_struct.v +./Coverage.v diff --git a/examples/coverage/src/lib.rs b/examples/coverage/src/lib.rs new file mode 100644 index 000000000..c0aeec187 --- /dev/null +++ b/examples/coverage/src/lib.rs @@ -0,0 +1,9 @@ +// https://doc.rust-lang.org/reference/types.html +mod test_primitives; +mod test_sequence; + +mod test_struct; +mod test_enum; + +mod test_functions; +mod test_closures; diff --git a/examples/coverage/src/test_closures.rs b/examples/coverage/src/test_closures.rs new file mode 100644 index 000000000..2a618ac81 --- /dev/null +++ b/examples/coverage/src/test_closures.rs @@ -0,0 +1,14 @@ +// TODO: +// fn test() { +// let add : fn(i32, i32) -> i32 = |x, y| x + y; +// let _ = (|x : &u8| { x + x })(&2); + +// fn f u8> (g: F) -> u8 { +// g() + 2 +// } + +// f(|| { +// 23 +// }); +// // Prints "foobar". +// } diff --git a/examples/coverage/src/test_enum.rs b/examples/coverage/src/test_enum.rs new file mode 100644 index 000000000..bef41a8ab --- /dev/null +++ b/examples/coverage/src/test_enum.rs @@ -0,0 +1,52 @@ +enum Foo<'a, T, const N : usize> { + Bar(u8), + Baz, + Qux {x : &'a T, y : [T; N], z : u8}, +} + +fn test() { + { + enum AnimalA { + Dog, + Cat, + } + + let mut a: AnimalA = AnimalA::Dog; + a = AnimalA::Cat; + } + + { + enum AnimalB { + Dog(String, f64), + Cat { name: String, weight: f64 }, + } + + let mut a: AnimalB = AnimalB::Dog("Cocoa".to_string(), 37.2); + a = AnimalB::Cat { name: "Spotty".to_string(), weight: 2.7 }; + } + { + enum Examples { + UnitLike, + TupleLike(i32), + StructLike { value: i32 }, + } + + use Examples::*; // Creates aliases to all variants. + let x = UnitLike; // Path expression of the const item. + let x = UnitLike {}; // Struct expression. + let y = TupleLike(123); // Call expression. + let y = TupleLike { 0: 123 }; // Struct expression using integer field names. + let z = StructLike { value: 123 }; // Struct expression. + } + { + #[repr(u8)] + enum Enum { + Unit = 3, + Tuple(u16), + Struct { + a: u8, + b: u16, + } = 1, + } + } +} diff --git a/examples/coverage/src/test_functions.rs b/examples/coverage/src/test_functions.rs new file mode 100644 index 000000000..e617da666 --- /dev/null +++ b/examples/coverage/src/test_functions.rs @@ -0,0 +1,25 @@ +fn first((value, _): (A, i32), y: B) -> A where B: Clone { value } + +// foo is generic over A and B + +fn foo1(x: A, y: B) { +} + +fn foo2(x: &[T], y: &[T;1]) where T: Clone { + // details elided +} + +fn test() { + let x = [1u8]; + foo2(&x, &x); + foo2(&[1, 2], &x); +} + +extern "Rust" fn foo3() {} + +// async fn regular_example() { } // TODO: Not yet supported + +// Requires std::fmt; +// fn documented() { +// #![doc = "Example"] +// } diff --git a/examples/coverage/src/test_primitives.rs b/examples/coverage/src/test_primitives.rs new file mode 100644 index 000000000..1c7ba2193 --- /dev/null +++ b/examples/coverage/src/test_primitives.rs @@ -0,0 +1,30 @@ +fn test(){ + // bool + let _ : bool = false; + let _ : bool = true; + + // Numerics + let _ : u8 = 12u8; + let _ : u16 = 123u16; + let _ : u32 = 1234u32; + let _ : u64 = 12345u64; + let _ : u128 = 123456u128; + let _ : usize = 32usize; + + let _ : i8 = -12i8; + let _ : i16 = 123i16; + let _ : i32 = -1234i32; + let _ : i64 = 12345i64; + let _ : i128 = 123456i128; + let _ : isize = -32isize; + + let _ : f32 = 1.2f32; + let _ : f64 = -1.23f64; + + // Textual + let _ : char = 'c'; + let _ : &str = "hello world"; + + // Never + // cannot be built +} diff --git a/examples/coverage/src/test_primtives.rs b/examples/coverage/src/test_primtives.rs new file mode 100644 index 000000000..e69de29bb diff --git a/examples/coverage/src/test_sequence.rs b/examples/coverage/src/test_sequence.rs new file mode 100644 index 000000000..24d92270d --- /dev/null +++ b/examples/coverage/src/test_sequence.rs @@ -0,0 +1,17 @@ +fn test() { + // Tuple + let _ : () = (); + let _ : (u8,u16,i8) = (1,2,3); + let _ : u8 = (1,2).0; + let _ : u8 = (1,).0; + let _ : u8 = (1,2,3,4,5).3; + + // Array + let _ : [u8; 0] = []; + let _ : [&str; 3] = ["23","a","hllo"]; + let _ : [u8; 14] = [2; 14]; + + // Slice + let _ : &[u8] = &[1,2,3,4]; + let _ : &[&str] = &[]; +} diff --git a/examples/coverage/src/test_struct.rs b/examples/coverage/src/test_struct.rs new file mode 100644 index 000000000..10b4d2070 --- /dev/null +++ b/examples/coverage/src/test_struct.rs @@ -0,0 +1,55 @@ +struct foo<'a, T, const N : usize> { + bar : &'a T, + baz : [T; N], + qux : u8, +} + +// Point {x: 10.0, y: 20.0}; +// NothingInMe {}; +// TuplePoint(10.0, 20.0); +// TuplePoint { 0: 10.0, 1: 20.0 }; // Results in the same value as the above line +// let u = game::User {name: "Joe", age: 35, score: 100_000}; +// some_fn::(Cookie); + +fn test(){ + { + struct Gamma; + let a = Gamma; // Gamma unit value. + let b = Gamma{}; // Exact same value as `a`. + } + { + struct Position(i32, i32, i32); + Position(0, 0, 0); // Typical way of creating a tuple struct. + let c = Position; // `c` is a function that takes 3 arguments. + let pos = c(8, 6, 7); // Creates a `Position` value. + } + { + struct Color(u8, u8, u8); + let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. + let c2 = Color{0: 255, 1: 127, 2: 0}; // Specifying fields by index. + let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct. + } + { + struct PointA {x: i32, y: i32} + let p = PointA {x: 10, y: 11}; + let px: i32 = p.x; + + let mut p2 = PointA {x: 10, y: 11}; + p2.x = 10; + p2.y = 14; + } + { + struct PointB(i32, i32); + let p = PointB(10, 11); + let px: i32 = match p { PointB(x, _) => x }; + } + { + struct CookieA; + let c = [CookieA, CookieA {}, CookieA, CookieA {}]; + } + { + struct Cookie {} + const Cookie: Cookie = Cookie {}; + let c = [Cookie, Cookie {}, Cookie, Cookie {}]; + } +} diff --git a/examples/coverage/src/test_struct_unit.rs b/examples/coverage/src/test_struct_unit.rs new file mode 100644 index 000000000..86b459a11 --- /dev/null +++ b/examples/coverage/src/test_struct_unit.rs @@ -0,0 +1,13 @@ +struct Gamma; +let a = Gamma; // Gamma unit value. +let b = Gamma{}; // Exact same value as `a`. + +struct Position(i32, i32, i32); +Position(0, 0, 0); // Typical way of creating a tuple struct. +let c = Position; // `c` is a function that takes 3 arguments. +let pos = c(8, 6, 7); // Creates a `Position` value. + +struct Color(u8, u8, u8); +let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. +let c2 = Color{0: 255, 1: 127, 2: 0}; // Specifying fields by index. +let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct. From 316c39d82a4e6a4d7b2694742c8ef7f04e241ce6 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 11 Nov 2024 10:11:14 +0100 Subject: [PATCH 07/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 384 ++++++++++++-------- engine/lib/concrete_ident/concrete_ident.ml | 8 +- engine/texput.log | 21 ++ 3 files changed, 267 insertions(+), 146 deletions(-) create mode 100644 engine/texput.log diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 44160dddf..4b9f83480 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -92,13 +92,9 @@ module CoqNamePolicy = struct (** Transformation applied to indexes fields name (i.e. [x.1]) *) let index_field_transform x = x - let field_name_transform ~struct_name x = - struct_name ^ "_" ^ x - + let field_name_transform ~struct_name x = struct_name ^ "_" ^ x let enum_constructor_name_transform ~enum_name x = x - let struct_constructor_name_transform x : string = - "Build_t_" ^ x - + let struct_constructor_name_transform x : string = "Build_t_" ^ x let constructor_prefix = "" end @@ -140,7 +136,8 @@ let dummy_lib = Definition t_String := string.\n\ Definition ToString_f_to_string (x : string) := x.\n\ Instance Sized_any : forall {t_A}, t_Sized t_A := {}.\n\ - Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}.\n" + Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x \ + => x}.\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -155,8 +152,11 @@ struct let default_string_for s = "TODO: please implement the method `" ^ s ^ "`" let default_document_for = default_string_for >> string - let concat_with ?(pre=empty) ?(post=empty) l = concat_map (fun x -> pre ^^ x ^^ post) l - let concat_map_with ?(pre=empty) ?(post=empty) f l = concat_map (fun x -> pre ^^ f x ^^ post) l + let concat_with ?(pre = empty) ?(post = empty) l = + concat_map (fun x -> pre ^^ x ^^ post) l + + let concat_map_with ?(pre = empty) ?(post = empty) f l = + concat_map (fun x -> pre ^^ f x ^^ post) l let concat_spaced_doc l = concat_map_with ~pre:space (fun x -> x#p) l @@ -184,14 +184,18 @@ struct let lemma = proof_struct (string "Lemma") let arguments name (explicivity : bool list) = - !^"Arguments" ^^ space ^^ name ^^ concat_map_with ~pre:space (function | true -> string "(_)" | false -> string "{_}") explicivity ^^ dot + !^"Arguments" ^^ space ^^ name + ^^ concat_map_with ~pre:space + (function true -> string "(_)" | false -> string "{_}") + explicivity + ^^ dot let notation pattern value = - !^"Notation" ^^ space ^^ string "\"" ^^ pattern ^^ string "\"" ^^ space ^^ !^":=" ^^ space ^^ value ^^ dot + !^"Notation" ^^ space ^^ string "\"" ^^ pattern ^^ string "\"" ^^ space + ^^ !^":=" ^^ space ^^ value ^^ dot let notation_name name value = - notation (string "'" ^^ name ^^ string "'") value - + notation (string "'" ^^ name ^^ string "'") value end type ('get_span_data, 'a) object_type = @@ -241,28 +245,22 @@ struct method expr'_App_application ~super:_ ~f ~args ~generics:_ = f#p ^^ concat_map_with ~pre:space (fun x -> parens x#p) args - method expr'_App_constant ~super:_ ~constant ~generics:_ = - constant#p + method expr'_App_constant ~super:_ ~constant ~generics:_ = constant#p method expr'_App_field_projection ~super:_ ~field ~e = field#p ^^ space ^^ e#p method expr'_App_tuple_projection ~super:_ ~size ~nth ~e = - let size = match e#v.e with - | Construct { - constructor; - is_record; - is_struct; - fields; - base; - } -> - List.length fields + let size = + match e#v.e with + | Construct { constructor; is_record; is_struct; fields; base } -> + List.length fields | _ -> size (* TODO: Size argument incorrect? *) in - List.fold_right ~init:(e#p) - ~f:(fun x y -> parens(x ^^ y)) + List.fold_right ~init:e#p + ~f:(fun x y -> parens (x ^^ y)) ((if Stdlib.(nth != 0) then [ string "snd" ] else []) - @ List.init (size - 1 - nth) ~f:(fun _ -> string "fst")) + @ List.init (size - 1 - nth) ~f:(fun _ -> string "fst")) method expr'_Ascription ~super:_ ~e ~typ = e#p ^^ space ^^ colon ^^ space ^^ typ#p @@ -280,9 +278,7 @@ struct match witness with _ -> . method expr'_Closure ~super:_ ~params ~body ~captures:_ = - !^"fun" - ^^ concat_spaced_doc params - ^^ space ^^ !^"=>" ^^ space + !^"fun" ^^ concat_spaced_doc params ^^ space ^^ !^"=>" ^^ space ^^ nest 2 (break 1 ^^ body#p) method expr'_Construct_inductive ~super:_ ~constructor ~is_record @@ -290,24 +286,29 @@ struct let fields_or_empty add_space = if List.is_empty fields then empty else - add_space - ^^ separate_map space (fun x -> parens((snd x)#p)) fields + add_space ^^ separate_map space (fun x -> parens (snd x)#p) fields in if is_record && is_struct then match base with | Some x -> - (* Update fields *) - x#p ^^ concat_map_with ~pre:space (fun x -> string "<|" ^^ (fst x)#p ^^ space ^^ !^":=" ^^ space ^^ (snd x)#p ^^ space ^^ string "|>") fields - | None -> - constructor#p ^^ fields_or_empty space + (* Update fields *) + x#p + ^^ concat_map_with ~pre:space + (fun x -> + string "<|" ^^ (fst x)#p ^^ space ^^ !^":=" ^^ space + ^^ (snd x)#p ^^ space ^^ string "|>") + fields + | None -> constructor#p ^^ fields_or_empty space else if not is_record then - if is_struct - then constructor#p ^^ fields_or_empty space + if is_struct then constructor#p ^^ fields_or_empty space else constructor#p ^^ fields_or_empty space else - constructor#p ^^ space ^^ string "{|" ^^ space ^^ - separate_map (semi ^^ space) (fun (ident, exp) -> ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) fields - ^^ space ^^ string "|}" + constructor#p ^^ space ^^ string "{|" ^^ space + ^^ separate_map (semi ^^ space) + (fun (ident, exp) -> + ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) + fields + ^^ space ^^ string "|}" method expr'_Construct_tuple ~super:_ ~components = if List.length components == 0 then !^"tt" @@ -355,7 +356,11 @@ struct method expr'_Match ~super:_ ~scrutinee ~arms = string "match" ^^ space ^^ scrutinee#p ^^ space ^^ string "with" ^^ break 1 - ^^ concat_map_with ~pre:(string "|" ^^ space) ~post:(break 1) (fun x -> x#p) arms + ^^ concat_map_with + ~pre:(string "|" ^^ space) + ~post:(break 1) + (fun x -> x#p) + arms ^^ string "end" method expr'_QuestionMark ~super:_ ~e:_ ~return_typ:_ ~witness = @@ -393,9 +398,10 @@ struct method generic_value_GType x1 = parens x1#p method generics ~params ~constraints = - let params_document = concat_map_with ~pre:space (fun x -> string "`" ^^ braces (x#p)) params in - let constraints_document = concat_spaced_doc constraints + let params_document = + concat_map_with ~pre:space (fun x -> string "`" ^^ braces x#p) params in + let constraints_document = concat_spaced_doc constraints in params_document ^^ constraints_document method guard ~guard:_ ~span:_ = default_document_for "guard" @@ -429,23 +435,19 @@ struct method impl_ident ~goal ~name:_ = goal#p method impl_item ~ii_span:_ ~ii_generics:_ ~ii_v ~ii_ident ~ii_attrs:_ = - ii_ident#p ^^ space ^^ string ":=" ^^ space ^^ ii_v#p ^^ semi + string (String.chop_prefix_exn ~prefix:"impl_" (U.Concrete_ident_view.to_definition_name ii_ident#v)) ^^ space ^^ string ":=" ^^ space ^^ ii_v#p ^^ semi method impl_item'_IIFn ~body ~params = if List.length params == 0 then body#p else - string "fun" ^^ space - ^^ concat_spaced_doc params - ^^ string "=>" + string "fun" ^^ space ^^ concat_spaced_doc params ^^ string "=>" ^^ nest 2 (break 1 ^^ body#p) method impl_item'_IIType ~typ ~parent_bounds:_ = typ#p method item ~v ~span:_ ~ident:_ ~attrs:_ = v#p ^^ break 1 method item'_Alias ~super:_ ~name ~item = - CoqNotation.notation_name - (name#p) - (parens item#p) + CoqNotation.notation_name name#p (parens item#p) method item'_Fn ~super ~name ~generics ~body ~params ~safety:_ = (* TODO: Why is type not available here ? *) @@ -459,15 +461,23 @@ struct in let params = - List.map ~f:(fun x -> match x#v with - | { pat = { p = PBinding { - mut; - mode; - var; - typ = _; - subpat; - }; span : span; typ = _ }; typ; typ_span; attrs } -> x#p - | _ -> string "'" ^^ x#p) params + List.map + ~f:(fun x -> + match x#v with + | { + pat = + { + p = PBinding { mut; mode; var; typ = _; subpat }; + span : span; + typ = _; + }; + typ; + typ_span; + attrs; + } -> + x#p + | _ -> string "'" ^^ x#p) + params in let get_expr_of kind f : document option = @@ -484,8 +494,7 @@ struct in let is_lemma = Attrs.lemma super.attrs in if is_lemma then - CoqNotation.lemma name#p generics#p - params + CoqNotation.lemma name#p generics#p params (Option.value ~default:empty requires ^^ space ^^ !^"->" ^^ break 1 ^^ Option.value ~default:empty ensures) @@ -517,7 +526,10 @@ struct (name#p ^^ concat_map_with ~pre:space (fun x -> parens x#p) args) (braces (nest 2 - (concat_map_with ~pre:(break 1 ^^ name#p ^^ !^"_") (fun x -> x#p) items) + (concat_map_with + ~pre:(break 1 ^^ string (String.drop_prefix (U.Concrete_ident_view.to_definition_name name#v) 2) ^^ !^"_") + (fun x -> x#p) + items) ^^ break 1)) method item'_NotImplementedYet = string "(* NotImplementedYet *)" @@ -527,26 +539,41 @@ struct method item'_Trait ~super:_ ~name ~generics ~items ~safety:_ = let _, params, constraints = generics#v in - CoqNotation.class_ name#p generics#p [] !^"Type" + CoqNotation.class_ name#p (concat_map_with ~pre:space + (fun x -> parens x#p) + params + ^^ concat_map_with ~pre:space + (fun x -> x#p) + constraints) [] !^"Type" (braces - (nest 2 (concat_map_with ~pre:(break 1) (fun x -> x#p) items) ^^ break 1)) + (nest 2 (concat_map_with ~pre:(break 1) (fun x -> x#p) items) + ^^ break 1)) ^^ break 1 - ^^ CoqNotation.arguments name#p (List.map ~f:(fun _ -> true) params @ List.map ~f:(fun _ -> false) constraints) + ^^ CoqNotation.arguments name#p + (List.map ~f:(fun _ -> true) params + @ List.map ~f:(fun _ -> false) constraints) method item'_TyAlias ~super:_ ~name ~generics:_ ~ty = - CoqNotation.notation_name - (name#p) - ty#p + CoqNotation.notation_name name#p ty#p - method item'_Type_struct ~super:_ ~name ~generics ~tuple_struct - ~arguments = + method item'_Type_struct ~super:_ ~name ~generics ~tuple_struct ~arguments + = let arguments_explicity_with_ty = - (List.map ~f:(fun _ -> true) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) + List.map ~f:(fun _ -> true) generics#v.params + @ List.map ~f:(fun _ -> false) generics#v.constraints in let arguments_explicity_without_ty = - (List.map ~f:(fun _ -> false) generics#v.params @ List.map ~f:(fun _ -> false) generics#v.constraints) + List.map ~f:(fun _ -> false) generics#v.params + @ List.map ~f:(fun _ -> false) generics#v.constraints in - CoqNotation.record name#p ((concat_map_with ~pre:space (fun x -> parens( self#entrypoint_generic_param x )) generics#v.params) ^^ (concat_map_with ~pre:space (fun x -> self#entrypoint_generic_constraint x ) generics#v.constraints)) [] (string "Type") + CoqNotation.record name#p + (concat_map_with ~pre:space + (fun x -> parens (self#entrypoint_generic_param x)) + generics#v.params + ^^ concat_map_with ~pre:space + (fun x -> self#entrypoint_generic_constraint x) + generics#v.constraints) + [] (string "Type") (braces (nest 2 (concat_map @@ -555,62 +582,112 @@ struct ^^ semi) arguments) ^^ break 1)) - ^^ break 1 ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) arguments_explicity_with_ty - ^^ concat_map_with ~pre:(break 1) (fun (ident, typ, attr) -> CoqNotation.arguments ident#p arguments_explicity_without_ty) arguments + ^^ break 1 + ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) + arguments_explicity_with_ty + ^^ concat_map_with ~pre:(break 1) + (fun (ident, typ, attr) -> + CoqNotation.arguments ident#p arguments_explicity_without_ty) + arguments ^^ break 1 ^^ !^"#[export]" ^^ space + ^^ (if List.is_empty arguments then empty + else + CoqNotation.instance + (string "settable" ^^ string "_" ^^ name#p) + generics#p [] + (!^"Settable" ^^ space ^^ !^"_") + (string "settable!" ^^ space + ^^ parens + (!^"Build_" ^^ name#p + ^^ concat_map_with ~pre:space + (fun (x : generic_param) -> + match x with + | { ident; _ } -> + (self#_do_not_override_lazy_of_local_ident + AstPos_item'_Type_generics ident) + #p) + generics#v.params) + ^^ space ^^ string "<" + ^^ separate_map (semi ^^ space) + (fun (ident, typ, attr) -> ident#p) + arguments + ^^ string ">")) ^^ - (if List.is_empty arguments - then empty - else - CoqNotation.instance - (string "settable" ^^ string "_" ^^ name#p) - generics#p [] - (!^"Settable" ^^ space ^^ !^"_") - (string "settable!" ^^ space - ^^ parens (!^"Build_" ^^ name#p ^^ (concat_map_with ~pre:space (fun (x : generic_param) -> match x with | { ident; _ } -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics ident)#p) generics#v.params)) - ^^ space ^^ string "<" - ^^ separate_map (semi ^^ space) - (fun (ident, typ, attr) -> ident#p) - arguments - ^^ string ">")) - ^^ - (if tuple_struct - then break 1 ^^ - (CoqNotation.notation_name (string (String.drop_prefix (U.Concrete_ident_view.to_definition_name name#v) 2 )) (!^"Build_" ^^ name#p)) - else empty) + if tuple_struct then + break 1 + ^^ CoqNotation.notation_name + (string + (String.drop_prefix + (U.Concrete_ident_view.to_definition_name name#v) + 2)) + (!^"Build_" ^^ name#p) + else empty (* map_def_path_item_string (fun x -> x) x#v.name *) method item'_Type_enum ~super ~name ~generics ~variants = - concat_map_with ~post:(break 1) (fun x -> - (self#item'_Type_struct ~super ~name:( - self#_do_not_override_lazy_of_concrete_ident - AstPos_variant__arguments ( - Concrete_ident.Create.map_last ~f:(fun x -> x ^ "_record") x#v.name - )) ~generics ~tuple_struct:false ~arguments:(List.map - ~f:(fun (ident, typ, attrs) -> - ( self#_do_not_override_lazy_of_concrete_ident - AstPos_variant__arguments ident, - self#_do_not_override_lazy_of_ty AstPos_variant__arguments - typ, - self#_do_not_override_lazy_of_attrs AstPos_variant__attrs - attrs )) - x#v.arguments)) - ) (List.filter ~f:(fun x -> x#v.is_record) variants) ^^ - CoqNotation.inductive name#p generics#p [] (string "Type") - (separate_map (break 1) - (fun x -> string "|" ^^ space ^^ x#p ^^ - (if x#v.is_record - then - (concat_map_with ~pre:space (fun (x : generic_param) -> (self#_do_not_override_lazy_of_local_ident AstPos_item'_Type_generics x.ident)#p) generics#v.params) ^^ space ^^ !^"->" ^^ space ^^ !^"_" - else empty)) - variants) - (* ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon *) - (* ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space *) - (* ^^ name#p *) - (* ^^ concat_map (fun _ -> space ^^ !^"(_)") generics#v.params *) - (* ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints *) - (* ^^ dot *) + let arguments_explicity_without_ty = + List.map ~f:(fun _ -> false) generics#v.params + @ List.map ~f:(fun _ -> false) generics#v.constraints + in + + concat_map_with ~post:(break 1) + (fun x -> + self#item'_Type_struct ~super + ~name: + (self#_do_not_override_lazy_of_concrete_ident + AstPos_variant__arguments + (Concrete_ident.Create.map_last + ~f:(fun x -> x ^ "_record") + x#v.name)) + ~generics ~tuple_struct:false + ~arguments: + (List.map + ~f:(fun (ident, typ, attrs) -> + ( self#_do_not_override_lazy_of_concrete_ident + AstPos_variant__arguments ident, + self#_do_not_override_lazy_of_ty + AstPos_variant__arguments typ, + self#_do_not_override_lazy_of_attrs AstPos_variant__attrs + attrs )) + x#v.arguments)) + (List.filter ~f:(fun x -> x#v.is_record) variants) + ^^ CoqNotation.inductive name#p + (concat_map_with ~pre:space + (fun x -> parens (self#entrypoint_generic_param x)) + generics#v.params + ^^ concat_map_with ~pre:space + (fun x -> self#entrypoint_generic_constraint x) + generics#v.constraints) + [] (string "Type") + (separate_map (break 1) + (fun x -> + string "|" ^^ space ^^ x#p + ^^ + if x#v.is_record then + concat_map_with ~pre:space + (fun (x : generic_param) -> + (self#_do_not_override_lazy_of_local_ident + AstPos_item'_Type_generics x.ident) + #p) + generics#v.params + ^^ space ^^ !^"->" ^^ space ^^ !^"_" + else empty) + variants) + ^^ concat_map_with ~pre:(break 1) + (fun v -> + CoqNotation.arguments + (self#_do_not_override_lazy_of_concrete_ident + AstPos_variant__arguments v#v.name) + #p + arguments_explicity_without_ty) + variants + (* ^^ break 1 ^^ !^"Arguments" ^^ space ^^ name#p ^^ colon *) + (* ^^ !^"clear implicits" ^^ dot ^^ break 1 ^^ !^"Arguments" ^^ space *) + (* ^^ name#p *) + (* ^^ concat_map (fun _ -> space ^^ !^"(_)") generics#v.params *) + (* ^^ concat_map (fun _ -> space ^^ !^"{_}") generics#v.constraints *) + (* ^^ dot *) method item'_Use ~super:_ ~path ~is_external ~rename:_ = if List.length path == 0 || is_external then empty @@ -666,9 +743,7 @@ struct string "\"" ^^ string (Char.escaped x1) ^^ string "\"" ^^ string "%char" method literal_Float ~value ~negative ~kind:_ = - (if negative - then parens(!^"-" ^^ string value) - else string value) + (if negative then parens (!^"-" ^^ string value) else string value) ^^ string "%float" method literal_Int ~value ~negative ~kind:_ = @@ -707,22 +782,23 @@ struct method pat'_PConstruct_inductive ~super:_ ~constructor ~is_record ~is_struct ~fields = - if is_record - then + if is_record then constructor#p ^^ space ^^ parens (separate_map (comma ^^ space) (fun field_pat -> (snd field_pat)#p) fields) - else - if is_record - then + else if is_record then (* constructor#p ^^ *) - string "{|" ^^ - separate_map (semi ^^ space) (fun (ident, exp) -> ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) fields + string "{|" + ^^ separate_map (semi ^^ space) + (fun (ident, exp) -> + ident#p ^^ space ^^ string ":=" ^^ space ^^ parens exp#p) + fields ^^ string "|}" else - constructor#p ^^ concat_map_with ~pre:space (fun (ident, exp) -> exp#p) fields + constructor#p + ^^ concat_map_with ~pre:space (fun (ident, exp) -> exp#p) fields method pat'_PConstruct_tuple ~super:_ ~components = (* TODO: Only add `'` if you are a top-level pattern *) @@ -851,16 +927,16 @@ struct (* (fun (ident, typ, attr) -> *) (* ident#p ^^ space ^^ colon ^^ space ^^ typ#p) *) (* arguments *) - else - if List.length arguments == 0 then name#p + else if List.length arguments == 0 then name#p else name#p ^^ space ^^ colon ^^ space ^^ separate_map - (space ^^ string "->" ^^ space) - (fun (ident, typ, attr) -> typ#p) - arguments + (space ^^ string "->" ^^ space) + (fun (ident, typ, attr) -> typ#p) + arguments ^^ space ^^ string "->" ^^ space ^^ string "_" + method quote (quote : quote) : document = empty method module_path_separator = "." method concrete_ident ~local:_ id : document = @@ -899,7 +975,7 @@ let make (module M : Attrs.WITH_ITEMS) = let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = let my_printer = make m in - U.group_items_by_namespace items + (U.group_items_by_namespace items |> Map.to_alist |> List.map ~f:(fun (ns, items) -> let mod_name = @@ -917,7 +993,31 @@ let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = in let sourcemap = Some sourcemap in let path = mod_name ^ ".v" in - Types.{ path; contents; sourcemap }) + Types.{ path; contents; sourcemap })) + @ [ + Types. + { + path = "_CoqProject"; + contents = + "-R ./ " ^ "TODO" ^ "\n-arg -w\n-arg all\n\n" + ^ String.concat ~sep:"\n" + (List.rev + (U.group_items_by_namespace items + |> Map.to_alist + |> List.map ~f:(fun (ns, items) -> + let mod_name = + String.concat ~sep:"_" + (List.map + ~f:(map_first_letter String.uppercase) + (fst ns :: snd ns)) + in + let contents, _annotations = + my_printer#entrypoint_modul items + in + mod_name ^ ".v"))); + sourcemap = None; + }; + ] open Phase_utils diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index ced38d163..b5a5fc67e 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -244,7 +244,7 @@ module View = struct let string_of_def_path_item : Imported.def_path_item -> string option = function | TypeNs s | ValueNs s | MacroNs s | LifetimeNs s -> Some s - | Impl -> Some "impl" + | Impl -> Some "impl" | AnonConst -> Some "anon_const" | _ -> None @@ -473,8 +473,8 @@ module MakeViewAPI (NP : NAME_POLICY) : VIEW_API = struct else escape name | Constructor { is_struct } -> let name = - if start_lowercase name || is_reserved_word name - then NP.constructor_prefix ^ name + if start_lowercase name || is_reserved_word name then + NP.constructor_prefix ^ name else escape name in if is_struct then NP.struct_constructor_name_transform name @@ -482,7 +482,7 @@ module MakeViewAPI (NP : NAME_POLICY) : VIEW_API = struct let enum_name = type_name |> Option.value_exn in NP.enum_constructor_name_transform ~enum_name name | Field | AssociatedItem _ -> - let struct_name = type_name |> Option.value_exn in + let struct_name = type_name |> Option.value_exn in NP.field_name_transform ~struct_name (match Stdlib.int_of_string_opt name with | Some _ -> NP.index_field_transform name diff --git a/engine/texput.log b/engine/texput.log new file mode 100644 index 000000000..66c945ef2 --- /dev/null +++ b/engine/texput.log @@ -0,0 +1,21 @@ +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex 2024.10.7) 31 OCT 2024 13:56 +entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. +** + +! Emergency stop. +<*> + +End of file on the terminal! + + +Here is how much of TeX's memory you used: + 3 strings out of 474222 + 116 string characters out of 5748733 + 1922975 words of memory out of 5000000 + 22359 multiletter control sequences out of 15000+600000 + 558069 words of font info for 36 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 0i,0n,0p,1b,6s stack positions out of 10000i,1000n,20000p,200000b,200000s +! ==> Fatal error occurred, no output PDF file produced! From 5aa766f3dc475cb19e3d12a94ce642c3cbd8b3cc Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 11 Nov 2024 10:12:09 +0100 Subject: [PATCH 08/35] CI for coq coverage --- .github/workflows/extract_and_run_coq.yml | 29 ++++++++++ engine/backends/coq/coq/coq_backend.ml | 29 ++++++---- engine/lib/concrete_ident/concrete_ident.ml | 16 ++++- engine/lib/concrete_ident/concrete_ident.mli | 3 + examples/Cargo.lock | 4 ++ examples/Cargo.toml | 3 +- .../coverage/proofs/coq/extraction/Coverage.v | 9 ++- .../coq/extraction/Coverage_Test_closures.v | 44 -------------- .../coq/extraction/Coverage_Test_enum.v | 56 ++++++++++++------ .../coq/extraction/Coverage_Test_enum_Test.v | 10 ++-- .../coq/extraction/Coverage_Test_functions.v | 7 ++- .../coq/extraction/Coverage_Test_instance.v | 58 +++++++++++++++++++ .../coq/extraction/Coverage_Test_primitives.v | 7 ++- .../coq/extraction/Coverage_Test_sequence.v | 7 ++- .../coq/extraction/Coverage_Test_struct.v | 7 ++- .../proofs/coq/extraction/_CoqProject | 11 ---- examples/coverage/src/lib.rs | 2 + examples/coverage/src/test_enum.rs | 28 +++++---- examples/coverage/src/test_instance.rs | 21 +++++++ 19 files changed, 237 insertions(+), 114 deletions(-) create mode 100644 .github/workflows/extract_and_run_coq.yml delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v create mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v delete mode 100644 examples/coverage/proofs/coq/extraction/_CoqProject create mode 100644 examples/coverage/src/test_instance.rs diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml new file mode 100644 index 000000000..34f96b605 --- /dev/null +++ b/.github/workflows/extract_and_run_coq.yml @@ -0,0 +1,29 @@ +name: Extract and Run - Coq + +on: [pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + path: hax + + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: ⤵ Install hax + run: | + nix profile install --verbose ./hax + + - name: build coverage example + working-directory: hax/examples/coverage + run: | + nix run . into coq + + - name: run coq + working-directory: hax/examples/coverage/proofs/coq/extraction + run: | + sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v + nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" + nix-shell --packages coq coqPackages.coq-record-update --run "make" diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 4b9f83480..956d44aa3 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -116,7 +116,7 @@ let hardcoded_coq_headers = Require Import Coq.Floats.Floats.\n\ From RecordUpdate Require Import RecordSet.\n\ Import RecordSetNotations.\n\n\ - From Core Require Import Core.\n" + (* From Core Require Import Core. *)\n" let dummy_lib = "Class t_Sized (T : Type) := { }.\n\ @@ -136,8 +136,11 @@ let dummy_lib = Definition t_String := string.\n\ Definition ToString_f_to_string (x : string) := x.\n\ Instance Sized_any : forall {t_A}, t_Sized t_A := {}.\n\ - Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x \ - => x}.\n" + Class t_Clone (T : Type) := { Clone_f_clone : T -> T }.\n\ + Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x \ + => x}.\n\ + Definition t_Slice (T : Type) := list T.\n\ + Definition unsize {T : Type} : list T -> t_Slice T := id.\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -435,7 +438,7 @@ struct method impl_ident ~goal ~name:_ = goal#p method impl_item ~ii_span:_ ~ii_generics:_ ~ii_v ~ii_ident ~ii_attrs:_ = - string (String.chop_prefix_exn ~prefix:"impl_" (U.Concrete_ident_view.to_definition_name ii_ident#v)) ^^ space ^^ string ":=" ^^ space ^^ ii_v#p ^^ semi + ii_ident#p ^^ space ^^ string ":=" ^^ space ^^ ii_v#p ^^ semi method impl_item'_IIFn ~body ~params = if List.length params == 0 then body#p @@ -527,7 +530,13 @@ struct (braces (nest 2 (concat_map_with - ~pre:(break 1 ^^ string (String.drop_prefix (U.Concrete_ident_view.to_definition_name name#v) 2) ^^ !^"_") + ~pre: + (break 1 + ^^ string + (String.drop_prefix + (U.Concrete_ident_view.to_definition_name name#v) + 2) + ^^ !^"_") (fun x -> x#p) items) ^^ break 1)) @@ -539,12 +548,10 @@ struct method item'_Trait ~super:_ ~name ~generics ~items ~safety:_ = let _, params, constraints = generics#v in - CoqNotation.class_ name#p (concat_map_with ~pre:space - (fun x -> parens x#p) - params - ^^ concat_map_with ~pre:space - (fun x -> x#p) - constraints) [] !^"Type" + CoqNotation.class_ name#p + (concat_map_with ~pre:space (fun x -> parens x#p) params + ^^ concat_map_with ~pre:space (fun x -> x#p) constraints) + [] !^"Type" (braces (nest 2 (concat_map_with ~pre:(break 1) (fun x -> x#p) items) ^^ break 1)) diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index b5a5fc67e..ddf13d62e 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -244,7 +244,7 @@ module View = struct let string_of_def_path_item : Imported.def_path_item -> string option = function | TypeNs s | ValueNs s | MacroNs s | LifetimeNs s -> Some s - | Impl -> Some "impl" + | Impl -> Some "impl" | AnonConst -> Some "anon_const" | _ -> None @@ -560,6 +560,8 @@ let to_debug_string = T.show let map_path_strings ~(f : string -> string) (cid : t) : t = { cid with def_id = Imported.map_path_strings ~f cid.def_id } +let parent (cid : t) : t = { cid with def_id = Imported.parent cid.def_id } + module DefaultNamePolicy = struct let reserved_words = Hash_set.create (module String) let index_field_transform = Fn.id @@ -649,3 +651,15 @@ let parent_impl (id : t) : t option = module DefaultViewAPI = MakeViewAPI (DefaultNamePolicy) include DefaultViewAPI + +let remove_impl old = + let new_parent = (parent (parent old)).def_id in + { + kind = Macro; + (* Field; *) + def_id = + { + new_parent with + path = new_parent.path @ [ List.last_exn old.def_id.path ]; + }; + } diff --git a/engine/lib/concrete_ident/concrete_ident.mli b/engine/lib/concrete_ident/concrete_ident.mli index e87f71b22..5fcd7dae2 100644 --- a/engine/lib/concrete_ident/concrete_ident.mli +++ b/engine/lib/concrete_ident/concrete_ident.mli @@ -74,3 +74,6 @@ identifier points to an [Impl] block. *) val parent_impl : t -> t option (** Returns the identifier pointing to the parent `impl` block, if it exists. *) + +val remove_impl : t -> t +(** Returns the parent *) diff --git a/examples/Cargo.lock b/examples/Cargo.lock index af90ddc48..668d60c74 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -151,6 +151,10 @@ dependencies = [ "hax-lib", ] +[[package]] +name = "coverage" +version = "0.1.0" + [[package]] name = "cpufeatures" version = "0.2.11" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 9b7eceb41..4aea4b684 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -6,7 +6,8 @@ members = [ "barrett", "kyber_compress", "proverif-psk", - "coq-example"] + "coq-example", + "coverage"] resolver = "2" [workspace.dependencies] diff --git a/examples/coverage/proofs/coq/extraction/Coverage.v b/examples/coverage/proofs/coq/extraction/Coverage.v index 73677f973..b3041e007 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage.v +++ b/examples/coverage/proofs/coq/extraction/Coverage.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,7 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. @@ -46,3 +49,5 @@ Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x (* NotImplementedYet *) (* NotImplementedYet *) + +(* NotImplementedYet *) diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v deleted file mode 100644 index a085ed82d..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_closures.v +++ /dev/null @@ -1,44 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -From Core Require Import Core. - -(* Class t_Sized (T : Type) := { }. *) -(* Definition t_u8 := Z. *) -(* Definition t_u16 := Z. *) -(* Definition t_u32 := Z. *) -(* Definition t_u64 := Z. *) -(* Definition t_u128 := Z. *) -(* Definition t_usize := Z. *) -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. - -(* Definition test__f `{v_F : Type} `{t_Sized (v_F)} `{t_FnOnce (v_F) (unit)} `{_.(t_FnOnce_f_Output) = t_u8} (g : v_F) : t_u8 := *) -(* t_Add_f_add (t_Add := _) (t_FnOnce_f_call_once (t_FnOnce := _) (g) (tt)) (Build_t_u8 (Build_t_U8 2)). *) - -(* Definition test '(_ : unit) : unit := *) -(* let add : t_i32 -> t_i32 -> t_i32 := fun x y => *) -(* t_Add_f_add (x) (y) in *) -(* let _ := Fn_f_call (fun x => *) -(* Add_f_add (x) (x)) ((2)) in *) -(* let _ := test__f (fun _ => *) -(* 23) in *) -(* tt. *) diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v index d32fd0595..619874948 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,28 +29,16 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. - -Record Foo_Qux_record (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := - { - Qux_f_x : v_T; - Qux_f_y : t_Array (v_T) (v_N); - Qux_f_z : t_u8; - }. -Arguments Build_Foo_Qux_record (_) (_) {_}. -Arguments Qux_f_x {_} {_} {_}. -Arguments Qux_f_y {_} {_} {_}. -Arguments Qux_f_z {_} {_} {_}. -#[export] Instance settable_Foo_Qux_record `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := - settable! (Build_Foo_Qux_record v_T v_N) . -Inductive t_Foo `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Type := -| Foo_Bar : t_u8 -> _ -| Foo_Baz -| Foo_Qux : Foo_Qux_record v_T v_N -> _. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Inductive t_test__AnimalA : Type := | test__AnimalA_Dog | test__AnimalA_Cat. +Arguments test__AnimalA_Dog. +Arguments test__AnimalA_Cat. Definition t_test__AnimalA_cast_to_repr (x : t_test__AnimalA) : t_isize := match x with @@ -73,6 +61,8 @@ Arguments Cat_f_weight. Inductive t_test__AnimalB : Type := | test__AnimalB_Dog : t_String -> float -> _ | test__AnimalB_Cat : test__AnimalB_Cat_record -> _. +Arguments test__AnimalB_Dog. +Arguments test__AnimalB_Cat. Record test__Enum_Struct_record : Type := { @@ -88,6 +78,9 @@ Inductive t_test__Enum : Type := | test__Enum_Unit | test__Enum_Tuple : t_u16 -> _ | test__Enum_Struct : test__Enum_Struct_record -> _. +Arguments test__Enum_Unit. +Arguments test__Enum_Tuple. +Arguments test__Enum_Struct. Record test__Examples_StructLike_record : Type := { @@ -101,8 +94,33 @@ Inductive t_test__Examples : Type := | test__Examples_UnitLike | test__Examples_TupleLike : t_i32 -> _ | test__Examples_StructLike : test__Examples_StructLike_record -> _. +Arguments test__Examples_UnitLike. +Arguments test__Examples_TupleLike. +Arguments test__Examples_StructLike. + +Record test__Foo_Qux_record (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := + { + Qux_f_x : v_T; + Qux_f_y : t_Array (v_T) (v_N); + Qux_f_z : t_u8; + }. +Arguments Build_test__Foo_Qux_record (_) (_) {_}. +Arguments Qux_f_x {_} {_} {_}. +Arguments Qux_f_y {_} {_} {_}. +Arguments Qux_f_z {_} {_} {_}. +#[export] Instance settable_test__Foo_Qux_record `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := + settable! (Build_test__Foo_Qux_record v_T v_N) . +Inductive t_test__Foo (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := +| test__Foo_Bar : t_u8 -> _ +| test__Foo_Baz +| test__Foo_Qux : test__Foo_Qux_record v_T v_N -> _. +Arguments test__Foo_Bar {_} {_} {_}. +Arguments test__Foo_Baz {_} {_} {_}. +Arguments test__Foo_Qux {_} {_} {_}. Definition test '(_ : unit) : unit := + let x : t_test__Foo ((t_u8)) (12) := test__Foo_Baz in + let _ := tt in let a : t_test__AnimalA := test__AnimalA_Dog in let a := test__AnimalA_Cat in let _ := tt in diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v index d2c30d4c9..946d186d1 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,10 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. - -From Coverage Require Import Examples. -Export Examples. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Definition discriminant_test__Enum_Struct : t_u8 := 1. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v index 6b18c8c9e..01103b49c 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,7 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Definition first `{v_A : Type} `{v_B : Type} `{t_Sized (v_A)} `{t_Sized (v_B)} `{t_Clone (v_B)} '((value,_) : (v_A*t_i32)) (y : v_B) : v_A := value. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v new file mode 100644 index 000000000..723497058 --- /dev/null +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v @@ -0,0 +1,58 @@ +(* File automatically generated by Hacspec *) +From Coq Require Import ZArith. +Require Import List. +Import List.ListNotations. +Open Scope Z_scope. +Open Scope bool_scope. +Require Import Ascii. +Require Import String. +Require Import Coq.Floats.Floats. +From RecordUpdate Require Import RecordSet. +Import RecordSetNotations. + +(* From Core Require Import Core. *) + +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. + +Inductive t_SomeEnum (v_T : Type) `{t_Sized (v_T)} : Type := +| SomeEnum_None +| SomeEnum_Some : v_T -> _. +Arguments SomeEnum_None {_} {_}. +Arguments SomeEnum_Some {_} {_}. + +Class t_SomeTrait (v_Self : Type) : Type := + { + SomeTrait_f_some_fun : v_Self -> v_Self; + }. +Arguments t_SomeTrait (_). + +Instance t_SomeTrait_153652929 `{v_T : Type} `{t_Sized (v_T)} `{t_SomeTrait (v_T)} : t_SomeTrait ((t_SomeEnum ((v_T)))) := + { + SomeTrait_impl_f_some_fun := fun (self : t_SomeEnum ((v_T)))=> + match self with + | SomeEnum_Some x => + SomeEnum_Some (SomeTrait_f_some_fun (x)) + | SomeEnum_None => + SomeEnum_None + end; + }. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v index 4aa5c8a02..f0ce9d790 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,7 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Definition test '(_ : unit) : unit := let _ : bool := false in diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v index dd8ecb148..f660f5434 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,7 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Definition test '(_ : unit) : unit := let _ : unit := tt in diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v index 984908e8b..e57490a49 100644 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v +++ b/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v @@ -10,7 +10,7 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. -From Core Require Import Core. +(* From Core Require Import Core. *) Class t_Sized (T : Type) := { }. Definition t_u8 := Z. @@ -29,7 +29,10 @@ Definition t_Array T (x : t_usize) := list T. Definition t_String := string. Definition ToString_f_to_string (x : string) := x. Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Instance Clone_any : forall {t_A}, t_Clone t_A := {t_Clone_f_clone := fun x => x}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. Record t_foo (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := { diff --git a/examples/coverage/proofs/coq/extraction/_CoqProject b/examples/coverage/proofs/coq/extraction/_CoqProject deleted file mode 100644 index 636260f7a..000000000 --- a/examples/coverage/proofs/coq/extraction/_CoqProject +++ /dev/null @@ -1,11 +0,0 @@ --R ./ Core --arg -w --arg all - -./Coverage_Test_closures.v -./Coverage_Test_enum.v -./Coverage_Test_functions.v -./Coverage_Test_primitives.v -./Coverage_Test_sequence.v -./Coverage_Test_struct.v -./Coverage.v diff --git a/examples/coverage/src/lib.rs b/examples/coverage/src/lib.rs index c0aeec187..2ce2b500b 100644 --- a/examples/coverage/src/lib.rs +++ b/examples/coverage/src/lib.rs @@ -7,3 +7,5 @@ mod test_enum; mod test_functions; mod test_closures; + +mod test_instance; diff --git a/examples/coverage/src/test_enum.rs b/examples/coverage/src/test_enum.rs index bef41a8ab..9e2b63ff0 100644 --- a/examples/coverage/src/test_enum.rs +++ b/examples/coverage/src/test_enum.rs @@ -1,10 +1,14 @@ -enum Foo<'a, T, const N : usize> { - Bar(u8), - Baz, - Qux {x : &'a T, y : [T; N], z : u8}, -} - fn test() { + { + enum Foo<'a, T, const N : usize> { + Bar(u8), + Baz, + Qux {x : &'a T, y : [T; N], z : u8}, + } + + let x : Foo = Foo::Baz; + } + { enum AnimalA { Dog, @@ -31,12 +35,12 @@ fn test() { StructLike { value: i32 }, } - use Examples::*; // Creates aliases to all variants. - let x = UnitLike; // Path expression of the const item. - let x = UnitLike {}; // Struct expression. - let y = TupleLike(123); // Call expression. - let y = TupleLike { 0: 123 }; // Struct expression using integer field names. - let z = StructLike { value: 123 }; // Struct expression. + // use Examples::*; // Creates aliases to all variants. + let x = Examples::UnitLike; // Path expression of the const item. + let x = Examples::UnitLike {}; // Struct expression. + let y = Examples::TupleLike(123); // Call expression. + let y = Examples::TupleLike { 0: 123 }; // Struct expression using integer field names. + let z = Examples::StructLike { value: 123 }; // Struct expression. } { #[repr(u8)] diff --git a/examples/coverage/src/test_instance.rs b/examples/coverage/src/test_instance.rs new file mode 100644 index 000000000..bee6c8ff8 --- /dev/null +++ b/examples/coverage/src/test_instance.rs @@ -0,0 +1,21 @@ +enum SomeEnum { + None, + Some(T), +} + +trait SomeTrait { + fn some_fun(&self) -> Self; +} + +impl SomeTrait for SomeEnum +where + T: SomeTrait, +{ + #[inline] + fn some_fun(&self) -> Self { + match self { + SomeEnum::Some(x) => SomeEnum::Some(x.some_fun()), + SomeEnum::None => SomeEnum::None, + } + } +} From dc95eea5cc4fa49e34fdfc03d98fcf4048db7e81 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Sun, 17 Nov 2024 21:05:43 +0100 Subject: [PATCH 09/35] fmt --- engine/lib/concrete_ident/concrete_ident.ml | 12 -- engine/lib/concrete_ident/concrete_ident.mli | 3 - engine/texput.log | 21 --- .../coverage/proofs/coq/extraction/Coverage.v | 53 ------ .../coq/extraction/Coverage_Test_enum.v | 136 ---------------- .../coq/extraction/Coverage_Test_enum_Test.v | 41 ----- .../coq/extraction/Coverage_Test_functions.v | 53 ------ .../coq/extraction/Coverage_Test_instance.v | 58 ------- .../coq/extraction/Coverage_Test_primitives.v | 56 ------- .../coq/extraction/Coverage_Test_sequence.v | 48 ------ .../coq/extraction/Coverage_Test_struct.v | 152 ------------------ examples/coverage/src/lib.rs | 4 +- examples/coverage/src/test_closures.rs | 2 +- examples/coverage/src/test_enum.rs | 16 +- examples/coverage/src/test_functions.rs | 15 +- examples/coverage/src/test_primitives.rs | 38 ++--- examples/coverage/src/test_sequence.rs | 20 +-- examples/coverage/src/test_struct.rs | 43 +++-- 18 files changed, 77 insertions(+), 694 deletions(-) delete mode 100644 engine/texput.log delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v delete mode 100644 examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index ddf13d62e..7175de961 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -651,15 +651,3 @@ let parent_impl (id : t) : t option = module DefaultViewAPI = MakeViewAPI (DefaultNamePolicy) include DefaultViewAPI - -let remove_impl old = - let new_parent = (parent (parent old)).def_id in - { - kind = Macro; - (* Field; *) - def_id = - { - new_parent with - path = new_parent.path @ [ List.last_exn old.def_id.path ]; - }; - } diff --git a/engine/lib/concrete_ident/concrete_ident.mli b/engine/lib/concrete_ident/concrete_ident.mli index 5fcd7dae2..e87f71b22 100644 --- a/engine/lib/concrete_ident/concrete_ident.mli +++ b/engine/lib/concrete_ident/concrete_ident.mli @@ -74,6 +74,3 @@ identifier points to an [Impl] block. *) val parent_impl : t -> t option (** Returns the identifier pointing to the parent `impl` block, if it exists. *) - -val remove_impl : t -> t -(** Returns the parent *) diff --git a/engine/texput.log b/engine/texput.log deleted file mode 100644 index 66c945ef2..000000000 --- a/engine/texput.log +++ /dev/null @@ -1,21 +0,0 @@ -This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex 2024.10.7) 31 OCT 2024 13:56 -entering extended mode - restricted \write18 enabled. - %&-line parsing enabled. -** - -! Emergency stop. -<*> - -End of file on the terminal! - - -Here is how much of TeX's memory you used: - 3 strings out of 474222 - 116 string characters out of 5748733 - 1922975 words of memory out of 5000000 - 22359 multiletter control sequences out of 15000+600000 - 558069 words of font info for 36 fonts, out of 8000000 for 9000 - 1141 hyphenation exceptions out of 8191 - 0i,0n,0p,1b,6s stack positions out of 10000i,1000n,20000p,200000b,200000s -! ==> Fatal error occurred, no output PDF file produced! diff --git a/examples/coverage/proofs/coq/extraction/Coverage.v b/examples/coverage/proofs/coq/extraction/Coverage.v deleted file mode 100644 index b3041e007..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage.v +++ /dev/null @@ -1,53 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - - - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) - -(* NotImplementedYet *) diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v deleted file mode 100644 index 619874948..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum.v +++ /dev/null @@ -1,136 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Inductive t_test__AnimalA : Type := -| test__AnimalA_Dog -| test__AnimalA_Cat. -Arguments test__AnimalA_Dog. -Arguments test__AnimalA_Cat. - -Definition t_test__AnimalA_cast_to_repr (x : t_test__AnimalA) : t_isize := - match x with - | test__AnimalA_Dog => - 0 - | test__AnimalA_Cat => - 1 - end. - -Record test__AnimalB_Cat_record : Type := - { - Cat_f_name : t_String; - Cat_f_weight : float; - }. -Arguments Build_test__AnimalB_Cat_record. -Arguments Cat_f_name. -Arguments Cat_f_weight. -#[export] Instance settable_test__AnimalB_Cat_record : Settable _ := - settable! (Build_test__AnimalB_Cat_record) . -Inductive t_test__AnimalB : Type := -| test__AnimalB_Dog : t_String -> float -> _ -| test__AnimalB_Cat : test__AnimalB_Cat_record -> _. -Arguments test__AnimalB_Dog. -Arguments test__AnimalB_Cat. - -Record test__Enum_Struct_record : Type := - { - Struct_f_a : t_u8; - Struct_f_b : t_u16; - }. -Arguments Build_test__Enum_Struct_record. -Arguments Struct_f_a. -Arguments Struct_f_b. -#[export] Instance settable_test__Enum_Struct_record : Settable _ := - settable! (Build_test__Enum_Struct_record) . -Inductive t_test__Enum : Type := -| test__Enum_Unit -| test__Enum_Tuple : t_u16 -> _ -| test__Enum_Struct : test__Enum_Struct_record -> _. -Arguments test__Enum_Unit. -Arguments test__Enum_Tuple. -Arguments test__Enum_Struct. - -Record test__Examples_StructLike_record : Type := - { - StructLike_f_value : t_i32; - }. -Arguments Build_test__Examples_StructLike_record. -Arguments StructLike_f_value. -#[export] Instance settable_test__Examples_StructLike_record : Settable _ := - settable! (Build_test__Examples_StructLike_record) . -Inductive t_test__Examples : Type := -| test__Examples_UnitLike -| test__Examples_TupleLike : t_i32 -> _ -| test__Examples_StructLike : test__Examples_StructLike_record -> _. -Arguments test__Examples_UnitLike. -Arguments test__Examples_TupleLike. -Arguments test__Examples_StructLike. - -Record test__Foo_Qux_record (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := - { - Qux_f_x : v_T; - Qux_f_y : t_Array (v_T) (v_N); - Qux_f_z : t_u8; - }. -Arguments Build_test__Foo_Qux_record (_) (_) {_}. -Arguments Qux_f_x {_} {_} {_}. -Arguments Qux_f_y {_} {_} {_}. -Arguments Qux_f_z {_} {_} {_}. -#[export] Instance settable_test__Foo_Qux_record `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := - settable! (Build_test__Foo_Qux_record v_T v_N) . -Inductive t_test__Foo (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := -| test__Foo_Bar : t_u8 -> _ -| test__Foo_Baz -| test__Foo_Qux : test__Foo_Qux_record v_T v_N -> _. -Arguments test__Foo_Bar {_} {_} {_}. -Arguments test__Foo_Baz {_} {_} {_}. -Arguments test__Foo_Qux {_} {_} {_}. - -Definition test '(_ : unit) : unit := - let x : t_test__Foo ((t_u8)) (12) := test__Foo_Baz in - let _ := tt in - let a : t_test__AnimalA := test__AnimalA_Dog in - let a := test__AnimalA_Cat in - let _ := tt in - let a : t_test__AnimalB := test__AnimalB_Dog (ToString_f_to_string ("Cocoa"%string)) (37.2%float) in - let a := test__AnimalB_Cat {| Cat_f_name := (ToString_f_to_string ("Spotty"%string)); Cat_f_weight := (2.7%float) |} in - let _ := tt in - let x := test__Examples_UnitLike in - let x := test__Examples_UnitLike in - let y := test__Examples_TupleLike (123) in - let y := test__Examples_TupleLike (123) in - let z := test__Examples_StructLike {| StructLike_f_value := (123) |} in - let _ := tt in - tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v deleted file mode 100644 index 946d186d1..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_enum_Test.v +++ /dev/null @@ -1,41 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Definition discriminant_test__Enum_Struct : t_u8 := - 1. - -Definition discriminant_test__Enum_Unit : t_u8 := - 3. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v deleted file mode 100644 index 01103b49c..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_functions.v +++ /dev/null @@ -1,53 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Definition first `{v_A : Type} `{v_B : Type} `{t_Sized (v_A)} `{t_Sized (v_B)} `{t_Clone (v_B)} '((value,_) : (v_A*t_i32)) (y : v_B) : v_A := - value. - -Definition foo1 `{v_A : Type} `{v_B : Type} `{t_Sized (v_A)} `{t_Sized (v_B)} (x : v_A) (y : v_B) : unit := - tt. - -Definition foo2 `{v_T : Type} `{t_Sized (v_T)} `{t_Clone (v_T)} (x : t_Slice v_T) (y : t_Array (v_T) (1)) : unit := - tt. - -Definition foo3 '(_ : unit) : unit := - tt. - -Definition test '(_ : unit) : unit := - let x := [1] in - let _ := foo2 (unsize (x)) (x) in - let _ := foo2 (unsize ([1; 2])) (x) in - tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v deleted file mode 100644 index 723497058..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_instance.v +++ /dev/null @@ -1,58 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Inductive t_SomeEnum (v_T : Type) `{t_Sized (v_T)} : Type := -| SomeEnum_None -| SomeEnum_Some : v_T -> _. -Arguments SomeEnum_None {_} {_}. -Arguments SomeEnum_Some {_} {_}. - -Class t_SomeTrait (v_Self : Type) : Type := - { - SomeTrait_f_some_fun : v_Self -> v_Self; - }. -Arguments t_SomeTrait (_). - -Instance t_SomeTrait_153652929 `{v_T : Type} `{t_Sized (v_T)} `{t_SomeTrait (v_T)} : t_SomeTrait ((t_SomeEnum ((v_T)))) := - { - SomeTrait_impl_f_some_fun := fun (self : t_SomeEnum ((v_T)))=> - match self with - | SomeEnum_Some x => - SomeEnum_Some (SomeTrait_f_some_fun (x)) - | SomeEnum_None => - SomeEnum_None - end; - }. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v deleted file mode 100644 index f0ce9d790..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_primitives.v +++ /dev/null @@ -1,56 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Definition test '(_ : unit) : unit := - let _ : bool := false in - let _ : bool := true in - let _ : t_u8 := 12 in - let _ : t_u16 := 123 in - let _ : t_u32 := 1234 in - let _ : t_u64 := 12345 in - let _ : t_u128 := 123456 in - let _ : t_usize := 32 in - let _ : t_i8 := -12 in - let _ : t_i16 := 123 in - let _ : t_i32 := -1234 in - let _ : t_i64 := 12345 in - let _ : t_i128 := 123456 in - let _ : t_isize := -32 in - let _ : float := 1.2%float in - let _ : float := (-1.23)%float in - let _ : ascii := "c"%char in - let _ : string := "hello world"%string in - tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v deleted file mode 100644 index f660f5434..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_sequence.v +++ /dev/null @@ -1,48 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Definition test '(_ : unit) : unit := - let _ : unit := tt in - let _ : (t_u8*t_u16*t_i8) := (1,2,3) in - let _ : t_u8 := (fst(1,2)) in - let _ : t_u8 := (1) in - let _ : t_u8 := (snd(fst(1,2,3,4,5))) in - let _ : t_Array (t_u8) (0) := [] in - let _ : t_Array (string) (3) := ["23"%string; "a"%string; "hllo"%string] in - let _ : t_Array (t_u8) (14) := repeat (2) (14) in - let _ : t_Slice t_u8 := unsize ([1; 2; 3; 4]) in - let _ : t_Slice string := unsize ([]) in - tt. diff --git a/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v b/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v deleted file mode 100644 index e57490a49..000000000 --- a/examples/coverage/proofs/coq/extraction/Coverage_Test_struct.v +++ /dev/null @@ -1,152 +0,0 @@ -(* File automatically generated by Hacspec *) -From Coq Require Import ZArith. -Require Import List. -Import List.ListNotations. -Open Scope Z_scope. -Open Scope bool_scope. -Require Import Ascii. -Require Import String. -Require Import Coq.Floats.Floats. -From RecordUpdate Require Import RecordSet. -Import RecordSetNotations. - -(* From Core Require Import Core. *) - -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. - -Record t_foo (v_T : Type) (v_N : t_usize) `{t_Sized (v_T)} : Type := - { - foo_f_bar : v_T; - foo_f_baz : t_Array (v_T) (v_N); - foo_f_qux : t_u8; - }. -Arguments Build_t_foo (_) (_) {_}. -Arguments foo_f_bar {_} {_} {_}. -Arguments foo_f_baz {_} {_} {_}. -Arguments foo_f_qux {_} {_} {_}. -#[export] Instance settable_t_foo `{v_T : Type} `{v_N : t_usize} `{t_Sized (v_T)} : Settable _ := - settable! (Build_t_foo v_T v_N) . - -Record t_test__Color : Type := - { - test__Color_0 : t_u8; - test__Color_1 : t_u8; - test__Color_2 : t_u8; - }. -Arguments Build_t_test__Color. -Arguments test__Color_0. -Arguments test__Color_1. -Arguments test__Color_2. -#[export] Instance settable_t_test__Color : Settable _ := - settable! (Build_t_test__Color) . -Notation "'test__Color'" := Build_t_test__Color. - -Record t_test__Cookie : Type := - { - }. -Arguments Build_t_test__Cookie. -#[export] -Notation "'test__Cookie'" := Build_t_test__Cookie. - -Record t_test__CookieA : Type := - { - }. -Arguments Build_t_test__CookieA. -#[export] -Notation "'test__CookieA'" := Build_t_test__CookieA. - -Record t_test__Gamma : Type := - { - }. -Arguments Build_t_test__Gamma. -#[export] -Notation "'test__Gamma'" := Build_t_test__Gamma. - -Record t_test__PointA : Type := - { - test__PointA_f_x : t_i32; - test__PointA_f_y : t_i32; - }. -Arguments Build_t_test__PointA. -Arguments test__PointA_f_x. -Arguments test__PointA_f_y. -#[export] Instance settable_t_test__PointA : Settable _ := - settable! (Build_t_test__PointA) . - -Record t_test__PointB : Type := - { - test__PointB_0 : t_i32; - test__PointB_1 : t_i32; - }. -Arguments Build_t_test__PointB. -Arguments test__PointB_0. -Arguments test__PointB_1. -#[export] Instance settable_t_test__PointB : Settable _ := - settable! (Build_t_test__PointB) . -Notation "'test__PointB'" := Build_t_test__PointB. - -Record t_test__Position : Type := - { - test__Position_0 : t_i32; - test__Position_1 : t_i32; - test__Position_2 : t_i32; - }. -Arguments Build_t_test__Position. -Arguments test__Position_0. -Arguments test__Position_1. -Arguments test__Position_2. -#[export] Instance settable_t_test__Position : Settable _ := - settable! (Build_t_test__Position) . -Notation "'test__Position'" := Build_t_test__Position. - -Definition test__Cookie : t_test__Cookie := - Build_t_test__Cookie. - -Definition test '(_ : unit) : unit := - let a := Build_t_test__Gamma in - let b := Build_t_test__Gamma in - let _ := tt in - let _ := Build_t_test__Position (0) (0) (0) in - let c := Build_t_test__Position in - let pos := test__Position (8) (6) (7) in - let _ := tt in - let c1 := Build_t_test__Color (0) (0) (0) in - let c2 := Build_t_test__Color (255) (127) (0) in - let c3 := Build_t_test__Color (0) in - let _ := tt in - let p := Build_t_test__PointA (10) (11) in - let px : t_i32 := test__PointA_f_x p in - let p2 := Build_t_test__PointA (10) (11) in - let p2 := p2 <|test__PointA_f_x := 10 |> in - let p2 := p2 <|test__PointA_f_y := 14 |> in - let _ := tt in - let p := Build_t_test__PointB (10) (11) in - let px : t_i32 := match p with - | Build_t_test__PointB x _ => - x - end in - let _ := tt in - let c := [Build_t_test__CookieA; Build_t_test__CookieA; Build_t_test__CookieA; Build_t_test__CookieA] in - let _ := tt in - let c := [test__Cookie; Build_t_test__Cookie; test__Cookie; Build_t_test__Cookie] in - tt. diff --git a/examples/coverage/src/lib.rs b/examples/coverage/src/lib.rs index 2ce2b500b..f1fbe110d 100644 --- a/examples/coverage/src/lib.rs +++ b/examples/coverage/src/lib.rs @@ -2,10 +2,10 @@ mod test_primitives; mod test_sequence; -mod test_struct; mod test_enum; +mod test_struct; -mod test_functions; mod test_closures; +mod test_functions; mod test_instance; diff --git a/examples/coverage/src/test_closures.rs b/examples/coverage/src/test_closures.rs index 2a618ac81..f761be221 100644 --- a/examples/coverage/src/test_closures.rs +++ b/examples/coverage/src/test_closures.rs @@ -1,4 +1,4 @@ -// TODO: +// TODO: // fn test() { // let add : fn(i32, i32) -> i32 = |x, y| x + y; // let _ = (|x : &u8| { x + x })(&2); diff --git a/examples/coverage/src/test_enum.rs b/examples/coverage/src/test_enum.rs index 9e2b63ff0..27c18b69f 100644 --- a/examples/coverage/src/test_enum.rs +++ b/examples/coverage/src/test_enum.rs @@ -1,12 +1,12 @@ fn test() { { - enum Foo<'a, T, const N : usize> { + enum Foo<'a, T, const N: usize> { Bar(u8), Baz, - Qux {x : &'a T, y : [T; N], z : u8}, + Qux { x: &'a T, y: [T; N], z: u8 }, } - let x : Foo = Foo::Baz; + let x: Foo = Foo::Baz; } { @@ -26,7 +26,10 @@ fn test() { } let mut a: AnimalB = AnimalB::Dog("Cocoa".to_string(), 37.2); - a = AnimalB::Cat { name: "Spotty".to_string(), weight: 2.7 }; + a = AnimalB::Cat { + name: "Spotty".to_string(), + weight: 2.7, + }; } { enum Examples { @@ -47,10 +50,7 @@ fn test() { enum Enum { Unit = 3, Tuple(u16), - Struct { - a: u8, - b: u16, - } = 1, + Struct { a: u8, b: u16 } = 1, } } } diff --git a/examples/coverage/src/test_functions.rs b/examples/coverage/src/test_functions.rs index e617da666..7db88a867 100644 --- a/examples/coverage/src/test_functions.rs +++ b/examples/coverage/src/test_functions.rs @@ -1,11 +1,18 @@ -fn first((value, _): (A, i32), y: B) -> A where B: Clone { value } +fn first((value, _): (A, i32), y: B) -> A +where + B: Clone, +{ + value +} // foo is generic over A and B -fn foo1(x: A, y: B) { -} +fn foo1(x: A, y: B) {} -fn foo2(x: &[T], y: &[T;1]) where T: Clone { +fn foo2(x: &[T], y: &[T; 1]) +where + T: Clone, +{ // details elided } diff --git a/examples/coverage/src/test_primitives.rs b/examples/coverage/src/test_primitives.rs index 1c7ba2193..27eafae70 100644 --- a/examples/coverage/src/test_primitives.rs +++ b/examples/coverage/src/test_primitives.rs @@ -1,29 +1,29 @@ -fn test(){ +fn test() { // bool - let _ : bool = false; - let _ : bool = true; + let _: bool = false; + let _: bool = true; // Numerics - let _ : u8 = 12u8; - let _ : u16 = 123u16; - let _ : u32 = 1234u32; - let _ : u64 = 12345u64; - let _ : u128 = 123456u128; - let _ : usize = 32usize; + let _: u8 = 12u8; + let _: u16 = 123u16; + let _: u32 = 1234u32; + let _: u64 = 12345u64; + let _: u128 = 123456u128; + let _: usize = 32usize; - let _ : i8 = -12i8; - let _ : i16 = 123i16; - let _ : i32 = -1234i32; - let _ : i64 = 12345i64; - let _ : i128 = 123456i128; - let _ : isize = -32isize; + let _: i8 = -12i8; + let _: i16 = 123i16; + let _: i32 = -1234i32; + let _: i64 = 12345i64; + let _: i128 = 123456i128; + let _: isize = -32isize; - let _ : f32 = 1.2f32; - let _ : f64 = -1.23f64; + let _: f32 = 1.2f32; + let _: f64 = -1.23f64; // Textual - let _ : char = 'c'; - let _ : &str = "hello world"; + let _: char = 'c'; + let _: &str = "hello world"; // Never // cannot be built diff --git a/examples/coverage/src/test_sequence.rs b/examples/coverage/src/test_sequence.rs index 24d92270d..d1539ecae 100644 --- a/examples/coverage/src/test_sequence.rs +++ b/examples/coverage/src/test_sequence.rs @@ -1,17 +1,17 @@ fn test() { // Tuple - let _ : () = (); - let _ : (u8,u16,i8) = (1,2,3); - let _ : u8 = (1,2).0; - let _ : u8 = (1,).0; - let _ : u8 = (1,2,3,4,5).3; + let _: () = (); + let _: (u8, u16, i8) = (1, 2, 3); + let _: u8 = (1, 2).0; + let _: u8 = (1,).0; + let _: u8 = (1, 2, 3, 4, 5).3; // Array - let _ : [u8; 0] = []; - let _ : [&str; 3] = ["23","a","hllo"]; - let _ : [u8; 14] = [2; 14]; + let _: [u8; 0] = []; + let _: [&str; 3] = ["23", "a", "hllo"]; + let _: [u8; 14] = [2; 14]; // Slice - let _ : &[u8] = &[1,2,3,4]; - let _ : &[&str] = &[]; + let _: &[u8] = &[1, 2, 3, 4]; + let _: &[&str] = &[]; } diff --git a/examples/coverage/src/test_struct.rs b/examples/coverage/src/test_struct.rs index 10b4d2070..a3ba8c7db 100644 --- a/examples/coverage/src/test_struct.rs +++ b/examples/coverage/src/test_struct.rs @@ -1,7 +1,7 @@ -struct foo<'a, T, const N : usize> { - bar : &'a T, - baz : [T; N], - qux : u8, +struct foo<'a, T, const N: usize> { + bar: &'a T, + baz: [T; N], + qux: u8, } // Point {x: 10.0, y: 20.0}; @@ -11,37 +11,46 @@ struct foo<'a, T, const N : usize> { // let u = game::User {name: "Joe", age: 35, score: 100_000}; // some_fn::(Cookie); -fn test(){ +fn test() { { struct Gamma; - let a = Gamma; // Gamma unit value. - let b = Gamma{}; // Exact same value as `a`. + let a = Gamma; // Gamma unit value. + let b = Gamma {}; // Exact same value as `a`. } { struct Position(i32, i32, i32); - Position(0, 0, 0); // Typical way of creating a tuple struct. - let c = Position; // `c` is a function that takes 3 arguments. - let pos = c(8, 6, 7); // Creates a `Position` value. + Position(0, 0, 0); // Typical way of creating a tuple struct. + let c = Position; // `c` is a function that takes 3 arguments. + let pos = c(8, 6, 7); // Creates a `Position` value. } { struct Color(u8, u8, u8); - let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. - let c2 = Color{0: 255, 1: 127, 2: 0}; // Specifying fields by index. - let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct. + let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. + let c2 = Color { + 0: 255, + 1: 127, + 2: 0, + }; // Specifying fields by index. + let c3 = Color { 1: 0, ..c2 }; // Fill out all other fields using a base struct. } { - struct PointA {x: i32, y: i32} - let p = PointA {x: 10, y: 11}; + struct PointA { + x: i32, + y: i32, + } + let p = PointA { x: 10, y: 11 }; let px: i32 = p.x; - let mut p2 = PointA {x: 10, y: 11}; + let mut p2 = PointA { x: 10, y: 11 }; p2.x = 10; p2.y = 14; } { struct PointB(i32, i32); let p = PointB(10, 11); - let px: i32 = match p { PointB(x, _) => x }; + let px: i32 = match p { + PointB(x, _) => x, + }; } { struct CookieA; From 1f124aba5eb7f60e0e88140c2d27c5ed59f67fac Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Sun, 17 Nov 2024 21:21:53 +0100 Subject: [PATCH 10/35] Remove unused file --- examples/coverage/src/test_struct_unit.rs | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 examples/coverage/src/test_struct_unit.rs diff --git a/examples/coverage/src/test_struct_unit.rs b/examples/coverage/src/test_struct_unit.rs deleted file mode 100644 index 86b459a11..000000000 --- a/examples/coverage/src/test_struct_unit.rs +++ /dev/null @@ -1,13 +0,0 @@ -struct Gamma; -let a = Gamma; // Gamma unit value. -let b = Gamma{}; // Exact same value as `a`. - -struct Position(i32, i32, i32); -Position(0, 0, 0); // Typical way of creating a tuple struct. -let c = Position; // `c` is a function that takes 3 arguments. -let pos = c(8, 6, 7); // Creates a `Position` value. - -struct Color(u8, u8, u8); -let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. -let c2 = Color{0: 255, 1: 127, 2: 0}; // Specifying fields by index. -let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct. From 52106f03b8d8dbd2c80ebe8517e0a71224848024 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Sun, 17 Nov 2024 21:38:36 +0100 Subject: [PATCH 11/35] random fmt bug? --- examples/coverage/src/test_primitives.rs | 2 +- examples/coverage/src/test_primtives.rs | 0 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 examples/coverage/src/test_primtives.rs diff --git a/examples/coverage/src/test_primitives.rs b/examples/coverage/src/test_primitives.rs index 27eafae70..6980f480b 100644 --- a/examples/coverage/src/test_primitives.rs +++ b/examples/coverage/src/test_primitives.rs @@ -1,4 +1,4 @@ -fn test() { +fn test_primtives() { // bool let _: bool = false; let _: bool = true; diff --git a/examples/coverage/src/test_primtives.rs b/examples/coverage/src/test_primtives.rs deleted file mode 100644 index e69de29bb..000000000 From a134f1a9d7f73b39a83fd7cd75821dc3a839b7d9 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 19 Nov 2024 11:38:06 +0100 Subject: [PATCH 12/35] Update snapshot --- .github/workflows/extract_and_run_coq.yml | 2 +- engine/backends/coq/coq/coq_backend.ml | 8 ++- engine/lib/concrete_ident/concrete_ident.ml | 2 - .../snapshots/toolchain__assert into-coq.snap | 33 +++++++++- .../toolchain__enum-repr into-coq.snap | 39 ++++++++++- .../snapshots/toolchain__guards into-coq.snap | 31 +++++++++ .../toolchain__include-flag into-coq.snap | 64 +++++++++++++------ .../toolchain__let-else into-coq.snap | 31 +++++++++ .../toolchain__literals into-coq.snap | 48 +++++++++++--- .../toolchain__pattern-or into-coq.snap | 35 +++++++++- .../toolchain__reordering into-coq.snap | 49 +++++++++++--- .../snapshots/toolchain__slices into-coq.snap | 35 +++++++++- .../toolchain__traits into-fstar.snap | 12 ++-- 13 files changed, 333 insertions(+), 56 deletions(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 34f96b605..c4d1c3f61 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -24,6 +24,6 @@ jobs: - name: run coq working-directory: hax/examples/coverage/proofs/coq/extraction run: | - sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v + sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" nix-shell --packages coq coqPackages.coq-record-update --run "make" diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 956d44aa3..3b74ad932 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -119,7 +119,8 @@ let hardcoded_coq_headers = (* From Core Require Import Core. *)\n" let dummy_lib = - "Class t_Sized (T : Type) := { }.\n\ + "(* TODO: Replace this dummy lib with core lib *)\n\ + Class t_Sized (T : Type) := { }.\n\ Definition t_u8 := Z.\n\ Definition t_u16 := Z.\n\ Definition t_u32 := Z.\n\ @@ -140,7 +141,8 @@ let dummy_lib = Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x \ => x}.\n\ Definition t_Slice (T : Type) := list T.\n\ - Definition unsize {T : Type} : list T -> t_Slice T := id.\n" + Definition unsize {T : Type} : list T -> t_Slice T := id.\n\ + (* / dummy lib *)\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -805,7 +807,7 @@ struct ^^ string "|}" else constructor#p - ^^ concat_map_with ~pre:space (fun (ident, exp) -> exp#p) fields + ^^ concat_map_with ~pre:space (fun (ident, exp) -> parens(exp#p)) fields method pat'_PConstruct_tuple ~super:_ ~components = (* TODO: Only add `'` if you are a top-level pattern *) diff --git a/engine/lib/concrete_ident/concrete_ident.ml b/engine/lib/concrete_ident/concrete_ident.ml index 7175de961..0a2b4918f 100644 --- a/engine/lib/concrete_ident/concrete_ident.ml +++ b/engine/lib/concrete_ident/concrete_ident.ml @@ -560,8 +560,6 @@ let to_debug_string = T.show let map_path_strings ~(f : string -> string) (cid : t) : t = { cid with def_id = Imported.map_path_strings ~f cid.def_id } -let parent (cid : t) : t = { cid with def_id = Imported.parent cid.def_id } - module DefaultNamePolicy = struct let reserved_words = Hash_set.create (module String) let index_field_transform = Fn.id diff --git a/test-harness/src/snapshots/toolchain__assert into-coq.snap b/test-harness/src/snapshots/toolchain__assert into-coq.snap index a000cc9f9..af900c615 100644 --- a/test-harness/src/snapshots/toolchain__assert into-coq.snap +++ b/test-harness/src/snapshots/toolchain__assert into-coq.snap @@ -39,11 +39,36 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) (* NotImplementedYet *) -Definition asserts (_ : unit) : unit := +Definition asserts '(_ : unit) : unit := let _ := assert (true) in let _ := assert (t_PartialEq_f_eq (1) (1)) in let _ := match (2,2) with @@ -56,3 +81,9 @@ Definition asserts (_ : unit) : unit := end in tt. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Assert.v''' diff --git a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap index bfe3bcc0a..70175a2e1 100644 --- a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap +++ b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap @@ -40,6 +40,31 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) Definition discriminant_EnumWithRepr_ExplicitDiscr1 : t_u16 := @@ -53,8 +78,10 @@ Inductive t_EnumWithRepr : Type := | EnumWithRepr_ExplicitDiscr2 | EnumWithRepr_ImplicitDiscrEmptyTuple | EnumWithRepr_ImplicitDiscrEmptyStruct. -Arguments t_EnumWithRepr:clear implicits. -Arguments t_EnumWithRepr. +Arguments EnumWithRepr_ExplicitDiscr1. +Arguments EnumWithRepr_ExplicitDiscr2. +Arguments EnumWithRepr_ImplicitDiscrEmptyTuple. +Arguments EnumWithRepr_ImplicitDiscrEmptyStruct. Definition t_EnumWithRepr_cast_to_repr (x : t_EnumWithRepr) : t_u16 := match x with @@ -70,7 +97,7 @@ Definition t_EnumWithRepr_cast_to_repr (x : t_EnumWithRepr) : t_u16 := (* NotImplementedYet *) -Definition f (_ : unit) : t_u32 := +Definition f '(_ : unit) : t_u32 := let v__x := cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) (0)) in t_Add_f_add (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyTuple))) (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyStruct))). @@ -83,3 +110,9 @@ Definition get_casted_repr (x : t_EnumWithRepr) : t_u64 := Definition get_repr (x : t_EnumWithRepr) : t_u16 := t_EnumWithRepr_cast_to_repr (x). ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Enum_repr.v''' diff --git a/test-harness/src/snapshots/toolchain__guards into-coq.snap b/test-harness/src/snapshots/toolchain__guards into-coq.snap index abd2a3274..413f93f0a 100644 --- a/test-harness/src/snapshots/toolchain__guards into-coq.snap +++ b/test-harness/src/snapshots/toolchain__guards into-coq.snap @@ -39,6 +39,31 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) (* NotImplementedYet *) @@ -160,3 +185,9 @@ Definition multiple_guards (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i end end. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Guards.v''' diff --git a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap index c86f3b275..36eb83d65 100644 --- a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap +++ b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap @@ -39,21 +39,43 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) Record t_Foo : Type := { }. -Arguments t_Foo:clear implicits. -Arguments t_Foo. Arguments Build_t_Foo. -#[export] Instance settable_t_Foo : Settable _ := - settable! (@Build_t_Foo) <>. +#[export] +Notation "'Foo'" := Build_t_Foo. -Class t_Trait `{v_Self : Type} : Type := +Class t_Trait (v_Self : Type) : Type := { }. -Arguments t_Trait:clear implicits. Arguments t_Trait (_). Instance t_Trait_254780795 : t_Trait ((t_Foo)) := @@ -62,13 +84,13 @@ Instance t_Trait_254780795 : t_Trait ((t_Foo)) := (* NotImplementedYet *) -Definition main_a_a (_ : unit) : unit := +Definition main_a_a '(_ : unit) : unit := tt. -Definition main_a_b (_ : unit) : unit := +Definition main_a_b '(_ : unit) : unit := tt. -Definition main_a_c (_ : unit) : unit := +Definition main_a_c '(_ : unit) : unit := tt. Definition main_a `{v_T : Type} `{t_Sized (v_T)} `{t_Trait (v_T)} (x : v_T) : unit := @@ -77,39 +99,45 @@ Definition main_a `{v_T : Type} `{t_Sized (v_T)} `{t_Trait (v_T)} (x : v_T) : un let _ := main_a_c (tt) in tt. -Definition main_b_a (_ : unit) : unit := +Definition main_b_a '(_ : unit) : unit := tt. -Definition main_b_b (_ : unit) : unit := +Definition main_b_b '(_ : unit) : unit := tt. -Definition main_b_c (_ : unit) : unit := +Definition main_b_c '(_ : unit) : unit := tt. -Definition main_b (_ : unit) : unit := +Definition main_b '(_ : unit) : unit := let _ := main_b_a (tt) in let _ := main_b_b (tt) in let _ := main_b_c (tt) in tt. -Definition main_c_a (_ : unit) : unit := +Definition main_c_a '(_ : unit) : unit := tt. -Definition main_c_b (_ : unit) : unit := +Definition main_c_b '(_ : unit) : unit := tt. -Definition main_c_c (_ : unit) : unit := +Definition main_c_c '(_ : unit) : unit := tt. -Definition main_c (_ : unit) : unit := +Definition main_c '(_ : unit) : unit := let _ := main_c_a (tt) in let _ := main_c_b (tt) in let _ := main_c_c (tt) in tt. -Definition main (_ : unit) : unit := +Definition main '(_ : unit) : unit := let _ := main_a (Build_t_Foo) in let _ := main_b (tt) in let _ := main_c (tt) in tt. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Include_flag.v''' diff --git a/test-harness/src/snapshots/toolchain__let-else into-coq.snap b/test-harness/src/snapshots/toolchain__let-else into-coq.snap index 330c601b3..30e5da462 100644 --- a/test-harness/src/snapshots/toolchain__let-else into-coq.snap +++ b/test-harness/src/snapshots/toolchain__let-else into-coq.snap @@ -39,6 +39,31 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) (* NotImplementedYet *) @@ -60,3 +85,9 @@ Definition let_else_different_type (opt : t_Option ((t_u32))) : bool := end in ControlFlow_Continue (let_else (hoist1))). ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Let_else.v''' diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index 4375f38c0..2636d280d 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -40,6 +40,31 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) From Literals Require Import Hax_lib (t_int). @@ -49,11 +74,10 @@ Record t_Foo : Type := { Foo_f_field : t_u8; }. -Arguments t_Foo:clear implicits. -Arguments t_Foo. Arguments Build_t_Foo. +Arguments Foo_f_field. #[export] Instance settable_t_Foo : Settable _ := - settable! (@Build_t_Foo) . + settable! (Build_t_Foo) . (* NotImplementedYet *) @@ -71,7 +95,7 @@ Definition casts (x8 : t_u8) (x16 : t_u16) (x32 : t_u32) (x64 : t_u64) (xs : t_u let _ : t_i8 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in tt. -Definition fn_pointer_cast (_ : unit) : unit := +Definition fn_pointer_cast '(_ : unit) : unit := let f : t_u32 -> t_u32 := fun x => x in tt. @@ -103,7 +127,7 @@ Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___un Definition null : ascii := "\000"%char. -Definition numeric (_ : unit) : unit := +Definition numeric '(_ : unit) : unit := let _ : t_usize := 123 in let _ : t_isize := -42 in let _ : t_isize := 42 in @@ -111,7 +135,7 @@ Definition numeric (_ : unit) : unit := let _ : t_u128 := 22222222222222222222 in tt. -Definition patterns (_ : unit) : unit := +Definition patterns '(_ : unit) : unit := let _ := match 1 with | 2 => tt @@ -125,17 +149,23 @@ Definition patterns (_ : unit) : unit := tt end in let _ := match Build_t_Foo (4) with - | Foo (3) => + | Build_t_Foo (3) => tt | _ => tt end in tt. -Definition panic_with_msg (_ : unit) : unit := +Definition panic_with_msg '(_ : unit) : unit := never_to_any (panic_fmt (impl_2__new_const (["with msg"%string]))). -Definition empty_array (_ : unit) : unit := +Definition empty_array '(_ : unit) : unit := let _ : t_Slice t_u8 := unsize ([]) in tt. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Literals.v''' diff --git a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap index f4b3cbfe0..8524dbe3d 100644 --- a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap +++ b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap @@ -40,13 +40,38 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) Inductive t_E : Type := | E_A | E_B. -Arguments t_E:clear implicits. -Arguments t_E. +Arguments E_A. +Arguments E_B. Definition t_E_cast_to_repr (x : t_E) : t_isize := match x with @@ -109,3 +134,9 @@ Definition nested (x : t_Option ((t_i32))) : t_i32 := 0 end. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Pattern_or.v''' diff --git a/test-harness/src/snapshots/toolchain__reordering into-coq.snap b/test-harness/src/snapshots/toolchain__reordering into-coq.snap index aafff19ec..1b7f108d8 100644 --- a/test-harness/src/snapshots/toolchain__reordering into-coq.snap +++ b/test-harness/src/snapshots/toolchain__reordering into-coq.snap @@ -39,23 +39,48 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) Inductive t_Foo : Type := | Foo_A | Foo_B. -Arguments t_Foo:clear implicits. -Arguments t_Foo. +Arguments Foo_A. +Arguments Foo_B. Record t_Bar : Type := { Bar_0 : t_Foo; }. -Arguments t_Bar:clear implicits. -Arguments t_Bar. Arguments Build_t_Bar. +Arguments Bar_0. #[export] Instance settable_t_Bar : Settable _ := - settable! (@Build_t_Bar) . + settable! (Build_t_Bar) . +Notation "'Bar'" := Build_t_Bar. Definition t_Foo_cast_to_repr (x : t_Foo) : t_isize := match x with @@ -67,15 +92,21 @@ Definition t_Foo_cast_to_repr (x : t_Foo) : t_isize := (* NotImplementedYet *) -Definition f (_ : t_u32) : t_Foo := +Definition f '(_ : t_u32) : t_Foo := Foo_A. -Definition g (_ : unit) : t_Bar := +Definition g '(_ : unit) : t_Bar := Build_t_Bar (f (32)). -Definition no_dependency_1_ (_ : unit) : unit := +Definition no_dependency_1_ '(_ : unit) : unit := tt. -Definition no_dependency_2_ (_ : unit) : unit := +Definition no_dependency_2_ '(_ : unit) : unit := tt. ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Reordering.v''' diff --git a/test-harness/src/snapshots/toolchain__slices into-coq.snap b/test-harness/src/snapshots/toolchain__slices into-coq.snap index 93fa425b0..d1c178703 100644 --- a/test-harness/src/snapshots/toolchain__slices into-coq.snap +++ b/test-harness/src/snapshots/toolchain__slices into-coq.snap @@ -40,6 +40,31 @@ Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. +(* From Core Require Import Core. *) + +(* TODO: Replace this dummy lib with core lib *) +Class t_Sized (T : Type) := { }. +Definition t_u8 := Z. +Definition t_u16 := Z. +Definition t_u32 := Z. +Definition t_u64 := Z. +Definition t_u128 := Z. +Definition t_usize := Z. +Definition t_i8 := Z. +Definition t_i16 := Z. +Definition t_i32 := Z. +Definition t_i64 := Z. +Definition t_i128 := Z. +Definition t_isize := Z. +Definition t_Array T (x : t_usize) := list T. +Definition t_String := string. +Definition ToString_f_to_string (x : string) := x. +Instance Sized_any : forall {t_A}, t_Sized t_A := {}. +Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. +Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. +Definition t_Slice (T : Type) := list T. +Definition unsize {T : Type} : list T -> t_Slice T := id. +(* / dummy lib *) (* NotImplementedYet *) @@ -47,12 +72,18 @@ Import RecordSetNotations. Definition v_VERSION : t_Slice t_u8 := unsize ([118; 49]). -Definition do_something (_ : t_Slice t_u8) : unit := +Definition do_something '(_ : t_Slice t_u8) : unit := tt. -Definition r#unsized (_ : t_Array (t_Slice t_u8) (1)) : unit := +Definition r#unsized '(_ : t_Array (t_Slice t_u8) (1)) : unit := tt. Definition sized (x : t_Array (t_Array (t_u8) (4)) (1)) : unit := r#unsized ([unsize (index (x) (0))]). ''' +_CoqProject = ''' +-R ./ TODO +-arg -w +-arg all + +Slices.v''' diff --git a/test-harness/src/snapshots/toolchain__traits into-fstar.snap b/test-harness/src/snapshots/toolchain__traits into-fstar.snap index fcc166dc9..3ada99292 100644 --- a/test-harness/src/snapshots/toolchain__traits into-fstar.snap +++ b/test-harness/src/snapshots/toolchain__traits into-fstar.snap @@ -55,7 +55,7 @@ open FStar.Mul class t_Bar (v_Self: Type0) (v_T: Type0) = { __marker_trait_t_Bar:Prims.unit } class t_Foo (v_Self: Type0) = { - [@@@ FStar.Tactics.Typeclasses.no_method]_super_5461126672499050919:t_Bar v_Self f_U; + [@@@ FStar.Tactics.Typeclasses.no_method]_super_12056653545434731362:t_Bar v_Self f_U; f_U:Type0 } ''' @@ -391,7 +391,7 @@ class t_SubTrait (v_Self: Type0) (v_TypeArg: Type0) (v_ConstArg: usize) = { v_TypeArg v_ConstArg; f_AssocType:Type0; - f_AssocType_5566993444404141271:t_Trait f_AssocType v_TypeArg v_ConstArg + f_AssocType_10469511598065652520:t_Trait f_AssocType v_TypeArg v_ConstArg } ''' "Traits.Interlaced_consts_types.fst" = ''' @@ -468,7 +468,7 @@ open FStar.Mul class t_Trait1 (v_Self: Type0) = { f_T:Type0; - f_T_7805326132379548775:t_Trait1 f_T + f_T_1640036513185240095:t_Trait1 f_T } class t_Trait2 (v_Self: Type0) = { @@ -613,8 +613,8 @@ let use_impl_trait (_: Prims.unit) : Prims.unit = class t_Foo (v_Self: Type0) = { f_AssocType:Type0; - f_AssocType_15012754260415912210:t_SuperTrait f_AssocType; - f_AssocType_3242921639065184873:Core.Clone.t_Clone f_AssocType; + f_AssocType_15525962639250476383:t_SuperTrait f_AssocType; + f_AssocType_17265963849229885182:Core.Clone.t_Clone f_AssocType; f_N:usize; f_assoc_f_pre:Prims.unit -> Type0; f_assoc_f_post:Prims.unit -> Prims.unit -> Type0; @@ -651,7 +651,7 @@ let g (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: t_Foo v_T) (x let impl_Foo_for_tuple_: t_Foo Prims.unit = { f_AssocType = i32; - f_AssocType_15012754260415912210 = FStar.Tactics.Typeclasses.solve; + f_AssocType_15525962639250476383 = FStar.Tactics.Typeclasses.solve; f_N = sz 32; f_assoc_f_pre = (fun (_: Prims.unit) -> true); f_assoc_f_post = (fun (_: Prims.unit) (out: Prims.unit) -> true); From 1801b1ce5e17d3b8e229910e61e42ca269a05a21 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 19 Nov 2024 11:42:01 +0100 Subject: [PATCH 13/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 3b74ad932..5608a6da2 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -807,7 +807,9 @@ struct ^^ string "|}" else constructor#p - ^^ concat_map_with ~pre:space (fun (ident, exp) -> parens(exp#p)) fields + ^^ concat_map_with ~pre:space + (fun (ident, exp) -> parens exp#p) + fields method pat'_PConstruct_tuple ~super:_ ~components = (* TODO: Only add `'` if you are a top-level pattern *) From e5e10ab14982db4a1f13056a327af98e6c223674 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 19 Nov 2024 15:40:40 +0100 Subject: [PATCH 14/35] Test some snapshots --- .github/workflows/extract_and_run_coq.yml | 19 ++++++++++++++++- engine/backends/coq/coq/coq_backend.ml | 25 +++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index c4d1c3f61..bd2fa9b1c 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -21,9 +21,26 @@ jobs: run: | nix run . into coq - - name: run coq + - name: run coq - coverage working-directory: hax/examples/coverage/proofs/coq/extraction run: | sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" nix-shell --packages coq coqPackages.coq-record-update --run "make" + + - name: build and run coq on tests + env: + FILES: assert attribute-opaque constructor-as-closure enum-repr enum-struct-variant even + NOT_SUPPORTED_FILES: attributes cli conditional-match cyclic-modules dyn functions + run: | + for f in $FILES; do \ + cd hax/tests/$f && \ + nix run . into coq && \ + cd ../../.. + done + for f in $FILES; do \ + cd hax/tests/$f/proofs/coq/extraction && \ + nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ + cd ../../../../../../ + done diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 5608a6da2..04ed9c9ac 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -142,6 +142,26 @@ let dummy_lib = => x}.\n\ Definition t_Slice (T : Type) := list T.\n\ Definition unsize {T : Type} : list T -> t_Slice T := id.\n\ + Definition t_PartialEq_f_eq x y := x =? y.\n\ + Definition t_Rem_f_rem (x y : Z) := x mod y.\n\ + Definition assert (b : bool) (* `{H_assert : b = true} *) : unit := tt.\n\ + Inductive globality := | t_Global.\n\ + Definition t_Vec T (_ : globality) : Type := list T.\n\ + Definition impl_1__append {T} l1 l2 : list T * list T := (app l1 l2, l2).\n\ + Definition impl_1__len {A} (l : list A) := Z.of_nat (List.length l).\n\ + Definition impl__new {A} (_ : Datatypes.unit) : list A := nil.\n\ + Definition impl__with_capacity {A} (_ : Z) : list A := nil.\n\ + Definition impl_1__push {A} l (x : A) := cons x l.\n\ + Class t_From (A B : Type) := { From_f_from : B -> A }.\n\ + Definition impl__to_vec {T} (x : t_Slice T) : t_Vec T t_Global := x.\n\ + Class t_Into (A B : Type) := { Into_f_into : A -> B }.\n\ + Instance t_Into_from_t_From {A B : Type} `{H : t_From B A} : t_Into A B := { Into_f_into x := @From_f_from B A H x }.\n\ + Definition from_elem {A} (x : A) (l : Z) := repeat x (Z.to_nat l).\n\ + Definition t_Option := option.\n\ + Definition impl__map {A B} (x : t_Option A) (f : A -> B) : t_Option B := match x with | Some x => Some (f x) | None => None end.\n\ + Definition t_Add_f_add x y := x + y.\n\ + Class Cast A B := { cast : A -> B }.\n\ + Instance cast_t_u8_t_u32 : Cast t_u8 t_u32 := {| cast x := x |}.\n\ (* / dummy lib *)\n" module BasePrinter = Generic_printer.Make (InputLanguage) @@ -265,7 +285,7 @@ struct List.fold_right ~init:e#p ~f:(fun x y -> parens (x ^^ y)) ((if Stdlib.(nth != 0) then [ string "snd" ] else []) - @ List.init (size - 1 - nth) ~f:(fun _ -> string "fst")) + @ if (size - 1 - nth) > 0 then List.init (size - 1 - nth) ~f:(fun _ -> string "fst") else []) method expr'_Ascription ~super:_ ~e ~typ = e#p ^^ space ^^ colon ^^ space ^^ typ#p @@ -1022,9 +1042,6 @@ let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = ~f:(map_first_letter String.uppercase) (fst ns :: snd ns)) in - let contents, _annotations = - my_printer#entrypoint_modul items - in mod_name ^ ".v"))); sourcemap = None; }; From b87a682c9046c3478fe6f779c55658b8c6970b60 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 19 Nov 2024 15:42:28 +0100 Subject: [PATCH 15/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 04ed9c9ac..adb9b0fd3 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -155,10 +155,12 @@ let dummy_lib = Class t_From (A B : Type) := { From_f_from : B -> A }.\n\ Definition impl__to_vec {T} (x : t_Slice T) : t_Vec T t_Global := x.\n\ Class t_Into (A B : Type) := { Into_f_into : A -> B }.\n\ - Instance t_Into_from_t_From {A B : Type} `{H : t_From B A} : t_Into A B := { Into_f_into x := @From_f_from B A H x }.\n\ + Instance t_Into_from_t_From {A B : Type} `{H : t_From B A} : t_Into A B := \ + { Into_f_into x := @From_f_from B A H x }.\n\ Definition from_elem {A} (x : A) (l : Z) := repeat x (Z.to_nat l).\n\ - Definition t_Option := option.\n\ - Definition impl__map {A B} (x : t_Option A) (f : A -> B) : t_Option B := match x with | Some x => Some (f x) | None => None end.\n\ + Definition t_Option := option.\n\ + Definition impl__map {A B} (x : t_Option A) (f : A -> B) : t_Option B := \ + match x with | Some x => Some (f x) | None => None end.\n\ Definition t_Add_f_add x y := x + y.\n\ Class Cast A B := { cast : A -> B }.\n\ Instance cast_t_u8_t_u32 : Cast t_u8 t_u32 := {| cast x := x |}.\n\ @@ -285,7 +287,10 @@ struct List.fold_right ~init:e#p ~f:(fun x y -> parens (x ^^ y)) ((if Stdlib.(nth != 0) then [ string "snd" ] else []) - @ if (size - 1 - nth) > 0 then List.init (size - 1 - nth) ~f:(fun _ -> string "fst") else []) + @ + if size - 1 - nth > 0 then + List.init (size - 1 - nth) ~f:(fun _ -> string "fst") + else []) method expr'_Ascription ~super:_ ~e ~typ = e#p ^^ space ^^ colon ^^ space ^^ typ#p From f6d7a826293be3f3dd66246e36f9b78ec1354a82 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Fri, 22 Nov 2024 11:50:15 +0100 Subject: [PATCH 16/35] Add example co-inductive/mutual recursion issues with trait --- examples/coverage/src/lib.rs | 2 ++ examples/coverage/src/test_trait.rs | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 examples/coverage/src/test_trait.rs diff --git a/examples/coverage/src/lib.rs b/examples/coverage/src/lib.rs index f1fbe110d..d9bf0077d 100644 --- a/examples/coverage/src/lib.rs +++ b/examples/coverage/src/lib.rs @@ -9,3 +9,5 @@ mod test_closures; mod test_functions; mod test_instance; + +mod test_trait; diff --git a/examples/coverage/src/test_trait.rs b/examples/coverage/src/test_trait.rs new file mode 100644 index 000000000..421715775 --- /dev/null +++ b/examples/coverage/src/test_trait.rs @@ -0,0 +1,11 @@ +// Broken.. + +// // Co-inductive trait +// trait TraitA { +// type B : TraitB; +// } + +// trait TraitB { +// fn test(other : U) -> U +// where U: TraitA; +// } From 00d44cb37015981aec769bf7cf0e900776c788d6 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 16:23:41 +0100 Subject: [PATCH 17/35] Update coq backend --- engine/backends/coq/coq/coq_backend.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index adb9b0fd3..97e5cf465 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -115,8 +115,8 @@ let hardcoded_coq_headers = Require Import String.\n\ Require Import Coq.Floats.Floats.\n\ From RecordUpdate Require Import RecordSet.\n\ - Import RecordSetNotations.\n\n\ - (* From Core Require Import Core. *)\n" + Import RecordSetNotations.\n\ + From Core Require Import Core.\n\n" let dummy_lib = "(* TODO: Replace this dummy lib with core lib *)\n\ @@ -780,8 +780,8 @@ struct (if negative then parens (!^"-" ^^ string value) else string value) ^^ string "%float" - method literal_Int ~value ~negative ~kind:_ = - (if negative then !^"-" else empty) ^^ string value + method literal_Int ~value ~negative ~kind = + parens((if negative then !^"-" else empty) ^^ string value ^^ colon ^^ space ^^ !^"t_" ^^ string (show_int_kind kind)) method literal_String x1 = string "\"" ^^ string x1 ^^ string "\"%string" @@ -1023,7 +1023,7 @@ let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = let sourcemap, contents = let annotated = my_printer#entrypoint_modul items in let open Generic_printer.AnnotatedString in - let header = pure (hardcoded_coq_headers ^ "\n" ^ dummy_lib) in + let header = pure (hardcoded_coq_headers) in let annotated = concat header annotated in (to_sourcemap annotated, to_string annotated) in From e3ff48a5471aae398b142b9562137e4d6637eb97 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 16:34:58 +0100 Subject: [PATCH 18/35] Use core for coq coverage test --- .github/workflows/extract_and_run_coq.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index bd2fa9b1c..3e84b9e57 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -28,6 +28,13 @@ jobs: nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" nix-shell --packages coq coqPackages.coq-record-update --run "make" + - name: build and run coq on tests + working-directory: hax/proof-libs/coq/coq/generated-core + run: | + nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + nix-shell --packages coq coqPackages.coq-record-update --run "make" + nix-shell --packages coq coqPackages.coq-record-update --run "make install" + - name: build and run coq on tests env: FILES: assert attribute-opaque constructor-as-closure enum-repr enum-struct-variant even From 783fca52a31ef7ddf000a6b71fc43a363a8c5ad3 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 16:38:08 +0100 Subject: [PATCH 19/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 97e5cf465..3bb3a73ef 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -781,7 +781,10 @@ struct ^^ string "%float" method literal_Int ~value ~negative ~kind = - parens((if negative then !^"-" else empty) ^^ string value ^^ colon ^^ space ^^ !^"t_" ^^ string (show_int_kind kind)) + parens + ((if negative then !^"-" else empty) + ^^ string value ^^ colon ^^ space ^^ !^"t_" + ^^ string (show_int_kind kind)) method literal_String x1 = string "\"" ^^ string x1 ^^ string "\"%string" @@ -1023,7 +1026,7 @@ let translate m _ ~bundles:_ (items : AST.item list) : Types.file list = let sourcemap, contents = let annotated = my_printer#entrypoint_modul items in let open Generic_printer.AnnotatedString in - let header = pure (hardcoded_coq_headers) in + let header = pure hardcoded_coq_headers in let annotated = concat header annotated in (to_sourcemap annotated, to_string annotated) in From 85c47667acfe1a9782888f72755413dd6166d170 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 17:24:21 +0100 Subject: [PATCH 20/35] snapshot --- .github/workflows/extract_and_run_coq.yml | 14 ++--- engine/backends/coq/coq/coq_backend.ml | 7 ++- .../snapshots/toolchain__assert into-coq.snap | 35 ++---------- .../toolchain__enum-repr into-coq.snap | 39 +++----------- .../snapshots/toolchain__guards into-coq.snap | 47 ++++------------ .../toolchain__include-flag into-coq.snap | 27 +--------- .../toolchain__let-else into-coq.snap | 35 ++---------- .../toolchain__literals into-coq.snap | 53 +++++-------------- .../toolchain__pattern-or into-coq.snap | 39 +++----------- .../toolchain__reordering into-coq.snap | 33 ++---------- .../snapshots/toolchain__slices into-coq.snap | 35 ++---------- 11 files changed, 69 insertions(+), 295 deletions(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 3e84b9e57..ad75c073f 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -21,6 +21,13 @@ jobs: run: | nix run . into coq + - name: install annotated core for coq + working-directory: hax/proof-libs/coq/coq/generated-core + run: | + nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + nix-shell --packages coq coqPackages.coq-record-update --run "make" + nix-shell --packages coq coqPackages.coq-record-update --run "make install" + - name: run coq - coverage working-directory: hax/examples/coverage/proofs/coq/extraction run: | @@ -28,13 +35,6 @@ jobs: nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" nix-shell --packages coq coqPackages.coq-record-update --run "make" - - name: build and run coq on tests - working-directory: hax/proof-libs/coq/coq/generated-core - run: | - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" - nix-shell --packages coq coqPackages.coq-record-update --run "make install" - - name: build and run coq on tests env: FILES: assert attribute-opaque constructor-as-closure enum-repr enum-struct-variant even diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 3bb3a73ef..94bcd535a 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -366,7 +366,8 @@ struct string "let" ^^ space ^^ lhs#p ^^ space ^^ string ":=" ^^ space ^^ rhs#p ^^ space ^^ string "in" ^^ break 1 ^^ body#p - method expr'_Literal ~super:_ x2 = x2#p + method expr'_Literal ~super x2 = + parens(x2#p ^^ space ^^ colon ^^ space ^^ (self#_do_not_override_lazy_of_ty AstPos_expr'_Literal_x0 super.typ)#p) method expr'_LocalVar ~super:_ x2 = x2#p method expr'_Loop ~super:_ ~body ~kind ~state ~control_flow ~label:_ @@ -781,10 +782,8 @@ struct ^^ string "%float" method literal_Int ~value ~negative ~kind = - parens ((if negative then !^"-" else empty) - ^^ string value ^^ colon ^^ space ^^ !^"t_" - ^^ string (show_int_kind kind)) + ^^ string value) method literal_String x1 = string "\"" ^^ string x1 ^^ string "\"%string" diff --git a/test-harness/src/snapshots/toolchain__assert into-coq.snap b/test-harness/src/snapshots/toolchain__assert into-coq.snap index af900c615..16195e222 100644 --- a/test-harness/src/snapshots/toolchain__assert into-coq.snap +++ b/test-harness/src/snapshots/toolchain__assert into-coq.snap @@ -38,44 +38,19 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. (* NotImplementedYet *) Definition asserts '(_ : unit) : unit := - let _ := assert (true) in - let _ := assert (t_PartialEq_f_eq (1) (1)) in - let _ := match (2,2) with + let _ := assert ((true : bool)) in + let _ := assert (t_PartialEq_f_eq ((1 : t_i32)) ((1 : t_i32))) in + let _ := match ((2 : t_i32),(2 : t_i32)) with | (left_val,right_val) => assert (t_PartialEq_f_eq (left_val) (right_val)) end in - let _ := match (1,2) with + let _ := match ((1 : t_i32),(2 : t_i32)) with | (left_val,right_val) => assert (negb (t_PartialEq_f_eq (left_val) (right_val))) end in diff --git a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap index 70175a2e1..132cb1bff 100644 --- a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap +++ b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap @@ -39,39 +39,14 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. Definition discriminant_EnumWithRepr_ExplicitDiscr1 : t_u16 := - 1. + (1 : t_u16). Definition discriminant_EnumWithRepr_ExplicitDiscr2 : t_u16 := - 5. + (5 : t_u16). Inductive t_EnumWithRepr : Type := | EnumWithRepr_ExplicitDiscr1 @@ -90,19 +65,19 @@ Definition t_EnumWithRepr_cast_to_repr (x : t_EnumWithRepr) : t_u16 := | EnumWithRepr_ExplicitDiscr2 => discriminant_EnumWithRepr_ExplicitDiscr2 | EnumWithRepr_ImplicitDiscrEmptyTuple => - t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) (1) + t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((1 : t_u16)) | EnumWithRepr_ImplicitDiscrEmptyStruct => - t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) (2) + t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((2 : t_u16)) end. (* NotImplementedYet *) Definition f '(_ : unit) : t_u32 := - let v__x := cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) (0)) in + let v__x := cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((0 : t_u16))) in t_Add_f_add (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyTuple))) (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyStruct))). Definition ff__CONST : t_u16 := - cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr1) (0)). + cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr1) ((0 : t_u16))). Definition get_casted_repr (x : t_EnumWithRepr) : t_u64 := cast (t_EnumWithRepr_cast_to_repr (x)). diff --git a/test-harness/src/snapshots/toolchain__guards into-coq.snap b/test-harness/src/snapshots/toolchain__guards into-coq.snap index 413f93f0a..87a392c17 100644 --- a/test-harness/src/snapshots/toolchain__guards into-coq.snap +++ b/test-harness/src/snapshots/toolchain__guards into-coq.snap @@ -38,32 +38,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. (* NotImplementedYet *) @@ -71,7 +46,7 @@ Definition unsize {T : Type} : list T -> t_Slice T := id. Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := match x with | Option_None => - 0 + (0 : t_i32) | _ => match match x with | Option_Some (v) => @@ -91,7 +66,7 @@ Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := | Option_Some (Result_Err (y)) => y | _ => - 1 + (1 : t_i32) end end end. @@ -99,7 +74,7 @@ Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := Definition if_guard (x : t_Option ((t_i32))) : t_i32 := match match x with | Option_Some (v) => - match t_PartialOrd_f_gt (v) (0) with + match t_PartialOrd_f_gt (v) ((0 : t_i32)) with | true => Option_Some (v) | _ => @@ -111,13 +86,13 @@ Definition if_guard (x : t_Option ((t_i32))) : t_i32 := | Option_Some (x) => x | Option_None => - 0 + (0 : t_i32) end. Definition if_let_guard (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := match x with | Option_None => - 0 + (0 : t_i32) | _ => match match x with | Option_Some (v) => @@ -137,7 +112,7 @@ Definition if_let_guard (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 | Option_Some (Result_Err (y)) => y | _ => - 1 + (1 : t_i32) end end end. @@ -145,13 +120,13 @@ Definition if_let_guard (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 Definition multiple_guards (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := match x with | Option_None => - 0 + (0 : t_i32) | _ => match match x with | Option_Some (Result_Ok (v)) => - match Option_Some (t_Add_f_add (v) (1)) with + match Option_Some (t_Add_f_add (v) ((1 : t_i32))) with | Option_Some (1) => - Option_Some (0) + Option_Some ((0 : t_i32)) | _ => Option_None end @@ -179,7 +154,7 @@ Definition multiple_guards (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i | Option_Some (Result_Err (y)) => y | _ => - 1 + (1 : t_i32) end end end diff --git a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap index 36eb83d65..0f711be0c 100644 --- a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap +++ b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap @@ -38,32 +38,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. Record t_Foo : Type := diff --git a/test-harness/src/snapshots/toolchain__let-else into-coq.snap b/test-harness/src/snapshots/toolchain__let-else into-coq.snap index 30e5da462..f4db7d996 100644 --- a/test-harness/src/snapshots/toolchain__let-else into-coq.snap +++ b/test-harness/src/snapshots/toolchain__let-else into-coq.snap @@ -38,32 +38,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. (* NotImplementedYet *) @@ -71,17 +46,17 @@ Definition unsize {T : Type} : list T -> t_Slice T := id. Definition let_else (opt : t_Option ((t_u32))) : bool := run (match opt with | Option_Some (x) => - ControlFlow_Continue (true) + ControlFlow_Continue ((true : bool)) | _ => - ControlFlow_Break (false) + ControlFlow_Break ((false : bool)) end). Definition let_else_different_type (opt : t_Option ((t_u32))) : bool := run (let hoist1 := match opt with | Option_Some (x) => - ControlFlow_Continue (Option_Some (t_Add_f_add (x) (1))) + ControlFlow_Continue (Option_Some (t_Add_f_add (x) ((1 : t_u32)))) | _ => - ControlFlow_Break (false) + ControlFlow_Break ((false : bool)) end in ControlFlow_Continue (let_else (hoist1))). ''' diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index 2636d280d..eaa6a7f1f 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -39,32 +39,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. From Literals Require Import Hax_lib (t_int). @@ -82,7 +57,7 @@ Arguments Foo_f_field. (* NotImplementedYet *) Definition v_CONSTANT : t_Foo := - Build_t_Foo (3). + Build_t_Foo ((3 : t_u8)). Definition casts (x8 : t_u8) (x16 : t_u16) (x32 : t_u32) (x64 : t_u64) (xs : t_usize) : unit := let _ : t_u64 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (x64)) (cast (xs)) in @@ -100,9 +75,9 @@ Definition fn_pointer_cast '(_ : unit) : unit := x in tt. -Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___unsafe_from_str ("0"%string))) (PartialOrd_f_lt (x) (impl__Int___unsafe_from_str ("16"%string))) = true} : t_u8 := - let _ : t_Int := Abstraction_f_lift (3) in - let _ := PartialOrd_f_gt (impl__Int___unsafe_from_str ("-340282366920938463463374607431768211455000"%string)) (impl__Int___unsafe_from_str ("340282366920938463463374607431768211455000"%string)) in +Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___unsafe_from_str (("0"%string : string)))) (PartialOrd_f_lt (x) (impl__Int___unsafe_from_str (("16"%string : string)))) = true} : t_u8 := + let _ : t_Int := Abstraction_f_lift ((3 : t_usize)) in + let _ := PartialOrd_f_gt (impl__Int___unsafe_from_str (("-340282366920938463463374607431768211455000"%string : string))) (impl__Int___unsafe_from_str (("340282366920938463463374607431768211455000"%string : string))) in let _ := PartialOrd_f_lt (x) (x) in let _ := PartialOrd_f_ge (x) (x) in let _ := PartialOrd_f_le (x) (x) in @@ -128,27 +103,27 @@ Definition null : ascii := "\000"%char. Definition numeric '(_ : unit) : unit := - let _ : t_usize := 123 in - let _ : t_isize := -42 in - let _ : t_isize := 42 in - let _ : t_i32 := -42 in - let _ : t_u128 := 22222222222222222222 in + let _ : t_usize := (123 : t_usize) in + let _ : t_isize := (-42 : t_isize) in + let _ : t_isize := (42 : t_isize) in + let _ : t_i32 := (-42 : t_i32) in + let _ : t_u128 := (22222222222222222222 : t_u128) in tt. Definition patterns '(_ : unit) : unit := - let _ := match 1 with + let _ := match (1 : t_u8) with | 2 => tt | _ => tt end in - let _ := match ("hello"%string,(123,["a"%string; "b"%string])) with + let _ := match (("hello"%string : string),((123 : t_i32),[("a"%string : string); ("b"%string : string)])) with | ("hello"%string,(123,v__todo)) => tt | _ => tt end in - let _ := match Build_t_Foo (4) with + let _ := match Build_t_Foo ((4 : t_u8)) with | Build_t_Foo (3) => tt | _ => @@ -157,7 +132,7 @@ Definition patterns '(_ : unit) : unit := tt. Definition panic_with_msg '(_ : unit) : unit := - never_to_any (panic_fmt (impl_2__new_const (["with msg"%string]))). + never_to_any (panic_fmt (impl_2__new_const ([("with msg"%string : string)]))). Definition empty_array '(_ : unit) : unit := let _ : t_Slice t_u8 := unsize ([]) in diff --git a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap index 8524dbe3d..4c8311cfb 100644 --- a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap +++ b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap @@ -39,32 +39,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. Inductive t_E : Type := @@ -76,9 +51,9 @@ Arguments E_B. Definition t_E_cast_to_repr (x : t_E) : t_isize := match x with | E_A => - 0 + (0 : t_isize) | E_B => - 1 + (1 : t_isize) end. (* NotImplementedYet *) @@ -95,7 +70,7 @@ Definition deep (x : (t_i32*t_Option ((t_i32)))) : t_i32 := | (1 | 2,Option_Some (3 | 4)) => - 0 + (0 : t_i32) | (x,_) => x end. @@ -118,7 +93,7 @@ Definition equivalent (x : (t_i32*t_Option ((t_i32)))) : t_i32 := | (1,Option_Some (4)) | (2,Option_Some (3)) | (2,Option_Some (4)) => - 0 + (0 : t_i32) | (x,_) => x end. @@ -127,11 +102,11 @@ Definition nested (x : t_Option ((t_i32))) : t_i32 := match x with | Option_Some (1 | 2) => - 1 + (1 : t_i32) | Option_Some (x) => x | Option_None => - 0 + (0 : t_i32) end. ''' _CoqProject = ''' diff --git a/test-harness/src/snapshots/toolchain__reordering into-coq.snap b/test-harness/src/snapshots/toolchain__reordering into-coq.snap index 1b7f108d8..caa800942 100644 --- a/test-harness/src/snapshots/toolchain__reordering into-coq.snap +++ b/test-harness/src/snapshots/toolchain__reordering into-coq.snap @@ -38,32 +38,7 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. Inductive t_Foo : Type := @@ -85,9 +60,9 @@ Notation "'Bar'" := Build_t_Bar. Definition t_Foo_cast_to_repr (x : t_Foo) : t_isize := match x with | Foo_A => - 0 + (0 : t_isize) | Foo_B => - 1 + (1 : t_isize) end. (* NotImplementedYet *) @@ -96,7 +71,7 @@ Definition f '(_ : t_u32) : t_Foo := Foo_A. Definition g '(_ : unit) : t_Bar := - Build_t_Bar (f (32)). + Build_t_Bar (f ((32 : t_u32))). Definition no_dependency_1_ '(_ : unit) : unit := tt. diff --git a/test-harness/src/snapshots/toolchain__slices into-coq.snap b/test-harness/src/snapshots/toolchain__slices into-coq.snap index d1c178703..bd3ad5bbf 100644 --- a/test-harness/src/snapshots/toolchain__slices into-coq.snap +++ b/test-harness/src/snapshots/toolchain__slices into-coq.snap @@ -39,47 +39,22 @@ Require Import String. Require Import Coq.Floats.Floats. From RecordUpdate Require Import RecordSet. Import RecordSetNotations. - -(* From Core Require Import Core. *) - -(* TODO: Replace this dummy lib with core lib *) -Class t_Sized (T : Type) := { }. -Definition t_u8 := Z. -Definition t_u16 := Z. -Definition t_u32 := Z. -Definition t_u64 := Z. -Definition t_u128 := Z. -Definition t_usize := Z. -Definition t_i8 := Z. -Definition t_i16 := Z. -Definition t_i32 := Z. -Definition t_i64 := Z. -Definition t_i128 := Z. -Definition t_isize := Z. -Definition t_Array T (x : t_usize) := list T. -Definition t_String := string. -Definition ToString_f_to_string (x : string) := x. -Instance Sized_any : forall {t_A}, t_Sized t_A := {}. -Class t_Clone (T : Type) := { Clone_f_clone : T -> T }. -Instance Clone_any : forall {t_A}, t_Clone t_A := {Clone_f_clone := fun x => x}. -Definition t_Slice (T : Type) := list T. -Definition unsize {T : Type} : list T -> t_Slice T := id. -(* / dummy lib *) +From Core Require Import Core. (* NotImplementedYet *) Definition v_VERSION : t_Slice t_u8 := - unsize ([118; 49]). + unsize ([(118 : t_u8); (49 : t_u8)]). Definition do_something '(_ : t_Slice t_u8) : unit := tt. -Definition r#unsized '(_ : t_Array (t_Slice t_u8) (1)) : unit := +Definition r#unsized '(_ : t_Array (t_Slice t_u8) ((1 : t_usize))) : unit := tt. -Definition sized (x : t_Array (t_Array (t_u8) (4)) (1)) : unit := - r#unsized ([unsize (index (x) (0))]). +Definition sized (x : t_Array (t_Array (t_u8) ((4 : t_usize))) ((1 : t_usize))) : unit := + r#unsized ([unsize (index (x) ((0 : t_usize)))]). ''' _CoqProject = ''' -R ./ TODO From 9cf8aeca3d9e4767c4c4946e01f6826e08feb006 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 17:25:13 +0100 Subject: [PATCH 21/35] fmt --- engine/backends/coq/coq/coq_backend.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 94bcd535a..04d3cf19c 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -367,7 +367,11 @@ struct ^^ space ^^ string "in" ^^ break 1 ^^ body#p method expr'_Literal ~super x2 = - parens(x2#p ^^ space ^^ colon ^^ space ^^ (self#_do_not_override_lazy_of_ty AstPos_expr'_Literal_x0 super.typ)#p) + parens + (x2#p ^^ space ^^ colon ^^ space + ^^ (self#_do_not_override_lazy_of_ty AstPos_expr'_Literal_x0 super.typ) + #p) + method expr'_LocalVar ~super:_ x2 = x2#p method expr'_Loop ~super:_ ~body ~kind ~state ~control_flow ~label:_ @@ -782,8 +786,7 @@ struct ^^ string "%float" method literal_Int ~value ~negative ~kind = - ((if negative then !^"-" else empty) - ^^ string value) + (if negative then !^"-" else empty) ^^ string value method literal_String x1 = string "\"" ^^ string x1 ^^ string "\"%string" From 014525ca314e64aa9e2783638fbf29e46832eb33 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 18:25:35 +0100 Subject: [PATCH 22/35] Snapshot update --- .github/workflows/extract_and_run_coq.yml | 4 ++-- engine/backends/coq/coq/coq_backend.ml | 18 +++++++++--------- .../snapshots/toolchain__assert into-coq.snap | 6 +++--- .../toolchain__enum-repr into-coq.snap | 10 +++++----- .../snapshots/toolchain__guards into-coq.snap | 4 ++-- .../toolchain__let-else into-coq.snap | 2 +- .../toolchain__literals into-coq.snap | 16 ++++++++-------- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index ad75c073f..648eaf1b7 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -37,8 +37,8 @@ jobs: - name: build and run coq on tests env: - FILES: assert attribute-opaque constructor-as-closure enum-repr enum-struct-variant even - NOT_SUPPORTED_FILES: attributes cli conditional-match cyclic-modules dyn functions + FILES: assert attribute-opaque enum-struct-variant + NOT_SUPPORTED_FILES: attributes cli conditional-match constructor-as-closure cyclic-modules enum-repr even dyn functions run: | for f in $FILES; do \ cd hax/tests/$f && \ diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 04d3cf19c..93eb4cf55 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -984,15 +984,15 @@ struct string (match id.definition with | "not" -> "negb" - | "eq" -> "t_PartialEq_f_eq" - | "lt" -> "t_PartialOrd_f_lt" - | "gt" -> "t_PartialOrd_f_gt" - | "le" -> "t_PartialOrd_f_le" - | "ge" -> "t_PartialOrd_f_ge" - | "rem" -> "t_Rem_f_rem" - | "add" -> "t_Add_f_add" - | "mul" -> "t_Mul_f_mul" - | "div" -> "t_Div_f_div" + | "eq" -> "PartialEq_f_eq" + | "lt" -> "PartialOrd_f_lt" + | "gt" -> "PartialOrd_f_gt" + | "le" -> "PartialOrd_f_le" + | "ge" -> "PartialOrd_f_ge" + | "rem" -> "Rem_f_rem" + | "add" -> "Add_f_add" + | "mul" -> "Mul_f_mul" + | "div" -> "Div_f_div" | x -> x) end diff --git a/test-harness/src/snapshots/toolchain__assert into-coq.snap b/test-harness/src/snapshots/toolchain__assert into-coq.snap index 16195e222..47726eeab 100644 --- a/test-harness/src/snapshots/toolchain__assert into-coq.snap +++ b/test-harness/src/snapshots/toolchain__assert into-coq.snap @@ -45,14 +45,14 @@ From Core Require Import Core. Definition asserts '(_ : unit) : unit := let _ := assert ((true : bool)) in - let _ := assert (t_PartialEq_f_eq ((1 : t_i32)) ((1 : t_i32))) in + let _ := assert (PartialEq_f_eq ((1 : t_i32)) ((1 : t_i32))) in let _ := match ((2 : t_i32),(2 : t_i32)) with | (left_val,right_val) => - assert (t_PartialEq_f_eq (left_val) (right_val)) + assert (PartialEq_f_eq (left_val) (right_val)) end in let _ := match ((1 : t_i32),(2 : t_i32)) with | (left_val,right_val) => - assert (negb (t_PartialEq_f_eq (left_val) (right_val))) + assert (negb (PartialEq_f_eq (left_val) (right_val))) end in tt. ''' diff --git a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap index 132cb1bff..946d341be 100644 --- a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap +++ b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap @@ -65,19 +65,19 @@ Definition t_EnumWithRepr_cast_to_repr (x : t_EnumWithRepr) : t_u16 := | EnumWithRepr_ExplicitDiscr2 => discriminant_EnumWithRepr_ExplicitDiscr2 | EnumWithRepr_ImplicitDiscrEmptyTuple => - t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((1 : t_u16)) + Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((1 : t_u16)) | EnumWithRepr_ImplicitDiscrEmptyStruct => - t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((2 : t_u16)) + Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((2 : t_u16)) end. (* NotImplementedYet *) Definition f '(_ : unit) : t_u32 := - let v__x := cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((0 : t_u16))) in - t_Add_f_add (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyTuple))) (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyStruct))). + let v__x := cast (Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr2) ((0 : t_u16))) in + Add_f_add (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyTuple))) (cast (t_EnumWithRepr_cast_to_repr (EnumWithRepr_ImplicitDiscrEmptyStruct))). Definition ff__CONST : t_u16 := - cast (t_Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr1) ((0 : t_u16))). + cast (Add_f_add (discriminant_EnumWithRepr_ExplicitDiscr1) ((0 : t_u16))). Definition get_casted_repr (x : t_EnumWithRepr) : t_u64 := cast (t_EnumWithRepr_cast_to_repr (x)). diff --git a/test-harness/src/snapshots/toolchain__guards into-coq.snap b/test-harness/src/snapshots/toolchain__guards into-coq.snap index 87a392c17..3fa858d26 100644 --- a/test-harness/src/snapshots/toolchain__guards into-coq.snap +++ b/test-harness/src/snapshots/toolchain__guards into-coq.snap @@ -74,7 +74,7 @@ Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := Definition if_guard (x : t_Option ((t_i32))) : t_i32 := match match x with | Option_Some (v) => - match t_PartialOrd_f_gt (v) ((0 : t_i32)) with + match PartialOrd_f_gt (v) ((0 : t_i32)) with | true => Option_Some (v) | _ => @@ -124,7 +124,7 @@ Definition multiple_guards (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i | _ => match match x with | Option_Some (Result_Ok (v)) => - match Option_Some (t_Add_f_add (v) ((1 : t_i32))) with + match Option_Some (Add_f_add (v) ((1 : t_i32))) with | Option_Some (1) => Option_Some ((0 : t_i32)) | _ => diff --git a/test-harness/src/snapshots/toolchain__let-else into-coq.snap b/test-harness/src/snapshots/toolchain__let-else into-coq.snap index f4db7d996..1fcdb664b 100644 --- a/test-harness/src/snapshots/toolchain__let-else into-coq.snap +++ b/test-harness/src/snapshots/toolchain__let-else into-coq.snap @@ -54,7 +54,7 @@ Definition let_else (opt : t_Option ((t_u32))) : bool := Definition let_else_different_type (opt : t_Option ((t_u32))) : bool := run (let hoist1 := match opt with | Option_Some (x) => - ControlFlow_Continue (Option_Some (t_Add_f_add (x) ((1 : t_u32)))) + ControlFlow_Continue (Option_Some (Add_f_add (x) ((1 : t_u32)))) | _ => ControlFlow_Break ((false : bool)) end in diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index eaa6a7f1f..9bbcfea03 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -60,14 +60,14 @@ Definition v_CONSTANT : t_Foo := Build_t_Foo ((3 : t_u8)). Definition casts (x8 : t_u8) (x16 : t_u16) (x32 : t_u32) (x64 : t_u64) (xs : t_usize) : unit := - let _ : t_u64 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (x64)) (cast (xs)) in - let _ : t_u32 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (x32)) (cast (x64))) (cast (xs)) in - let _ : t_u16 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (x16)) (cast (x32))) (cast (x64))) (cast (xs)) in - let _ : t_u8 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (x8) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in - let _ : t_i64 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in - let _ : t_i32 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in - let _ : t_i16 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in - let _ : t_i8 := t_Add_f_add (t_Add_f_add (t_Add_f_add (t_Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_u64 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (x64)) (cast (xs)) in + let _ : t_u32 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (x32)) (cast (x64))) (cast (xs)) in + let _ : t_u16 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (x16)) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_u8 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (x8) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_i64 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_i32 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_i16 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in + let _ : t_i8 := Add_f_add (Add_f_add (Add_f_add (Add_f_add (cast (x8)) (cast (x16))) (cast (x32))) (cast (x64))) (cast (xs)) in tt. Definition fn_pointer_cast '(_ : unit) : unit := From 5dd787f1fb4a59105cf264e7c389697b68b9901f Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Mon, 25 Nov 2024 18:51:28 +0100 Subject: [PATCH 23/35] CI --- .github/workflows/extract_and_run_coq.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 648eaf1b7..ba12d3652 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -25,7 +25,7 @@ jobs: working-directory: hax/proof-libs/coq/coq/generated-core run: | nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" + nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ nix-shell --packages coq coqPackages.coq-record-update --run "make install" - name: run coq - coverage From f4edc30bd6bad4fbf2860f9fb8e1ff43e30e7828 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 26 Nov 2024 15:28:28 +0100 Subject: [PATCH 24/35] Minor changes --- engine/backends/coq/coq/coq_backend.ml | 4 ++- examples/Cargo.lock | 3 +-- examples/coverage/src/lib.rs | 2 ++ examples/coverage/src/test_arrays.rs | 35 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 examples/coverage/src/test_arrays.rs diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 93eb4cf55..ba8134a56 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -623,7 +623,7 @@ struct ^^ break 1)) ^^ break 1 ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) - arguments_explicity_with_ty + arguments_explicity_without_ty (* arguments_explicity_with_ty *) ^^ concat_map_with ~pre:(break 1) (fun (ident, typ, attr) -> CoqNotation.arguments ident#p arguments_explicity_without_ty) @@ -991,8 +991,10 @@ struct | "ge" -> "PartialOrd_f_ge" | "rem" -> "Rem_f_rem" | "add" -> "Add_f_add" + | "sub" -> "Sub_f_sub" | "mul" -> "Mul_f_mul" | "div" -> "Div_f_div" + | "index" -> "Index_f_index" | x -> x) end diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 668d60c74..1160deeab 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -389,7 +389,6 @@ name = "kyber_compress" version = "0.1.0" dependencies = [ "hax-lib", - "hax-lib-macros", ] [[package]] @@ -737,7 +736,7 @@ dependencies = [ name = "sha256" version = "0.1.0" dependencies = [ - "hax-lib-macros", + "hax-lib", ] [[package]] diff --git a/examples/coverage/src/lib.rs b/examples/coverage/src/lib.rs index d9bf0077d..2b5521210 100644 --- a/examples/coverage/src/lib.rs +++ b/examples/coverage/src/lib.rs @@ -11,3 +11,5 @@ mod test_functions; mod test_instance; mod test_trait; + +mod test_arrays; diff --git a/examples/coverage/src/test_arrays.rs b/examples/coverage/src/test_arrays.rs new file mode 100644 index 000000000..d6ab14e11 --- /dev/null +++ b/examples/coverage/src/test_arrays.rs @@ -0,0 +1,35 @@ + +// // This function borrows a slice. +// fn analyze_slice(slice: &[i32]) { +// let _ = slice[0]; +// let _ = slice.len(); +// } + +// fn test(){ +// // Fixed-size array (type signature is superfluous). +// let xs: [i32; 5] = [1, 2, 3, 4, 5]; + +// // All elements can be initialized to the same value. +// let ys: [i32; 500] = [0; 500]; + +// // Indexing starts at 0. +// let _ = xs[0]; +// let _ = xs[1]; + +// // `len` returns the count of elements in the array. +// let _ = xs.len(); + +// // Arrays can be automatically borrowed as slices. +// analyze_slice(&xs); + +// // Slices can point to a section of an array. +// // They are of the form [starting_index..ending_index]. +// // `starting_index` is the first position in the slice. +// // `ending_index` is one more than the last position in the slice. +// analyze_slice(&ys[1 .. 4]); + +// // Example of empty slice `&[]`: +// let empty_array: [u32; 0] = []; +// assert_eq!(&empty_array, &[]); +// assert_eq!(&empty_array, &[][..]); // Same but more verbose +// } From 0b6a19cf5ee90ee5f29edb29a284cce8460024b0 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 26 Nov 2024 15:32:37 +0100 Subject: [PATCH 25/35] snapshot --- engine/backends/coq/coq/coq_backend.ml | 2 +- examples/coverage/src/test_arrays.rs | 1 - test-harness/src/snapshots/toolchain__slices into-coq.snap | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index ba8134a56..fddc6757b 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -623,7 +623,7 @@ struct ^^ break 1)) ^^ break 1 ^^ CoqNotation.arguments (!^"Build_" ^^ name#p) - arguments_explicity_without_ty (* arguments_explicity_with_ty *) + arguments_explicity_without_ty (* arguments_explicity_with_ty *) ^^ concat_map_with ~pre:(break 1) (fun (ident, typ, attr) -> CoqNotation.arguments ident#p arguments_explicity_without_ty) diff --git a/examples/coverage/src/test_arrays.rs b/examples/coverage/src/test_arrays.rs index d6ab14e11..939f85f73 100644 --- a/examples/coverage/src/test_arrays.rs +++ b/examples/coverage/src/test_arrays.rs @@ -1,4 +1,3 @@ - // // This function borrows a slice. // fn analyze_slice(slice: &[i32]) { // let _ = slice[0]; diff --git a/test-harness/src/snapshots/toolchain__slices into-coq.snap b/test-harness/src/snapshots/toolchain__slices into-coq.snap index bd3ad5bbf..e73a5639c 100644 --- a/test-harness/src/snapshots/toolchain__slices into-coq.snap +++ b/test-harness/src/snapshots/toolchain__slices into-coq.snap @@ -54,7 +54,7 @@ Definition r#unsized '(_ : t_Array (t_Slice t_u8) ((1 : t_usize))) : unit := tt. Definition sized (x : t_Array (t_Array (t_u8) ((4 : t_usize))) ((1 : t_usize))) : unit := - r#unsized ([unsize (index (x) ((0 : t_usize)))]). + r#unsized ([unsize (Index_f_index (x) ((0 : t_usize)))]). ''' _CoqProject = ''' -R ./ TODO From b058cf80ab5ee5779efa2200b8fc6f14118a9d06 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Wed, 27 Nov 2024 09:15:17 +0100 Subject: [PATCH 26/35] CI? --- .github/workflows/extract_and_run_coq.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index ba12d3652..46a8f4976 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -26,7 +26,7 @@ jobs: run: | nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make install" + nix-shell --packages coq coqPackages.coq-record-update --run "sudo make install" - name: run coq - coverage working-directory: hax/examples/coverage/proofs/coq/extraction From 6d8a65393379a0d75c58a900584d883ed081d6c2 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Thu, 28 Nov 2024 14:45:58 +0100 Subject: [PATCH 27/35] wip --- .github/workflows/extract_and_run_coq.yml | 66 +++++++++++------------ examples/coverage/default.nix | 52 ++++++++++++++++++ flake.nix | 6 +++ 3 files changed, 91 insertions(+), 33 deletions(-) create mode 100644 examples/coverage/default.nix diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 46a8f4976..0cd929bef 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -14,40 +14,40 @@ jobs: - name: ⤵ Install hax run: | - nix profile install --verbose ./hax + nix build .\#coq-coverage-example - - name: build coverage example - working-directory: hax/examples/coverage - run: | - nix run . into coq + # - name: build coverage example + # working-directory: hax/examples/coverage + # run: | + # nix run . into coq - - name: install annotated core for coq - working-directory: hax/proof-libs/coq/coq/generated-core - run: | - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "sudo make install" + # - name: install annotated core for coq + # working-directory: hax/proof-libs/coq/coq/generated-core + # run: | + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "sudo make install" - - name: run coq - coverage - working-directory: hax/examples/coverage/proofs/coq/extraction - run: | - sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" - nix-shell --packages coq coqPackages.coq-record-update --run "make" + # - name: run coq - coverage + # working-directory: hax/examples/coverage/proofs/coq/extraction + # run: | + # sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" + # nix-shell --packages coq coqPackages.coq-record-update --run "make" - - name: build and run coq on tests - env: - FILES: assert attribute-opaque enum-struct-variant - NOT_SUPPORTED_FILES: attributes cli conditional-match constructor-as-closure cyclic-modules enum-repr even dyn functions - run: | - for f in $FILES; do \ - cd hax/tests/$f && \ - nix run . into coq && \ - cd ../../.. - done - for f in $FILES; do \ - cd hax/tests/$f/proofs/coq/extraction && \ - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ - cd ../../../../../../ - done + # - name: build and run coq on tests + # env: + # FILES: assert attribute-opaque enum-struct-variant + # NOT_SUPPORTED_FILES: attributes cli conditional-match constructor-as-closure cyclic-modules enum-repr even dyn functions + # run: | + # for f in $FILES; do \ + # cd hax/tests/$f && \ + # nix run . into coq && \ + # cd ../../.. + # done + # for f in $FILES; do \ + # cd hax/tests/$f/proofs/coq/extraction && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ + # cd ../../../../../../ + # done diff --git a/examples/coverage/default.nix b/examples/coverage/default.nix new file mode 100644 index 000000000..4cfe65fdb --- /dev/null +++ b/examples/coverage/default.nix @@ -0,0 +1,52 @@ +{ + stdenv, + lib, + hax, + coqPackages, + gnused, + craneLib, +}: +let + commonArgs = { + version = "0.1.0"; + src = craneLib.cleanCargoSource ../..; + doCheck = false; + cargoLockListrgoVendorDir = craneLib.vendorMultipleCargoDeps { + cargoLockList = [ + ../Cargo.lock + ../../Cargo.lock + ]; + }; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in + craneLib.mkCargoDerivation (commonArgs + // { + inherit cargoArtifacts; + pname = "coverage"; + doCheck = false; + buildPhaseCargoCommand = '' + cp -r --no-preserve=mode ${../../proof-libs/coq/coq/generated-core} generated-core + + cd generated-core + + coq_makefile -f _CoqProject -o Makefile + make + sudo make install + + cd ../examples/coverage + + cargo hax into coq + cd proofs/coq/extraction + + sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. + coq_makefile -f _CoqProject -o Makefile + make + ''; + buildInputs = [ + hax + coqPackages.coq-record-update + coqPackages.coq + gnused + ]; + }) diff --git a/flake.nix b/flake.nix index 168556d28..cf7f1e499 100644 --- a/flake.nix +++ b/flake.nix @@ -91,6 +91,12 @@ check-examples = checks.examples; check-readme-coherency = checks.readme-coherency; + coq-coverage-example = pkgs.callPackage ./examples/coverage { + inherit (packages) hax; + inherit (pkgs) coqPackages; + inherit craneLib; + }; + rust-by-example-hax-extraction = pkgs.stdenv.mkDerivation { name = "rust-by-example-hax-extraction"; phases = ["installPhase"]; From ff429a0b95f71f4db767d2988356b164b33e02c2 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 15:11:08 +0100 Subject: [PATCH 28/35] Fix tests --- examples/coverage/src/test_instance.rs | 38 +++++++++---------- .../snapshots/toolchain__assert into-coq.snap | 1 + .../toolchain__enum-repr into-coq.snap | 1 + .../snapshots/toolchain__guards into-coq.snap | 1 + .../toolchain__include-flag into-coq.snap | 1 + .../toolchain__let-else into-coq.snap | 1 + .../toolchain__literals into-coq.snap | 3 +- .../toolchain__pattern-or into-coq.snap | 1 + .../toolchain__reordering into-coq.snap | 1 + .../snapshots/toolchain__slices into-coq.snap | 1 + 10 files changed, 29 insertions(+), 20 deletions(-) diff --git a/examples/coverage/src/test_instance.rs b/examples/coverage/src/test_instance.rs index bee6c8ff8..81f8d1204 100644 --- a/examples/coverage/src/test_instance.rs +++ b/examples/coverage/src/test_instance.rs @@ -1,21 +1,21 @@ -enum SomeEnum { - None, - Some(T), -} +// enum SomeEnum { +// None, +// Some(T), +// } -trait SomeTrait { - fn some_fun(&self) -> Self; -} +// trait SomeTrait { +// fn some_fun(&self) -> Self; +// } -impl SomeTrait for SomeEnum -where - T: SomeTrait, -{ - #[inline] - fn some_fun(&self) -> Self { - match self { - SomeEnum::Some(x) => SomeEnum::Some(x.some_fun()), - SomeEnum::None => SomeEnum::None, - } - } -} +// impl SomeTrait for SomeEnum +// where +// T: SomeTrait, +// { +// #[inline] +// fn some_fun(&self) -> Self { +// match self { +// SomeEnum::Some(x) => SomeEnum::Some(x.some_fun()), +// SomeEnum::None => SomeEnum::None, +// } +// } +// } diff --git a/test-harness/src/snapshots/toolchain__assert into-coq.snap b/test-harness/src/snapshots/toolchain__assert into-coq.snap index 47726eeab..6f94866e0 100644 --- a/test-harness/src/snapshots/toolchain__assert into-coq.snap +++ b/test-harness/src/snapshots/toolchain__assert into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition asserts '(_ : unit) : unit := diff --git a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap index 946d341be..7293ed72f 100644 --- a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap +++ b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + Definition discriminant_EnumWithRepr_ExplicitDiscr1 : t_u16 := (1 : t_u16). diff --git a/test-harness/src/snapshots/toolchain__guards into-coq.snap b/test-harness/src/snapshots/toolchain__guards into-coq.snap index 3fa858d26..739f6efe8 100644 --- a/test-harness/src/snapshots/toolchain__guards into-coq.snap +++ b/test-harness/src/snapshots/toolchain__guards into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := diff --git a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap index 0f711be0c..4e449530c 100644 --- a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap +++ b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + Record t_Foo : Type := { }. diff --git a/test-harness/src/snapshots/toolchain__let-else into-coq.snap b/test-harness/src/snapshots/toolchain__let-else into-coq.snap index 1fcdb664b..1f3aeb359 100644 --- a/test-harness/src/snapshots/toolchain__let-else into-coq.snap +++ b/test-harness/src/snapshots/toolchain__let-else into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition let_else (opt : t_Option ((t_u32))) : bool := diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index 9bbcfea03..c9fa99b7d 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + From Literals Require Import Hax_lib (t_int). Export Hax_lib (t_int). @@ -100,7 +101,7 @@ Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___un impl__Int__to_u8 (Add_f_add (x) (Mul_f_mul (x) (x))). Definition null : ascii := - "\000"%char. + ("\000"%char : ascii). Definition numeric '(_ : unit) : unit := let _ : t_usize := (123 : t_usize) in diff --git a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap index 4c8311cfb..10ed9a1f3 100644 --- a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap +++ b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + Inductive t_E : Type := | E_A | E_B. diff --git a/test-harness/src/snapshots/toolchain__reordering into-coq.snap b/test-harness/src/snapshots/toolchain__reordering into-coq.snap index caa800942..648f01f46 100644 --- a/test-harness/src/snapshots/toolchain__reordering into-coq.snap +++ b/test-harness/src/snapshots/toolchain__reordering into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + Inductive t_Foo : Type := | Foo_A | Foo_B. diff --git a/test-harness/src/snapshots/toolchain__slices into-coq.snap b/test-harness/src/snapshots/toolchain__slices into-coq.snap index e73a5639c..80cde0df4 100644 --- a/test-harness/src/snapshots/toolchain__slices into-coq.snap +++ b/test-harness/src/snapshots/toolchain__slices into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition v_VERSION : t_Slice t_u8 := From 13b86ce33b409fd0da33bf3d8f55e6d4f5346000 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 15:11:08 +0100 Subject: [PATCH 29/35] Fix tests --- examples/coverage/src/test_instance.rs | 38 +++++++++---------- .../snapshots/toolchain__assert into-coq.snap | 1 + .../toolchain__enum-repr into-coq.snap | 1 + .../snapshots/toolchain__guards into-coq.snap | 1 + .../toolchain__include-flag into-coq.snap | 1 + .../toolchain__let-else into-coq.snap | 1 + .../toolchain__literals into-coq.snap | 3 +- .../toolchain__pattern-or into-coq.snap | 1 + .../toolchain__reordering into-coq.snap | 1 + .../snapshots/toolchain__slices into-coq.snap | 1 + 10 files changed, 29 insertions(+), 20 deletions(-) diff --git a/examples/coverage/src/test_instance.rs b/examples/coverage/src/test_instance.rs index bee6c8ff8..81f8d1204 100644 --- a/examples/coverage/src/test_instance.rs +++ b/examples/coverage/src/test_instance.rs @@ -1,21 +1,21 @@ -enum SomeEnum { - None, - Some(T), -} +// enum SomeEnum { +// None, +// Some(T), +// } -trait SomeTrait { - fn some_fun(&self) -> Self; -} +// trait SomeTrait { +// fn some_fun(&self) -> Self; +// } -impl SomeTrait for SomeEnum -where - T: SomeTrait, -{ - #[inline] - fn some_fun(&self) -> Self { - match self { - SomeEnum::Some(x) => SomeEnum::Some(x.some_fun()), - SomeEnum::None => SomeEnum::None, - } - } -} +// impl SomeTrait for SomeEnum +// where +// T: SomeTrait, +// { +// #[inline] +// fn some_fun(&self) -> Self { +// match self { +// SomeEnum::Some(x) => SomeEnum::Some(x.some_fun()), +// SomeEnum::None => SomeEnum::None, +// } +// } +// } diff --git a/test-harness/src/snapshots/toolchain__assert into-coq.snap b/test-harness/src/snapshots/toolchain__assert into-coq.snap index 47726eeab..6f94866e0 100644 --- a/test-harness/src/snapshots/toolchain__assert into-coq.snap +++ b/test-harness/src/snapshots/toolchain__assert into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition asserts '(_ : unit) : unit := diff --git a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap index 946d341be..7293ed72f 100644 --- a/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap +++ b/test-harness/src/snapshots/toolchain__enum-repr into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + Definition discriminant_EnumWithRepr_ExplicitDiscr1 : t_u16 := (1 : t_u16). diff --git a/test-harness/src/snapshots/toolchain__guards into-coq.snap b/test-harness/src/snapshots/toolchain__guards into-coq.snap index 3fa858d26..739f6efe8 100644 --- a/test-harness/src/snapshots/toolchain__guards into-coq.snap +++ b/test-harness/src/snapshots/toolchain__guards into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition equivalent (x : t_Option ((t_Result ((t_i32)) ((t_i32))))) : t_i32 := diff --git a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap index 0f711be0c..4e449530c 100644 --- a/test-harness/src/snapshots/toolchain__include-flag into-coq.snap +++ b/test-harness/src/snapshots/toolchain__include-flag into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + Record t_Foo : Type := { }. diff --git a/test-harness/src/snapshots/toolchain__let-else into-coq.snap b/test-harness/src/snapshots/toolchain__let-else into-coq.snap index 1fcdb664b..1f3aeb359 100644 --- a/test-harness/src/snapshots/toolchain__let-else into-coq.snap +++ b/test-harness/src/snapshots/toolchain__let-else into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition let_else (opt : t_Option ((t_u32))) : bool := diff --git a/test-harness/src/snapshots/toolchain__literals into-coq.snap b/test-harness/src/snapshots/toolchain__literals into-coq.snap index 9bbcfea03..c9fa99b7d 100644 --- a/test-harness/src/snapshots/toolchain__literals into-coq.snap +++ b/test-harness/src/snapshots/toolchain__literals into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + From Literals Require Import Hax_lib (t_int). Export Hax_lib (t_int). @@ -100,7 +101,7 @@ Definition math_integers (x : t_Int) `{andb (PartialOrd_f_gt (x) (impl__Int___un impl__Int__to_u8 (Add_f_add (x) (Mul_f_mul (x) (x))). Definition null : ascii := - "\000"%char. + ("\000"%char : ascii). Definition numeric '(_ : unit) : unit := let _ : t_usize := (123 : t_usize) in diff --git a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap index 4c8311cfb..10ed9a1f3 100644 --- a/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap +++ b/test-harness/src/snapshots/toolchain__pattern-or into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + Inductive t_E : Type := | E_A | E_B. diff --git a/test-harness/src/snapshots/toolchain__reordering into-coq.snap b/test-harness/src/snapshots/toolchain__reordering into-coq.snap index caa800942..648f01f46 100644 --- a/test-harness/src/snapshots/toolchain__reordering into-coq.snap +++ b/test-harness/src/snapshots/toolchain__reordering into-coq.snap @@ -41,6 +41,7 @@ Import RecordSetNotations. From Core Require Import Core. + Inductive t_Foo : Type := | Foo_A | Foo_B. diff --git a/test-harness/src/snapshots/toolchain__slices into-coq.snap b/test-harness/src/snapshots/toolchain__slices into-coq.snap index e73a5639c..80cde0df4 100644 --- a/test-harness/src/snapshots/toolchain__slices into-coq.snap +++ b/test-harness/src/snapshots/toolchain__slices into-coq.snap @@ -42,6 +42,7 @@ Import RecordSetNotations. From Core Require Import Core. + (* NotImplementedYet *) Definition v_VERSION : t_Slice t_u8 := From 197d1a362b436c4bc7a1b47cd2fb72ee6b11d0ff Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Thu, 28 Nov 2024 14:45:58 +0100 Subject: [PATCH 30/35] CI: nix files for coq coverage example and library --- .github/workflows/extract_and_run_coq.yml | 66 +++++++++++------------ examples/commonArgs.nix | 26 +++++++++ examples/coverage/default.nix | 38 +++++++++++++ examples/default.nix | 21 +------- flake.nix | 6 +++ proof-libs/coq/coq/default.nix | 22 ++++++++ 6 files changed, 126 insertions(+), 53 deletions(-) create mode 100644 examples/commonArgs.nix create mode 100644 examples/coverage/default.nix create mode 100644 proof-libs/coq/coq/default.nix diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 46a8f4976..0cd929bef 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -14,40 +14,40 @@ jobs: - name: ⤵ Install hax run: | - nix profile install --verbose ./hax + nix build .\#coq-coverage-example - - name: build coverage example - working-directory: hax/examples/coverage - run: | - nix run . into coq + # - name: build coverage example + # working-directory: hax/examples/coverage + # run: | + # nix run . into coq - - name: install annotated core for coq - working-directory: hax/proof-libs/coq/coq/generated-core - run: | - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "sudo make install" + # - name: install annotated core for coq + # working-directory: hax/proof-libs/coq/coq/generated-core + # run: | + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "sudo make install" - - name: run coq - coverage - working-directory: hax/examples/coverage/proofs/coq/extraction - run: | - sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" - nix-shell --packages coq coqPackages.coq-record-update --run "make" + # - name: run coq - coverage + # working-directory: hax/examples/coverage/proofs/coq/extraction + # run: | + # sed 's/_impl_f_/_f_/' < Coverage_Test_instance.v > Coverage_Test_instance.v # TODO: this is a hotfix, should be solved in backend and removed from here. + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" + # nix-shell --packages coq coqPackages.coq-record-update --run "make" - - name: build and run coq on tests - env: - FILES: assert attribute-opaque enum-struct-variant - NOT_SUPPORTED_FILES: attributes cli conditional-match constructor-as-closure cyclic-modules enum-repr even dyn functions - run: | - for f in $FILES; do \ - cd hax/tests/$f && \ - nix run . into coq && \ - cd ../../.. - done - for f in $FILES; do \ - cd hax/tests/$f/proofs/coq/extraction && \ - nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ - nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ - cd ../../../../../../ - done + # - name: build and run coq on tests + # env: + # FILES: assert attribute-opaque enum-struct-variant + # NOT_SUPPORTED_FILES: attributes cli conditional-match constructor-as-closure cyclic-modules enum-repr even dyn functions + # run: | + # for f in $FILES; do \ + # cd hax/tests/$f && \ + # nix run . into coq && \ + # cd ../../.. + # done + # for f in $FILES; do \ + # cd hax/tests/$f/proofs/coq/extraction && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "coq_makefile -f _CoqProject -o Makefile" && \ + # nix-shell --packages coq coqPackages.coq-record-update --run "make" && \ + # cd ../../../../../../ + # done diff --git a/examples/commonArgs.nix b/examples/commonArgs.nix new file mode 100644 index 000000000..6238f52ea --- /dev/null +++ b/examples/commonArgs.nix @@ -0,0 +1,26 @@ +{ + craneLib, + lib, +}: +let + matches = re: path: !builtins.isNull (builtins.match re path); +in +{ + version = "0.0.1"; + src = lib.cleanSourceWith { + src = craneLib.path ./..; + filter = path: type: + # We include only certain files. FStar files under the example + # directory are listed out. Same for proverif (*.pvl) files. + ( matches ".*(Makefile|.*[.](rs|toml|lock|diff|fsti?|pv))$" path + && !matches ".*examples/.*[.]fsti?$" path + ) || ("directory" == type); + }; + doCheck = false; + cargoVendorDir = craneLib.vendorMultipleCargoDeps { + cargoLockList = [ + ./Cargo.lock + ../Cargo.lock + ]; + }; +} diff --git a/examples/coverage/default.nix b/examples/coverage/default.nix new file mode 100644 index 000000000..abc457c6a --- /dev/null +++ b/examples/coverage/default.nix @@ -0,0 +1,38 @@ +{ + stdenv, + lib, + hax, + coqPackages, + gnused, + craneLib, + bat, + coqGeneratedCore ? import ../../proof-libs/coq/coq {inherit stdenv coqPackages;}, +}: +let + commonArgs = import ../commonArgs.nix {inherit craneLib lib;}; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in + craneLib.mkCargoDerivation (commonArgs + // { + inherit cargoArtifacts; + pname = "coverage"; + doCheck = false; + buildPhaseCargoCommand = '' + cd examples/coverage + cargo hax into coq + + cd proofs/coq/extraction + echo -e "-R ${coqGeneratedCore}/lib/coq/user-contrib/Core Core\n$(cat _CoqProject)" > _CoqProject + coq_makefile -f _CoqProject -o Makefile + make + ''; + buildInputs = [ + hax + coqPackages.coq-record-update + coqPackages.coq + gnused + ]; + }) + + + # COQLIB diff --git a/examples/default.nix b/examples/default.nix index bd602e515..29f68c404 100644 --- a/examples/default.nix +++ b/examples/default.nix @@ -9,26 +9,7 @@ jq, proverif, }: let - matches = re: path: !builtins.isNull (builtins.match re path); - commonArgs = { - version = "0.0.1"; - src = lib.cleanSourceWith { - src = craneLib.path ./..; - filter = path: type: - # We include only certain files. FStar files under the example - # directory are listed out. Same for proverif (*.pvl) files. - ( matches ".*(Makefile|.*[.](rs|toml|lock|diff|fsti?|pv))$" path - && !matches ".*examples/.*[.]fsti?$" path - ) || ("directory" == type); - }; - doCheck = false; - cargoVendorDir = craneLib.vendorMultipleCargoDeps { - cargoLockList = [ - ./Cargo.lock - ../Cargo.lock - ]; - }; - }; + commonArgs = import ./commonArgs.nix {inherit craneLib lib;}; cargoArtifacts = craneLib.buildDepsOnly commonArgs; in craneLib.mkCargoDerivation (commonArgs diff --git a/flake.nix b/flake.nix index 168556d28..cf7f1e499 100644 --- a/flake.nix +++ b/flake.nix @@ -91,6 +91,12 @@ check-examples = checks.examples; check-readme-coherency = checks.readme-coherency; + coq-coverage-example = pkgs.callPackage ./examples/coverage { + inherit (packages) hax; + inherit (pkgs) coqPackages; + inherit craneLib; + }; + rust-by-example-hax-extraction = pkgs.stdenv.mkDerivation { name = "rust-by-example-hax-extraction"; phases = ["installPhase"]; diff --git a/proof-libs/coq/coq/default.nix b/proof-libs/coq/coq/default.nix new file mode 100644 index 000000000..d0ccfd8f0 --- /dev/null +++ b/proof-libs/coq/coq/default.nix @@ -0,0 +1,22 @@ +{ + stdenv ? (import {}).stdenv, + coqPackages ? (import {}).coqPackages, +}: +stdenv.mkDerivation { + name = "hax-coq-generated-core"; + src = ./generated-core; + buildPhase = '' + coq_makefile -f _CoqProject -o Makefile + make + ''; + installPhase = '' + export DESTDIR=$out + make install + mv $out/nix/store/*/lib $out + rm -rf $out/nix + ''; + buildInputs = [ + coqPackages.coq-record-update + coqPackages.coq + ]; +} From 71e0a6568acc6237bf37e3487b9a139945135752 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 18:30:11 +0100 Subject: [PATCH 31/35] Fixed coverage tests --- engine/backends/coq/coq/coq_backend.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index fddc6757b..24cc1b919 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -641,10 +641,12 @@ struct ^^ concat_map_with ~pre:space (fun (x : generic_param) -> match x with - | { ident; _ } -> - (self#_do_not_override_lazy_of_local_ident - AstPos_item'_Type_generics ident) - #p) + | { ident; _ } -> + let idx = (self#_do_not_override_lazy_of_local_ident + AstPos_item'_Type_generics ident) + #p + in + parens(idx ^^ space ^^ !^":=" ^^ space ^^ idx) ) generics#v.params) ^^ space ^^ string "<" ^^ separate_map (semi ^^ space) From 7b28517c73ee8fd57b5d094a707719d93b37d7e5 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 18:36:32 +0100 Subject: [PATCH 32/35] CI --- .github/workflows/extract_and_run_coq.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 0cd929bef..5b08decda 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -13,6 +13,7 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@main - name: ⤵ Install hax + working-directory: hax run: | nix build .\#coq-coverage-example From a1d69f13d3f9127ba6fa9ef60a17d384088d93c2 Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 18:44:47 +0100 Subject: [PATCH 33/35] fmt --- .github/workflows/extract_and_run_coq.yml | 4 ---- engine/backends/coq/coq/coq_backend.ml | 11 ++++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/extract_and_run_coq.yml b/.github/workflows/extract_and_run_coq.yml index 5b08decda..e5bd83514 100644 --- a/.github/workflows/extract_and_run_coq.yml +++ b/.github/workflows/extract_and_run_coq.yml @@ -6,14 +6,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - path: hax - - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - name: ⤵ Install hax - working-directory: hax run: | nix build .\#coq-coverage-example diff --git a/engine/backends/coq/coq/coq_backend.ml b/engine/backends/coq/coq/coq_backend.ml index 24cc1b919..6862028d7 100644 --- a/engine/backends/coq/coq/coq_backend.ml +++ b/engine/backends/coq/coq/coq_backend.ml @@ -641,12 +641,13 @@ struct ^^ concat_map_with ~pre:space (fun (x : generic_param) -> match x with - | { ident; _ } -> - let idx = (self#_do_not_override_lazy_of_local_ident - AstPos_item'_Type_generics ident) - #p + | { ident; _ } -> + let idx = + (self#_do_not_override_lazy_of_local_ident + AstPos_item'_Type_generics ident) + #p in - parens(idx ^^ space ^^ !^":=" ^^ space ^^ idx) ) + parens (idx ^^ space ^^ !^":=" ^^ space ^^ idx)) generics#v.params) ^^ space ^^ string "<" ^^ separate_map (semi ^^ space) From d58eb4fe1a7670836581bd55c68789a5ac1d8f8e Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Thu, 28 Nov 2024 19:16:38 +0100 Subject: [PATCH 34/35] snapshot --- .../src/snapshots/toolchain__traits into-fstar.snap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test-harness/src/snapshots/toolchain__traits into-fstar.snap b/test-harness/src/snapshots/toolchain__traits into-fstar.snap index 3ada99292..fcc166dc9 100644 --- a/test-harness/src/snapshots/toolchain__traits into-fstar.snap +++ b/test-harness/src/snapshots/toolchain__traits into-fstar.snap @@ -55,7 +55,7 @@ open FStar.Mul class t_Bar (v_Self: Type0) (v_T: Type0) = { __marker_trait_t_Bar:Prims.unit } class t_Foo (v_Self: Type0) = { - [@@@ FStar.Tactics.Typeclasses.no_method]_super_12056653545434731362:t_Bar v_Self f_U; + [@@@ FStar.Tactics.Typeclasses.no_method]_super_5461126672499050919:t_Bar v_Self f_U; f_U:Type0 } ''' @@ -391,7 +391,7 @@ class t_SubTrait (v_Self: Type0) (v_TypeArg: Type0) (v_ConstArg: usize) = { v_TypeArg v_ConstArg; f_AssocType:Type0; - f_AssocType_10469511598065652520:t_Trait f_AssocType v_TypeArg v_ConstArg + f_AssocType_5566993444404141271:t_Trait f_AssocType v_TypeArg v_ConstArg } ''' "Traits.Interlaced_consts_types.fst" = ''' @@ -468,7 +468,7 @@ open FStar.Mul class t_Trait1 (v_Self: Type0) = { f_T:Type0; - f_T_1640036513185240095:t_Trait1 f_T + f_T_7805326132379548775:t_Trait1 f_T } class t_Trait2 (v_Self: Type0) = { @@ -613,8 +613,8 @@ let use_impl_trait (_: Prims.unit) : Prims.unit = class t_Foo (v_Self: Type0) = { f_AssocType:Type0; - f_AssocType_15525962639250476383:t_SuperTrait f_AssocType; - f_AssocType_17265963849229885182:Core.Clone.t_Clone f_AssocType; + f_AssocType_15012754260415912210:t_SuperTrait f_AssocType; + f_AssocType_3242921639065184873:Core.Clone.t_Clone f_AssocType; f_N:usize; f_assoc_f_pre:Prims.unit -> Type0; f_assoc_f_post:Prims.unit -> Prims.unit -> Type0; @@ -651,7 +651,7 @@ let g (#v_T: Type0) (#[FStar.Tactics.Typeclasses.tcresolve ()] i1: t_Foo v_T) (x let impl_Foo_for_tuple_: t_Foo Prims.unit = { f_AssocType = i32; - f_AssocType_15525962639250476383 = FStar.Tactics.Typeclasses.solve; + f_AssocType_15012754260415912210 = FStar.Tactics.Typeclasses.solve; f_N = sz 32; f_assoc_f_pre = (fun (_: Prims.unit) -> true); f_assoc_f_post = (fun (_: Prims.unit) (out: Prims.unit) -> true); From 77687e6b907d7e8da93db7a6c5165cd6a80cadaf Mon Sep 17 00:00:00 2001 From: Lasse Letager Hansen Date: Tue, 10 Dec 2024 15:09:13 +0100 Subject: [PATCH 35/35] Typo --- .../src/Core_Base_interface_Int.v | 414 +++++++++--------- 1 file changed, 207 insertions(+), 207 deletions(-) diff --git a/proof-libs/coq/coq/generated-core/src/Core_Base_interface_Int.v b/proof-libs/coq/coq/generated-core/src/Core_Base_interface_Int.v index 0fa9edfaf..de6d3af4d 100644 --- a/proof-libs/coq/coq/generated-core/src/Core_Base_interface_Int.v +++ b/proof-libs/coq/coq/generated-core/src/Core_Base_interface_Int.v @@ -441,19 +441,19 @@ Definition impl_219__WORDSIZE : t_HaxInt := Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (Abstraction_f_lift (x) : t_Z); }. -#[globa] Instance t_From_106548803 : t_From ((t_I32)) ((t_I128)) := +#[global] Instance t_From_106548803 : t_From ((t_I32)) ((t_I128)) := { From_f_from := fun (x : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (Abstraction_f_lift (x) : t_Z); }. -#[globa] Instance t_From_237552649 : t_From ((t_I64)) ((t_I128)) := +#[global] Instance t_From_237552649 : t_From ((t_I64)) ((t_I128)) := { From_f_from := fun (x : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (Abstraction_f_lift (x) : t_Z); }. -#[globa] Instance t_PartialEq_488790252 : t_PartialEq ((t_I128)) ((t_I128)) := +#[global] Instance t_PartialEq_488790252 : t_PartialEq ((t_I128)) ((t_I128)) := { PartialEq_f_eq := fun (self : t_I128) (rhs : t_I128)=> PartialEq_f_eq (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -461,7 +461,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_387128921 : t_PartialOrd ((t_I128)) ((t_I128)) := +#[global] Instance t_PartialOrd_387128921 : t_PartialOrd ((t_I128)) ((t_I128)) := { PartialOrd_f_partial_cmp := fun (self : t_I128) (rhs : t_I128)=> Option_Some (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -497,38 +497,38 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_692501606 : t_Abstraction ((t_I64)) := +#[global] Instance t_Abstraction_692501606 : t_Abstraction ((t_I64)) := { Abstraction_f_AbstractType := t_Z; Abstraction_f_lift := fun (self : t_I64)=> I64_f_v self; }. -#[globa] Instance t_From_318313768 : t_From ((t_I8)) ((t_I64)) := +#[global] Instance t_From_318313768 : t_From ((t_I8)) ((t_I64)) := { From_f_from := fun (x : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_215423074 : t_From ((t_I16)) ((t_I64)) := +#[global] Instance t_From_215423074 : t_From ((t_I16)) ((t_I64)) := { From_f_from := fun (x : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_221659723 : t_From ((t_I32)) ((t_I64)) := +#[global] Instance t_From_221659723 : t_From ((t_I32)) ((t_I64)) := { From_f_from := fun (x : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_927453474 : t_From ((t_I128)) ((t_I64)) := +#[global] Instance t_From_927453474 : t_From ((t_I128)) ((t_I64)) := { From_f_from := fun (x : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_PartialEq_474861724 : t_PartialEq ((t_I64)) ((t_I64)) := +#[global] Instance t_PartialEq_474861724 : t_PartialEq ((t_I64)) ((t_I64)) := { PartialEq_f_eq := fun (self : t_I64) (rhs : t_I64)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -536,7 +536,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_552634265 : t_PartialOrd ((t_I64)) ((t_I64)) := +#[global] Instance t_PartialOrd_552634265 : t_PartialOrd ((t_I64)) ((t_I64)) := { PartialOrd_f_partial_cmp := fun (self : t_I64) (rhs : t_I64)=> Option_Some (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -572,38 +572,38 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_493183574 : t_Abstraction ((t_I32)) := +#[global] Instance t_Abstraction_493183574 : t_Abstraction ((t_I32)) := { Abstraction_f_AbstractType := t_Z; Abstraction_f_lift := fun (self : t_I32)=> I32_f_v self; }. -#[globa] Instance t_From_573287156 : t_From ((t_I8)) ((t_I32)) := +#[global] Instance t_From_573287156 : t_From ((t_I8)) ((t_I32)) := { From_f_from := fun (x : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_278670998 : t_From ((t_I16)) ((t_I32)) := +#[global] Instance t_From_278670998 : t_From ((t_I16)) ((t_I32)) := { From_f_from := fun (x : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_697572388 : t_From ((t_I64)) ((t_I32)) := +#[global] Instance t_From_697572388 : t_From ((t_I64)) ((t_I32)) := { From_f_from := fun (x : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_30146175 : t_From ((t_I128)) ((t_I32)) := +#[global] Instance t_From_30146175 : t_From ((t_I128)) ((t_I32)) := { From_f_from := fun (x : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_PartialEq_795859780 : t_PartialEq ((t_I32)) ((t_I32)) := +#[global] Instance t_PartialEq_795859780 : t_PartialEq ((t_I32)) ((t_I32)) := { PartialEq_f_eq := fun (self : t_I32) (rhs : t_I32)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -611,7 +611,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_126468614 : t_PartialOrd ((t_I32)) ((t_I32)) := +#[global] Instance t_PartialOrd_126468614 : t_PartialOrd ((t_I32)) ((t_I32)) := { PartialOrd_f_partial_cmp := fun (self : t_I32) (rhs : t_I32)=> Option_Some (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -647,38 +647,38 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_8671741 : t_Abstraction ((t_I16)) := +#[global] Instance t_Abstraction_8671741 : t_Abstraction ((t_I16)) := { Abstraction_f_AbstractType := t_Z; Abstraction_f_lift := fun (self : t_I16)=> I16_f_v self; }. -#[globa] Instance t_From_767089390 : t_From ((t_I8)) ((t_I16)) := +#[global] Instance t_From_767089390 : t_From ((t_I8)) ((t_I16)) := { From_f_from := fun (x : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_339600325 : t_From ((t_I32)) ((t_I16)) := +#[global] Instance t_From_339600325 : t_From ((t_I32)) ((t_I16)) := { From_f_from := fun (x : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_929749154 : t_From ((t_I64)) ((t_I16)) := +#[global] Instance t_From_929749154 : t_From ((t_I64)) ((t_I16)) := { From_f_from := fun (x : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_366897745 : t_From ((t_I128)) ((t_I16)) := +#[global] Instance t_From_366897745 : t_From ((t_I128)) ((t_I16)) := { From_f_from := fun (x : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_PartialEq_359538097 : t_PartialEq ((t_I16)) ((t_I16)) := +#[global] Instance t_PartialEq_359538097 : t_PartialEq ((t_I16)) ((t_I16)) := { PartialEq_f_eq := fun (self : t_I16) (rhs : t_I16)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -686,7 +686,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_524872806 : t_PartialOrd ((t_I16)) ((t_I16)) := +#[global] Instance t_PartialOrd_524872806 : t_PartialOrd ((t_I16)) ((t_I16)) := { PartialOrd_f_partial_cmp := fun (self : t_I16) (rhs : t_I16)=> Option_Some (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -722,38 +722,38 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_78490685 : t_Abstraction ((t_I8)) := +#[global] Instance t_Abstraction_78490685 : t_Abstraction ((t_I8)) := { Abstraction_f_AbstractType := t_Z; Abstraction_f_lift := fun (self : t_I8)=> I8_f_v self; }. -#[globa] Instance t_From_995744130 : t_From ((t_I16)) ((t_I8)) := +#[global] Instance t_From_995744130 : t_From ((t_I16)) ((t_I8)) := { From_f_from := fun (x : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_513826093 : t_From ((t_I32)) ((t_I8)) := +#[global] Instance t_From_513826093 : t_From ((t_I32)) ((t_I8)) := { From_f_from := fun (x : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_843443999 : t_From ((t_I64)) ((t_I8)) := +#[global] Instance t_From_843443999 : t_From ((t_I64)) ((t_I8)) := { From_f_from := fun (x : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_532428771 : t_From ((t_I128)) ((t_I8)) := +#[global] Instance t_From_532428771 : t_From ((t_I128)) ((t_I8)) := { From_f_from := fun (x : t_I8)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_Z t_I128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_PartialEq_594648758 : t_PartialEq ((t_I8)) ((t_I8)) := +#[global] Instance t_PartialEq_594648758 : t_PartialEq ((t_I8)) ((t_I8)) := { PartialEq_f_eq := fun (self : t_I8) (rhs : t_I8)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -761,7 +761,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_221919414 : t_PartialOrd ((t_I8)) ((t_I8)) := +#[global] Instance t_PartialOrd_221919414 : t_PartialOrd ((t_I8)) ((t_I8)) := { PartialOrd_f_partial_cmp := fun (self : t_I8) (rhs : t_I8)=> Option_Some (z_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -797,14 +797,14 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_133243863 : t_Abstraction ((t_U128)) := +#[global] Instance t_Abstraction_133243863 : t_Abstraction ((t_U128)) := { Abstraction_f_AbstractType := t_HaxInt; Abstraction_f_lift := fun (self : t_U128)=> U128_f_v self; }. -#[globa] Instance t_PartialEq_792968920 : t_PartialEq ((t_U128)) ((t_U128)) := +#[global] Instance t_PartialEq_792968920 : t_PartialEq ((t_U128)) ((t_U128)) := { PartialEq_f_eq := fun (self : t_U128) (rhs : t_U128)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -812,7 +812,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_168269581 : t_PartialOrd ((t_U128)) ((t_U128)) := +#[global] Instance t_PartialOrd_168269581 : t_PartialOrd ((t_U128)) ((t_U128)) := { PartialOrd_f_partial_cmp := fun (self : t_U128) (rhs : t_U128)=> Option_Some (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -848,14 +848,14 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_219241396 : t_Abstraction ((t_U64)) := +#[global] Instance t_Abstraction_219241396 : t_Abstraction ((t_U64)) := { Abstraction_f_AbstractType := t_HaxInt; Abstraction_f_lift := fun (self : t_U64)=> U64_f_v self; }. -#[globa] Instance t_PartialEq_162514109 : t_PartialEq ((t_U64)) ((t_U64)) := +#[global] Instance t_PartialEq_162514109 : t_PartialEq ((t_U64)) ((t_U64)) := { PartialEq_f_eq := fun (self : t_U64) (rhs : t_U64)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -863,7 +863,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_210240032 : t_PartialOrd ((t_U64)) ((t_U64)) := +#[global] Instance t_PartialOrd_210240032 : t_PartialOrd ((t_U64)) ((t_U64)) := { PartialOrd_f_partial_cmp := fun (self : t_U64) (rhs : t_U64)=> Option_Some (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -899,14 +899,14 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_517050128 : t_Abstraction ((t_U32)) := +#[global] Instance t_Abstraction_517050128 : t_Abstraction ((t_U32)) := { Abstraction_f_AbstractType := t_HaxInt; Abstraction_f_lift := fun (self : t_U32)=> U32_f_v self; }. -#[globa] Instance t_PartialEq_894496962 : t_PartialEq ((t_U32)) ((t_U32)) := +#[global] Instance t_PartialEq_894496962 : t_PartialEq ((t_U32)) ((t_U32)) := { PartialEq_f_eq := fun (self : t_U32) (rhs : t_U32)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -914,7 +914,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_534404445 : t_PartialOrd ((t_U32)) ((t_U32)) := +#[global] Instance t_PartialOrd_534404445 : t_PartialOrd ((t_U32)) ((t_U32)) := { PartialOrd_f_partial_cmp := fun (self : t_U32) (rhs : t_U32)=> Option_Some (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -950,14 +950,14 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_994821584 : t_Abstraction ((t_U16)) := +#[global] Instance t_Abstraction_994821584 : t_Abstraction ((t_U16)) := { Abstraction_f_AbstractType := t_HaxInt; Abstraction_f_lift := fun (self : t_U16)=> U16_f_v self; }. -#[globa] Instance t_PartialEq_603208302 : t_PartialEq ((t_U16)) ((t_U16)) := +#[global] Instance t_PartialEq_603208302 : t_PartialEq ((t_U16)) ((t_U16)) := { PartialEq_f_eq := fun (self : t_U16) (rhs : t_U16)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -965,7 +965,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_595325431 : t_PartialOrd ((t_U16)) ((t_U16)) := +#[global] Instance t_PartialOrd_595325431 : t_PartialOrd ((t_U16)) ((t_U16)) := { PartialOrd_f_partial_cmp := fun (self : t_U16) (rhs : t_U16)=> Option_Some (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -1001,14 +1001,14 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Abstraction_789996186 : t_Abstraction ((t_U8)) := +#[global] Instance t_Abstraction_789996186 : t_Abstraction ((t_U8)) := { Abstraction_f_AbstractType := t_HaxInt; Abstraction_f_lift := fun (self : t_U8)=> U8_f_v self; }. -#[globa] Instance t_PartialEq_774173636 : t_PartialEq ((t_U8)) ((t_U8)) := +#[global] Instance t_PartialEq_774173636 : t_PartialEq ((t_U8)) ((t_U8)) := { PartialEq_f_eq := fun (self : t_U8) (rhs : t_U8)=> PartialEq_f_eq (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); @@ -1016,7 +1016,7 @@ Definition impl_219__WORDSIZE : t_HaxInt := PartialEq_f_ne (t_PartialEq := _ : t_PartialEq t_Ordering t_Ordering) (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))) (Ordering_Equal); }. -#[globa] Instance t_PartialOrd_577399304 : t_PartialOrd ((t_U8)) ((t_U8)) := +#[global] Instance t_PartialOrd_577399304 : t_PartialOrd ((t_U8)) ((t_U8)) := { PartialOrd_f_partial_cmp := fun (self : t_U8) (rhs : t_U8)=> Option_Some (haxint_cmp (Abstraction_f_lift (Clone_f_clone (self))) (Abstraction_f_lift (Clone_f_clone (rhs)))); @@ -1052,1095 +1052,1095 @@ Definition impl_219__WORDSIZE : t_HaxInt := end; }. -#[globa] Instance t_Neg_375517228 : t_Neg ((t_I128)) := +#[global] Instance t_Neg_375517228 : t_Neg ((t_I128)) := { Neg_f_Output := t_I128; Neg_f_neg := fun (self : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_neg (Abstraction_f_lift (self))); }. -#[globa] Instance t_BitOr_938342430 : t_BitOr ((t_I128)) ((t_I128)) := +#[global] Instance t_BitOr_938342430 : t_BitOr ((t_I128)) ((t_I128)) := { BitOr_f_Output := t_I128; BitOr_f_bitor := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_210530286 : t_Neg ((t_I64)) := +#[global] Instance t_Neg_210530286 : t_Neg ((t_I64)) := { Neg_f_Output := t_I64; Neg_f_neg := fun (self : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_neg (Abstraction_f_lift (self))); }. -#[globa] Instance t_BitOr_329754853 : t_BitOr ((t_I64)) ((t_I64)) := +#[global] Instance t_BitOr_329754853 : t_BitOr ((t_I64)) ((t_I64)) := { BitOr_f_Output := t_I64; BitOr_f_bitor := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_104016941 : t_Neg ((t_I32)) := +#[global] Instance t_Neg_104016941 : t_Neg ((t_I32)) := { Neg_f_Output := t_I32; Neg_f_neg := fun (self : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_neg (Abstraction_f_lift (self))); }. -#[globa] Instance t_BitOr_840483685 : t_BitOr ((t_I32)) ((t_I32)) := +#[global] Instance t_BitOr_840483685 : t_BitOr ((t_I32)) ((t_I32)) := { BitOr_f_Output := t_I32; BitOr_f_bitor := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_1063990797 : t_Neg ((t_I16)) := +#[global] Instance t_Neg_1063990797 : t_Neg ((t_I16)) := { Neg_f_Output := t_I16; Neg_f_neg := fun (self : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_neg (Abstraction_f_lift (self))); }. -#[globa] Instance t_BitOr_450806124 : t_BitOr ((t_I16)) ((t_I16)) := +#[global] Instance t_BitOr_450806124 : t_BitOr ((t_I16)) ((t_I16)) := { BitOr_f_Output := t_I16; BitOr_f_bitor := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_979719905 : t_Neg ((t_I8)) := +#[global] Instance t_Neg_979719905 : t_Neg ((t_I8)) := { Neg_f_Output := t_I8; Neg_f_neg := fun (self : t_I8)=> Concretization_f_concretize (z_neg (Abstraction_f_lift (self))); }. -#[globa] Instance t_BitOr_828862178 : t_BitOr ((t_I8)) ((t_I8)) := +#[global] Instance t_BitOr_828862178 : t_BitOr ((t_I8)) ((t_I8)) := { BitOr_f_Output := t_I8; BitOr_f_bitor := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (z_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_749575336 : t_Add ((t_I128)) ((t_I128)) := +#[global] Instance t_Add_749575336 : t_Add ((t_I128)) ((t_I128)) := { Add_f_Output := t_I128; Add_f_add := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_800692471 : t_Sub ((t_I128)) ((t_I128)) := +#[global] Instance t_Sub_800692471 : t_Sub ((t_I128)) ((t_I128)) := { Sub_f_Output := t_I128; Sub_f_sub := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_sub (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_87367909 : t_Add ((t_I64)) ((t_I64)) := +#[global] Instance t_Add_87367909 : t_Add ((t_I64)) ((t_I64)) := { Add_f_Output := t_I64; Add_f_add := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_741383133 : t_Sub ((t_I64)) ((t_I64)) := +#[global] Instance t_Sub_741383133 : t_Sub ((t_I64)) ((t_I64)) := { Sub_f_Output := t_I64; Sub_f_sub := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_sub (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_574043038 : t_Add ((t_I32)) ((t_I32)) := +#[global] Instance t_Add_574043038 : t_Add ((t_I32)) ((t_I32)) := { Add_f_Output := t_I32; Add_f_add := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_699874712 : t_Sub ((t_I32)) ((t_I32)) := +#[global] Instance t_Sub_699874712 : t_Sub ((t_I32)) ((t_I32)) := { Sub_f_Output := t_I32; Sub_f_sub := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_sub (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_413164706 : t_Add ((t_I16)) ((t_I16)) := +#[global] Instance t_Add_413164706 : t_Add ((t_I16)) ((t_I16)) := { Add_f_Output := t_I16; Add_f_add := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_544358249 : t_Sub ((t_I16)) ((t_I16)) := +#[global] Instance t_Sub_544358249 : t_Sub ((t_I16)) ((t_I16)) := { Sub_f_Output := t_I16; Sub_f_sub := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_sub (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_335735231 : t_Add ((t_I8)) ((t_I8)) := +#[global] Instance t_Add_335735231 : t_Add ((t_I8)) ((t_I8)) := { Add_f_Output := t_I8; Add_f_add := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (z_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_257575332 : t_Sub ((t_I8)) ((t_I8)) := +#[global] Instance t_Sub_257575332 : t_Sub ((t_I8)) ((t_I8)) := { Sub_f_Output := t_I8; Sub_f_sub := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (z_sub (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Concretization_943450188 : t_Concretization ((t_HaxInt)) ((t_U128)) := +#[global] Instance t_Concretization_943450188 : t_Concretization ((t_HaxInt)) ((t_U128)) := { Concretization_f_concretize := fun (self : t_HaxInt)=> Build_t_U128 (haxint_rem (self) (v_WORDSIZE_128_)); }. -#[globa] Instance t_From_355161674 : t_From ((t_U128)) ((t_U8)) := +#[global] Instance t_From_355161674 : t_From ((t_U128)) ((t_U8)) := { From_f_from := fun (x : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_739905379 : t_From ((t_U128)) ((t_U16)) := +#[global] Instance t_From_739905379 : t_From ((t_U128)) ((t_U16)) := { From_f_from := fun (x : t_U16)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_487010006 : t_From ((t_U128)) ((t_U32)) := +#[global] Instance t_From_487010006 : t_From ((t_U128)) ((t_U32)) := { From_f_from := fun (x : t_U32)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_665417617 : t_From ((t_U128)) ((t_U64)) := +#[global] Instance t_From_665417617 : t_From ((t_U128)) ((t_U64)) := { From_f_from := fun (x : t_U64)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U128) (Abstraction_f_lift (x)); }. -#[globa] Instance t_Concretization_10977439 : t_Concretization ((t_HaxInt)) ((t_U64)) := +#[global] Instance t_Concretization_10977439 : t_Concretization ((t_HaxInt)) ((t_U64)) := { Concretization_f_concretize := fun (self : t_HaxInt)=> Build_t_U64 (haxint_rem (self) (v_WORDSIZE_64_)); }. -#[globa] Instance t_From_746191059 : t_From ((t_U64)) ((t_U8)) := +#[global] Instance t_From_746191059 : t_From ((t_U64)) ((t_U8)) := { From_f_from := fun (x : t_U8)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_598353876 : t_From ((t_U64)) ((t_U16)) := +#[global] Instance t_From_598353876 : t_From ((t_U64)) ((t_U16)) := { From_f_from := fun (x : t_U16)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_293255347 : t_From ((t_U64)) ((t_U32)) := +#[global] Instance t_From_293255347 : t_From ((t_U64)) ((t_U32)) := { From_f_from := fun (x : t_U32)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_478031507 : t_From ((t_U64)) ((t_U128)) := +#[global] Instance t_From_478031507 : t_From ((t_U64)) ((t_U128)) := { From_f_from := fun (x : t_U128)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U64) (Abstraction_f_lift (x)); }. -#[globa] Instance t_Concretization_264065114 : t_Concretization ((t_HaxInt)) ((t_U32)) := +#[global] Instance t_Concretization_264065114 : t_Concretization ((t_HaxInt)) ((t_U32)) := { Concretization_f_concretize := fun (self : t_HaxInt)=> Build_t_U32 (haxint_rem (self) (v_WORDSIZE_32_)); }. -#[globa] Instance t_From_675834555 : t_From ((t_U32)) ((t_U8)) := +#[global] Instance t_From_675834555 : t_From ((t_U32)) ((t_U8)) := { From_f_from := fun (x : t_U8)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_410569540 : t_From ((t_U32)) ((t_U16)) := +#[global] Instance t_From_410569540 : t_From ((t_U32)) ((t_U16)) := { From_f_from := fun (x : t_U16)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_616913228 : t_From ((t_U32)) ((t_U64)) := +#[global] Instance t_From_616913228 : t_From ((t_U32)) ((t_U64)) := { From_f_from := fun (x : t_U64)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_376625380 : t_From ((t_U32)) ((t_U128)) := +#[global] Instance t_From_376625380 : t_From ((t_U32)) ((t_U128)) := { From_f_from := fun (x : t_U128)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U32) (Abstraction_f_lift (x)); }. -#[globa] Instance t_Concretization_656994795 : t_Concretization ((t_HaxInt)) ((t_U16)) := +#[global] Instance t_Concretization_656994795 : t_Concretization ((t_HaxInt)) ((t_U16)) := { Concretization_f_concretize := fun (self : t_HaxInt)=> Build_t_U16 (haxint_rem (self) (v_WORDSIZE_16_)); }. -#[globa] Instance t_From_352276566 : t_From ((t_U16)) ((t_U8)) := +#[global] Instance t_From_352276566 : t_From ((t_U16)) ((t_U8)) := { From_f_from := fun (x : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_699842532 : t_From ((t_U16)) ((t_U32)) := +#[global] Instance t_From_699842532 : t_From ((t_U16)) ((t_U32)) := { From_f_from := fun (x : t_U32)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_326646767 : t_From ((t_U16)) ((t_U64)) := +#[global] Instance t_From_326646767 : t_From ((t_U16)) ((t_U64)) := { From_f_from := fun (x : t_U64)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_604186294 : t_From ((t_U16)) ((t_U128)) := +#[global] Instance t_From_604186294 : t_From ((t_U16)) ((t_U128)) := { From_f_from := fun (x : t_U128)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U16) (Abstraction_f_lift (x)); }. -#[globa] Instance t_Concretization_492312374 : t_Concretization ((t_HaxInt)) ((t_U8)) := +#[global] Instance t_Concretization_492312374 : t_Concretization ((t_HaxInt)) ((t_U8)) := { Concretization_f_concretize := fun (self : t_HaxInt)=> Build_t_U8 (haxint_rem (self) (v_WORDSIZE_8_)); }. -#[globa] Instance t_From_374313775 : t_From ((t_U8)) ((t_U16)) := +#[global] Instance t_From_374313775 : t_From ((t_U8)) ((t_U16)) := { From_f_from := fun (x : t_U16)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_42776580 : t_From ((t_U8)) ((t_U32)) := +#[global] Instance t_From_42776580 : t_From ((t_U8)) ((t_U32)) := { From_f_from := fun (x : t_U32)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_480314375 : t_From ((t_U8)) ((t_U64)) := +#[global] Instance t_From_480314375 : t_From ((t_U8)) ((t_U64)) := { From_f_from := fun (x : t_U64)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_From_135782329 : t_From ((t_U8)) ((t_U128)) := +#[global] Instance t_From_135782329 : t_From ((t_U8)) ((t_U128)) := { From_f_from := fun (x : t_U128)=> Concretization_f_concretize(t_Concretization := _ : t_Concretization t_HaxInt t_U8) (Abstraction_f_lift (x)); }. -#[globa] Instance t_Mul_180009375 : t_Mul ((t_I128)) ((t_I128)) := +#[global] Instance t_Mul_180009375 : t_Mul ((t_I128)) ((t_I128)) := { Mul_f_Output := t_I128; Mul_f_mul := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Mul_1051209688 : t_Mul ((t_I64)) ((t_I64)) := +#[global] Instance t_Mul_1051209688 : t_Mul ((t_I64)) ((t_I64)) := { Mul_f_Output := t_I64; Mul_f_mul := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Mul_481497752 : t_Mul ((t_I32)) ((t_I32)) := +#[global] Instance t_Mul_481497752 : t_Mul ((t_I32)) ((t_I32)) := { Mul_f_Output := t_I32; Mul_f_mul := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Mul_768005208 : t_Mul ((t_I16)) ((t_I16)) := +#[global] Instance t_Mul_768005208 : t_Mul ((t_I16)) ((t_I16)) := { Mul_f_Output := t_I16; Mul_f_mul := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Mul_1057691929 : t_Mul ((t_I8)) ((t_I8)) := +#[global] Instance t_Mul_1057691929 : t_Mul ((t_I8)) ((t_I8)) := { Mul_f_Output := t_I8; Mul_f_mul := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (z_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_200638412 : t_Neg ((t_U128)) := +#[global] Instance t_Neg_200638412 : t_Neg ((t_U128)) := { Neg_f_Output := t_U128; Neg_f_neg := fun (self : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_sub (v_WORDSIZE_128_) (haxint_rem (Abstraction_f_lift (self)) (v_WORDSIZE_128_))); }. -#[globa] Instance t_Mul_508073751 : t_Mul ((t_U128)) ((t_U128)) := +#[global] Instance t_Mul_508073751 : t_Mul ((t_U128)) ((t_U128)) := { Mul_f_Output := t_U128; Mul_f_mul := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_184769952 : t_Rem ((t_U128)) ((t_U128)) := +#[global] Instance t_Rem_184769952 : t_Rem ((t_U128)) ((t_U128)) := { Rem_f_Output := t_U128; Rem_f_rem := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_74062568 : t_Add ((t_U128)) ((t_U128)) := +#[global] Instance t_Add_74062568 : t_Add ((t_U128)) ((t_U128)) := { Add_f_Output := t_U128; Add_f_add := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_697142148 : t_Div ((t_U128)) ((t_U128)) := +#[global] Instance t_Div_697142148 : t_Div ((t_U128)) ((t_U128)) := { Div_f_Output := t_U128; Div_f_div := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_912131656 : t_Shl ((t_U128)) ((t_U8)) := +#[global] Instance t_Shl_912131656 : t_Shl ((t_U128)) ((t_U8)) := { Shl_f_Output := t_U128; Shl_f_shl := fun (self : t_U128) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_188720840 : t_Shl ((t_U128)) ((t_U16)) := +#[global] Instance t_Shl_188720840 : t_Shl ((t_U128)) ((t_U16)) := { Shl_f_Output := t_U128; Shl_f_shl := fun (self : t_U128) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_674581806 : t_Shl ((t_U128)) ((t_U32)) := +#[global] Instance t_Shl_674581806 : t_Shl ((t_U128)) ((t_U32)) := { Shl_f_Output := t_U128; Shl_f_shl := fun (self : t_U128) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_230523808 : t_Shl ((t_U128)) ((t_U64)) := +#[global] Instance t_Shl_230523808 : t_Shl ((t_U128)) ((t_U64)) := { Shl_f_Output := t_U128; Shl_f_shl := fun (self : t_U128) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_304350501 : t_Shl ((t_U128)) ((t_U128)) := +#[global] Instance t_Shl_304350501 : t_Shl ((t_U128)) ((t_U128)) := { Shl_f_Output := t_U128; Shl_f_shl := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_584068908 : t_Shr ((t_U128)) ((t_U8)) := +#[global] Instance t_Shr_584068908 : t_Shr ((t_U128)) ((t_U8)) := { Shr_f_Output := t_U128; Shr_f_shr := fun (self : t_U128) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_73833277 : t_Shr ((t_U128)) ((t_U16)) := +#[global] Instance t_Shr_73833277 : t_Shr ((t_U128)) ((t_U16)) := { Shr_f_Output := t_U128; Shr_f_shr := fun (self : t_U128) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_50912121 : t_Shr ((t_U128)) ((t_U32)) := +#[global] Instance t_Shr_50912121 : t_Shr ((t_U128)) ((t_U32)) := { Shr_f_Output := t_U128; Shr_f_shr := fun (self : t_U128) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_282345299 : t_Shr ((t_U128)) ((t_U64)) := +#[global] Instance t_Shr_282345299 : t_Shr ((t_U128)) ((t_U64)) := { Shr_f_Output := t_U128; Shr_f_shr := fun (self : t_U128) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_354892033 : t_Shr ((t_U128)) ((t_U128)) := +#[global] Instance t_Shr_354892033 : t_Shr ((t_U128)) ((t_U128)) := { Shr_f_Output := t_U128; Shr_f_shr := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitXor_457452962 : t_BitXor ((t_U128)) ((t_U128)) := +#[global] Instance t_BitXor_457452962 : t_BitXor ((t_U128)) ((t_U128)) := { BitXor_f_Output := t_U128; BitXor_f_bitxor := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_bitxor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitAnd_499214249 : t_BitAnd ((t_U128)) ((t_U128)) := +#[global] Instance t_BitAnd_499214249 : t_BitAnd ((t_U128)) ((t_U128)) := { BitAnd_f_Output := t_U128; BitAnd_f_bitand := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_bitand (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitOr_579754702 : t_BitOr ((t_U128)) ((t_U128)) := +#[global] Instance t_BitOr_579754702 : t_BitOr ((t_U128)) ((t_U128)) := { BitOr_f_Output := t_U128; BitOr_f_bitor := fun (self : t_U128) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U128) (haxint_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_338880159 : t_Neg ((t_U64)) := +#[global] Instance t_Neg_338880159 : t_Neg ((t_U64)) := { Neg_f_Output := t_U64; Neg_f_neg := fun (self : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_sub (v_WORDSIZE_64_) (haxint_rem (Abstraction_f_lift (self)) (v_WORDSIZE_64_))); }. -#[globa] Instance t_Mul_785129859 : t_Mul ((t_U64)) ((t_U64)) := +#[global] Instance t_Mul_785129859 : t_Mul ((t_U64)) ((t_U64)) := { Mul_f_Output := t_U64; Mul_f_mul := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_450198244 : t_Rem ((t_U64)) ((t_U64)) := +#[global] Instance t_Rem_450198244 : t_Rem ((t_U64)) ((t_U64)) := { Rem_f_Output := t_U64; Rem_f_rem := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_880469818 : t_Add ((t_U64)) ((t_U64)) := +#[global] Instance t_Add_880469818 : t_Add ((t_U64)) ((t_U64)) := { Add_f_Output := t_U64; Add_f_add := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_1065913959 : t_Div ((t_U64)) ((t_U64)) := +#[global] Instance t_Div_1065913959 : t_Div ((t_U64)) ((t_U64)) := { Div_f_Output := t_U64; Div_f_div := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_307107617 : t_Shl ((t_U64)) ((t_U8)) := +#[global] Instance t_Shl_307107617 : t_Shl ((t_U64)) ((t_U8)) := { Shl_f_Output := t_U64; Shl_f_shl := fun (self : t_U64) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64 )(haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_521831749 : t_Shl ((t_U64)) ((t_U16)) := +#[global] Instance t_Shl_521831749 : t_Shl ((t_U64)) ((t_U16)) := { Shl_f_Output := t_U64; Shl_f_shl := fun (self : t_U64) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_243646433 : t_Shl ((t_U64)) ((t_U32)) := +#[global] Instance t_Shl_243646433 : t_Shl ((t_U64)) ((t_U32)) := { Shl_f_Output := t_U64; Shl_f_shl := fun (self : t_U64) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_732371970 : t_Shl ((t_U64)) ((t_U64)) := +#[global] Instance t_Shl_732371970 : t_Shl ((t_U64)) ((t_U64)) := { Shl_f_Output := t_U64; Shl_f_shl := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_362455113 : t_Shl ((t_U64)) ((t_U128)) := +#[global] Instance t_Shl_362455113 : t_Shl ((t_U64)) ((t_U128)) := { Shl_f_Output := t_U64; Shl_f_shl := fun (self : t_U64) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_675607391 : t_Shr ((t_U64)) ((t_U8)) := +#[global] Instance t_Shr_675607391 : t_Shr ((t_U64)) ((t_U8)) := { Shr_f_Output := t_U64; Shr_f_shr := fun (self : t_U64) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_163042579 : t_Shr ((t_U64)) ((t_U16)) := +#[global] Instance t_Shr_163042579 : t_Shr ((t_U64)) ((t_U16)) := { Shr_f_Output := t_U64; Shr_f_shr := fun (self : t_U64) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_329072619 : t_Shr ((t_U64)) ((t_U32)) := +#[global] Instance t_Shr_329072619 : t_Shr ((t_U64)) ((t_U32)) := { Shr_f_Output := t_U64; Shr_f_shr := fun (self : t_U64) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_1046321056 : t_Shr ((t_U64)) ((t_U64)) := +#[global] Instance t_Shr_1046321056 : t_Shr ((t_U64)) ((t_U64)) := { Shr_f_Output := t_U64; Shr_f_shr := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_1027159812 : t_Shr ((t_U64)) ((t_U128)) := +#[global] Instance t_Shr_1027159812 : t_Shr ((t_U64)) ((t_U128)) := { Shr_f_Output := t_U64; Shr_f_shr := fun (self : t_U64) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitXor_771705591 : t_BitXor ((t_U64)) ((t_U64)) := +#[global] Instance t_BitXor_771705591 : t_BitXor ((t_U64)) ((t_U64)) := { BitXor_f_Output := t_U64; BitXor_f_bitxor := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_bitxor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitAnd_61309855 : t_BitAnd ((t_U64)) ((t_U64)) := +#[global] Instance t_BitAnd_61309855 : t_BitAnd ((t_U64)) ((t_U64)) := { BitAnd_f_Output := t_U64; BitAnd_f_bitand := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_bitand (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitOr_584478327 : t_BitOr ((t_U64)) ((t_U64)) := +#[global] Instance t_BitOr_584478327 : t_BitOr ((t_U64)) ((t_U64)) := { BitOr_f_Output := t_U64; BitOr_f_bitor := fun (self : t_U64) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U64) (haxint_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_660092460 : t_Neg ((t_U32)) := +#[global] Instance t_Neg_660092460 : t_Neg ((t_U32)) := { Neg_f_Output := t_U32; Neg_f_neg := fun (self : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_sub (v_WORDSIZE_32_) (haxint_rem (Abstraction_f_lift (self)) (v_WORDSIZE_32_))); }. -#[globa] Instance t_Mul_907086750 : t_Mul ((t_U32)) ((t_U32)) := +#[global] Instance t_Mul_907086750 : t_Mul ((t_U32)) ((t_U32)) := { Mul_f_Output := t_U32; Mul_f_mul := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_754047547 : t_Rem ((t_U32)) ((t_U32)) := +#[global] Instance t_Rem_754047547 : t_Rem ((t_U32)) ((t_U32)) := { Rem_f_Output := t_U32; Rem_f_rem := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_62760194 : t_Add ((t_U32)) ((t_U32)) := +#[global] Instance t_Add_62760194 : t_Add ((t_U32)) ((t_U32)) := { Add_f_Output := t_U32; Add_f_add := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_1036065219 : t_Div ((t_U32)) ((t_U32)) := +#[global] Instance t_Div_1036065219 : t_Div ((t_U32)) ((t_U32)) := { Div_f_Output := t_U32; Div_f_div := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_940272829 : t_Shl ((t_U32)) ((t_U8)) := +#[global] Instance t_Shl_940272829 : t_Shl ((t_U32)) ((t_U8)) := { Shl_f_Output := t_U32; Shl_f_shl := fun (self : t_U32) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_184065944 : t_Shl ((t_U32)) ((t_U16)) := +#[global] Instance t_Shl_184065944 : t_Shl ((t_U32)) ((t_U16)) := { Shl_f_Output := t_U32; Shl_f_shl := fun (self : t_U32) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_512141775 : t_Shl ((t_U32)) ((t_U32)) := +#[global] Instance t_Shl_512141775 : t_Shl ((t_U32)) ((t_U32)) := { Shl_f_Output := t_U32; Shl_f_shl := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_760382167 : t_Shl ((t_U32)) ((t_U64)) := +#[global] Instance t_Shl_760382167 : t_Shl ((t_U32)) ((t_U64)) := { Shl_f_Output := t_U32; Shl_f_shl := fun (self : t_U32) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_938844716 : t_Shl ((t_U32)) ((t_U128)) := +#[global] Instance t_Shl_938844716 : t_Shl ((t_U32)) ((t_U128)) := { Shl_f_Output := t_U32; Shl_f_shl := fun (self : t_U32) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_376401556 : t_Shr ((t_U32)) ((t_U8)) := +#[global] Instance t_Shr_376401556 : t_Shr ((t_U32)) ((t_U8)) := { Shr_f_Output := t_U32; Shr_f_shr := fun (self : t_U32) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_816225657 : t_Shr ((t_U32)) ((t_U16)) := +#[global] Instance t_Shr_816225657 : t_Shr ((t_U32)) ((t_U16)) := { Shr_f_Output := t_U32; Shr_f_shr := fun (self : t_U32) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_131570199 : t_Shr ((t_U32)) ((t_U32)) := +#[global] Instance t_Shr_131570199 : t_Shr ((t_U32)) ((t_U32)) := { Shr_f_Output := t_U32; Shr_f_shr := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_643141508 : t_Shr ((t_U32)) ((t_U64)) := +#[global] Instance t_Shr_643141508 : t_Shr ((t_U32)) ((t_U64)) := { Shr_f_Output := t_U32; Shr_f_shr := fun (self : t_U32) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_472576920 : t_Shr ((t_U32)) ((t_U128)) := +#[global] Instance t_Shr_472576920 : t_Shr ((t_U32)) ((t_U128)) := { Shr_f_Output := t_U32; Shr_f_shr := fun (self : t_U32) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitXor_568575701 : t_BitXor ((t_U32)) ((t_U32)) := +#[global] Instance t_BitXor_568575701 : t_BitXor ((t_U32)) ((t_U32)) := { BitXor_f_Output := t_U32; BitXor_f_bitxor := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_bitxor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitAnd_188629984 : t_BitAnd ((t_U32)) ((t_U32)) := +#[global] Instance t_BitAnd_188629984 : t_BitAnd ((t_U32)) ((t_U32)) := { BitAnd_f_Output := t_U32; BitAnd_f_bitand := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_bitand (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitOr_727300711 : t_BitOr ((t_U32)) ((t_U32)) := +#[global] Instance t_BitOr_727300711 : t_BitOr ((t_U32)) ((t_U32)) := { BitOr_f_Output := t_U32; BitOr_f_bitor := fun (self : t_U32) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U32) (haxint_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_524209972 : t_Neg ((t_U16)) := +#[global] Instance t_Neg_524209972 : t_Neg ((t_U16)) := { Neg_f_Output := t_U16; Neg_f_neg := fun (self : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_sub (v_WORDSIZE_16_) (haxint_rem (Abstraction_f_lift (self)) (v_WORDSIZE_16_))); }. -#[globa] Instance t_Mul_813798593 : t_Mul ((t_U16)) ((t_U16)) := +#[global] Instance t_Mul_813798593 : t_Mul ((t_U16)) ((t_U16)) := { Mul_f_Output := t_U16; Mul_f_mul := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_1023129312 : t_Rem ((t_U16)) ((t_U16)) := +#[global] Instance t_Rem_1023129312 : t_Rem ((t_U16)) ((t_U16)) := { Rem_f_Output := t_U16; Rem_f_rem := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_669194837 : t_Add ((t_U16)) ((t_U16)) := +#[global] Instance t_Add_669194837 : t_Add ((t_U16)) ((t_U16)) := { Add_f_Output := t_U16; Add_f_add := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_599727096 : t_Div ((t_U16)) ((t_U16)) := +#[global] Instance t_Div_599727096 : t_Div ((t_U16)) ((t_U16)) := { Div_f_Output := t_U16; Div_f_div := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_254354835 : t_Shl ((t_U16)) ((t_U8)) := +#[global] Instance t_Shl_254354835 : t_Shl ((t_U16)) ((t_U8)) := { Shl_f_Output := t_U16; Shl_f_shl := fun (self : t_U16) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_786190756 : t_Shl ((t_U16)) ((t_U16)) := +#[global] Instance t_Shl_786190756 : t_Shl ((t_U16)) ((t_U16)) := { Shl_f_Output := t_U16; Shl_f_shl := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_961613024 : t_Shl ((t_U16)) ((t_U32)) := +#[global] Instance t_Shl_961613024 : t_Shl ((t_U16)) ((t_U32)) := { Shl_f_Output := t_U16; Shl_f_shl := fun (self : t_U16) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_699049796 : t_Shl ((t_U16)) ((t_U64)) := +#[global] Instance t_Shl_699049796 : t_Shl ((t_U16)) ((t_U64)) := { Shl_f_Output := t_U16; Shl_f_shl := fun (self : t_U16) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_98667823 : t_Shl ((t_U16)) ((t_U128)) := +#[global] Instance t_Shl_98667823 : t_Shl ((t_U16)) ((t_U128)) := { Shl_f_Output := t_U16; Shl_f_shl := fun (self : t_U16) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_116990915 : t_Shr ((t_U16)) ((t_U8)) := +#[global] Instance t_Shr_116990915 : t_Shr ((t_U16)) ((t_U8)) := { Shr_f_Output := t_U16; Shr_f_shr := fun (self : t_U16) (rhs : t_U8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_53270962 : t_Shr ((t_U16)) ((t_U16)) := +#[global] Instance t_Shr_53270962 : t_Shr ((t_U16)) ((t_U16)) := { Shr_f_Output := t_U16; Shr_f_shr := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_622272332 : t_Shr ((t_U16)) ((t_U32)) := +#[global] Instance t_Shr_622272332 : t_Shr ((t_U16)) ((t_U32)) := { Shr_f_Output := t_U16; Shr_f_shr := fun (self : t_U16) (rhs : t_U32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_1061476863 : t_Shr ((t_U16)) ((t_U64)) := +#[global] Instance t_Shr_1061476863 : t_Shr ((t_U16)) ((t_U64)) := { Shr_f_Output := t_U16; Shr_f_shr := fun (self : t_U16) (rhs : t_U64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_148349277 : t_Shr ((t_U16)) ((t_U128)) := +#[global] Instance t_Shr_148349277 : t_Shr ((t_U16)) ((t_U128)) := { Shr_f_Output := t_U16; Shr_f_shr := fun (self : t_U16) (rhs : t_U128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitXor_39308972 : t_BitXor ((t_U16)) ((t_U16)) := +#[global] Instance t_BitXor_39308972 : t_BitXor ((t_U16)) ((t_U16)) := { BitXor_f_Output := t_U16; BitXor_f_bitxor := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_bitxor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitAnd_100986953 : t_BitAnd ((t_U16)) ((t_U16)) := +#[global] Instance t_BitAnd_100986953 : t_BitAnd ((t_U16)) ((t_U16)) := { BitAnd_f_Output := t_U16; BitAnd_f_bitand := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_bitand (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitOr_321212552 : t_BitOr ((t_U16)) ((t_U16)) := +#[global] Instance t_BitOr_321212552 : t_BitOr ((t_U16)) ((t_U16)) := { BitOr_f_Output := t_U16; BitOr_f_bitor := fun (self : t_U16) (rhs : t_U16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_HaxInt t_U16) (haxint_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Neg_410091205 : t_Neg ((t_U8)) := +#[global] Instance t_Neg_410091205 : t_Neg ((t_U8)) := { Neg_f_Output := t_U8; Neg_f_neg := fun (self : t_U8)=> Concretization_f_concretize (haxint_sub (v_WORDSIZE_8_) (haxint_rem (Abstraction_f_lift (self)) (v_WORDSIZE_8_))); }. -#[globa] Instance t_Mul_116494850 : t_Mul ((t_U8)) ((t_U8)) := +#[global] Instance t_Mul_116494850 : t_Mul ((t_U8)) ((t_U8)) := { Mul_f_Output := t_U8; Mul_f_mul := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_mul (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_674469245 : t_Rem ((t_U8)) ((t_U8)) := +#[global] Instance t_Rem_674469245 : t_Rem ((t_U8)) ((t_U8)) := { Rem_f_Output := t_U8; Rem_f_rem := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Add_886374338 : t_Add ((t_U8)) ((t_U8)) := +#[global] Instance t_Add_886374338 : t_Add ((t_U8)) ((t_U8)) := { Add_f_Output := t_U8; Add_f_add := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_add (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_7559770 : t_Div ((t_U8)) ((t_U8)) := +#[global] Instance t_Div_7559770 : t_Div ((t_U8)) ((t_U8)) := { Div_f_Output := t_U8; Div_f_div := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_889664521 : t_Shl ((t_U8)) ((t_U8)) := +#[global] Instance t_Shl_889664521 : t_Shl ((t_U8)) ((t_U8)) := { Shl_f_Output := t_U8; Shl_f_shl := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_268581730 : t_Shl ((t_U8)) ((t_U16)) := +#[global] Instance t_Shl_268581730 : t_Shl ((t_U8)) ((t_U16)) := { Shl_f_Output := t_U8; Shl_f_shl := fun (self : t_U8) (rhs : t_U16)=> Concretization_f_concretize (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_833473770 : t_Shl ((t_U8)) ((t_U32)) := +#[global] Instance t_Shl_833473770 : t_Shl ((t_U8)) ((t_U32)) := { Shl_f_Output := t_U8; Shl_f_shl := fun (self : t_U8) (rhs : t_U32)=> Concretization_f_concretize (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_896563459 : t_Shl ((t_U8)) ((t_U64)) := +#[global] Instance t_Shl_896563459 : t_Shl ((t_U8)) ((t_U64)) := { Shl_f_Output := t_U8; Shl_f_shl := fun (self : t_U8) (rhs : t_U64)=> Concretization_f_concretize (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shl_595294021 : t_Shl ((t_U8)) ((t_U128)) := +#[global] Instance t_Shl_595294021 : t_Shl ((t_U8)) ((t_U128)) := { Shl_f_Output := t_U8; Shl_f_shl := fun (self : t_U8) (rhs : t_U128)=> Concretization_f_concretize (haxint_shl (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_467626732 : t_Shr ((t_U8)) ((t_U8)) := +#[global] Instance t_Shr_467626732 : t_Shr ((t_U8)) ((t_U8)) := { Shr_f_Output := t_U8; Shr_f_shr := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_985367369 : t_Shr ((t_U8)) ((t_U16)) := +#[global] Instance t_Shr_985367369 : t_Shr ((t_U8)) ((t_U16)) := { Shr_f_Output := t_U8; Shr_f_shr := fun (self : t_U8) (rhs : t_U16)=> Concretization_f_concretize (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_868101800 : t_Shr ((t_U8)) ((t_U32)) := +#[global] Instance t_Shr_868101800 : t_Shr ((t_U8)) ((t_U32)) := { Shr_f_Output := t_U8; Shr_f_shr := fun (self : t_U8) (rhs : t_U32)=> Concretization_f_concretize (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_300023283 : t_Shr ((t_U8)) ((t_U64)) := +#[global] Instance t_Shr_300023283 : t_Shr ((t_U8)) ((t_U64)) := { Shr_f_Output := t_U8; Shr_f_shr := fun (self : t_U8) (rhs : t_U64)=> Concretization_f_concretize (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Shr_794091640 : t_Shr ((t_U8)) ((t_U128)) := +#[global] Instance t_Shr_794091640 : t_Shr ((t_U8)) ((t_U128)) := { Shr_f_Output := t_U8; Shr_f_shr := fun (self : t_U8) (rhs : t_U128)=> Concretization_f_concretize (haxint_shr (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitXor_24738444 : t_BitXor ((t_U8)) ((t_U8)) := +#[global] Instance t_BitXor_24738444 : t_BitXor ((t_U8)) ((t_U8)) := { BitXor_f_Output := t_U8; BitXor_f_bitxor := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_bitxor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitAnd_358790390 : t_BitAnd ((t_U8)) ((t_U8)) := +#[global] Instance t_BitAnd_358790390 : t_BitAnd ((t_U8)) ((t_U8)) := { BitAnd_f_Output := t_U8; BitAnd_f_bitand := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_bitand (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_BitOr_349401480 : t_BitOr ((t_U8)) ((t_U8)) := +#[global] Instance t_BitOr_349401480 : t_BitOr ((t_U8)) ((t_U8)) := { BitOr_f_Output := t_U8; BitOr_f_bitor := fun (self : t_U8) (rhs : t_U8)=> Concretization_f_concretize (haxint_bitor (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_998027599 : t_Rem ((t_I128)) ((t_I128)) := +#[global] Instance t_Rem_998027599 : t_Rem ((t_I128)) ((t_I128)) := { Rem_f_Output := t_I128; Rem_f_rem := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_865866956 : t_Div ((t_I128)) ((t_I128)) := +#[global] Instance t_Div_865866956 : t_Div ((t_I128)) ((t_I128)) := { Div_f_Output := t_I128; Div_f_div := fun (self : t_I128) (rhs : t_I128)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I128) (z_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_957489424 : t_Rem ((t_I64)) ((t_I64)) := +#[global] Instance t_Rem_957489424 : t_Rem ((t_I64)) ((t_I64)) := { Rem_f_Output := t_I64; Rem_f_rem := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_611785525 : t_Div ((t_I64)) ((t_I64)) := +#[global] Instance t_Div_611785525 : t_Div ((t_I64)) ((t_I64)) := { Div_f_Output := t_I64; Div_f_div := fun (self : t_I64) (rhs : t_I64)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I64) (z_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_219303214 : t_Rem ((t_I32)) ((t_I32)) := +#[global] Instance t_Rem_219303214 : t_Rem ((t_I32)) ((t_I32)) := { Rem_f_Output := t_I32; Rem_f_rem := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_1002924104 : t_Div ((t_I32)) ((t_I32)) := +#[global] Instance t_Div_1002924104 : t_Div ((t_I32)) ((t_I32)) := { Div_f_Output := t_I32; Div_f_div := fun (self : t_I32) (rhs : t_I32)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I32) (z_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_948867246 : t_Rem ((t_I16)) ((t_I16)) := +#[global] Instance t_Rem_948867246 : t_Rem ((t_I16)) ((t_I16)) := { Rem_f_Output := t_I16; Rem_f_rem := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_357493436 : t_Div ((t_I16)) ((t_I16)) := +#[global] Instance t_Div_357493436 : t_Div ((t_I16)) ((t_I16)) := { Div_f_Output := t_I16; Div_f_div := fun (self : t_I16) (rhs : t_I16)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I16) (z_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Rem_228000167 : t_Rem ((t_I8)) ((t_I8)) := +#[global] Instance t_Rem_228000167 : t_Rem ((t_I8)) ((t_I8)) := { Rem_f_Output := t_I8; Rem_f_rem := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (z_rem (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Div_470010025 : t_Div ((t_I8)) ((t_I8)) := +#[global] Instance t_Div_470010025 : t_Div ((t_I8)) ((t_I8)) := { Div_f_Output := t_I8; Div_f_div := fun (self : t_I8) (rhs : t_I8)=> Concretization_f_concretize (t_Concretization := _ : t_Concretization t_Z t_I8) (z_div (Abstraction_f_lift (self)) (Abstraction_f_lift (rhs))); }. -#[globa] Instance t_Sub_1018502693 : t_Sub ((t_U128)) ((t_U128)) := +#[global] Instance t_Sub_1018502693 : t_Sub ((t_U128)) ((t_U128)) := { Sub_f_Output := t_U128; Sub_f_sub := fun (self : t_U128) (rhs : t_U128)=> Add_f_add (t_Add := _ : t_Add t_U128 t_U128) (self) (Neg_f_neg (rhs)); }. -#[globa] Instance t_Not_758360759 : t_Not ((t_U128)) := +#[global] Instance t_Not_758360759 : t_Not ((t_U128)) := { Not_f_Output := t_U128; Not_f_not := fun (self : t_U128)=> BitXor_f_bitxor (self) (Constants_f_MAX); }. -#[globa] Instance t_Sub_919216830 : t_Sub ((t_U64)) ((t_U64)) := +#[global] Instance t_Sub_919216830 : t_Sub ((t_U64)) ((t_U64)) := { Sub_f_Output := t_U64; Sub_f_sub := fun (self : t_U64) (rhs : t_U64)=> Add_f_add (t_Add := _ : t_Add _ t_U64) (self) (Neg_f_neg (rhs)); }. -#[globa] Instance t_Not_693249901 : t_Not ((t_U64)) := +#[global] Instance t_Not_693249901 : t_Not ((t_U64)) := { Not_f_Output := t_U64; Not_f_not := fun (self : t_U64)=> BitXor_f_bitxor (self) (Constants_f_MAX); }. -#[globa] Instance t_Sub_22623594 : t_Sub ((t_U32)) ((t_U32)) := +#[global] Instance t_Sub_22623594 : t_Sub ((t_U32)) ((t_U32)) := { Sub_f_Output := t_U32; Sub_f_sub := fun (self : t_U32) (rhs : t_U32)=> Add_f_add (t_Add := _ : t_Add _ t_U32) (self) (Neg_f_neg (rhs)); }. -#[globa] Instance t_Not_183316157 : t_Not ((t_U32)) := +#[global] Instance t_Not_183316157 : t_Not ((t_U32)) := { Not_f_Output := t_U32; Not_f_not := fun (self : t_U32)=> BitXor_f_bitxor (self) (Constants_f_MAX); }. -#[globa] Instance t_Sub_502320750 : t_Sub ((t_U16)) ((t_U16)) := +#[global] Instance t_Sub_502320750 : t_Sub ((t_U16)) ((t_U16)) := { Sub_f_Output := t_U16; Sub_f_sub := fun (self : t_U16) (rhs : t_U16)=> Add_f_add (t_Add := _ : t_Add _ t_U16) (self) (Neg_f_neg (rhs)); }. -#[globa] Instance t_Not_669226601 : t_Not ((t_U16)) := +#[global] Instance t_Not_669226601 : t_Not ((t_U16)) := { Not_f_Output := t_U16; Not_f_not := fun (self : t_U16)=> BitXor_f_bitxor (self) (Constants_f_MAX); }. -#[globa] Instance t_Sub_299023787 : t_Sub ((t_U8)) ((t_U8)) := +#[global] Instance t_Sub_299023787 : t_Sub ((t_U8)) ((t_U8)) := { Sub_f_Output := t_U8; Sub_f_sub := fun (self : t_U8) (rhs : t_U8)=> Add_f_add (t_Add := _ : t_Add _ t_U8) (self) (Neg_f_neg (rhs)); }. -#[globa] Instance t_Not_761019181 : t_Not ((t_U8)) := +#[global] Instance t_Not_761019181 : t_Not ((t_U8)) := { Not_f_Output := t_U8; Not_f_not := fun (self : t_U8)=>