(* Generated by coq-of-rust *)
Require Import CoqOfRust.CoqOfRust.

Module context.
  Module context_precompiles.
    (*
    Enum ContextPrecompile
    {
      const_params := [];
      ty_params := [ "DB" ];
      variants :=
        [
          {
            name := "Ordinary";
            item := StructTuple [ Ty.path "revm_primitives::precompile::Precompile" ];
            discriminant := None;
          };
          {
            name := "ContextStateful";
            item :=
              StructTuple
                [
                  Ty.apply
                    (Ty.path "alloc::sync::Arc")
                    []
                    [
                      Ty.dyn
                        [
                          ("revm::context::context_precompiles::ContextStatefulPrecompile::Trait",
                            [])
                        ];
                      Ty.path "alloc::alloc::Global"
                    ]
                ];
            discriminant := None;
          };
          {
            name := "ContextStatefulMut";
            item :=
              StructTuple
                [
                  Ty.apply
                    (Ty.path "alloc::boxed::Box")
                    []
                    [
                      Ty.dyn
                        [
                          ("revm::context::context_precompiles::ContextStatefulPrecompileMut::Trait",
                            [])
                        ];
                      Ty.path "alloc::alloc::Global"
                    ]
                ];
            discriminant := None;
          }
        ];
    }
    *)
    
    Module Impl_core_clone_Clone_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompile_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompile") [] [ DB ].
      
      (*
          fn clone(&self) -> Self {
              match self {
                  Self::Ordinary(arg0) => Self::Ordinary(arg0.clone()),
                  Self::ContextStateful(arg0) => Self::ContextStateful(arg0.clone()),
                  Self::ContextStatefulMut(arg0) => Self::ContextStatefulMut(arg0.clone()),
              }
          }
      *)
      Definition clone (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.read (|
              M.match_operator (|
                self,
                [
                  fun γ =>
                    ltac:(M.monadic
                      (let γ := M.read (| γ |) in
                      let γ1_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "revm::context::context_precompiles::ContextPrecompile::Ordinary",
                          0
                        |) in
                      let arg0 := M.alloc (| γ1_0 |) in
                      M.alloc (|
                        Value.StructTuple
                          "revm::context::context_precompiles::ContextPrecompile::Ordinary"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::clone::Clone",
                                Ty.path "revm_primitives::precompile::Precompile",
                                [],
                                "clone",
                                []
                              |),
                              [ M.read (| arg0 |) ]
                            |)
                          ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let γ := M.read (| γ |) in
                      let γ1_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "revm::context::context_precompiles::ContextPrecompile::ContextStateful",
                          0
                        |) in
                      let arg0 := M.alloc (| γ1_0 |) in
                      M.alloc (|
                        Value.StructTuple
                          "revm::context::context_precompiles::ContextPrecompile::ContextStateful"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::clone::Clone",
                                Ty.apply
                                  (Ty.path "alloc::sync::Arc")
                                  []
                                  [
                                    Ty.dyn
                                      [
                                        ("revm::context::context_precompiles::ContextStatefulPrecompile::Trait",
                                          [])
                                      ];
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                [],
                                "clone",
                                []
                              |),
                              [ M.read (| arg0 |) ]
                            |)
                          ]
                      |)));
                  fun γ =>
                    ltac:(M.monadic
                      (let γ := M.read (| γ |) in
                      let γ1_0 :=
                        M.SubPointer.get_struct_tuple_field (|
                          γ,
                          "revm::context::context_precompiles::ContextPrecompile::ContextStatefulMut",
                          0
                        |) in
                      let arg0 := M.alloc (| γ1_0 |) in
                      M.alloc (|
                        Value.StructTuple
                          "revm::context::context_precompiles::ContextPrecompile::ContextStatefulMut"
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::clone::Clone",
                                Ty.apply
                                  (Ty.path "alloc::boxed::Box")
                                  []
                                  [
                                    Ty.dyn
                                      [
                                        ("revm::context::context_precompiles::ContextStatefulPrecompileMut::Trait",
                                          [])
                                      ];
                                    Ty.path "alloc::alloc::Global"
                                  ],
                                [],
                                "clone",
                                []
                              |),
                              [ M.read (| arg0 |) ]
                            |)
                          ]
                      |)))
                ]
              |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::clone::Clone"
          (Self DB)
          (* Trait polymorphic types *) []
          (* Instance *) [ ("clone", InstanceField.Method (clone DB)) ].
    End Impl_core_clone_Clone_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompile_DB.
    
    (* StructRecord
      {
        name := "ContextPrecompiles";
        const_params := [];
        ty_params := [ "DB" ];
        fields :=
          [
            ("inner",
              Ty.apply
                (Ty.path "std::collections::hash::map::HashMap")
                []
                [
                  Ty.path "alloy_primitives::bits::address::Address";
                  Ty.apply
                    (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                    []
                    [ DB ];
                  Ty.path "std::hash::random::RandomState"
                ])
          ];
      } *)
    
    Module Impl_core_clone_Clone_where_core_clone_Clone_DB_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (* Clone *)
      Definition clone (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            Value.StructRecord
              "revm::context::context_precompiles::ContextPrecompiles"
              [
                ("inner",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::clone::Clone",
                      Ty.apply
                        (Ty.path "std::collections::hash::map::HashMap")
                        []
                        [
                          Ty.path "alloy_primitives::bits::address::Address";
                          Ty.apply
                            (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                            []
                            [ DB ];
                          Ty.path "std::hash::random::RandomState"
                        ],
                      [],
                      "clone",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "revm::context::context_precompiles::ContextPrecompiles",
                        "inner"
                      |)
                    ]
                  |))
              ]))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::clone::Clone"
          (Self DB)
          (* Trait polymorphic types *) []
          (* Instance *) [ ("clone", InstanceField.Method (clone DB)) ].
    End Impl_core_clone_Clone_where_core_clone_Clone_DB_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    Module Impl_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*
          pub fn addresses(&self) -> impl Iterator<Item = &Address> {
              self.inner.keys()
          }
      *)
      Definition addresses (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.call_closure (|
              M.get_associated_function (|
                Ty.apply
                  (Ty.path "std::collections::hash::map::HashMap")
                  []
                  [
                    Ty.path "alloy_primitives::bits::address::Address";
                    Ty.apply
                      (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                      []
                      [ DB ];
                    Ty.path "std::hash::random::RandomState"
                  ],
                "keys",
                []
              |),
              [
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "revm::context::context_precompiles::ContextPrecompiles",
                  "inner"
                |)
              ]
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom AssociatedFunction_addresses :
        forall (DB : Ty.t),
        M.IsAssociatedFunction (Self DB) "addresses" (addresses DB).
      
      (*
          pub fn extend(
              &mut self,
              other: impl IntoIterator<Item = impl Into<(Address, ContextPrecompile<DB>)>>,
          ) {
              self.inner.extend(other.into_iter().map(Into::into));
          }
      *)
      Definition extend (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [],
            [
              impl_Into__Address__ContextPrecompile_DB___;
              impl_IntoIterator_Item___impl_Into__Address__ContextPrecompile_DB____
            ],
            [ self; other ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let other := M.alloc (| other |) in
            M.read (|
              let~ _ :=
                M.alloc (|
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::collect::Extend",
                      Ty.apply
                        (Ty.path "std::collections::hash::map::HashMap")
                        []
                        [
                          Ty.path "alloy_primitives::bits::address::Address";
                          Ty.apply
                            (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                            []
                            [ DB ];
                          Ty.path "std::hash::random::RandomState"
                        ],
                      [
                        Ty.tuple
                          [
                            Ty.path "alloy_primitives::bits::address::Address";
                            Ty.apply
                              (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                              []
                              [ DB ]
                          ]
                      ],
                      "extend",
                      [
                        Ty.apply
                          (Ty.path "core::iter::adapters::map::Map")
                          []
                          [
                            Ty.associated;
                            Ty.function
                              [ impl_Into__Address__ContextPrecompile_DB___ ]
                              (Ty.tuple
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.apply
                                    (Ty.path
                                      "revm::context::context_precompiles::ContextPrecompile")
                                    []
                                    [ DB ]
                                ])
                          ]
                      ]
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "revm::context::context_precompiles::ContextPrecompiles",
                        "inner"
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.associated,
                          [],
                          "map",
                          [
                            Ty.tuple
                              [
                                Ty.path "alloy_primitives::bits::address::Address";
                                Ty.apply
                                  (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                                  []
                                  [ DB ]
                              ];
                            Ty.function
                              [ impl_Into__Address__ContextPrecompile_DB___ ]
                              (Ty.tuple
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.apply
                                    (Ty.path
                                      "revm::context::context_precompiles::ContextPrecompile")
                                    []
                                    [ DB ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::iter::traits::collect::IntoIterator",
                              impl_IntoIterator_Item___impl_Into__Address__ContextPrecompile_DB____,
                              [],
                              "into_iter",
                              []
                            |),
                            [ M.read (| other |) ]
                          |);
                          M.get_trait_method (|
                            "core::convert::Into",
                            impl_Into__Address__ContextPrecompile_DB___,
                            [
                              Ty.tuple
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.apply
                                    (Ty.path
                                      "revm::context::context_precompiles::ContextPrecompile")
                                    []
                                    [ DB ]
                                ]
                            ],
                            "into",
                            []
                          |)
                        ]
                      |)
                    ]
                  |)
                |) in
              M.alloc (| Value.Tuple [] |)
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom AssociatedFunction_extend :
        forall (DB : Ty.t),
        M.IsAssociatedFunction (Self DB) "extend" (extend DB).
      
      (*
          pub fn call(
              &mut self,
              addess: Address,
              bytes: &Bytes,
              gas_price: u64,
              evmctx: &mut InnerEvmContext<DB>,
          ) -> Option<PrecompileResult> {
              let precompile = self.inner.get_mut(&addess)?;
      
              match precompile {
                  ContextPrecompile::Ordinary(p) => Some(p.call(bytes, gas_price, &evmctx.env)),
                  ContextPrecompile::ContextStatefulMut(p) => Some(p.call_mut(bytes, gas_price, evmctx)),
                  ContextPrecompile::ContextStateful(p) => Some(p.call(bytes, gas_price, evmctx)),
              }
          }
      *)
      Definition call (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self; addess; bytes; gas_price; evmctx ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let addess := M.alloc (| addess |) in
            let bytes := M.alloc (| bytes |) in
            let gas_price := M.alloc (| gas_price |) in
            let evmctx := M.alloc (| evmctx |) in
            M.catch_return (|
              ltac:(M.monadic
                (M.read (|
                  let~ precompile :=
                    M.copy (|
                      M.match_operator (|
                        M.alloc (|
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::ops::try_trait::Try",
                              Ty.apply
                                (Ty.path "core::option::Option")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "&mut")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path
                                          "revm::context::context_precompiles::ContextPrecompile")
                                        []
                                        [ DB ]
                                    ]
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "std::collections::hash::map::HashMap")
                                    []
                                    [
                                      Ty.path "alloy_primitives::bits::address::Address";
                                      Ty.apply
                                        (Ty.path
                                          "revm::context::context_precompiles::ContextPrecompile")
                                        []
                                        [ DB ];
                                      Ty.path "std::hash::random::RandomState"
                                    ],
                                  "get_mut",
                                  [ Ty.path "alloy_primitives::bits::address::Address" ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "revm::context::context_precompiles::ContextPrecompiles",
                                    "inner"
                                  |);
                                  addess
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Break",
                                  0
                                |) in
                              let residual := M.copy (| γ0_0 |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::try_trait::FromResidual",
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "core::result::Result")
                                                []
                                                [
                                                  Ty.tuple
                                                    [
                                                      Ty.path "u64";
                                                      Ty.path "alloy_primitives::bytes_::Bytes"
                                                    ];
                                                  Ty.path
                                                    "revm_primitives::precompile::PrecompileError"
                                                ]
                                            ],
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [ Ty.path "core::convert::Infallible" ]
                                          ],
                                          "from_residual",
                                          []
                                        |),
                                        [ M.read (| residual |) ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ =>
                            ltac:(M.monadic
                              (let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::ops::control_flow::ControlFlow::Continue",
                                  0
                                |) in
                              let val := M.copy (| γ0_0 |) in
                              val))
                        ]
                      |)
                    |) in
                  M.match_operator (|
                    precompile,
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.read (| γ |) in
                          let γ1_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "revm::context::context_precompiles::ContextPrecompile::Ordinary",
                              0
                            |) in
                          let p := M.alloc (| γ1_0 |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::option::Option::Some"
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.path "revm_primitives::precompile::Precompile",
                                    "call",
                                    []
                                  |),
                                  [
                                    M.read (| p |);
                                    M.read (| bytes |);
                                    M.read (| gas_price |);
                                    M.read (|
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| evmctx |),
                                        "revm::context::inner_evm_context::InnerEvmContext",
                                        "env"
                                      |)
                                    |)
                                  ]
                                |)
                              ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.read (| γ |) in
                          let γ1_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "revm::context::context_precompiles::ContextPrecompile::ContextStatefulMut",
                              0
                            |) in
                          let p := M.alloc (| γ1_0 |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::option::Option::Some"
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "revm::context::context_precompiles::ContextStatefulPrecompileMut",
                                    Ty.dyn
                                      [
                                        ("revm::context::context_precompiles::ContextStatefulPrecompileMut::Trait",
                                          [])
                                      ],
                                    [ DB ],
                                    "call_mut",
                                    []
                                  |),
                                  [
                                    M.read (| M.read (| p |) |);
                                    M.read (| bytes |);
                                    M.read (| gas_price |);
                                    M.read (| evmctx |)
                                  ]
                                |)
                              ]
                          |)));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.read (| γ |) in
                          let γ1_0 :=
                            M.SubPointer.get_struct_tuple_field (|
                              γ,
                              "revm::context::context_precompiles::ContextPrecompile::ContextStateful",
                              0
                            |) in
                          let p := M.alloc (| γ1_0 |) in
                          M.alloc (|
                            Value.StructTuple
                              "core::option::Option::Some"
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "revm::context::context_precompiles::ContextStatefulPrecompile",
                                    Ty.dyn
                                      [
                                        ("revm::context::context_precompiles::ContextStatefulPrecompile::Trait",
                                          [])
                                      ],
                                    [ DB ],
                                    "call",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::deref::Deref",
                                        Ty.apply
                                          (Ty.path "alloc::sync::Arc")
                                          []
                                          [
                                            Ty.dyn
                                              [
                                                ("revm::context::context_precompiles::ContextStatefulPrecompile::Trait",
                                                  [])
                                              ];
                                            Ty.path "alloc::alloc::Global"
                                          ],
                                        [],
                                        "deref",
                                        []
                                      |),
                                      [ M.read (| p |) ]
                                    |);
                                    M.read (| bytes |);
                                    M.read (| gas_price |);
                                    M.read (| evmctx |)
                                  ]
                                |)
                              ]
                          |)))
                    ]
                  |)
                |)))
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom AssociatedFunction_call :
        forall (DB : Ty.t),
        M.IsAssociatedFunction (Self DB) "call" (call DB).
    End Impl_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    Module Impl_core_default_Default_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*
          fn default() -> Self {
              Self {
                  inner: Default::default(),
              }
          }
      *)
      Definition default (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [] =>
          ltac:(M.monadic
            (Value.StructRecord
              "revm::context::context_precompiles::ContextPrecompiles"
              [
                ("inner",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::default::Default",
                      Ty.apply
                        (Ty.path "std::collections::hash::map::HashMap")
                        []
                        [
                          Ty.path "alloy_primitives::bits::address::Address";
                          Ty.apply
                            (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                            []
                            [ DB ];
                          Ty.path "std::hash::random::RandomState"
                        ],
                      [],
                      "default",
                      []
                    |),
                    []
                  |))
              ]))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::default::Default"
          (Self DB)
          (* Trait polymorphic types *) []
          (* Instance *) [ ("default", InstanceField.Method (default DB)) ].
    End Impl_core_default_Default_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    Module Impl_core_ops_deref_Deref_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*     type Target = HashMap<Address, ContextPrecompile<DB>>; *)
      Definition _Target (DB : Ty.t) : Ty.t :=
        Ty.apply
          (Ty.path "std::collections::hash::map::HashMap")
          []
          [
            Ty.path "alloy_primitives::bits::address::Address";
            Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompile") [] [ DB ];
            Ty.path "std::hash::random::RandomState"
          ].
      
      (*
          fn deref(&self) -> &Self::Target {
              &self.inner
          }
      *)
      Definition deref (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "revm::context::context_precompiles::ContextPrecompiles",
              "inner"
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::ops::deref::Deref"
          (Self DB)
          (* Trait polymorphic types *) []
          (* Instance *)
          [ ("Target", InstanceField.Ty (_Target DB)); ("deref", InstanceField.Method (deref DB)) ].
    End Impl_core_ops_deref_Deref_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    Module Impl_core_ops_deref_DerefMut_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*
          fn deref_mut(&mut self) -> &mut Self::Target {
              &mut self.inner
          }
      *)
      Definition deref_mut (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ self ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            M.SubPointer.get_struct_record_field (|
              M.read (| self |),
              "revm::context::context_precompiles::ContextPrecompiles",
              "inner"
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::ops::deref::DerefMut"
          (Self DB)
          (* Trait polymorphic types *) []
          (* Instance *) [ ("deref_mut", InstanceField.Method (deref_mut DB)) ].
    End Impl_core_ops_deref_DerefMut_where_revm_primitives_db_Database_DB_for_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    (* Trait *)
    (* Empty module 'ContextStatefulPrecompile' *)
    
    (* Trait *)
    (* Empty module 'ContextStatefulPrecompileMut' *)
    
    Axiom ContextStatefulPrecompileArc :
      forall (DB : Ty.t),
      (Ty.apply
          (Ty.path "revm::context::context_precompiles::ContextStatefulPrecompileArc")
          []
          [ DB ]) =
        (Ty.apply
          (Ty.path "alloc::sync::Arc")
          []
          [
            Ty.dyn [ ("revm::context::context_precompiles::ContextStatefulPrecompile::Trait", []) ];
            Ty.path "alloc::alloc::Global"
          ]).
    
    Axiom ContextStatefulPrecompileBox :
      forall (DB : Ty.t),
      (Ty.apply
          (Ty.path "revm::context::context_precompiles::ContextStatefulPrecompileBox")
          []
          [ DB ]) =
        (Ty.apply
          (Ty.path "alloc::boxed::Box")
          []
          [
            Ty.dyn
              [ ("revm::context::context_precompiles::ContextStatefulPrecompileMut::Trait", []) ];
            Ty.path "alloc::alloc::Global"
          ]).
    
    Module Impl_core_convert_From_where_revm_primitives_db_Database_DB_revm_primitives_precompile_Precompile_for_revm_context_context_precompiles_ContextPrecompile_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompile") [] [ DB ].
      
      (*
          fn from(p: Precompile) -> Self {
              ContextPrecompile::Ordinary(p)
          }
      *)
      Definition from (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ p ] =>
          ltac:(M.monadic
            (let p := M.alloc (| p |) in
            Value.StructTuple
              "revm::context::context_precompiles::ContextPrecompile::Ordinary"
              [ M.read (| p |) ]))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::convert::From"
          (Self DB)
          (* Trait polymorphic types *)
          [ (* T *) Ty.path "revm_primitives::precompile::Precompile" ]
          (* Instance *) [ ("from", InstanceField.Method (from DB)) ].
    End Impl_core_convert_From_where_revm_primitives_db_Database_DB_revm_primitives_precompile_Precompile_for_revm_context_context_precompiles_ContextPrecompile_DB.
    
    Module Impl_core_convert_From_where_revm_primitives_db_Database_DB_revm_precompile_Precompiles_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*
          fn from(p: Precompiles) -> Self {
              ContextPrecompiles {
                  inner: p.inner.into_iter().map(|(k, v)| (k, v.into())).collect(),
              }
          }
      *)
      Definition from (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ p ] =>
          ltac:(M.monadic
            (let p := M.alloc (| p |) in
            Value.StructRecord
              "revm::context::context_precompiles::ContextPrecompiles"
              [
                ("inner",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply
                        (Ty.path "core::iter::adapters::map::Map")
                        []
                        [
                          Ty.apply
                            (Ty.path "std::collections::hash::map::IntoIter")
                            []
                            [
                              Ty.path "alloy_primitives::bits::address::Address";
                              Ty.path "revm_primitives::precompile::Precompile"
                            ];
                          Ty.function
                            [
                              Ty.tuple
                                [
                                  Ty.tuple
                                    [
                                      Ty.path "alloy_primitives::bits::address::Address";
                                      Ty.path "revm_primitives::precompile::Precompile"
                                    ]
                                ]
                            ]
                            (Ty.tuple
                              [
                                Ty.path "alloy_primitives::bits::address::Address";
                                Ty.apply
                                  (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                                  []
                                  [ DB ]
                              ])
                        ],
                      [],
                      "collect",
                      [
                        Ty.apply
                          (Ty.path "std::collections::hash::map::HashMap")
                          []
                          [
                            Ty.path "alloy_primitives::bits::address::Address";
                            Ty.apply
                              (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                              []
                              [ DB ];
                            Ty.path "std::hash::random::RandomState"
                          ]
                      ]
                    |),
                    [
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply
                            (Ty.path "std::collections::hash::map::IntoIter")
                            []
                            [
                              Ty.path "alloy_primitives::bits::address::Address";
                              Ty.path "revm_primitives::precompile::Precompile"
                            ],
                          [],
                          "map",
                          [
                            Ty.tuple
                              [
                                Ty.path "alloy_primitives::bits::address::Address";
                                Ty.apply
                                  (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                                  []
                                  [ DB ]
                              ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.path "alloy_primitives::bits::address::Address";
                                        Ty.path "revm_primitives::precompile::Precompile"
                                      ]
                                  ]
                              ]
                              (Ty.tuple
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.apply
                                    (Ty.path
                                      "revm::context::context_precompiles::ContextPrecompile")
                                    []
                                    [ DB ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_trait_method (|
                              "core::iter::traits::collect::IntoIterator",
                              Ty.apply
                                (Ty.path "std::collections::hash::map::HashMap")
                                []
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.path "revm_primitives::precompile::Precompile";
                                  Ty.path "std::hash::random::RandomState"
                                ],
                              [],
                              "into_iter",
                              []
                            |),
                            [
                              M.read (|
                                M.SubPointer.get_struct_record_field (|
                                  p,
                                  "revm_precompile::Precompiles",
                                  "inner"
                                |)
                              |)
                            ]
                          |);
                          M.closure
                            (fun γ =>
                              ltac:(M.monadic
                                match γ with
                                | [ α0 ] =>
                                  ltac:(M.monadic
                                    (M.match_operator (|
                                      M.alloc (| α0 |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                            let k := M.copy (| γ0_0 |) in
                                            let v := M.copy (| γ0_1 |) in
                                            Value.Tuple
                                              [
                                                M.read (| k |);
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::convert::Into",
                                                    Ty.path
                                                      "revm_primitives::precompile::Precompile",
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "revm::context::context_precompiles::ContextPrecompile")
                                                        []
                                                        [ DB ]
                                                    ],
                                                    "into",
                                                    []
                                                  |),
                                                  [ M.read (| v |) ]
                                                |)
                                              ]))
                                      ]
                                    |)))
                                | _ => M.impossible "wrong number of arguments"
                                end))
                        ]
                      |)
                    ]
                  |))
              ]))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::convert::From"
          (Self DB)
          (* Trait polymorphic types *) [ (* T *) Ty.path "revm_precompile::Precompiles" ]
          (* Instance *) [ ("from", InstanceField.Method (from DB)) ].
    End Impl_core_convert_From_where_revm_primitives_db_Database_DB_revm_precompile_Precompiles_for_revm_context_context_precompiles_ContextPrecompiles_DB.
    
    Module Impl_core_convert_From_where_revm_primitives_db_Database_DB_ref__revm_precompile_Precompiles_for_revm_context_context_precompiles_ContextPrecompiles_DB.
      Definition Self (DB : Ty.t) : Ty.t :=
        Ty.apply (Ty.path "revm::context::context_precompiles::ContextPrecompiles") [] [ DB ].
      
      (*
          fn from(p: &Precompiles) -> Self {
              ContextPrecompiles {
                  inner: p
                      .inner
                      .iter()
                      .map(|(&k, v)| (k, v.clone().into()))
                      .collect(),
              }
          }
      *)
      Definition from (DB : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        let Self : Ty.t := Self DB in
        match ε, τ, α with
        | [], [], [ p ] =>
          ltac:(M.monadic
            (let p := M.alloc (| p |) in
            Value.StructRecord
              "revm::context::context_precompiles::ContextPrecompiles"
              [
                ("inner",
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply
                        (Ty.path "core::iter::adapters::map::Map")
                        []
                        [
                          Ty.apply
                            (Ty.path "std::collections::hash::map::Iter")
                            []
                            [
                              Ty.path "alloy_primitives::bits::address::Address";
                              Ty.path "revm_primitives::precompile::Precompile"
                            ];
                          Ty.function
                            [
                              Ty.tuple
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply
                                        (Ty.path "&")
                                        []
                                        [ Ty.path "alloy_primitives::bits::address::Address" ];
                                      Ty.apply
                                        (Ty.path "&")
                                        []
                                        [ Ty.path "revm_primitives::precompile::Precompile" ]
                                    ]
                                ]
                            ]
                            (Ty.tuple
                              [
                                Ty.path "alloy_primitives::bits::address::Address";
                                Ty.apply
                                  (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                                  []
                                  [ DB ]
                              ])
                        ],
                      [],
                      "collect",
                      [
                        Ty.apply
                          (Ty.path "std::collections::hash::map::HashMap")
                          []
                          [
                            Ty.path "alloy_primitives::bits::address::Address";
                            Ty.apply
                              (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                              []
                              [ DB ];
                            Ty.path "std::hash::random::RandomState"
                          ]
                      ]
                    |),
                    [
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply
                            (Ty.path "std::collections::hash::map::Iter")
                            []
                            [
                              Ty.path "alloy_primitives::bits::address::Address";
                              Ty.path "revm_primitives::precompile::Precompile"
                            ],
                          [],
                          "map",
                          [
                            Ty.tuple
                              [
                                Ty.path "alloy_primitives::bits::address::Address";
                                Ty.apply
                                  (Ty.path "revm::context::context_precompiles::ContextPrecompile")
                                  []
                                  [ DB ]
                              ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply
                                          (Ty.path "&")
                                          []
                                          [ Ty.path "alloy_primitives::bits::address::Address" ];
                                        Ty.apply
                                          (Ty.path "&")
                                          []
                                          [ Ty.path "revm_primitives::precompile::Precompile" ]
                                      ]
                                  ]
                              ]
                              (Ty.tuple
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.apply
                                    (Ty.path
                                      "revm::context::context_precompiles::ContextPrecompile")
                                    []
                                    [ DB ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "std::collections::hash::map::HashMap")
                                []
                                [
                                  Ty.path "alloy_primitives::bits::address::Address";
                                  Ty.path "revm_primitives::precompile::Precompile";
                                  Ty.path "std::hash::random::RandomState"
                                ],
                              "iter",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| p |),
                                "revm_precompile::Precompiles",
                                "inner"
                              |)
                            ]
                          |);
                          M.closure
                            (fun γ =>
                              ltac:(M.monadic
                                match γ with
                                | [ α0 ] =>
                                  ltac:(M.monadic
                                    (M.match_operator (|
                                      M.alloc (| α0 |),
                                      [
                                        fun γ =>
                                          ltac:(M.monadic
                                            (let γ0_0 := M.SubPointer.get_tuple_field (| γ, 0 |) in
                                            let γ0_1 := M.SubPointer.get_tuple_field (| γ, 1 |) in
                                            let γ0_0 := M.read (| γ0_0 |) in
                                            let k := M.copy (| γ0_0 |) in
                                            let v := M.copy (| γ0_1 |) in
                                            Value.Tuple
                                              [
                                                M.read (| k |);
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::convert::Into",
                                                    Ty.path
                                                      "revm_primitives::precompile::Precompile",
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "revm::context::context_precompiles::ContextPrecompile")
                                                        []
                                                        [ DB ]
                                                    ],
                                                    "into",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::clone::Clone",
                                                        Ty.path
                                                          "revm_primitives::precompile::Precompile",
                                                        [],
                                                        "clone",
                                                        []
                                                      |),
                                                      [ M.read (| v |) ]
                                                    |)
                                                  ]
                                                |)
                                              ]))
                                      ]
                                    |)))
                                | _ => M.impossible "wrong number of arguments"
                                end))
                        ]
                      |)
                    ]
                  |))
              ]))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        forall (DB : Ty.t),
        M.IsTraitInstance
          "core::convert::From"
          (Self DB)
          (* Trait polymorphic types *)
          [ (* T *) Ty.apply (Ty.path "&") [] [ Ty.path "revm_precompile::Precompiles" ] ]
          (* Instance *) [ ("from", InstanceField.Method (from DB)) ].
    End Impl_core_convert_From_where_revm_primitives_db_Database_DB_ref__revm_precompile_Precompiles_for_revm_context_context_precompiles_ContextPrecompiles_DB.
  End context_precompiles.
End context.
