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

Module collections.
  Module btree.
    Module map.
      Definition value_MIN_LEN : Value.t :=
        M.run
          ltac:(M.monadic
            (M.get_constant (| "alloc::collections::btree::node::MIN_LEN_AFTER_SPLIT" |))).
      
      (* StructRecord
        {
          name := "BTreeMap";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("root",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "alloc::collections::btree::node::NodeRef")
                      []
                      [
                        Ty.path "alloc::collections::btree::node::marker::Owned";
                        K;
                        V;
                        Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                      ]
                  ]);
              ("length", Ty.path "usize");
              ("alloc", Ty.apply (Ty.path "core::mem::manually_drop::ManuallyDrop") [] [ A ]);
              ("_marker",
                Ty.apply
                  (Ty.path "core::marker::PhantomData")
                  []
                  [ Ty.apply (Ty.path "alloc::boxed::Box") [] [ Ty.tuple [ K; V ]; A ] ])
            ];
        } *)
      
      Module Impl_core_ops_drop_Drop_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn drop(&mut self) {
                drop(unsafe { ptr::read(self) }.into_iter())
            }
        *)
        Definition drop (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_function (|
                  "core::mem::drop",
                  [ Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ] ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::collect::IntoIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      [],
                      "into_iter",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_function (|
                          "core::ptr::read",
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ]
                          ]
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::ops::drop::Drop"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("drop", InstanceField.Method (drop K V A)) ].
      End Impl_core_ops_drop_Drop_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_panic_unwind_safe_UnwindSafe_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_panic_unwind_safe_UnwindSafe_A_where_core_panic_unwind_safe_RefUnwindSafe_K_where_core_panic_unwind_safe_RefUnwindSafe_V_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::panic::unwind_safe::UnwindSafe"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_panic_unwind_safe_UnwindSafe_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_panic_unwind_safe_UnwindSafe_A_where_core_panic_unwind_safe_RefUnwindSafe_K_where_core_panic_unwind_safe_RefUnwindSafe_V_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_clone_Clone_where_core_clone_Clone_K_where_core_clone_Clone_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn clone(&self) -> BTreeMap<K, V, A> {
                fn clone_subtree<'a, K: Clone, V: Clone, A: Allocator + Clone>(
                    node: NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal>,
                    alloc: A,
                ) -> BTreeMap<K, V, A>
                where
                    K: 'a,
                    V: 'a,
                {
                    match node.force() {
                        Leaf(leaf) => {
                            let mut out_tree = BTreeMap {
                                root: Some(Root::new(alloc.clone())),
                                length: 0,
                                alloc: ManuallyDrop::new(alloc),
                                _marker: PhantomData,
                            };
        
                            {
                                let root = out_tree.root.as_mut().unwrap(); // unwrap succeeds because we just wrapped
                                let mut out_node = match root.borrow_mut().force() {
                                    Leaf(leaf) => leaf,
                                    Internal(_) => unreachable!(),
                                };
        
                                let mut in_edge = leaf.first_edge();
                                while let Ok(kv) = in_edge.right_kv() {
                                    let (k, v) = kv.into_kv();
                                    in_edge = kv.right_edge();
        
                                    out_node.push(k.clone(), v.clone());
                                    out_tree.length += 1;
                                }
                            }
        
                            out_tree
                        }
                        Internal(internal) => {
                            let mut out_tree =
                                clone_subtree(internal.first_edge().descend(), alloc.clone());
        
                            {
                                let out_root = out_tree.root.as_mut().unwrap();
                                let mut out_node = out_root.push_internal_level(alloc.clone());
                                let mut in_edge = internal.first_edge();
                                while let Ok(kv) = in_edge.right_kv() {
                                    let (k, v) = kv.into_kv();
                                    in_edge = kv.right_edge();
        
                                    let k = ( *k).clone();
                                    let v = ( *v).clone();
                                    let subtree = clone_subtree(in_edge.descend(), alloc.clone());
        
                                    // We can't destructure subtree directly
                                    // because BTreeMap implements Drop
                                    let (subroot, sublength) = unsafe {
                                        let subtree = ManuallyDrop::new(subtree);
                                        let root = ptr::read(&subtree.root);
                                        let length = subtree.length;
                                        (root, length)
                                    };
        
                                    out_node.push(
                                        k,
                                        v,
                                        subroot.unwrap_or_else(|| Root::new(alloc.clone())),
                                    );
                                    out_tree.length += 1 + sublength;
                                }
                            }
        
                            out_tree
                        }
                    }
                }
        
                if self.is_empty() {
                    BTreeMap::new_in(( *self.alloc).clone())
                } else {
                    clone_subtree(self.root.as_ref().unwrap().reborrow(), ( *self.alloc).clone()) // unwrap succeeds because not empty
                }
            }
        *)
        Definition clone (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::BTreeMap")
                                    []
                                    [ K; V; A ],
                                  "is_empty",
                                  []
                                |),
                                [ M.read (| self |) ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::BTreeMap")
                                []
                                [ K; V; A ],
                              "new_in",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                        []
                                        [ A ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "alloc::collections::btree::map::BTreeMap",
                                        "alloc"
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (| Self, "clone_subtree.clone", [] |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::NodeRef")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::Owned";
                                      K;
                                      V;
                                      Ty.path
                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                    ],
                                  "reborrow",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "core::option::Option")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      "unwrap",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                ]
                              |);
                              M.call_closure (|
                                M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                        []
                                        [ A ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "alloc::collections::btree::map::BTreeMap",
                                        "alloc"
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V A)) ].
      End Impl_core_clone_Clone_where_core_clone_Clone_K_where_core_clone_Clone_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_alloc_collections_btree_Recover_where_core_marker_Sized_Q_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_borrow_Borrow_K_Q_where_core_cmp_Ord_K_where_core_cmp_Ord_Q_Q_for_alloc_collections_btree_map_BTreeMap_K_alloc_collections_btree_set_val_SetValZST_A.
        Definition Self (K Q A : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::BTreeMap")
            []
            [ K; Ty.path "alloc::collections::btree::set_val::SetValZST"; A ].
        
        (*     type Key = K; *)
        Definition _Key (K Q A : Ty.t) : Ty.t := K.
        
        (*
            fn get(&self, key: &Q) -> Option<&K> {
                let root_node = self.root.as_ref()?.reborrow();
                match root_node.search_tree(key) {
                    Found(handle) => Some(handle.into_kv().0),
                    GoDown(_) => None,
                }
            }
        *)
        Definition get (K Q A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K Q A in
          match ε, τ, α with
          | [], [], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                Ty.path "alloc::collections::btree::set_val::SetValZST";
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "reborrow",
                            []
                          |),
                          [
                            M.read (|
                              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 "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  Ty.path
                                                    "alloc::collections::btree::set_val::SetValZST";
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  Ty.path
                                                    "alloc::collections::btree::set_val::SetValZST";
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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 "&") [] [ K ] ],
                                                  [
                                                    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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Immut";
                                K;
                                Ty.path "alloc::collections::btree::set_val::SetValZST";
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "search_tree",
                            [ Q ]
                          |),
                          [ M.read (| root_node |); M.read (| key |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::Found",
                                0
                              |) in
                            let handle := M.copy (| γ0_0 |) in
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  M.read (|
                                    M.SubPointer.get_tuple_field (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Immut";
                                                    K;
                                                    Ty.path
                                                      "alloc::collections::btree::set_val::SetValZST";
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ],
                                            "into_kv",
                                            []
                                          |),
                                          [ M.read (| handle |) ]
                                        |)
                                      |),
                                      0
                                    |)
                                  |)
                                ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::GoDown",
                                0
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn take(&mut self, key: &Q) -> Option<K> {
                let (map, dormant_map) = DormantMutRef::new(self);
                let root_node = map.root.as_mut()?.borrow_mut();
                match root_node.search_tree(key) {
                    Found(handle) => Some(
                        OccupiedEntry {
                            handle,
                            dormant_map,
                            alloc: ( *map.alloc).clone(),
                            _marker: PhantomData,
                        }
                        .remove_kv()
                        .0,
                    ),
                    GoDown(_) => None,
                }
            }
        *)
        Definition take (K Q A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K Q A in
          match ε, τ, α with
          | [], [], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; Ty.path "alloc::collections::btree::set_val::SetValZST"; A ]
                              ],
                            "new",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      |),
                      [
                        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 map := M.copy (| γ0_0 |) in
                            let dormant_map := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        Ty.path "alloc::collections::btree::set_val::SetValZST";
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "borrow_mut",
                                    []
                                  |),
                                  [
                                    M.read (|
                                      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
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          Ty.path
                                                            "alloc::collections::btree::set_val::SetValZST";
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          Ty.path
                                                            "alloc::collections::btree::set_val::SetValZST";
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| map |),
                                                    "alloc::collections::btree::map::BTreeMap",
                                                    "root"
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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")
                                                            []
                                                            [ K ],
                                                          [
                                                            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 (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        Ty.path "alloc::collections::btree::set_val::SetValZST";
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "search_tree",
                                    [ Q ]
                                  |),
                                  [ M.read (| root_node |); M.read (| key |) ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "alloc::collections::btree::search::SearchResult::Found",
                                        0
                                      |) in
                                    let handle := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      Value.StructTuple
                                        "core::option::Option::Some"
                                        [
                                          M.read (|
                                            M.SubPointer.get_tuple_field (|
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::map::entry::OccupiedEntry")
                                                      []
                                                      [
                                                        K;
                                                        Ty.path
                                                          "alloc::collections::btree::set_val::SetValZST";
                                                        A
                                                      ],
                                                    "remove_kv",
                                                    []
                                                  |),
                                                  [
                                                    Value.StructRecord
                                                      "alloc::collections::btree::map::entry::OccupiedEntry"
                                                      [
                                                        ("handle", M.read (| handle |));
                                                        ("dormant_map", M.read (| dormant_map |));
                                                        ("alloc",
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::clone::Clone",
                                                              A,
                                                              [],
                                                              "clone",
                                                              []
                                                            |),
                                                            [
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::deref::Deref",
                                                                  Ty.apply
                                                                    (Ty.path
                                                                      "core::mem::manually_drop::ManuallyDrop")
                                                                    []
                                                                    [ A ],
                                                                  [],
                                                                  "deref",
                                                                  []
                                                                |),
                                                                [
                                                                  M.SubPointer.get_struct_record_field (|
                                                                    M.read (| map |),
                                                                    "alloc::collections::btree::map::BTreeMap",
                                                                    "alloc"
                                                                  |)
                                                                ]
                                                              |)
                                                            ]
                                                          |));
                                                        ("_marker",
                                                          Value.StructTuple
                                                            "core::marker::PhantomData"
                                                            [])
                                                      ]
                                                  ]
                                                |)
                                              |),
                                              0
                                            |)
                                          |)
                                        ]
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "alloc::collections::btree::search::SearchResult::GoDown",
                                        0
                                      |) in
                                    M.alloc (|
                                      Value.StructTuple "core::option::Option::None" []
                                    |)))
                              ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn replace(&mut self, key: K) -> Option<K> {
                let (map, dormant_map) = DormantMutRef::new(self);
                let root_node =
                    map.root.get_or_insert_with(|| Root::new(( *map.alloc).clone())).borrow_mut();
                match root_node.search_tree::<K>(&key) {
                    Found(mut kv) => Some(mem::replace(kv.key_mut(), key)),
                    GoDown(handle) => {
                        VacantEntry {
                            key,
                            handle: Some(handle),
                            dormant_map,
                            alloc: ( *map.alloc).clone(),
                            _marker: PhantomData,
                        }
                        .insert(SetValZST::default());
                        None
                    }
                }
            }
        *)
        Definition replace
            (K Q A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K Q A in
          match ε, τ, α with
          | [], [], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                          []
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; Ty.path "alloc::collections::btree::set_val::SetValZST"; A ]
                          ],
                        "new",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |),
                  [
                    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 map := M.copy (| γ0_0 |) in
                        let dormant_map := M.copy (| γ0_1 |) in
                        let~ root_node :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Owned";
                                    K;
                                    Ty.path "alloc::collections::btree::set_val::SetValZST";
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ],
                                "borrow_mut",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Owned";
                                            K;
                                            Ty.path "alloc::collections::btree::set_val::SetValZST";
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ]
                                      ],
                                    "get_or_insert_with",
                                    [
                                      Ty.function
                                        [ Ty.tuple [] ]
                                        (Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Owned";
                                            K;
                                            Ty.path "alloc::collections::btree::set_val::SetValZST";
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ])
                                    ]
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| map |),
                                      "alloc::collections::btree::map::BTreeMap",
                                      "root"
                                    |);
                                    M.closure
                                      (fun γ =>
                                        ltac:(M.monadic
                                          match γ with
                                          | [ α0 ] =>
                                            ltac:(M.monadic
                                              (M.match_operator (|
                                                M.alloc (| α0 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::NodeRef")
                                                            []
                                                            [
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Owned";
                                                              K;
                                                              Ty.path
                                                                "alloc::collections::btree::set_val::SetValZST";
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                            ],
                                                          "new",
                                                          [ A ]
                                                        |),
                                                        [
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::clone::Clone",
                                                              A,
                                                              [],
                                                              "clone",
                                                              []
                                                            |),
                                                            [
                                                              M.call_closure (|
                                                                M.get_trait_method (|
                                                                  "core::ops::deref::Deref",
                                                                  Ty.apply
                                                                    (Ty.path
                                                                      "core::mem::manually_drop::ManuallyDrop")
                                                                    []
                                                                    [ A ],
                                                                  [],
                                                                  "deref",
                                                                  []
                                                                |),
                                                                [
                                                                  M.SubPointer.get_struct_record_field (|
                                                                    M.read (| map |),
                                                                    "alloc::collections::btree::map::BTreeMap",
                                                                    "alloc"
                                                                  |)
                                                                ]
                                                              |)
                                                            ]
                                                          |)
                                                        ]
                                                      |)))
                                                ]
                                              |)))
                                          | _ => M.impossible "wrong number of arguments"
                                          end))
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    Ty.path "alloc::collections::btree::set_val::SetValZST";
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ],
                                "search_tree",
                                [ K ]
                              |),
                              [ M.read (| root_node |); key ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "alloc::collections::btree::search::SearchResult::Found",
                                    0
                                  |) in
                                let kv := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "core::option::Option::Some"
                                    [
                                      M.call_closure (|
                                        M.get_function (| "core::mem::replace", [ K ] |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      Ty.path
                                                        "alloc::collections::btree::set_val::SetValZST";
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::KV"
                                                ],
                                              "key_mut",
                                              []
                                            |),
                                            [ kv ]
                                          |);
                                          M.read (| key |)
                                        ]
                                      |)
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "alloc::collections::btree::search::SearchResult::GoDown",
                                    0
                                  |) in
                                let handle := M.copy (| γ0_0 |) in
                                let~ _ :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path
                                            "alloc::collections::btree::map::entry::VacantEntry")
                                          []
                                          [
                                            K;
                                            Ty.path "alloc::collections::btree::set_val::SetValZST";
                                            A
                                          ],
                                        "insert",
                                        []
                                      |),
                                      [
                                        Value.StructRecord
                                          "alloc::collections::btree::map::entry::VacantEntry"
                                          [
                                            ("key", M.read (| key |));
                                            ("handle",
                                              Value.StructTuple
                                                "core::option::Option::Some"
                                                [ M.read (| handle |) ]);
                                            ("dormant_map", M.read (| dormant_map |));
                                            ("alloc",
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::clone::Clone",
                                                  A,
                                                  [],
                                                  "clone",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::ops::deref::Deref",
                                                      Ty.apply
                                                        (Ty.path
                                                          "core::mem::manually_drop::ManuallyDrop")
                                                        []
                                                        [ A ],
                                                      [],
                                                      "deref",
                                                      []
                                                    |),
                                                    [
                                                      M.SubPointer.get_struct_record_field (|
                                                        M.read (| map |),
                                                        "alloc::collections::btree::map::BTreeMap",
                                                        "alloc"
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |));
                                            ("_marker",
                                              Value.StructTuple "core::marker::PhantomData" [])
                                          ];
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::default::Default",
                                            Ty.path "alloc::collections::btree::set_val::SetValZST",
                                            [],
                                            "default",
                                            []
                                          |),
                                          []
                                        |)
                                      ]
                                    |)
                                  |) in
                                M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K Q A : Ty.t),
          M.IsTraitInstance
            "alloc::collections::btree::Recover"
            (Self K Q A)
            (* Trait polymorphic types *) [ (* Q *) Q ]
            (* Instance *)
            [
              ("Key", InstanceField.Ty (_Key K Q A));
              ("get", InstanceField.Method (get K Q A));
              ("take", InstanceField.Method (take K Q A));
              ("replace", InstanceField.Method (replace K Q A))
            ].
      End Impl_alloc_collections_btree_Recover_where_core_marker_Sized_Q_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_borrow_Borrow_K_Q_where_core_cmp_Ord_K_where_core_cmp_Ord_Q_Q_for_alloc_collections_btree_map_BTreeMap_K_alloc_collections_btree_set_val_SetValZST_A.
      
      (* StructRecord
        {
          name := "Iter";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("range",
                Ty.apply
                  (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                  []
                  [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ]);
              ("length", Ty.path "usize")
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.clone()).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.tuple
                          [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::clone::Clone",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                          [],
                          "clone",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn default() -> Self {
                Iter { range: Default::default(), length: 0 }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::Iter"
                [
                  ("range",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("length", Value.Integer IntegerKind.Usize 0)
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_Iter_K_V.
      
      (* StructRecord
        {
          name := "IterMut";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("range",
                Ty.apply
                  (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                  []
                  [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ]);
              ("length", Ty.path "usize");
              ("_marker",
                Ty.apply
                  (Ty.path "core::marker::PhantomData")
                  []
                  [ Ty.apply (Ty.path "&mut") [] [ Ty.tuple [ K; V ] ] ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                let range = Iter { range: self.range.reborrow(), length: self.length };
                f.debug_list().entries(range).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.read (|
                let~ range :=
                  M.alloc (|
                    Value.StructRecord
                      "alloc::collections::btree::map::Iter"
                      [
                        ("range",
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                []
                                [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                              "reborrow",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::map::IterMut",
                                "range"
                              |)
                            ]
                          |));
                        ("length",
                          M.read (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::IterMut",
                              "length"
                            |)
                          |))
                      ]
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "finish",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "core::fmt::builders::DebugList",
                          "entries",
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                            Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]
                          ]
                        |),
                        [
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "core::fmt::Formatter",
                                "debug_list",
                                []
                              |),
                              [ M.read (| f |) ]
                            |)
                          |);
                          M.read (| range |)
                        ]
                      |)
                    ]
                  |)
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            fn default() -> Self {
                IterMut { range: Default::default(), length: 0, _marker: PhantomData {} }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::IterMut"
                [
                  ("range",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("length", Value.Integer IntegerKind.Usize 0);
                  ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_IterMut_K_V.
      
      (* StructRecord
        {
          name := "IntoIter";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("range",
                Ty.apply
                  (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                  []
                  [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V ]);
              ("length", Ty.path "usize");
              ("alloc", A)
            ];
        } *)
      
      Module Impl_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            pub(super) fn iter(&self) -> Iter<'_, K, V> {
                Iter { range: self.range.reborrow(), length: self.length }
            }
        *)
        Definition iter (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Iter"
                [
                  ("range",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V ],
                        "reborrow",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::IntoIter",
                          "range"
                        |)
                      ]
                    |));
                  ("length",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IntoIter",
                        "length"
                      |)
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "iter" (iter K V A).
        (*
            fn dying_next(
                &mut self,
            ) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
                if self.length == 0 {
                    self.range.deallocating_end(self.alloc.clone());
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.deallocating_next_unchecked(self.alloc.clone()) })
                }
            }
        *)
        Definition dying_next
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IntoIter",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                  []
                                  [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V
                                  ],
                                "deallocating_end",
                                [ A ]
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::IntoIter",
                                  "range"
                                |);
                                M.call_closure (|
                                  M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::IntoIter",
                                      "alloc"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::IntoIter",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V
                                    ],
                                  "deallocating_next_unchecked",
                                  [ A ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IntoIter",
                                    "range"
                                  |);
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::clone::Clone",
                                      A,
                                      [],
                                      "clone",
                                      []
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "alloc::collections::btree::map::IntoIter",
                                        "alloc"
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_dying_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "dying_next" (dying_next K V A).
        
        (*
            fn dying_next_back(
                &mut self,
            ) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>> {
                if self.length == 0 {
                    self.range.deallocating_end(self.alloc.clone());
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.deallocating_next_back_unchecked(self.alloc.clone()) })
                }
            }
        *)
        Definition dying_next_back
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IntoIter",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                  []
                                  [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V
                                  ],
                                "deallocating_end",
                                [ A ]
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::IntoIter",
                                  "range"
                                |);
                                M.call_closure (|
                                  M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::IntoIter",
                                      "alloc"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::IntoIter",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V
                                    ],
                                  "deallocating_next_back_unchecked",
                                  [ A ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IntoIter",
                                    "range"
                                  |);
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::clone::Clone",
                                      A,
                                      [],
                                      "clone",
                                      []
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "alloc::collections::btree::map::IntoIter",
                                        "alloc"
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_dying_next_back :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "dying_next_back" (dying_next_back K V A).
      End Impl_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.iter()).finish()
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.tuple
                          [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "alloc::collections::btree::map::IntoIter")
                            []
                            [ K; V; A ],
                          "iter",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn default() -> Self {
                IntoIter { range: Default::default(), length: 0, alloc: Default::default() }
            }
        *)
        Definition default
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::IntoIter"
                [
                  ("range",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Dying"; K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("length", Value.Integer IntegerKind.Usize 0);
                  ("alloc",
                    M.call_closure (|
                      M.get_trait_method (| "core::default::Default", A, [], "default", [] |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V A)) ].
      End Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      (* StructRecord
        {
          name := "Keys";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [ ("inner", Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]) ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.clone()).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ K ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::clone::Clone",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ],
                          [],
                          "clone",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_for_alloc_collections_btree_map_Keys_K_V.
      
      (* StructRecord
        {
          name := "Values";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [ ("inner", Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]) ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.clone()).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ V ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::clone::Clone",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ],
                          [],
                          "clone",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Values_K_V.
      
      (* StructRecord
        {
          name := "ValuesMut";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [ ("inner", Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ]) ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_V_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.inner.iter().map(|(_, val)| val)).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ V ];
                        Ty.apply
                          (Ty.path "core::iter::adapters::map::Map")
                          []
                          [
                            Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ V ])
                          ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                          [],
                          "map",
                          [
                            Ty.apply (Ty.path "&") [] [ V ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ V ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::IterMut")
                                []
                                [ K; V ],
                              "iter",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::map::ValuesMut",
                                "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 val := M.copy (| γ0_1 |) in
                                            M.read (| val |)))
                                      ]
                                    |)))
                                | _ => M.impossible "wrong number of arguments"
                                end))
                        ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_V_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      (* StructRecord
        {
          name := "IntoKeys";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("inner",
                Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.inner.iter().map(|(key, _)| key)).finish()
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ K ];
                        Ty.apply
                          (Ty.path "core::iter::adapters::map::Map")
                          []
                          [
                            Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ K ])
                          ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                          [],
                          "map",
                          [
                            Ty.apply (Ty.path "&") [] [ K ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ K ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::IntoIter")
                                []
                                [ K; V; A ],
                              "iter",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::map::IntoKeys",
                                "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 key := M.copy (| γ0_0 |) in
                                            M.read (| key |)))
                                      ]
                                    |)))
                                | _ => M.impossible "wrong number of arguments"
                                end))
                        ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      (* StructRecord
        {
          name := "IntoValues";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("inner",
                Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.inner.iter().map(|(_, val)| val)).finish()
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ V ];
                        Ty.apply
                          (Ty.path "core::iter::adapters::map::Map")
                          []
                          [
                            Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ V ])
                          ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::iterator::Iterator",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                          [],
                          "map",
                          [
                            Ty.apply (Ty.path "&") [] [ V ];
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                              (Ty.apply (Ty.path "&") [] [ V ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::IntoIter")
                                []
                                [ K; V; A ],
                              "iter",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::map::IntoValues",
                                "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 val := M.copy (| γ0_1 |) in
                                            M.read (| val |)))
                                      ]
                                    |)))
                                | _ => M.impossible "wrong number of arguments"
                                end))
                        ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      (* StructRecord
        {
          name := "Range";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("inner",
                Ty.apply
                  (Ty.path "alloc::collections::btree::navigate::LeafRange")
                  []
                  [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_list().entries(self.clone()).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugList",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "entries",
                      [
                        Ty.tuple
                          [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_list",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::clone::Clone",
                          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ],
                          [],
                          "clone",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Range_K_V.
      
      (* StructRecord
        {
          name := "RangeMut";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("inner",
                Ty.apply
                  (Ty.path "alloc::collections::btree::navigate::LeafRange")
                  []
                  [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ]);
              ("_marker",
                Ty.apply
                  (Ty.path "core::marker::PhantomData")
                  []
                  [ Ty.apply (Ty.path "&mut") [] [ Ty.tuple [ K; V ] ] ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_RangeMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                let range = Range { inner: self.inner.reborrow() };
                f.debug_list().entries(range).finish()
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.read (|
                let~ range :=
                  M.alloc (|
                    Value.StructRecord
                      "alloc::collections::btree::map::Range"
                      [
                        ("inner",
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::navigate::LeafRange")
                                []
                                [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                              "reborrow",
                              []
                            |),
                            [
                              M.SubPointer.get_struct_record_field (|
                                M.read (| self |),
                                "alloc::collections::btree::map::RangeMut",
                                "inner"
                              |)
                            ]
                          |))
                      ]
                  |) in
                M.alloc (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugList",
                      "finish",
                      []
                    |),
                    [
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "core::fmt::builders::DebugList",
                          "entries",
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                            Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ]
                          ]
                        |),
                        [
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "core::fmt::Formatter",
                                "debug_list",
                                []
                              |),
                              [ M.read (| f |) ]
                            |)
                          |);
                          M.read (| range |)
                        ]
                      |)
                    ]
                  |)
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_RangeMut_K_V.
      
      Module Impl_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::BTreeMap")
            []
            [ K; V; Ty.path "alloc::alloc::Global" ].
        
        (*
            pub const fn new() -> BTreeMap<K, V> {
                BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(Global), _marker: PhantomData }
            }
        *)
        Definition new (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::BTreeMap"
                [
                  ("root", Value.StructTuple "core::option::Option::None" []);
                  ("length", Value.Integer IntegerKind.Usize 0);
                  ("alloc",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::mem::manually_drop::ManuallyDrop")
                          []
                          [ Ty.path "alloc::alloc::Global" ],
                        "new",
                        []
                      |),
                      [ Value.StructTuple "alloc::alloc::Global" [] ]
                    |));
                  ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "new" (new K V).
      End Impl_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
      
      Module Impl_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            pub fn clear(&mut self) {
                // avoid moving the allocator
                drop(BTreeMap {
                    root: mem::replace(&mut self.root, None),
                    length: mem::replace(&mut self.length, 0),
                    alloc: self.alloc.clone(),
                    _marker: PhantomData,
                });
            }
        *)
        Definition clear (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (|
                        "core::mem::drop",
                        [
                          Ty.apply
                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                            []
                            [ K; V; A ]
                        ]
                      |),
                      [
                        Value.StructRecord
                          "alloc::collections::btree::map::BTreeMap"
                          [
                            ("root",
                              M.call_closure (|
                                M.get_function (|
                                  "core::mem::replace",
                                  [
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Owned";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ]
                                      ]
                                  ]
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "root"
                                  |);
                                  Value.StructTuple "core::option::Option::None" []
                                ]
                              |));
                            ("length",
                              M.call_closure (|
                                M.get_function (| "core::mem::replace", [ Ty.path "usize" ] |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "length"
                                  |);
                                  Value.Integer IntegerKind.Usize 0
                                ]
                              |));
                            ("alloc",
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::clone::Clone",
                                  Ty.apply
                                    (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                    []
                                    [ A ],
                                  [],
                                  "clone",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "alloc"
                                  |)
                                ]
                              |));
                            ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                          ]
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_clear :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "clear" (clear K V A).
        
        (*
            pub const fn new_in(alloc: A) -> BTreeMap<K, V, A> {
                BTreeMap { root: None, length: 0, alloc: ManuallyDrop::new(alloc), _marker: PhantomData }
            }
        *)
        Definition new_in
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ alloc ] =>
            ltac:(M.monadic
              (let alloc := M.alloc (| alloc |) in
              Value.StructRecord
                "alloc::collections::btree::map::BTreeMap"
                [
                  ("root", Value.StructTuple "core::option::Option::None" []);
                  ("length", Value.Integer IntegerKind.Usize 0);
                  ("alloc",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply (Ty.path "core::mem::manually_drop::ManuallyDrop") [] [ A ],
                        "new",
                        []
                      |),
                      [ M.read (| alloc |) ]
                    |));
                  ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_new_in :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "new_in" (new_in K V A).
        (*
            pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let root_node = self.root.as_ref()?.reborrow();
                match root_node.search_tree(key) {
                    Found(handle) => Some(handle.into_kv().1),
                    GoDown(_) => None,
                }
            }
        *)
        Definition get (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "reborrow",
                            []
                          |),
                          [
                            M.read (|
                              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 "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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 "&") [] [ V ] ],
                                                  [
                                                    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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Immut";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "search_tree",
                            [ Q ]
                          |),
                          [ M.read (| root_node |); M.read (| key |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::Found",
                                0
                              |) in
                            let handle := M.copy (| γ0_0 |) in
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  M.read (|
                                    M.SubPointer.get_tuple_field (|
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Immut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ],
                                            "into_kv",
                                            []
                                          |),
                                          [ M.read (| handle |) ]
                                        |)
                                      |),
                                      1
                                    |)
                                  |)
                                ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::GoDown",
                                0
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_get :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "get" (get K V A).
        
        (*
            pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let root_node = self.root.as_ref()?.reborrow();
                match root_node.search_tree(k) {
                    Found(handle) => Some(handle.into_kv()),
                    GoDown(_) => None,
                }
            }
        *)
        Definition get_key_value
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; k ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let k := M.alloc (| k |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "reborrow",
                            []
                          |),
                          [
                            M.read (|
                              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 "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple
                                                        [
                                                          Ty.apply (Ty.path "&") [] [ K ];
                                                          Ty.apply (Ty.path "&") [] [ V ]
                                                        ]
                                                    ],
                                                  [
                                                    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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Immut";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "search_tree",
                            [ Q ]
                          |),
                          [ M.read (| root_node |); M.read (| k |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::Found",
                                0
                              |) in
                            let handle := M.copy (| γ0_0 |) in
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::Handle")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::NodeRef")
                                            []
                                            [
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Immut";
                                              K;
                                              V;
                                              Ty.path
                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                            ];
                                          Ty.path "alloc::collections::btree::node::marker::KV"
                                        ],
                                      "into_kv",
                                      []
                                    |),
                                    [ M.read (| handle |) ]
                                  |)
                                ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::GoDown",
                                0
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_get_key_value :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "get_key_value" (get_key_value K V A).
        
        (*
            pub fn first_key_value(&self) -> Option<(&K, &V)>
            where
                K: Ord,
            {
                let root_node = self.root.as_ref()?.reborrow();
                root_node.first_leaf_edge().right_kv().ok().map(Handle::into_kv)
            }
        *)
        Definition first_key_value
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "reborrow",
                            []
                          |),
                          [
                            M.read (|
                              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 "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple
                                                        [
                                                          Ty.apply (Ty.path "&") [] [ K ];
                                                          Ty.apply (Ty.path "&") [] [ V ]
                                                        ]
                                                    ],
                                                  [
                                                    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.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::option::Option")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::node::Handle")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::NodeRef")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::Immut";
                                      K;
                                      V;
                                      Ty.path "alloc::collections::btree::node::marker::Leaf"
                                    ];
                                  Ty.path "alloc::collections::btree::node::marker::KV"
                                ]
                            ],
                          "map",
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                            Ty.function
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::KV"
                                  ]
                              ]
                              (Ty.tuple
                                [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::KV"
                                    ];
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::Edge"
                                    ]
                                ],
                              "ok",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::Edge"
                                    ],
                                  "right_kv",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ],
                                      "first_leaf_edge",
                                      []
                                    |),
                                    [ M.read (| root_node |) ]
                                  |)
                                ]
                              |)
                            ]
                          |);
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "into_kv",
                            []
                          |)
                        ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_first_key_value :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "first_key_value" (first_key_value K V A).
        
        (*
            pub fn first_entry(&mut self) -> Option<OccupiedEntry<'_, K, V, A>>
            where
                K: Ord,
            {
                let (map, dormant_map) = DormantMutRef::new(self);
                let root_node = map.root.as_mut()?.borrow_mut();
                let kv = root_node.first_leaf_edge().right_kv().ok()?;
                Some(OccupiedEntry {
                    handle: kv.forget_node_type(),
                    dormant_map,
                    alloc: ( *map.alloc).clone(),
                    _marker: PhantomData,
                })
            }
        *)
        Definition first_entry
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ]
                              ],
                            "new",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      |),
                      [
                        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 map := M.copy (| γ0_0 |) in
                            let dormant_map := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "borrow_mut",
                                    []
                                  |),
                                  [
                                    M.read (|
                                      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
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| map |),
                                                    "alloc::collections::btree::map::BTreeMap",
                                                    "root"
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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
                                                                  "alloc::collections::btree::map::entry::OccupiedEntry")
                                                                []
                                                                [ K; V; A ]
                                                            ],
                                                          [
                                                            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
                            let~ kv :=
                              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 "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Mut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Leaf"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ]
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::KV"
                                                  ];
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Edge"
                                                  ]
                                              ],
                                            "ok",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Edge"
                                                  ],
                                                "right_kv",
                                                []
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                                      ],
                                                    "first_leaf_edge",
                                                    []
                                                  |),
                                                  [ M.read (| root_node |) ]
                                                |)
                                              ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    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
                                                            "alloc::collections::btree::map::entry::OccupiedEntry")
                                                          []
                                                          [ K; V; A ]
                                                      ],
                                                    [
                                                      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.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  Value.StructRecord
                                    "alloc::collections::btree::map::entry::OccupiedEntry"
                                    [
                                      ("handle",
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Mut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Leaf"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ],
                                            "forget_node_type",
                                            []
                                          |),
                                          [ M.read (| kv |) ]
                                        |));
                                      ("dormant_map", M.read (| dormant_map |));
                                      ("alloc",
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::clone::Clone",
                                            A,
                                            [],
                                            "clone",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::deref::Deref",
                                                Ty.apply
                                                  (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                                  []
                                                  [ A ],
                                                [],
                                                "deref",
                                                []
                                              |),
                                              [
                                                M.SubPointer.get_struct_record_field (|
                                                  M.read (| map |),
                                                  "alloc::collections::btree::map::BTreeMap",
                                                  "alloc"
                                                |)
                                              ]
                                            |)
                                          ]
                                        |));
                                      ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                                    ]
                                ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_first_entry :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "first_entry" (first_entry K V A).
        
        (*
            pub fn pop_first(&mut self) -> Option<(K, V)>
            where
                K: Ord,
            {
                self.first_entry().map(|entry| entry.remove_entry())
            }
        *)
        Definition pop_first
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.apply
                        (Ty.path "alloc::collections::btree::map::entry::OccupiedEntry")
                        []
                        [ K; V; A ]
                    ],
                  "map",
                  [
                    Ty.tuple [ K; V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::entry::OccupiedEntry")
                              []
                              [ K; V; A ]
                          ]
                      ]
                      (Ty.tuple [ K; V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "first_entry",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          ltac:(M.monadic
                            (M.match_operator (|
                              M.alloc (| α0 |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let entry := M.copy (| γ |) in
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path
                                            "alloc::collections::btree::map::entry::OccupiedEntry")
                                          []
                                          [ K; V; A ],
                                        "remove_entry",
                                        []
                                      |),
                                      [ M.read (| entry |) ]
                                    |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_pop_first :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "pop_first" (pop_first K V A).
        
        (*
            pub fn last_key_value(&self) -> Option<(&K, &V)>
            where
                K: Ord,
            {
                let root_node = self.root.as_ref()?.reborrow();
                root_node.last_leaf_edge().left_kv().ok().map(Handle::into_kv)
            }
        *)
        Definition last_key_value
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "reborrow",
                            []
                          |),
                          [
                            M.read (|
                              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 "&")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_ref",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple
                                                        [
                                                          Ty.apply (Ty.path "&") [] [ K ];
                                                          Ty.apply (Ty.path "&") [] [ V ]
                                                        ]
                                                    ],
                                                  [
                                                    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.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::option::Option")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::node::Handle")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::NodeRef")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::Immut";
                                      K;
                                      V;
                                      Ty.path "alloc::collections::btree::node::marker::Leaf"
                                    ];
                                  Ty.path "alloc::collections::btree::node::marker::KV"
                                ]
                            ],
                          "map",
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                            Ty.function
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::KV"
                                  ]
                              ]
                              (Ty.tuple
                                [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::KV"
                                    ];
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::Edge"
                                    ]
                                ],
                              "ok",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::Edge"
                                    ],
                                  "left_kv",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ],
                                      "last_leaf_edge",
                                      []
                                    |),
                                    [ M.read (| root_node |) ]
                                  |)
                                ]
                              |)
                            ]
                          |);
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "into_kv",
                            []
                          |)
                        ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_last_key_value :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "last_key_value" (last_key_value K V A).
        
        (*
            pub fn last_entry(&mut self) -> Option<OccupiedEntry<'_, K, V, A>>
            where
                K: Ord,
            {
                let (map, dormant_map) = DormantMutRef::new(self);
                let root_node = map.root.as_mut()?.borrow_mut();
                let kv = root_node.last_leaf_edge().left_kv().ok()?;
                Some(OccupiedEntry {
                    handle: kv.forget_node_type(),
                    dormant_map,
                    alloc: ( *map.alloc).clone(),
                    _marker: PhantomData,
                })
            }
        *)
        Definition last_entry
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ]
                              ],
                            "new",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      |),
                      [
                        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 map := M.copy (| γ0_0 |) in
                            let dormant_map := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "borrow_mut",
                                    []
                                  |),
                                  [
                                    M.read (|
                                      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
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| map |),
                                                    "alloc::collections::btree::map::BTreeMap",
                                                    "root"
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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
                                                                  "alloc::collections::btree::map::entry::OccupiedEntry")
                                                                []
                                                                [ K; V; A ]
                                                            ],
                                                          [
                                                            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
                            let~ kv :=
                              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 "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Mut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Leaf"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ]
                                          ],
                                        [],
                                        "branch",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "core::result::Result")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::KV"
                                                  ];
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Edge"
                                                  ]
                                              ],
                                            "ok",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_associated_function (|
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::Handle")
                                                  []
                                                  [
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ];
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Edge"
                                                  ],
                                                "left_kv",
                                                []
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Mut";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                                      ],
                                                    "last_leaf_edge",
                                                    []
                                                  |),
                                                  [ M.read (| root_node |) ]
                                                |)
                                              ]
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    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
                                                            "alloc::collections::btree::map::entry::OccupiedEntry")
                                                          []
                                                          [ K; V; A ]
                                                      ],
                                                    [
                                                      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.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  Value.StructRecord
                                    "alloc::collections::btree::map::entry::OccupiedEntry"
                                    [
                                      ("handle",
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Mut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Leaf"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ],
                                            "forget_node_type",
                                            []
                                          |),
                                          [ M.read (| kv |) ]
                                        |));
                                      ("dormant_map", M.read (| dormant_map |));
                                      ("alloc",
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::clone::Clone",
                                            A,
                                            [],
                                            "clone",
                                            []
                                          |),
                                          [
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::ops::deref::Deref",
                                                Ty.apply
                                                  (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                                  []
                                                  [ A ],
                                                [],
                                                "deref",
                                                []
                                              |),
                                              [
                                                M.SubPointer.get_struct_record_field (|
                                                  M.read (| map |),
                                                  "alloc::collections::btree::map::BTreeMap",
                                                  "alloc"
                                                |)
                                              ]
                                            |)
                                          ]
                                        |));
                                      ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                                    ]
                                ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_last_entry :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "last_entry" (last_entry K V A).
        
        (*
            pub fn pop_last(&mut self) -> Option<(K, V)>
            where
                K: Ord,
            {
                self.last_entry().map(|entry| entry.remove_entry())
            }
        *)
        Definition pop_last
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.apply
                        (Ty.path "alloc::collections::btree::map::entry::OccupiedEntry")
                        []
                        [ K; V; A ]
                    ],
                  "map",
                  [
                    Ty.tuple [ K; V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::entry::OccupiedEntry")
                              []
                              [ K; V; A ]
                          ]
                      ]
                      (Ty.tuple [ K; V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "last_entry",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          ltac:(M.monadic
                            (M.match_operator (|
                              M.alloc (| α0 |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let entry := M.copy (| γ |) in
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path
                                            "alloc::collections::btree::map::entry::OccupiedEntry")
                                          []
                                          [ K; V; A ],
                                        "remove_entry",
                                        []
                                      |),
                                      [ M.read (| entry |) ]
                                    |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_pop_last :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "pop_last" (pop_last K V A).
        
        (*
            pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                self.get(key).is_some()
            }
        *)
        Definition contains_key
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.apply (Ty.path "&") [] [ V ] ],
                  "is_some",
                  []
                |),
                [
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "get",
                        [ Q ]
                      |),
                      [ M.read (| self |); M.read (| key |) ]
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_contains_key :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "contains_key" (contains_key K V A).
        
        (*
            pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let root_node = self.root.as_mut()?.borrow_mut();
                match root_node.search_tree(key) {
                    Found(handle) => Some(handle.into_val_mut()),
                    GoDown(_) => None,
                }
            }
        *)
        Definition get_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "borrow_mut",
                            []
                          |),
                          [
                            M.read (|
                              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 "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::option::Option")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "as_mut",
                                          []
                                        |),
                                        [
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "root"
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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 "&mut") [] [ V ] ],
                                                  [
                                                    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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Mut";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "search_tree",
                            [ Q ]
                          |),
                          [ M.read (| root_node |); M.read (| key |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::Found",
                                0
                              |) in
                            let handle := M.copy (| γ0_0 |) in
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::Handle")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::NodeRef")
                                            []
                                            [
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Mut";
                                              K;
                                              V;
                                              Ty.path
                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                            ];
                                          Ty.path "alloc::collections::btree::node::marker::KV"
                                        ],
                                      "into_val_mut",
                                      []
                                    |),
                                    [ M.read (| handle |) ]
                                  |)
                                ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "alloc::collections::btree::search::SearchResult::GoDown",
                                0
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_get_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "get_mut" (get_mut K V A).
        
        (*
            pub fn insert(&mut self, key: K, value: V) -> Option<V>
            where
                K: Ord,
            {
                match self.entry(key) {
                    Occupied(mut entry) => Some(entry.insert(value)),
                    Vacant(entry) => {
                        entry.insert(value);
                        None
                    }
                }
            }
        *)
        Definition insert
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "entry",
                        []
                      |),
                      [ M.read (| self |); M.read (| key |) ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::map::entry::Entry::Occupied",
                            0
                          |) in
                        let entry := M.copy (| γ0_0 |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::entry::OccupiedEntry")
                                    []
                                    [ K; V; A ],
                                  "insert",
                                  []
                                |),
                                [ entry; M.read (| value |) ]
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::map::entry::Entry::Vacant",
                            0
                          |) in
                        let entry := M.copy (| γ0_0 |) in
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::entry::VacantEntry")
                                  []
                                  [ K; V; A ],
                                "insert",
                                []
                              |),
                              [ M.read (| entry |); M.read (| value |) ]
                            |)
                          |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "insert" (insert K V A).
        
        (*
            pub fn try_insert(&mut self, key: K, value: V) -> Result<&mut V, OccupiedError<'_, K, V, A>>
            where
                K: Ord,
            {
                match self.entry(key) {
                    Occupied(entry) => Err(OccupiedError { entry, value }),
                    Vacant(entry) => Ok(entry.insert(value)),
                }
            }
        *)
        Definition try_insert
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "entry",
                        []
                      |),
                      [ M.read (| self |); M.read (| key |) ]
                    |)
                  |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::map::entry::Entry::Occupied",
                            0
                          |) in
                        let entry := M.copy (| γ0_0 |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Err"
                            [
                              Value.StructRecord
                                "alloc::collections::btree::map::entry::OccupiedError"
                                [ ("entry", M.read (| entry |)); ("value", M.read (| value |)) ]
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "alloc::collections::btree::map::entry::Entry::Vacant",
                            0
                          |) in
                        let entry := M.copy (| γ0_0 |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::entry::VacantEntry")
                                    []
                                    [ K; V; A ],
                                  "insert",
                                  []
                                |),
                                [ M.read (| entry |); M.read (| value |) ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_try_insert :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "try_insert" (try_insert K V A).
        
        (*
            pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                self.remove_entry(key).map(|(_, v)| v)
            }
        *)
        Definition remove
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.tuple [ K; V ] ],
                  "map",
                  [ V; Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] V ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "remove_entry",
                      [ Q ]
                    |),
                    [ M.read (| self |); M.read (| key |) ]
                  |);
                  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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove" (remove K V A).
        
        (*
            pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let (map, dormant_map) = DormantMutRef::new(self);
                let root_node = map.root.as_mut()?.borrow_mut();
                match root_node.search_tree(key) {
                    Found(handle) => Some(
                        OccupiedEntry {
                            handle,
                            dormant_map,
                            alloc: ( *map.alloc).clone(),
                            _marker: PhantomData,
                        }
                        .remove_entry(),
                    ),
                    GoDown(_) => None,
                }
            }
        *)
        Definition remove_entry
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ]
                              ],
                            "new",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      |),
                      [
                        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 map := M.copy (| γ0_0 |) in
                            let dormant_map := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "borrow_mut",
                                    []
                                  |),
                                  [
                                    M.read (|
                                      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
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              [],
                                              "branch",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| map |),
                                                    "alloc::collections::btree::map::BTreeMap",
                                                    "root"
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |),
                                        [
                                          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.tuple [ K; V ] ],
                                                          [
                                                            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 (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "search_tree",
                                    [ Q ]
                                  |),
                                  [ M.read (| root_node |); M.read (| key |) ]
                                |)
                              |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "alloc::collections::btree::search::SearchResult::Found",
                                        0
                                      |) in
                                    let handle := M.copy (| γ0_0 |) in
                                    M.alloc (|
                                      Value.StructTuple
                                        "core::option::Option::Some"
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path
                                                  "alloc::collections::btree::map::entry::OccupiedEntry")
                                                []
                                                [ K; V; A ],
                                              "remove_entry",
                                              []
                                            |),
                                            [
                                              Value.StructRecord
                                                "alloc::collections::btree::map::entry::OccupiedEntry"
                                                [
                                                  ("handle", M.read (| handle |));
                                                  ("dormant_map", M.read (| dormant_map |));
                                                  ("alloc",
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::clone::Clone",
                                                        A,
                                                        [],
                                                        "clone",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.apply
                                                              (Ty.path
                                                                "core::mem::manually_drop::ManuallyDrop")
                                                              []
                                                              [ A ],
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| map |),
                                                              "alloc::collections::btree::map::BTreeMap",
                                                              "alloc"
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |));
                                                  ("_marker",
                                                    Value.StructTuple
                                                      "core::marker::PhantomData"
                                                      [])
                                                ]
                                            ]
                                          |)
                                        ]
                                    |)));
                                fun γ =>
                                  ltac:(M.monadic
                                    (let γ0_0 :=
                                      M.SubPointer.get_struct_tuple_field (|
                                        γ,
                                        "alloc::collections::btree::search::SearchResult::GoDown",
                                        0
                                      |) in
                                    M.alloc (|
                                      Value.StructTuple "core::option::Option::None" []
                                    |)))
                              ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove_entry :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove_entry" (remove_entry K V A).
        
        (*
            pub fn retain<F>(&mut self, mut f: F)
            where
                K: Ord,
                F: FnMut(&K, &mut V) -> bool,
            {
                self.extract_if(|k, v| !f(k, v)).for_each(drop);
            }
        *)
        Definition retain
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ F ], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::iterator::Iterator",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::ExtractIf")
                          []
                          [
                            K;
                            V;
                            Ty.function
                              [
                                Ty.tuple
                                  [
                                    Ty.apply (Ty.path "&") [] [ K ];
                                    Ty.apply (Ty.path "&mut") [] [ V ]
                                  ]
                              ]
                              (Ty.path "bool");
                            A
                          ],
                        [],
                        "for_each",
                        [ Ty.function [ Ty.tuple [ K; V ] ] (Ty.tuple []) ]
                      |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ],
                            "extract_if",
                            [
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply (Ty.path "&") [] [ K ];
                                      Ty.apply (Ty.path "&mut") [] [ V ]
                                    ]
                                ]
                                (Ty.path "bool")
                            ]
                          |),
                          [
                            M.read (| self |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0; α1 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let k := M.copy (| γ |) in
                                              M.match_operator (|
                                                M.alloc (| α1 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let v := M.copy (| γ |) in
                                                      UnOp.not (|
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::function::FnMut",
                                                            F,
                                                            [
                                                              Ty.tuple
                                                                [
                                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                                  Ty.apply (Ty.path "&mut") [] [ V ]
                                                                ]
                                                            ],
                                                            "call_mut",
                                                            []
                                                          |),
                                                          [
                                                            f;
                                                            Value.Tuple
                                                              [ M.read (| k |); M.read (| v |) ]
                                                          ]
                                                        |)
                                                      |)))
                                                ]
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |);
                        M.get_function (| "core::mem::drop", [ Ty.tuple [ K; V ] ] |)
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_retain :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "retain" (retain K V A).
        
        (*
            pub fn append(&mut self, other: &mut Self)
            where
                K: Ord,
                A: Clone,
            {
                // Do we have to append anything at all?
                if other.is_empty() {
                    return;
                }
        
                // We can just swap `self` and `other` if `self` is empty.
                if self.is_empty() {
                    mem::swap(self, other);
                    return;
                }
        
                let self_iter = mem::replace(self, Self::new_in(( *self.alloc).clone())).into_iter();
                let other_iter = mem::replace(other, Self::new_in(( *self.alloc).clone())).into_iter();
                let root = self.root.get_or_insert_with(|| Root::new(( *self.alloc).clone()));
                root.append_from_sorted_iters(
                    self_iter,
                    other_iter,
                    &mut self.length,
                    ( *self.alloc).clone(),
                )
            }
        *)
        Definition append
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                                          []
                                          [ K; V; A ],
                                        "is_empty",
                                        []
                                      |),
                                      [ M.read (| other |) ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (| M.read (| M.return_ (| Value.Tuple [] |) |) |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                                          []
                                          [ K; V; A ],
                                        "is_empty",
                                        []
                                      |),
                                      [ M.read (| self |) ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    let~ _ :=
                                      M.alloc (|
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::mem::swap",
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::map::BTreeMap")
                                                []
                                                [ K; V; A ]
                                            ]
                                          |),
                                          [ M.read (| self |); M.read (| other |) ]
                                        |)
                                      |) in
                                    M.return_ (| Value.Tuple [] |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ self_iter :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::collect::IntoIterator",
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ],
                            [],
                            "into_iter",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "core::mem::replace",
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::BTreeMap")
                                    []
                                    [ K; V; A ]
                                ]
                              |),
                              [
                                M.read (| self |);
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::map::BTreeMap")
                                      []
                                      [ K; V; A ],
                                    "new_in",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::clone::Clone",
                                        A,
                                        [],
                                        "clone",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::deref::Deref",
                                            Ty.apply
                                              (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                              []
                                              [ A ],
                                            [],
                                            "deref",
                                            []
                                          |),
                                          [
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "alloc::collections::btree::map::BTreeMap",
                                              "alloc"
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |) in
                    let~ other_iter :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::collect::IntoIterator",
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ],
                            [],
                            "into_iter",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_function (|
                                "core::mem::replace",
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::BTreeMap")
                                    []
                                    [ K; V; A ]
                                ]
                              |),
                              [
                                M.read (| other |);
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::map::BTreeMap")
                                      []
                                      [ K; V; A ],
                                    "new_in",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::clone::Clone",
                                        A,
                                        [],
                                        "clone",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::ops::deref::Deref",
                                            Ty.apply
                                              (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                              []
                                              [ A ],
                                            [],
                                            "deref",
                                            []
                                          |),
                                          [
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "alloc::collections::btree::map::BTreeMap",
                                              "alloc"
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |) in
                    let~ root :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "core::option::Option")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Owned";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ]
                              ],
                            "get_or_insert_with",
                            [
                              Ty.function
                                [ Ty.tuple [] ]
                                (Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Owned";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ])
                            ]
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Owned";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ],
                                                  "new",
                                                  [ A ]
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_trait_method (|
                                                      "core::clone::Clone",
                                                      A,
                                                      [],
                                                      "clone",
                                                      []
                                                    |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::ops::deref::Deref",
                                                          Ty.apply
                                                            (Ty.path
                                                              "core::mem::manually_drop::ManuallyDrop")
                                                            []
                                                            [ A ],
                                                          [],
                                                          "deref",
                                                          []
                                                        |),
                                                        [
                                                          M.SubPointer.get_struct_record_field (|
                                                            M.read (| self |),
                                                            "alloc::collections::btree::map::BTreeMap",
                                                            "alloc"
                                                          |)
                                                        ]
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      |) in
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "alloc::collections::btree::node::NodeRef")
                            []
                            [
                              Ty.path "alloc::collections::btree::node::marker::Owned";
                              K;
                              V;
                              Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                            ],
                          "append_from_sorted_iters",
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::IntoIter")
                              []
                              [ K; V; A ];
                            A
                          ]
                        |),
                        [
                          M.read (| root |);
                          M.read (| self_iter |);
                          M.read (| other_iter |);
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::map::BTreeMap",
                            "length"
                          |);
                          M.call_closure (|
                            M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "core::ops::deref::Deref",
                                  Ty.apply
                                    (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                    []
                                    [ A ],
                                  [],
                                  "deref",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "alloc"
                                  |)
                                ]
                              |)
                            ]
                          |)
                        ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_append :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "append" (append K V A).
        
        (*
            pub fn range<T: ?Sized, R>(&self, range: R) -> Range<'_, K, V>
            where
                T: Ord,
                K: Borrow<T> + Ord,
                R: RangeBounds<T>,
            {
                if let Some(root) = &self.root {
                    Range { inner: root.reborrow().range_search(range) }
                } else {
                    Range { inner: LeafRange::none() }
                }
            }
        *)
        Definition range (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ T; R ], [ self; range ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let range := M.alloc (| range |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          |) in
                        let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::Range"
                            [
                              ("inner",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "range_search",
                                    [ T; R ]
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Owned";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "reborrow",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |);
                                    M.read (| range |)
                                  ]
                                |))
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::Range"
                            [
                              ("inner",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::navigate::LeafRange")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V
                                      ],
                                    "none",
                                    []
                                  |),
                                  []
                                |))
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_range :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "range" (range K V A).
        
        (*
            pub fn range_mut<T: ?Sized, R>(&mut self, range: R) -> RangeMut<'_, K, V>
            where
                T: Ord,
                K: Borrow<T> + Ord,
                R: RangeBounds<T>,
            {
                if let Some(root) = &mut self.root {
                    RangeMut { inner: root.borrow_valmut().range_search(range), _marker: PhantomData }
                } else {
                    RangeMut { inner: LeafRange::none(), _marker: PhantomData }
                }
            }
        *)
        Definition range_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ T; R ], [ self; range ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let range := M.alloc (| range |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          |) in
                        let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.alloc (| γ1_0 |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::RangeMut"
                            [
                              ("inner",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::ValMut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "range_search",
                                    [ T; R ]
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Owned";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "borrow_valmut",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |);
                                    M.read (| range |)
                                  ]
                                |));
                              ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::RangeMut"
                            [
                              ("inner",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::navigate::LeafRange")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::ValMut";
                                        K;
                                        V
                                      ],
                                    "none",
                                    []
                                  |),
                                  []
                                |));
                              ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_range_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "range_mut" (range_mut K V A).
        
        (*
            pub fn entry(&mut self, key: K) -> Entry<'_, K, V, A>
            where
                K: Ord,
            {
                let (map, dormant_map) = DormantMutRef::new(self);
                match map.root {
                    None => Vacant(VacantEntry {
                        key,
                        handle: None,
                        dormant_map,
                        alloc: ( *map.alloc).clone(),
                        _marker: PhantomData,
                    }),
                    Some(ref mut root) => match root.borrow_mut().search_tree(&key) {
                        Found(handle) => Occupied(OccupiedEntry {
                            handle,
                            dormant_map,
                            alloc: ( *map.alloc).clone(),
                            _marker: PhantomData,
                        }),
                        GoDown(handle) => Vacant(VacantEntry {
                            key,
                            handle: Some(handle),
                            dormant_map,
                            alloc: ( *map.alloc).clone(),
                            _marker: PhantomData,
                        }),
                    },
                }
            }
        *)
        Definition entry (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                          []
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ]
                          ],
                        "new",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |),
                  [
                    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 map := M.copy (| γ0_0 |) in
                        let dormant_map := M.copy (| γ0_1 |) in
                        M.match_operator (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| map |),
                            "alloc::collections::btree::map::BTreeMap",
                            "root"
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                M.alloc (|
                                  Value.StructTuple
                                    "alloc::collections::btree::map::entry::Entry::Vacant"
                                    [
                                      Value.StructRecord
                                        "alloc::collections::btree::map::entry::VacantEntry"
                                        [
                                          ("key", M.read (| key |));
                                          ("handle",
                                            Value.StructTuple "core::option::Option::None" []);
                                          ("dormant_map", M.read (| dormant_map |));
                                          ("alloc",
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::clone::Clone",
                                                A,
                                                [],
                                                "clone",
                                                []
                                              |),
                                              [
                                                M.call_closure (|
                                                  M.get_trait_method (|
                                                    "core::ops::deref::Deref",
                                                    Ty.apply
                                                      (Ty.path
                                                        "core::mem::manually_drop::ManuallyDrop")
                                                      []
                                                      [ A ],
                                                    [],
                                                    "deref",
                                                    []
                                                  |),
                                                  [
                                                    M.SubPointer.get_struct_record_field (|
                                                      M.read (| map |),
                                                      "alloc::collections::btree::map::BTreeMap",
                                                      "alloc"
                                                    |)
                                                  ]
                                                |)
                                              ]
                                            |));
                                          ("_marker",
                                            Value.StructTuple "core::marker::PhantomData" [])
                                        ]
                                    ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let root := M.alloc (| γ0_0 |) in
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "search_tree",
                                        [ K ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Owned";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ],
                                            "borrow_mut",
                                            []
                                          |),
                                          [ M.read (| root |) ]
                                        |);
                                        key
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "alloc::collections::btree::search::SearchResult::Found",
                                            0
                                          |) in
                                        let handle := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          Value.StructTuple
                                            "alloc::collections::btree::map::entry::Entry::Occupied"
                                            [
                                              Value.StructRecord
                                                "alloc::collections::btree::map::entry::OccupiedEntry"
                                                [
                                                  ("handle", M.read (| handle |));
                                                  ("dormant_map", M.read (| dormant_map |));
                                                  ("alloc",
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::clone::Clone",
                                                        A,
                                                        [],
                                                        "clone",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.apply
                                                              (Ty.path
                                                                "core::mem::manually_drop::ManuallyDrop")
                                                              []
                                                              [ A ],
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| map |),
                                                              "alloc::collections::btree::map::BTreeMap",
                                                              "alloc"
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |));
                                                  ("_marker",
                                                    Value.StructTuple
                                                      "core::marker::PhantomData"
                                                      [])
                                                ]
                                            ]
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "alloc::collections::btree::search::SearchResult::GoDown",
                                            0
                                          |) in
                                        let handle := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          Value.StructTuple
                                            "alloc::collections::btree::map::entry::Entry::Vacant"
                                            [
                                              Value.StructRecord
                                                "alloc::collections::btree::map::entry::VacantEntry"
                                                [
                                                  ("key", M.read (| key |));
                                                  ("handle",
                                                    Value.StructTuple
                                                      "core::option::Option::Some"
                                                      [ M.read (| handle |) ]);
                                                  ("dormant_map", M.read (| dormant_map |));
                                                  ("alloc",
                                                    M.call_closure (|
                                                      M.get_trait_method (|
                                                        "core::clone::Clone",
                                                        A,
                                                        [],
                                                        "clone",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_trait_method (|
                                                            "core::ops::deref::Deref",
                                                            Ty.apply
                                                              (Ty.path
                                                                "core::mem::manually_drop::ManuallyDrop")
                                                              []
                                                              [ A ],
                                                            [],
                                                            "deref",
                                                            []
                                                          |),
                                                          [
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| map |),
                                                              "alloc::collections::btree::map::BTreeMap",
                                                              "alloc"
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |));
                                                  ("_marker",
                                                    Value.StructTuple
                                                      "core::marker::PhantomData"
                                                      [])
                                                ]
                                            ]
                                        |)))
                                  ]
                                |)))
                          ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_entry :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "entry" (entry K V A).
        
        (*
            pub fn split_off<Q: ?Sized + Ord>(&mut self, key: &Q) -> Self
            where
                K: Borrow<Q> + Ord,
                A: Clone,
            {
                if self.is_empty() {
                    return Self::new_in(( *self.alloc).clone());
                }
        
                let total_num = self.len();
                let left_root = self.root.as_mut().unwrap(); // unwrap succeeds because not empty
        
                let right_root = left_root.split_off(key, ( *self.alloc).clone());
        
                let (new_left_len, right_len) = Root::calc_split_length(total_num, &left_root, &right_root);
                self.length = new_left_len;
        
                BTreeMap {
                    root: Some(right_root),
                    length: right_len,
                    alloc: self.alloc.clone(),
                    _marker: PhantomData,
                }
            }
        *)
        Definition split_off
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                                          []
                                          [ K; V; A ],
                                        "is_empty",
                                        []
                                      |),
                                      [ M.read (| self |) ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                                            []
                                            [ K; V; A ],
                                          "new_in",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::clone::Clone",
                                              A,
                                              [],
                                              "clone",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::ops::deref::Deref",
                                                  Ty.apply
                                                    (Ty.path
                                                      "core::mem::manually_drop::ManuallyDrop")
                                                    []
                                                    [ A ],
                                                  [],
                                                  "deref",
                                                  []
                                                |),
                                                [
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| self |),
                                                    "alloc::collections::btree::map::BTreeMap",
                                                    "alloc"
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ total_num :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ],
                            "len",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      |) in
                    let~ left_root :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "core::option::Option")
                              []
                              [
                                Ty.apply
                                  (Ty.path "&mut")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ]
                              ],
                            "unwrap",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_mut",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |)
                          ]
                        |)
                      |) in
                    let~ right_root :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "split_off",
                            [ Q; A ]
                          |),
                          [
                            M.read (| left_root |);
                            M.read (| key |);
                            M.call_closure (|
                              M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                              [
                                M.call_closure (|
                                  M.get_trait_method (|
                                    "core::ops::deref::Deref",
                                    Ty.apply
                                      (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                      []
                                      [ A ],
                                    [],
                                    "deref",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::BTreeMap",
                                      "alloc"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          ]
                        |)
                      |) in
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "calc_split_length",
                            []
                          |),
                          [ M.read (| total_num |); M.read (| left_root |); right_root ]
                        |)
                      |),
                      [
                        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 new_left_len := M.copy (| γ0_0 |) in
                            let right_len := M.copy (| γ0_1 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "length"
                                |),
                                M.read (| new_left_len |)
                              |) in
                            M.alloc (|
                              Value.StructRecord
                                "alloc::collections::btree::map::BTreeMap"
                                [
                                  ("root",
                                    Value.StructTuple
                                      "core::option::Option::Some"
                                      [ M.read (| right_root |) ]);
                                  ("length", M.read (| right_len |));
                                  ("alloc",
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::clone::Clone",
                                        Ty.apply
                                          (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                          []
                                          [ A ],
                                        [],
                                        "clone",
                                        []
                                      |),
                                      [
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "alloc::collections::btree::map::BTreeMap",
                                          "alloc"
                                        |)
                                      ]
                                    |));
                                  ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                                ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_split_off :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "split_off" (split_off K V A).
        
        (*
            pub fn extract_if<F>(&mut self, pred: F) -> ExtractIf<'_, K, V, F, A>
            where
                K: Ord,
                F: FnMut(&K, &mut V) -> bool,
            {
                let (inner, alloc) = self.extract_if_inner();
                ExtractIf { pred, inner, alloc }
            }
        *)
        Definition extract_if
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ F ], [ self; pred ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let pred := M.alloc (| pred |) in
              M.read (|
                M.match_operator (|
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "extract_if_inner",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |),
                  [
                    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 inner := M.copy (| γ0_0 |) in
                        let alloc := M.copy (| γ0_1 |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::ExtractIf"
                            [
                              ("pred", M.read (| pred |));
                              ("inner", M.read (| inner |));
                              ("alloc", M.read (| alloc |))
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_extract_if :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "extract_if" (extract_if K V A).
        
        (*
            pub(super) fn extract_if_inner(&mut self) -> (ExtractIfInner<'_, K, V>, A)
            where
                K: Ord,
            {
                if let Some(root) = self.root.as_mut() {
                    let (root, dormant_root) = DormantMutRef::new(root);
                    let front = root.borrow_mut().first_leaf_edge();
                    (
                        ExtractIfInner {
                            length: &mut self.length,
                            dormant_root: Some(dormant_root),
                            cur_leaf_edge: Some(front),
                        },
                        ( *self.alloc).clone(),
                    )
                } else {
                    (
                        ExtractIfInner {
                            length: &mut self.length,
                            dormant_root: None,
                            cur_leaf_edge: None,
                        },
                        ( *self.alloc).clone(),
                    )
                }
            }
        *)
        Definition extract_if_inner
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_mut",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.copy (| γ0_0 |) in
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "new",
                                []
                              |),
                              [ M.read (| root |) ]
                            |)
                          |),
                          [
                            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 root := M.copy (| γ0_0 |) in
                                let dormant_root := M.copy (| γ0_1 |) in
                                let~ front :=
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "first_leaf_edge",
                                        []
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_associated_function (|
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Owned";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ],
                                            "borrow_mut",
                                            []
                                          |),
                                          [ M.read (| root |) ]
                                        |)
                                      ]
                                    |)
                                  |) in
                                M.alloc (|
                                  Value.Tuple
                                    [
                                      Value.StructRecord
                                        "alloc::collections::btree::map::ExtractIfInner"
                                        [
                                          ("length",
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "alloc::collections::btree::map::BTreeMap",
                                              "length"
                                            |));
                                          ("dormant_root",
                                            Value.StructTuple
                                              "core::option::Option::Some"
                                              [ M.read (| dormant_root |) ]);
                                          ("cur_leaf_edge",
                                            Value.StructTuple
                                              "core::option::Option::Some"
                                              [ M.read (| front |) ])
                                        ];
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::clone::Clone",
                                          A,
                                          [],
                                          "clone",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::deref::Deref",
                                              Ty.apply
                                                (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                                []
                                                [ A ],
                                              [],
                                              "deref",
                                              []
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "alloc::collections::btree::map::BTreeMap",
                                                "alloc"
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    ]
                                |)))
                          ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.Tuple
                            [
                              Value.StructRecord
                                "alloc::collections::btree::map::ExtractIfInner"
                                [
                                  ("length",
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::BTreeMap",
                                      "length"
                                    |));
                                  ("dormant_root",
                                    Value.StructTuple "core::option::Option::None" []);
                                  ("cur_leaf_edge",
                                    Value.StructTuple "core::option::Option::None" [])
                                ];
                              M.call_closure (|
                                M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                                [
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::Deref",
                                      Ty.apply
                                        (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                        []
                                        [ A ],
                                      [],
                                      "deref",
                                      []
                                    |),
                                    [
                                      M.SubPointer.get_struct_record_field (|
                                        M.read (| self |),
                                        "alloc::collections::btree::map::BTreeMap",
                                        "alloc"
                                      |)
                                    ]
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_extract_if_inner :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "extract_if_inner" (extract_if_inner K V A).
        
        (*
            pub fn into_keys(self) -> IntoKeys<K, V, A> {
                IntoKeys { inner: self.into_iter() }
            }
        *)
        Definition into_keys
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::IntoKeys"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::collect::IntoIterator",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        [],
                        "into_iter",
                        []
                      |),
                      [ M.read (| self |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_into_keys :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "into_keys" (into_keys K V A).
        
        (*
            pub fn into_values(self) -> IntoValues<K, V, A> {
                IntoValues { inner: self.into_iter() }
            }
        *)
        Definition into_values
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::IntoValues"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::collect::IntoIterator",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        [],
                        "into_iter",
                        []
                      |),
                      [ M.read (| self |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_into_values :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "into_values" (into_values K V A).
        
        (*
            pub(crate) fn bulk_build_from_sorted_iter<I>(iter: I, alloc: A) -> Self
            where
                K: Ord,
                I: IntoIterator<Item = (K, V)>,
            {
                let mut root = Root::new(alloc.clone());
                let mut length = 0;
                root.bulk_push(DedupSortedIter::new(iter.into_iter()), &mut length, alloc.clone());
                BTreeMap { root: Some(root), length, alloc: ManuallyDrop::new(alloc), _marker: PhantomData }
            }
        *)
        Definition bulk_build_from_sorted_iter
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ _ as I ], [ iter; alloc ] =>
            ltac:(M.monadic
              (let iter := M.alloc (| iter |) in
              let alloc := M.alloc (| alloc |) in
              M.read (|
                let~ root :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Owned";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                          ],
                        "new",
                        [ A ]
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                          [ alloc ]
                        |)
                      ]
                    |)
                  |) in
                let~ length := M.alloc (| Value.Integer IntegerKind.Usize 0 |) in
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Owned";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                          ],
                        "bulk_push",
                        [
                          Ty.apply
                            (Ty.path
                              "alloc::collections::btree::dedup_sorted_iter::DedupSortedIter")
                            []
                            [ K; V; Ty.associated ];
                          A
                        ]
                      |),
                      [
                        root;
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path
                                "alloc::collections::btree::dedup_sorted_iter::DedupSortedIter")
                              []
                              [ K; V; Ty.associated ],
                            "new",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::iter::traits::collect::IntoIterator",
                                I,
                                [],
                                "into_iter",
                                []
                              |),
                              [ M.read (| iter |) ]
                            |)
                          ]
                        |);
                        length;
                        M.call_closure (|
                          M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                          [ alloc ]
                        |)
                      ]
                    |)
                  |) in
                M.alloc (|
                  Value.StructRecord
                    "alloc::collections::btree::map::BTreeMap"
                    [
                      ("root",
                        Value.StructTuple "core::option::Option::Some" [ M.read (| root |) ]);
                      ("length", M.read (| length |));
                      ("alloc",
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "core::mem::manually_drop::ManuallyDrop") [] [ A ],
                            "new",
                            []
                          |),
                          [ M.read (| alloc |) ]
                        |));
                      ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                    ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_bulk_build_from_sorted_iter :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction
            (Self K V A)
            "bulk_build_from_sorted_iter"
            (bulk_build_from_sorted_iter K V A).
        (*
            pub fn iter(&self) -> Iter<'_, K, V> {
                if let Some(root) = &self.root {
                    let full_range = root.reborrow().full_range();
        
                    Iter { range: full_range, length: self.length }
                } else {
                    Iter { range: LazyLeafRange::none(), length: 0 }
                }
            }
        *)
        Definition iter (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          |) in
                        let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.alloc (| γ1_0 |) in
                        let~ full_range :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ],
                                "full_range",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "reborrow",
                                    []
                                  |),
                                  [ M.read (| root |) ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::Iter"
                            [
                              ("range", M.read (| full_range |));
                              ("length",
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "length"
                                  |)
                                |))
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::Iter"
                            [
                              ("range",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V
                                      ],
                                    "none",
                                    []
                                  |),
                                  []
                                |));
                              ("length", Value.Integer IntegerKind.Usize 0)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "iter" (iter K V A).
        
        (*
            pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
                if let Some(root) = &mut self.root {
                    let full_range = root.borrow_valmut().full_range();
        
                    IterMut { range: full_range, length: self.length, _marker: PhantomData }
                } else {
                    IterMut { range: LazyLeafRange::none(), length: 0, _marker: PhantomData }
                }
            }
        *)
        Definition iter_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          |) in
                        let γ := M.read (| γ |) in
                        let γ1_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.alloc (| γ1_0 |) in
                        let~ full_range :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::ValMut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ],
                                "full_range",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "borrow_valmut",
                                    []
                                  |),
                                  [ M.read (| root |) ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::IterMut"
                            [
                              ("range", M.read (| full_range |));
                              ("length",
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "length"
                                  |)
                                |));
                              ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::IterMut"
                            [
                              ("range",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::ValMut";
                                        K;
                                        V
                                      ],
                                    "none",
                                    []
                                  |),
                                  []
                                |));
                              ("length", Value.Integer IntegerKind.Usize 0);
                              ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "iter_mut" (iter_mut K V A).
        
        (*
            pub fn keys(&self) -> Keys<'_, K, V> {
                Keys { inner: self.iter() }
            }
        *)
        Definition keys (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Keys"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "iter",
                        []
                      |),
                      [ M.read (| self |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_keys :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "keys" (keys K V A).
        
        (*
            pub fn values(&self) -> Values<'_, K, V> {
                Values { inner: self.iter() }
            }
        *)
        Definition values
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Values"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "iter",
                        []
                      |),
                      [ M.read (| self |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_values :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "values" (values K V A).
        
        (*
            pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
                ValuesMut { inner: self.iter_mut() }
            }
        *)
        Definition values_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::ValuesMut"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        "iter_mut",
                        []
                      |),
                      [ M.read (| self |) ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_values_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "values_mut" (values_mut K V A).
        
        (*
            pub const fn len(&self) -> usize {
                self.length
            }
        *)
        Definition len (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "alloc::collections::btree::map::BTreeMap",
                  "length"
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_len :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "len" (len K V A).
        
        (*
            pub const fn is_empty(&self) -> bool {
                self.len() == 0
            }
        *)
        Definition is_empty
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              BinOp.eq (|
                M.call_closure (|
                  M.get_associated_function (|
                    Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                    "len",
                    []
                  |),
                  [ M.read (| self |) ]
                |),
                Value.Integer IntegerKind.Usize 0
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_is_empty :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "is_empty" (is_empty K V A).
        
        (*
            pub fn lower_bound<Q: ?Sized>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let root_node = match self.root.as_ref() {
                    None => return Cursor { current: None, root: None },
                    Some(root) => root.reborrow(),
                };
                let edge = root_node.lower_bound(SearchBound::from_range(bound));
                Cursor { current: Some(edge), root: self.root.as_ref() }
            }
        *)
        Definition lower_bound
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; bound ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let bound := M.alloc (| bound |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.copy (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_ref",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructRecord
                                          "alloc::collections::btree::map::Cursor"
                                          [
                                            ("current",
                                              Value.StructTuple "core::option::Option::None" []);
                                            ("root",
                                              Value.StructTuple "core::option::Option::None" [])
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let root := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Owned";
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ],
                                      "reborrow",
                                      []
                                    |),
                                    [ M.read (| root |) ]
                                  |)
                                |)))
                          ]
                        |)
                      |) in
                    let~ edge :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Immut";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "lower_bound",
                            [ Q ]
                          |),
                          [
                            M.read (| root_node |);
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::search::SearchBound")
                                  []
                                  [ Ty.apply (Ty.path "&") [] [ Q ] ],
                                "from_range",
                                []
                              |),
                              [ M.read (| bound |) ]
                            |)
                          ]
                        |)
                      |) in
                    M.alloc (|
                      Value.StructRecord
                        "alloc::collections::btree::map::Cursor"
                        [
                          ("current",
                            Value.StructTuple "core::option::Option::Some" [ M.read (| edge |) ]);
                          ("root",
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_ref",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |))
                        ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_lower_bound :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "lower_bound" (lower_bound K V A).
        
        (*
            pub fn lower_bound_mut<Q: ?Sized>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V, A>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let (root, dormant_root) = DormantMutRef::new(&mut self.root);
                let root_node = match root.as_mut() {
                    None => {
                        return CursorMut {
                            inner: CursorMutKey {
                                current: None,
                                root: dormant_root,
                                length: &mut self.length,
                                alloc: &mut *self.alloc,
                            },
                        };
                    }
                    Some(root) => root.borrow_mut(),
                };
                let edge = root_node.lower_bound(SearchBound::from_range(bound));
                CursorMut {
                    inner: CursorMutKey {
                        current: Some(edge),
                        root: dormant_root,
                        length: &mut self.length,
                        alloc: &mut *self.alloc,
                    },
                }
            }
        *)
        Definition lower_bound_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; bound ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let bound := M.alloc (| bound |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ]
                              ],
                            "new",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          ]
                        |)
                      |),
                      [
                        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 root := M.copy (| γ0_0 |) in
                            let dormant_root := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.copy (|
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Owned";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ]
                                          ],
                                        "as_mut",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let _ :=
                                          M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                Value.StructRecord
                                                  "alloc::collections::btree::map::CursorMut"
                                                  [
                                                    ("inner",
                                                      Value.StructRecord
                                                        "alloc::collections::btree::map::CursorMutKey"
                                                        [
                                                          ("current",
                                                            Value.StructTuple
                                                              "core::option::Option::None"
                                                              []);
                                                          ("root", M.read (| dormant_root |));
                                                          ("length",
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| self |),
                                                              "alloc::collections::btree::map::BTreeMap",
                                                              "length"
                                                            |));
                                                          ("alloc",
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::deref::DerefMut",
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "core::mem::manually_drop::ManuallyDrop")
                                                                  []
                                                                  [ A ],
                                                                [],
                                                                "deref_mut",
                                                                []
                                                              |),
                                                              [
                                                                M.SubPointer.get_struct_record_field (|
                                                                  M.read (| self |),
                                                                  "alloc::collections::btree::map::BTreeMap",
                                                                  "alloc"
                                                                |)
                                                              ]
                                                            |))
                                                        ])
                                                  ]
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::option::Option::Some",
                                            0
                                          |) in
                                        let root := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ],
                                              "borrow_mut",
                                              []
                                            |),
                                            [ M.read (| root |) ]
                                          |)
                                        |)))
                                  ]
                                |)
                              |) in
                            let~ edge :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "lower_bound",
                                    [ Q ]
                                  |),
                                  [
                                    M.read (| root_node |);
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::search::SearchBound")
                                          []
                                          [ Ty.apply (Ty.path "&") [] [ Q ] ],
                                        "from_range",
                                        []
                                      |),
                                      [ M.read (| bound |) ]
                                    |)
                                  ]
                                |)
                              |) in
                            M.alloc (|
                              Value.StructRecord
                                "alloc::collections::btree::map::CursorMut"
                                [
                                  ("inner",
                                    Value.StructRecord
                                      "alloc::collections::btree::map::CursorMutKey"
                                      [
                                        ("current",
                                          Value.StructTuple
                                            "core::option::Option::Some"
                                            [ M.read (| edge |) ]);
                                        ("root", M.read (| dormant_root |));
                                        ("length",
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "length"
                                          |));
                                        ("alloc",
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::deref::DerefMut",
                                              Ty.apply
                                                (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                                []
                                                [ A ],
                                              [],
                                              "deref_mut",
                                              []
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "alloc::collections::btree::map::BTreeMap",
                                                "alloc"
                                              |)
                                            ]
                                          |))
                                      ])
                                ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_lower_bound_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "lower_bound_mut" (lower_bound_mut K V A).
        
        (*
            pub fn upper_bound<Q: ?Sized>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let root_node = match self.root.as_ref() {
                    None => return Cursor { current: None, root: None },
                    Some(root) => root.reborrow(),
                };
                let edge = root_node.upper_bound(SearchBound::from_range(bound));
                Cursor { current: Some(edge), root: self.root.as_ref() }
            }
        *)
        Definition upper_bound
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; bound ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let bound := M.alloc (| bound |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ root_node :=
                      M.copy (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_ref",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      M.return_ (|
                                        Value.StructRecord
                                          "alloc::collections::btree::map::Cursor"
                                          [
                                            ("current",
                                              Value.StructTuple "core::option::Option::None" []);
                                            ("root",
                                              Value.StructTuple "core::option::Option::None" [])
                                          ]
                                      |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let root := M.copy (| γ0_0 |) in
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Owned";
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ],
                                      "reborrow",
                                      []
                                    |),
                                    [ M.read (| root |) ]
                                  |)
                                |)))
                          ]
                        |)
                      |) in
                    let~ edge :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Immut";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ],
                            "upper_bound",
                            [ Q ]
                          |),
                          [
                            M.read (| root_node |);
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::search::SearchBound")
                                  []
                                  [ Ty.apply (Ty.path "&") [] [ Q ] ],
                                "from_range",
                                []
                              |),
                              [ M.read (| bound |) ]
                            |)
                          ]
                        |)
                      |) in
                    M.alloc (|
                      Value.StructRecord
                        "alloc::collections::btree::map::Cursor"
                        [
                          ("current",
                            Value.StructTuple "core::option::Option::Some" [ M.read (| edge |) ]);
                          ("root",
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "as_ref",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |))
                        ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_upper_bound :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "upper_bound" (upper_bound K V A).
        
        (*
            pub fn upper_bound_mut<Q: ?Sized>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V, A>
            where
                K: Borrow<Q> + Ord,
                Q: Ord,
            {
                let (root, dormant_root) = DormantMutRef::new(&mut self.root);
                let root_node = match root.as_mut() {
                    None => {
                        return CursorMut {
                            inner: CursorMutKey {
                                current: None,
                                root: dormant_root,
                                length: &mut self.length,
                                alloc: &mut *self.alloc,
                            },
                        };
                    }
                    Some(root) => root.borrow_mut(),
                };
                let edge = root_node.upper_bound(SearchBound::from_range(bound));
                CursorMut {
                    inner: CursorMutKey {
                        current: Some(edge),
                        root: dormant_root,
                        length: &mut self.length,
                        alloc: &mut *self.alloc,
                    },
                }
            }
        *)
        Definition upper_bound_mut
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ Q ], [ self; bound ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let bound := M.alloc (| bound |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ]
                              ],
                            "new",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::BTreeMap",
                              "root"
                            |)
                          ]
                        |)
                      |),
                      [
                        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 root := M.copy (| γ0_0 |) in
                            let dormant_root := M.copy (| γ0_1 |) in
                            let~ root_node :=
                              M.copy (|
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::option::Option")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Owned";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ]
                                          ],
                                        "as_mut",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let _ :=
                                          M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              M.return_ (|
                                                Value.StructRecord
                                                  "alloc::collections::btree::map::CursorMut"
                                                  [
                                                    ("inner",
                                                      Value.StructRecord
                                                        "alloc::collections::btree::map::CursorMutKey"
                                                        [
                                                          ("current",
                                                            Value.StructTuple
                                                              "core::option::Option::None"
                                                              []);
                                                          ("root", M.read (| dormant_root |));
                                                          ("length",
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| self |),
                                                              "alloc::collections::btree::map::BTreeMap",
                                                              "length"
                                                            |));
                                                          ("alloc",
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::ops::deref::DerefMut",
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "core::mem::manually_drop::ManuallyDrop")
                                                                  []
                                                                  [ A ],
                                                                [],
                                                                "deref_mut",
                                                                []
                                                              |),
                                                              [
                                                                M.SubPointer.get_struct_record_field (|
                                                                  M.read (| self |),
                                                                  "alloc::collections::btree::map::BTreeMap",
                                                                  "alloc"
                                                                |)
                                                              ]
                                                            |))
                                                        ])
                                                  ]
                                              |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::option::Option::Some",
                                            0
                                          |) in
                                        let root := M.copy (| γ0_0 |) in
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ],
                                              "borrow_mut",
                                              []
                                            |),
                                            [ M.read (| root |) ]
                                          |)
                                        |)))
                                  ]
                                |)
                              |) in
                            let~ edge :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "upper_bound",
                                    [ Q ]
                                  |),
                                  [
                                    M.read (| root_node |);
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::search::SearchBound")
                                          []
                                          [ Ty.apply (Ty.path "&") [] [ Q ] ],
                                        "from_range",
                                        []
                                      |),
                                      [ M.read (| bound |) ]
                                    |)
                                  ]
                                |)
                              |) in
                            M.alloc (|
                              Value.StructRecord
                                "alloc::collections::btree::map::CursorMut"
                                [
                                  ("inner",
                                    Value.StructRecord
                                      "alloc::collections::btree::map::CursorMutKey"
                                      [
                                        ("current",
                                          Value.StructTuple
                                            "core::option::Option::Some"
                                            [ M.read (| edge |) ]);
                                        ("root", M.read (| dormant_root |));
                                        ("length",
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::BTreeMap",
                                            "length"
                                          |));
                                        ("alloc",
                                          M.call_closure (|
                                            M.get_trait_method (|
                                              "core::ops::deref::DerefMut",
                                              Ty.apply
                                                (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                                []
                                                [ A ],
                                              [],
                                              "deref_mut",
                                              []
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "alloc::collections::btree::map::BTreeMap",
                                                "alloc"
                                              |)
                                            ]
                                          |))
                                      ])
                                ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_upper_bound_mut :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "upper_bound_mut" (upper_bound_mut K V A).
      End Impl_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      
      Module Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_ref__alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "&")
            []
            [ Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ] ].
        
        (*     type Item = (&'a K, &'a V); *)
        Definition _Item (K V A : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ].
        
        (*     type IntoIter = Iter<'a, K, V>; *)
        Definition _IntoIter (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn into_iter(self) -> Iter<'a, K, V> {
                self.iter()
            }
        *)
        Definition into_iter
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                  "iter",
                  []
                |),
                [ M.read (| self |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::IntoIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("IntoIter", InstanceField.Ty (_IntoIter K V A));
              ("into_iter", InstanceField.Method (into_iter K V A))
            ].
      End Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_ref__alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*     type Item = (&'a K, &'a V); *)
        Definition _Item (K V : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ].
        
        (*
            fn next(&mut self) -> Option<(&'a K, &'a V)> {
                if self.length == 0 {
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.next_unchecked() })
                }
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::Iter",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::Iter",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V
                                    ],
                                  "next_unchecked",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::Iter",
                                    "range"
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                (self.length, Some(self.length))
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "alloc::collections::btree::map::Iter",
                      "length"
                    |)
                  |);
                  Value.StructTuple
                    "core::option::Option::Some"
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::Iter",
                          "length"
                        |)
                      |)
                    ]
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<(&'a K, &'a V)> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<(&'a K, &'a V)>
            where
                (&'a K, &'a V): Ord,
            {
                self.next()
            }
        *)
        Definition min (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<(&'a K, &'a V)>
            where
                (&'a K, &'a V): Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("size_hint", InstanceField.Method (size_hint K V));
              ("last", InstanceField.Method (last K V));
              ("min", InstanceField.Method (min K V));
              ("max", InstanceField.Method (max K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
                if self.length == 0 {
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.next_back_unchecked() })
                }
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::Iter",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::Iter",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V
                                    ],
                                  "next_back_unchecked",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::Iter",
                                    "range"
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn len(&self) -> usize {
                self.length
            }
        *)
        Definition len (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "alloc::collections::btree::map::Iter",
                  "length"
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_Iter_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ].
        
        (*
            fn clone(&self) -> Self {
                Iter { range: self.range.clone(), length: self.length }
            }
        *)
        Definition clone (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Iter"
                [
                  ("range",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::Iter",
                          "range"
                        |)
                      ]
                    |));
                  ("length",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::Iter",
                        "length"
                      |)
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V)) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_Iter_K_V.
      
      Module Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_ref_mut_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "&mut")
            []
            [ Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ] ].
        
        (*     type Item = (&'a K, &'a mut V); *)
        Definition _Item (K V A : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ] ].
        
        (*     type IntoIter = IterMut<'a, K, V>; *)
        Definition _IntoIter (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            fn into_iter(self) -> IterMut<'a, K, V> {
                self.iter_mut()
            }
        *)
        Definition into_iter
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                  "iter_mut",
                  []
                |),
                [ M.read (| self |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::IntoIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("IntoIter", InstanceField.Ty (_IntoIter K V A));
              ("into_iter", InstanceField.Method (into_iter K V A))
            ].
      End Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_ref_mut_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*     type Item = (&'a K, &'a mut V); *)
        Definition _Item (K V : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ] ].
        
        (*
            fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
                if self.length == 0 {
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.next_unchecked() })
                }
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IterMut",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::IterMut",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::ValMut";
                                      K;
                                      V
                                    ],
                                  "next_unchecked",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IterMut",
                                    "range"
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                (self.length, Some(self.length))
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "alloc::collections::btree::map::IterMut",
                      "length"
                    |)
                  |);
                  Value.StructTuple
                    "core::option::Option::Some"
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::IterMut",
                          "length"
                        |)
                      |)
                    ]
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<(&'a K, &'a mut V)> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<(&'a K, &'a mut V)>
            where
                (&'a K, &'a mut V): Ord,
            {
                self.next()
            }
        *)
        Definition min (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<(&'a K, &'a mut V)>
            where
                (&'a K, &'a mut V): Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("size_hint", InstanceField.Method (size_hint K V));
              ("last", InstanceField.Method (last K V));
              ("min", InstanceField.Method (min K V));
              ("max", InstanceField.Method (max K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
                if self.length == 0 {
                    None
                } else {
                    self.length -= 1;
                    Some(unsafe { self.range.next_back_unchecked() })
                }
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              BinOp.eq (|
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IterMut",
                                    "length"
                                  |)
                                |),
                                Value.Integer IntegerKind.Usize 0
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (| Value.StructTuple "core::option::Option::None" [] |)));
                    fun γ =>
                      ltac:(M.monadic
                        (let~ _ :=
                          let β :=
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::IterMut",
                              "length"
                            |) in
                          M.write (|
                            β,
                            BinOp.Wrap.sub (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                          |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::option::Option::Some"
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::ValMut";
                                      K;
                                      V
                                    ],
                                  "next_back_unchecked",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::IterMut",
                                    "range"
                                  |)
                                ]
                              |)
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            fn len(&self) -> usize {
                self.length
            }
        *)
        Definition len (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "alloc::collections::btree::map::IterMut",
                  "length"
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_alloc_collections_btree_map_IterMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ].
        
        (*
            pub(super) fn iter(&self) -> Iter<'_, K, V> {
                Iter { range: self.range.reborrow(), length: self.length }
            }
        *)
        Definition iter (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Iter"
                [
                  ("range",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                        "reborrow",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::IterMut",
                          "range"
                        |)
                      ]
                    |));
                  ("length",
                    M.read (|
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IterMut",
                        "length"
                      |)
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_iter :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "iter" (iter K V).
      End Impl_alloc_collections_btree_map_IterMut_K_V.
      
      Module Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*     type Item = (K, V); *)
        Definition _Item (K V A : Ty.t) : Ty.t := Ty.tuple [ K; V ].
        
        (*     type IntoIter = IntoIter<K, V, A>; *)
        Definition _IntoIter (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn into_iter(self) -> IntoIter<K, V, A> {
                let mut me = ManuallyDrop::new(self);
                if let Some(root) = me.root.take() {
                    let full_range = root.into_dying().full_range();
        
                    IntoIter {
                        range: full_range,
                        length: me.length,
                        alloc: unsafe { ManuallyDrop::take(&mut me.alloc) },
                    }
                } else {
                    IntoIter {
                        range: LazyLeafRange::none(),
                        length: 0,
                        alloc: unsafe { ManuallyDrop::take(&mut me.alloc) },
                    }
                }
            }
        *)
        Definition into_iter
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                let~ me :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::mem::manually_drop::ManuallyDrop")
                          []
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ]
                          ],
                        "new",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |) in
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ],
                                "take",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.call_closure (|
                                    M.get_trait_method (|
                                      "core::ops::deref::DerefMut",
                                      Ty.apply
                                        (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                                            []
                                            [ K; V; A ]
                                        ],
                                      [],
                                      "deref_mut",
                                      []
                                    |),
                                    [ me ]
                                  |),
                                  "alloc::collections::btree::map::BTreeMap",
                                  "root"
                                |)
                              ]
                            |)
                          |) in
                        let γ0_0 :=
                          M.SubPointer.get_struct_tuple_field (|
                            γ,
                            "core::option::Option::Some",
                            0
                          |) in
                        let root := M.copy (| γ0_0 |) in
                        let~ full_range :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Dying";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ],
                                "full_range",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ],
                                    "into_dying",
                                    []
                                  |),
                                  [ M.read (| root |) ]
                                |)
                              ]
                            |)
                          |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::IntoIter"
                            [
                              ("range", M.read (| full_range |));
                              ("length",
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::ops::deref::Deref",
                                        Ty.apply
                                          (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                                              []
                                              [ K; V; A ]
                                          ],
                                        [],
                                        "deref",
                                        []
                                      |),
                                      [ me ]
                                    |),
                                    "alloc::collections::btree::map::BTreeMap",
                                    "length"
                                  |)
                                |));
                              ("alloc",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                      []
                                      [ A ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::deref::DerefMut",
                                          Ty.apply
                                            (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::map::BTreeMap")
                                                []
                                                [ K; V; A ]
                                            ],
                                          [],
                                          "deref_mut",
                                          []
                                        |),
                                        [ me ]
                                      |),
                                      "alloc::collections::btree::map::BTreeMap",
                                      "alloc"
                                    |)
                                  ]
                                |))
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::IntoIter"
                            [
                              ("range",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::navigate::LazyLeafRange")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Dying";
                                        K;
                                        V
                                      ],
                                    "none",
                                    []
                                  |),
                                  []
                                |));
                              ("length", Value.Integer IntegerKind.Usize 0);
                              ("alloc",
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                      []
                                      [ A ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.call_closure (|
                                        M.get_trait_method (|
                                          "core::ops::deref::DerefMut",
                                          Ty.apply
                                            (Ty.path "core::mem::manually_drop::ManuallyDrop")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::map::BTreeMap")
                                                []
                                                [ K; V; A ]
                                            ],
                                          [],
                                          "deref_mut",
                                          []
                                        |),
                                        [ me ]
                                      |),
                                      "alloc::collections::btree::map::BTreeMap",
                                      "alloc"
                                    |)
                                  ]
                                |))
                            ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::IntoIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("IntoIter", InstanceField.Ty (_IntoIter K V A));
              ("into_iter", InstanceField.Method (into_iter K V A))
            ].
      End Impl_core_iter_traits_collect_IntoIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_ops_drop_Drop_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn drop(&mut self) {
                struct DropGuard<'a, K, V, A: Allocator + Clone>(&'a mut IntoIter<K, V, A>);
        
                impl<'a, K, V, A: Allocator + Clone> Drop for DropGuard<'a, K, V, A> {
                    fn drop(&mut self) {
                        // Continue the same loop we perform below. This only runs when unwinding, so we
                        // don't have to care about panics this time (they'll abort).
                        while let Some(kv) = self.0.dying_next() {
                            // SAFETY: we consume the dying handle immediately.
                            unsafe { kv.drop_key_val() };
                        }
                    }
                }
        
                while let Some(kv) = self.dying_next() {
                    let guard = DropGuard(self);
                    // SAFETY: we don't touch the tree before consuming the dying handle.
                    unsafe { kv.drop_key_val() };
                    mem::forget(guard);
                }
            }
        *)
        Definition drop (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.loop (|
                  ltac:(M.monadic
                    (M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::map::IntoIter")
                                      []
                                      [ K; V; A ],
                                    "dying_next",
                                    []
                                  |),
                                  [ M.read (| self |) ]
                                |)
                              |) in
                            let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::option::Option::Some",
                                0
                              |) in
                            let kv := M.copy (| γ0_0 |) in
                            let~ guard :=
                              M.alloc (|
                                Value.StructTuple
                                  "alloc::collections::btree::map::drop::DropGuard"
                                  [ M.read (| self |) ]
                              |) in
                            let~ _ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Dying";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::KV"
                                      ],
                                    "drop_key_val",
                                    []
                                  |),
                                  [ M.read (| kv |) ]
                                |)
                              |) in
                            let~ _ :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "core::mem::forget",
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::map::drop::DropGuard")
                                        []
                                        [ K; V; A ]
                                    ]
                                  |),
                                  [ M.read (| guard |) ]
                                |)
                              |) in
                            M.alloc (| Value.Tuple [] |)));
                        fun γ =>
                          ltac:(M.monadic
                            (M.alloc (|
                              M.never_to_any (|
                                M.read (|
                                  let~ _ :=
                                    M.alloc (| M.never_to_any (| M.read (| M.break (||) |) |) |) in
                                  M.alloc (| Value.Tuple [] |)
                                |)
                              |)
                            |)))
                      ]
                    |)))
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::ops::drop::Drop"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("drop", InstanceField.Method (drop K V A)) ].
      End Impl_core_ops_drop_Drop_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*     type Item = (K, V); *)
        Definition _Item (K V A : Ty.t) : Ty.t := Ty.tuple [ K; V ].
        
        (*
            fn next(&mut self) -> Option<(K, V)> {
                // SAFETY: we consume the dying handle immediately.
                self.dying_next().map(unsafe { |kv| kv.into_key_val() })
            }
        *)
        Definition next (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.apply
                        (Ty.path "alloc::collections::btree::node::Handle")
                        []
                        [
                          Ty.apply
                            (Ty.path "alloc::collections::btree::node::NodeRef")
                            []
                            [
                              Ty.path "alloc::collections::btree::node::marker::Dying";
                              K;
                              V;
                              Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                            ];
                          Ty.path "alloc::collections::btree::node::marker::KV"
                        ]
                    ],
                  "map",
                  [
                    Ty.tuple [ K; V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Dying";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ]
                          ]
                      ]
                      (Ty.tuple [ K; V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      "dying_next",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          ltac:(M.monadic
                            (M.match_operator (|
                              M.alloc (| α0 |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let kv := M.copy (| γ |) in
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Dying";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "into_key_val",
                                        []
                                      |),
                                      [ M.read (| kv |) ]
                                    |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                (self.length, Some(self.length))
            }
        *)
        Definition size_hint
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple
                [
                  M.read (|
                    M.SubPointer.get_struct_record_field (|
                      M.read (| self |),
                      "alloc::collections::btree::map::IntoIter",
                      "length"
                    |)
                  |);
                  Value.StructTuple
                    "core::option::Option::Some"
                    [
                      M.read (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::IntoIter",
                          "length"
                        |)
                      |)
                    ]
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("next", InstanceField.Method (next K V A));
              ("size_hint", InstanceField.Method (size_hint K V A))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn next_back(&mut self) -> Option<(K, V)> {
                // SAFETY: we consume the dying handle immediately.
                self.dying_next_back().map(unsafe { |kv| kv.into_key_val() })
            }
        *)
        Definition next_back
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.apply
                        (Ty.path "alloc::collections::btree::node::Handle")
                        []
                        [
                          Ty.apply
                            (Ty.path "alloc::collections::btree::node::NodeRef")
                            []
                            [
                              Ty.path "alloc::collections::btree::node::marker::Dying";
                              K;
                              V;
                              Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                            ];
                          Ty.path "alloc::collections::btree::node::marker::KV"
                        ]
                    ],
                  "map",
                  [
                    Ty.tuple [ K; V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Dying";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ]
                          ]
                      ]
                      (Ty.tuple [ K; V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      "dying_next_back",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.closure
                    (fun γ =>
                      ltac:(M.monadic
                        match γ with
                        | [ α0 ] =>
                          ltac:(M.monadic
                            (M.match_operator (|
                              M.alloc (| α0 |),
                              [
                                fun γ =>
                                  ltac:(M.monadic
                                    (let kv := M.copy (| γ |) in
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Dying";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "into_key_val",
                                        []
                                      |),
                                      [ M.read (| kv |) ]
                                    |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V A)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        (*
            fn len(&self) -> usize {
                self.length
            }
        *)
        Definition len (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  M.read (| self |),
                  "alloc::collections::btree::map::IntoIter",
                  "length"
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V A)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ].
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoIter_K_V_A.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*     type Item = &'a K; *)
        Definition _Item (K V : Ty.t) : Ty.t := Ty.apply (Ty.path "&") [] [ K ].
        
        (*
            fn next(&mut self) -> Option<&'a K> {
                self.inner.next().map(|(k, _)| k)
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [ Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&") [] [ K ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&") [] [ K ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                      [],
                      "next",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::Keys",
                        "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
                                    M.read (| k |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Keys",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<&'a K> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<&'a K>
            where
                &'a K: Ord,
            {
                self.next()
            }
        *)
        Definition min (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<&'a K>
            where
                &'a K: Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("size_hint", InstanceField.Method (size_hint K V));
              ("last", InstanceField.Method (last K V));
              ("min", InstanceField.Method (min K V));
              ("max", InstanceField.Method (max K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<&'a K> {
                self.inner.next_back().map(|(k, _)| k)
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [ Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&") [] [ K ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&") [] [ K ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::double_ended::DoubleEndedIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                      [],
                      "next_back",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::Keys",
                        "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
                                    M.read (| k |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*
            fn len(&self) -> usize {
                self.inner.len()
            }
        *)
        Definition len (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::exact_size::ExactSizeIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "len",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Keys",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*
            fn clone(&self) -> Self {
                Keys { inner: self.inner.clone() }
            }
        *)
        Definition clone (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Keys"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::Keys",
                          "inner"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V)) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_Keys_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Keys") [] [ K; V ].
        
        (*
            fn default() -> Self {
                Keys { inner: Default::default() }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::Keys"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_Keys_K_V.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*     type Item = &'a V; *)
        Definition _Item (K V : Ty.t) : Ty.t := Ty.apply (Ty.path "&") [] [ V ].
        
        (*
            fn next(&mut self) -> Option<&'a V> {
                self.inner.next().map(|(_, v)| v)
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [ Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&") [] [ V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&") [] [ V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                      [],
                      "next",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::Values",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Values",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<&'a V> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("size_hint", InstanceField.Method (size_hint K V));
              ("last", InstanceField.Method (last K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Values_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<&'a V> {
                self.inner.next_back().map(|(_, v)| v)
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [ Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&") [] [ V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&") [] [ V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::double_ended::DoubleEndedIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                      [],
                      "next_back",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::Values",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Values_K_V.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*
            fn len(&self) -> usize {
                self.inner.len()
            }
        *)
        Definition len (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::exact_size::ExactSizeIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "len",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Values",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_Values_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Values_K_V.
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*
            fn clone(&self) -> Self {
                Values { inner: self.inner.clone() }
            }
        *)
        Definition clone (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Values"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::Values",
                          "inner"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V)) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_Values_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_Values_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Values") [] [ K; V ].
        
        (*
            fn default() -> Self {
                Values { inner: Default::default() }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::Values"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_Values_K_V.
      
      (* StructRecord
        {
          name := "ExtractIf";
          const_params := [];
          ty_params := [ "K"; "V"; "F"; "A" ];
          fields :=
            [
              ("pred", F);
              ("inner",
                Ty.apply (Ty.path "alloc::collections::btree::map::ExtractIfInner") [] [ K; V ]);
              ("alloc", A)
            ];
        } *)
      
      (* StructRecord
        {
          name := "ExtractIfInner";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("length", Ty.apply (Ty.path "&mut") [] [ Ty.path "usize" ]);
              ("dormant_root",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Owned";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                          ]
                      ]
                  ]);
              ("cur_leaf_edge",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "alloc::collections::btree::node::Handle")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Mut";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                          ];
                        Ty.path "alloc::collections::btree::node::marker::Edge"
                      ]
                  ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_alloc_alloc_Global.
        Definition Self (K V F : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::ExtractIf")
            []
            [ K; V; F; Ty.path "alloc::alloc::Global" ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_tuple("ExtractIf").field(&self.inner.peek()).finish()
            }
        *)
        Definition fmt (K V F : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V F in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugTuple",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugTuple",
                      "field",
                      []
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_tuple",
                            []
                          |),
                          [ M.read (| f |); M.read (| Value.String "ExtractIf" |) ]
                        |)
                      |);
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::ExtractIfInner")
                              []
                              [ K; V ],
                            "peek",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::ExtractIf",
                              "inner"
                            |)
                          ]
                        |)
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V F : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V F)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V F)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_alloc_alloc_Global.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_A.
        Definition Self (K V F A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ExtractIf") [] [ K; V; F; A ].
        
        (*     type Item = (K, V); *)
        Definition _Item (K V F A : Ty.t) : Ty.t := Ty.tuple [ K; V ].
        
        (*
            fn next(&mut self) -> Option<(K, V)> {
                self.inner.next(&mut self.pred, self.alloc.clone())
            }
        *)
        Definition next
            (K V F A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V F A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::ExtractIfInner") [] [ K; V ],
                  "next",
                  [ F; A ]
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::ExtractIf",
                    "inner"
                  |);
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::ExtractIf",
                    "pred"
                  |);
                  M.call_closure (|
                    M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::ExtractIf",
                        "alloc"
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V F A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V F A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::ExtractIfInner") [] [ K; V ],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::ExtractIf",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V F A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V F A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V F A));
              ("next", InstanceField.Method (next K V F A));
              ("size_hint", InstanceField.Method (size_hint K V F A))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_A.
      
      Module Impl_alloc_collections_btree_map_ExtractIfInner_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ExtractIfInner") [] [ K; V ].
        
        (*
            pub(super) fn peek(&self) -> Option<(&K, &V)> {
                let edge = self.cur_leaf_edge.as_ref()?;
                edge.reborrow().next_kv().ok().map(Handle::into_kv)
            }
        *)
        Definition peek (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ edge :=
                      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 "&")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "as_ref",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::ExtractIfInner",
                                      "cur_leaf_edge"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&") [] [ K ];
                                                    Ty.apply (Ty.path "&") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "core::option::Option")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::node::Handle")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::NodeRef")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::Immut";
                                      K;
                                      V;
                                      Ty.path
                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                    ];
                                  Ty.path "alloc::collections::btree::node::marker::KV"
                                ]
                            ],
                          "map",
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ];
                            Ty.function
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Immut";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::KV"
                                  ]
                              ]
                              (Ty.tuple
                                [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ]
                                ])
                          ]
                        |),
                        [
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "core::result::Result")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::KV"
                                    ];
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::NodeRef")
                                    []
                                    [
                                      Ty.path "alloc::collections::btree::node::marker::Immut";
                                      K;
                                      V;
                                      Ty.path
                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                    ]
                                ],
                              "ok",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::node::Handle")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::NodeRef")
                                        []
                                        [
                                          Ty.path "alloc::collections::btree::node::marker::Immut";
                                          K;
                                          V;
                                          Ty.path "alloc::collections::btree::node::marker::Leaf"
                                        ];
                                      Ty.path "alloc::collections::btree::node::marker::Edge"
                                    ],
                                  "next_kv",
                                  []
                                |),
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::Handle")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::NodeRef")
                                            []
                                            [
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Mut";
                                              K;
                                              V;
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Leaf"
                                            ];
                                          Ty.path "alloc::collections::btree::node::marker::Edge"
                                        ],
                                      "reborrow",
                                      []
                                    |),
                                    [ M.read (| edge |) ]
                                  |)
                                ]
                              |)
                            ]
                          |);
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "into_kv",
                            []
                          |)
                        ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "peek" (peek K V).
        
        (*
            pub(super) fn next<F, A: Allocator + Clone>(&mut self, pred: &mut F, alloc: A) -> Option<(K, V)>
            where
                F: FnMut(&K, &mut V) -> bool,
            {
                while let Ok(mut kv) = self.cur_leaf_edge.take()?.next_kv() {
                    let (k, v) = kv.kv_mut();
                    if pred(k, v) {
                        *self.length -= 1;
                        let (kv, pos) = kv.remove_kv_tracking(
                            || {
                                // SAFETY: we will touch the root in a way that will not
                                // invalidate the position returned.
                                let root = unsafe { self.dormant_root.take().unwrap().awaken() };
                                root.pop_internal_level(alloc.clone());
                                self.dormant_root = Some(DormantMutRef::new(root).1);
                            },
                            alloc.clone(),
                        );
                        self.cur_leaf_edge = Some(pos);
                        return Some(kv);
                    }
                    self.cur_leaf_edge = Some(kv.next_leaf_edge());
                }
                None
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [ F; A ], [ self; pred; alloc ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let pred := M.alloc (| pred |) in
              let alloc := M.alloc (| alloc |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.loop (|
                        ltac:(M.monadic
                          (M.match_operator (|
                            M.alloc (| Value.Tuple [] |),
                            [
                              fun γ =>
                                ltac:(M.monadic
                                  (let γ :=
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Leaf"
                                                ];
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Edge"
                                            ],
                                          "next_kv",
                                          []
                                        |),
                                        [
                                          M.read (|
                                            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
                                                            "alloc::collections::btree::node::Handle")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Mut";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Leaf"
                                                              ];
                                                            Ty.path
                                                              "alloc::collections::btree::node::marker::Edge"
                                                          ]
                                                      ],
                                                    [],
                                                    "branch",
                                                    []
                                                  |),
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path "core::option::Option")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::Handle")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::node::NodeRef")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Mut";
                                                                    K;
                                                                    V;
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Leaf"
                                                                  ];
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Edge"
                                                              ]
                                                          ],
                                                        "take",
                                                        []
                                                      |),
                                                      [
                                                        M.SubPointer.get_struct_record_field (|
                                                          M.read (| self |),
                                                          "alloc::collections::btree::map::ExtractIfInner",
                                                          "cur_leaf_edge"
                                                        |)
                                                      ]
                                                    |)
                                                  ]
                                                |)
                                              |),
                                              [
                                                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.tuple [ K; V ] ],
                                                                [
                                                                  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
                                  let γ0_0 :=
                                    M.SubPointer.get_struct_tuple_field (|
                                      γ,
                                      "core::result::Result::Ok",
                                      0
                                    |) in
                                  let kv := M.copy (| γ0_0 |) in
                                  M.match_operator (|
                                    M.alloc (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ];
                                              Ty.path "alloc::collections::btree::node::marker::KV"
                                            ],
                                          "kv_mut",
                                          []
                                        |),
                                        [ kv ]
                                      |)
                                    |),
                                    [
                                      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
                                          let~ _ :=
                                            M.match_operator (|
                                              M.alloc (| Value.Tuple [] |),
                                              [
                                                fun γ =>
                                                  ltac:(M.monadic
                                                    (let γ :=
                                                      M.use
                                                        (M.alloc (|
                                                          M.call_closure (|
                                                            M.get_trait_method (|
                                                              "core::ops::function::FnMut",
                                                              F,
                                                              [
                                                                Ty.tuple
                                                                  [
                                                                    Ty.apply (Ty.path "&") [] [ K ];
                                                                    Ty.apply
                                                                      (Ty.path "&mut")
                                                                      []
                                                                      [ V ]
                                                                  ]
                                                              ],
                                                              "call_mut",
                                                              []
                                                            |),
                                                            [
                                                              M.read (| pred |);
                                                              Value.Tuple
                                                                [ M.read (| k |); M.read (| v |) ]
                                                            ]
                                                          |)
                                                        |)) in
                                                    let _ :=
                                                      M.is_constant_or_break_match (|
                                                        M.read (| γ |),
                                                        Value.Bool true
                                                      |) in
                                                    M.alloc (|
                                                      M.never_to_any (|
                                                        M.read (|
                                                          let~ _ :=
                                                            let β :=
                                                              M.read (|
                                                                M.SubPointer.get_struct_record_field (|
                                                                  M.read (| self |),
                                                                  "alloc::collections::btree::map::ExtractIfInner",
                                                                  "length"
                                                                |)
                                                              |) in
                                                            M.write (|
                                                              β,
                                                              BinOp.Wrap.sub (|
                                                                M.read (| β |),
                                                                Value.Integer IntegerKind.Usize 1
                                                              |)
                                                            |) in
                                                          M.match_operator (|
                                                            M.alloc (|
                                                              M.call_closure (|
                                                                M.get_associated_function (|
                                                                  Ty.apply
                                                                    (Ty.path
                                                                      "alloc::collections::btree::node::Handle")
                                                                    []
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path
                                                                          "alloc::collections::btree::node::NodeRef")
                                                                        []
                                                                        [
                                                                          Ty.path
                                                                            "alloc::collections::btree::node::marker::Mut";
                                                                          K;
                                                                          V;
                                                                          Ty.path
                                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                        ];
                                                                      Ty.path
                                                                        "alloc::collections::btree::node::marker::KV"
                                                                    ],
                                                                  "remove_kv_tracking",
                                                                  [
                                                                    Ty.function
                                                                      [ Ty.tuple [] ]
                                                                      (Ty.tuple []);
                                                                    A
                                                                  ]
                                                                |),
                                                                [
                                                                  M.read (| kv |);
                                                                  M.closure
                                                                    (fun γ =>
                                                                      ltac:(M.monadic
                                                                        match γ with
                                                                        | [ α0 ] =>
                                                                          ltac:(M.monadic
                                                                            (M.match_operator (|
                                                                              M.alloc (| α0 |),
                                                                              [
                                                                                fun γ =>
                                                                                  ltac:(M.monadic
                                                                                    (M.read (|
                                                                                      let~ root :=
                                                                                        M.alloc (|
                                                                                          M.call_closure (|
                                                                                            M.get_associated_function (|
                                                                                              Ty.apply
                                                                                                (Ty.path
                                                                                                  "alloc::collections::btree::borrow::DormantMutRef")
                                                                                                []
                                                                                                [
                                                                                                  Ty.apply
                                                                                                    (Ty.path
                                                                                                      "alloc::collections::btree::node::NodeRef")
                                                                                                    []
                                                                                                    [
                                                                                                      Ty.path
                                                                                                        "alloc::collections::btree::node::marker::Owned";
                                                                                                      K;
                                                                                                      V;
                                                                                                      Ty.path
                                                                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                                                    ]
                                                                                                ],
                                                                                              "awaken",
                                                                                              []
                                                                                            |),
                                                                                            [
                                                                                              M.call_closure (|
                                                                                                M.get_associated_function (|
                                                                                                  Ty.apply
                                                                                                    (Ty.path
                                                                                                      "core::option::Option")
                                                                                                    []
                                                                                                    [
                                                                                                      Ty.apply
                                                                                                        (Ty.path
                                                                                                          "alloc::collections::btree::borrow::DormantMutRef")
                                                                                                        []
                                                                                                        [
                                                                                                          Ty.apply
                                                                                                            (Ty.path
                                                                                                              "alloc::collections::btree::node::NodeRef")
                                                                                                            []
                                                                                                            [
                                                                                                              Ty.path
                                                                                                                "alloc::collections::btree::node::marker::Owned";
                                                                                                              K;
                                                                                                              V;
                                                                                                              Ty.path
                                                                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                                                            ]
                                                                                                        ]
                                                                                                    ],
                                                                                                  "unwrap",
                                                                                                  []
                                                                                                |),
                                                                                                [
                                                                                                  M.call_closure (|
                                                                                                    M.get_associated_function (|
                                                                                                      Ty.apply
                                                                                                        (Ty.path
                                                                                                          "core::option::Option")
                                                                                                        []
                                                                                                        [
                                                                                                          Ty.apply
                                                                                                            (Ty.path
                                                                                                              "alloc::collections::btree::borrow::DormantMutRef")
                                                                                                            []
                                                                                                            [
                                                                                                              Ty.apply
                                                                                                                (Ty.path
                                                                                                                  "alloc::collections::btree::node::NodeRef")
                                                                                                                []
                                                                                                                [
                                                                                                                  Ty.path
                                                                                                                    "alloc::collections::btree::node::marker::Owned";
                                                                                                                  K;
                                                                                                                  V;
                                                                                                                  Ty.path
                                                                                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                                                                ]
                                                                                                            ]
                                                                                                        ],
                                                                                                      "take",
                                                                                                      []
                                                                                                    |),
                                                                                                    [
                                                                                                      M.SubPointer.get_struct_record_field (|
                                                                                                        M.read (|
                                                                                                          self
                                                                                                        |),
                                                                                                        "alloc::collections::btree::map::ExtractIfInner",
                                                                                                        "dormant_root"
                                                                                                      |)
                                                                                                    ]
                                                                                                  |)
                                                                                                ]
                                                                                              |)
                                                                                            ]
                                                                                          |)
                                                                                        |) in
                                                                                      let~ _ :=
                                                                                        M.alloc (|
                                                                                          M.call_closure (|
                                                                                            M.get_associated_function (|
                                                                                              Ty.apply
                                                                                                (Ty.path
                                                                                                  "alloc::collections::btree::node::NodeRef")
                                                                                                []
                                                                                                [
                                                                                                  Ty.path
                                                                                                    "alloc::collections::btree::node::marker::Owned";
                                                                                                  K;
                                                                                                  V;
                                                                                                  Ty.path
                                                                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                                                ],
                                                                                              "pop_internal_level",
                                                                                              [ A ]
                                                                                            |),
                                                                                            [
                                                                                              M.read (|
                                                                                                root
                                                                                              |);
                                                                                              M.call_closure (|
                                                                                                M.get_trait_method (|
                                                                                                  "core::clone::Clone",
                                                                                                  A,
                                                                                                  [],
                                                                                                  "clone",
                                                                                                  []
                                                                                                |),
                                                                                                [
                                                                                                  alloc
                                                                                                ]
                                                                                              |)
                                                                                            ]
                                                                                          |)
                                                                                        |) in
                                                                                      let~ _ :=
                                                                                        M.write (|
                                                                                          M.SubPointer.get_struct_record_field (|
                                                                                            M.read (|
                                                                                              self
                                                                                            |),
                                                                                            "alloc::collections::btree::map::ExtractIfInner",
                                                                                            "dormant_root"
                                                                                          |),
                                                                                          Value.StructTuple
                                                                                            "core::option::Option::Some"
                                                                                            [
                                                                                              M.read (|
                                                                                                M.SubPointer.get_tuple_field (|
                                                                                                  M.alloc (|
                                                                                                    M.call_closure (|
                                                                                                      M.get_associated_function (|
                                                                                                        Ty.apply
                                                                                                          (Ty.path
                                                                                                            "alloc::collections::btree::borrow::DormantMutRef")
                                                                                                          []
                                                                                                          [
                                                                                                            Ty.apply
                                                                                                              (Ty.path
                                                                                                                "alloc::collections::btree::node::NodeRef")
                                                                                                              []
                                                                                                              [
                                                                                                                Ty.path
                                                                                                                  "alloc::collections::btree::node::marker::Owned";
                                                                                                                K;
                                                                                                                V;
                                                                                                                Ty.path
                                                                                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                                                              ]
                                                                                                          ],
                                                                                                        "new",
                                                                                                        []
                                                                                                      |),
                                                                                                      [
                                                                                                        M.read (|
                                                                                                          root
                                                                                                        |)
                                                                                                      ]
                                                                                                    |)
                                                                                                  |),
                                                                                                  1
                                                                                                |)
                                                                                              |)
                                                                                            ]
                                                                                        |) in
                                                                                      M.alloc (|
                                                                                        Value.Tuple
                                                                                          []
                                                                                      |)
                                                                                    |)))
                                                                              ]
                                                                            |)))
                                                                        | _ =>
                                                                          M.impossible
                                                                            "wrong number of arguments"
                                                                        end));
                                                                  M.call_closure (|
                                                                    M.get_trait_method (|
                                                                      "core::clone::Clone",
                                                                      A,
                                                                      [],
                                                                      "clone",
                                                                      []
                                                                    |),
                                                                    [ alloc ]
                                                                  |)
                                                                ]
                                                              |)
                                                            |),
                                                            [
                                                              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 kv := M.copy (| γ0_0 |) in
                                                                  let pos := M.copy (| γ0_1 |) in
                                                                  let~ _ :=
                                                                    M.write (|
                                                                      M.SubPointer.get_struct_record_field (|
                                                                        M.read (| self |),
                                                                        "alloc::collections::btree::map::ExtractIfInner",
                                                                        "cur_leaf_edge"
                                                                      |),
                                                                      Value.StructTuple
                                                                        "core::option::Option::Some"
                                                                        [ M.read (| pos |) ]
                                                                    |) in
                                                                  M.return_ (|
                                                                    Value.StructTuple
                                                                      "core::option::Option::Some"
                                                                      [ M.read (| kv |) ]
                                                                  |)))
                                                            ]
                                                          |)
                                                        |)
                                                      |)
                                                    |)));
                                                fun γ =>
                                                  ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                              ]
                                            |) in
                                          let~ _ :=
                                            M.write (|
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "alloc::collections::btree::map::ExtractIfInner",
                                                "cur_leaf_edge"
                                              |),
                                              Value.StructTuple
                                                "core::option::Option::Some"
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::Handle")
                                                        []
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::NodeRef")
                                                            []
                                                            [
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Mut";
                                                              K;
                                                              V;
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                            ];
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::KV"
                                                        ],
                                                      "next_leaf_edge",
                                                      []
                                                    |),
                                                    [ M.read (| kv |) ]
                                                  |)
                                                ]
                                            |) in
                                          M.alloc (| Value.Tuple [] |)))
                                    ]
                                  |)));
                              fun γ =>
                                ltac:(M.monadic
                                  (M.alloc (|
                                    M.never_to_any (|
                                      M.read (|
                                        let~ _ :=
                                          M.alloc (|
                                            M.never_to_any (| M.read (| M.break (||) |) |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)
                                      |)
                                    |)
                                  |)))
                            ]
                          |)))
                      |) in
                    M.alloc (| Value.StructTuple "core::option::Option::None" [] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_next :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "next" (next K V).
        
        (*
            pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
                // In most of the btree iterators, `self.length` is the number of elements
                // yet to be visited. Here, it includes elements that were visited and that
                // the predicate decided not to drain. Making this upper bound more tight
                // during iteration would require an extra field.
                (0, Some( *self.length))
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple
                [
                  Value.Integer IntegerKind.Usize 0;
                  Value.StructTuple
                    "core::option::Option::Some"
                    [
                      M.read (|
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::map::ExtractIfInner",
                            "length"
                          |)
                        |)
                      |)
                    ]
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_size_hint :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "size_hint" (size_hint K V).
      End Impl_alloc_collections_btree_map_ExtractIfInner_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_alloc_alloc_Global.
        Definition Self (K V F : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::ExtractIf")
            []
            [ K; V; F; Ty.path "alloc::alloc::Global" ].
        
        Axiom Implements :
          forall (K V F : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V F)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_ops_function_FnMut_F_Tuple_ref__K_ref_mut_V__for_alloc_collections_btree_map_ExtractIf_K_V_F_alloc_alloc_Global.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        (*     type Item = (&'a K, &'a V); *)
        Definition _Item (K V : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ].
        
        (*
            fn next(&mut self) -> Option<(&'a K, &'a V)> {
                self.inner.next_checked()
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::collections::btree::navigate::LeafRange")
                    []
                    [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                  "next_checked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Range",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<(&'a K, &'a V)> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<(&'a K, &'a V)>
            where
                (&'a K, &'a V): Ord,
            {
                self.next()
            }
        *)
        Definition min (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<(&'a K, &'a V)>
            where
                (&'a K, &'a V): Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("last", InstanceField.Method (last K V));
              ("min", InstanceField.Method (min K V));
              ("max", InstanceField.Method (max K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_Range_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        (*
            fn default() -> Self {
                Range { inner: Default::default() }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::Range"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_Range_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_RangeMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ].
        
        (*
            fn default() -> Self {
                RangeMut { inner: Default::default(), _marker: PhantomData }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::RangeMut"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |));
                  ("_marker", Value.StructTuple "core::marker::PhantomData" [])
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_RangeMut_K_V.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        (*     type Item = &'a mut V; *)
        Definition _Item (K V : Ty.t) : Ty.t := Ty.apply (Ty.path "&mut") [] [ V ].
        
        (*
            fn next(&mut self) -> Option<&'a mut V> {
                self.inner.next().map(|(_, v)| v)
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.tuple
                        [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&mut") [] [ V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ]
                              ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&mut") [] [ V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                      [],
                      "next",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::ValuesMut",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::ValuesMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<&'a mut V> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("size_hint", InstanceField.Method (size_hint K V));
              ("last", InstanceField.Method (last K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<&'a mut V> {
                self.inner.next_back().map(|(_, v)| v)
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "core::option::Option")
                    []
                    [
                      Ty.tuple
                        [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ] ]
                    ],
                  "map",
                  [
                    Ty.apply (Ty.path "&mut") [] [ V ];
                    Ty.function
                      [
                        Ty.tuple
                          [
                            Ty.tuple
                              [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ]
                              ]
                          ]
                      ]
                      (Ty.apply (Ty.path "&mut") [] [ V ])
                  ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::double_ended::DoubleEndedIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                      [],
                      "next_back",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::ValuesMut",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        (*
            fn len(&self) -> usize {
                self.inner.len()
            }
        *)
        Definition len (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::exact_size::ExactSizeIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                  [],
                  "len",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::ValuesMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_ValuesMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::ValuesMut") [] [ K; V ].
        
        (*
            fn default() -> Self {
                ValuesMut { inner: Default::default() }
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::ValuesMut"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply (Ty.path "alloc::collections::btree::map::IterMut") [] [ K; V ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_ValuesMut_K_V.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        (*     type Item = K; *)
        Definition _Item (K V A : Ty.t) : Ty.t := K.
        
        (*
            fn next(&mut self) -> Option<K> {
                self.inner.next().map(|(k, _)| k)
            }
        *)
        Definition next (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.tuple [ K; V ] ],
                  "map",
                  [ K; Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] K ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      [],
                      "next",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IntoKeys",
                        "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
                                    M.read (| k |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::IntoKeys",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<K> {
                self.next_back()
            }
        *)
        Definition last (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<K>
            where
                K: Ord,
            {
                self.next()
            }
        *)
        Definition min (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<K>
            where
                K: Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("next", InstanceField.Method (next K V A));
              ("size_hint", InstanceField.Method (size_hint K V A));
              ("last", InstanceField.Method (last K V A));
              ("min", InstanceField.Method (min K V A));
              ("max", InstanceField.Method (max K V A))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        (*
            fn next_back(&mut self) -> Option<K> {
                self.inner.next_back().map(|(k, _)| k)
            }
        *)
        Definition next_back
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.tuple [ K; V ] ],
                  "map",
                  [ K; Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] K ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::double_ended::DoubleEndedIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      [],
                      "next_back",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IntoKeys",
                        "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
                                    M.read (| k |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V A)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        (*
            fn len(&self) -> usize {
                self.inner.len()
            }
        *)
        Definition len (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::exact_size::ExactSizeIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                  [],
                  "len",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::IntoKeys",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V A)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      Module Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoKeys") [] [ K; V; A ].
        
        (*
            fn default() -> Self {
                IntoKeys { inner: Default::default() }
            }
        *)
        Definition default
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::IntoKeys"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::IntoIter")
                          []
                          [ K; V; A ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V A)) ].
      End Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoKeys_K_V_A.
      
      Module Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        (*     type Item = V; *)
        Definition _Item (K V A : Ty.t) : Ty.t := V.
        
        (*
            fn next(&mut self) -> Option<V> {
                self.inner.next().map(|(_, v)| v)
            }
        *)
        Definition next (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.tuple [ K; V ] ],
                  "map",
                  [ V; Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] V ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      [],
                      "next",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IntoValues",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn size_hint(&self) -> (usize, Option<usize>) {
                self.inner.size_hint()
            }
        *)
        Definition size_hint
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                  [],
                  "size_hint",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::IntoValues",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<V> {
                self.next_back()
            }
        *)
        Definition last (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V A));
              ("next", InstanceField.Method (next K V A));
              ("size_hint", InstanceField.Method (size_hint K V A));
              ("last", InstanceField.Method (last K V A))
            ].
      End Impl_core_iter_traits_iterator_Iterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        (*
            fn next_back(&mut self) -> Option<V> {
                self.inner.next_back().map(|(_, v)| v)
            }
        *)
        Definition next_back
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.tuple [ K; V ] ],
                  "map",
                  [ V; Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] V ]
                |),
                [
                  M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::double_ended::DoubleEndedIterator",
                      Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                      [],
                      "next_back",
                      []
                    |),
                    [
                      M.SubPointer.get_struct_record_field (|
                        M.read (| self |),
                        "alloc::collections::btree::map::IntoValues",
                        "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 v := M.copy (| γ0_1 |) in
                                    M.read (| v |)))
                              ]
                            |)))
                        | _ => M.impossible "wrong number of arguments"
                        end))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V A)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      Module Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        (*
            fn len(&self) -> usize {
                self.inner.len()
            }
        *)
        Definition len (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::exact_size::ExactSizeIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::IntoIter") [] [ K; V; A ],
                  [],
                  "len",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::IntoValues",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::exact_size::ExactSizeIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("len", InstanceField.Method (len K V A)) ].
      End Impl_core_iter_traits_exact_size_ExactSizeIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      Module Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      Module Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::IntoValues") [] [ K; V; A ].
        
        (*
            fn default() -> Self {
                IntoValues { inner: Default::default() }
            }
        *)
        Definition default
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (Value.StructRecord
                "alloc::collections::btree::map::IntoValues"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::default::Default",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::IntoIter")
                          []
                          [ K; V; A ],
                        [],
                        "default",
                        []
                      |),
                      []
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V A)) ].
      End Impl_core_default_Default_where_core_alloc_Allocator_A_where_core_default_Default_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_IntoValues_K_V_A.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
                self.inner.next_back_checked()
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::collections::btree::navigate::LeafRange")
                    []
                    [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                  "next_back_checked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::Range",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_Range_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_Range_K_V.
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_Range_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Range") [] [ K; V ].
        
        (*
            fn clone(&self) -> Self {
                Range { inner: self.inner.clone() }
            }
        *)
        Definition clone (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Range"
                [
                  ("inner",
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::navigate::LeafRange")
                          []
                          [ Ty.path "alloc::collections::btree::node::marker::Immut"; K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::Range",
                          "inner"
                        |)
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V)) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_Range_K_V.
      
      Module Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_RangeMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ].
        
        (*     type Item = (&'a K, &'a mut V); *)
        Definition _Item (K V : Ty.t) : Ty.t :=
          Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&mut") [] [ V ] ].
        
        (*
            fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
                self.inner.next_checked()
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::collections::btree::navigate::LeafRange")
                    []
                    [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                  "next_checked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::RangeMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn last(mut self) -> Option<(&'a K, &'a mut V)> {
                self.next_back()
            }
        *)
        Definition last (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn min(mut self) -> Option<(&'a K, &'a mut V)>
            where
                (&'a K, &'a mut V): Ord,
            {
                self.next()
            }
        *)
        Definition min (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ],
                  [],
                  "next",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn max(mut self) -> Option<(&'a K, &'a mut V)>
            where
                (&'a K, &'a mut V): Ord,
            {
                self.next_back()
            }
        *)
        Definition max (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::double_ended::DoubleEndedIterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ],
                  [],
                  "next_back",
                  []
                |),
                [ self ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::iterator::Iterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *)
            [
              ("Item", InstanceField.Ty (_Item K V));
              ("next", InstanceField.Method (next K V));
              ("last", InstanceField.Method (last K V));
              ("min", InstanceField.Method (min K V));
              ("max", InstanceField.Method (max K V))
            ].
      End Impl_core_iter_traits_iterator_Iterator_for_alloc_collections_btree_map_RangeMut_K_V.
      
      Module Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_RangeMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ].
        
        (*
            fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
                self.inner.next_back_checked()
            }
        *)
        Definition next_back
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::collections::btree::navigate::LeafRange")
                    []
                    [ Ty.path "alloc::collections::btree::node::marker::ValMut"; K; V ],
                  "next_back_checked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::RangeMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::double_ended::DoubleEndedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("next_back", InstanceField.Method (next_back K V)) ].
      End Impl_core_iter_traits_double_ended_DoubleEndedIterator_for_alloc_collections_btree_map_RangeMut_K_V.
      
      Module Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_RangeMut_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::RangeMut") [] [ K; V ].
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::marker::FusedIterator"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_iter_traits_marker_FusedIterator_for_alloc_collections_btree_map_RangeMut_K_V.
      
      Module Impl_core_iter_traits_collect_FromIterator_where_core_cmp_Ord_K_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::BTreeMap")
            []
            [ K; V; Ty.path "alloc::alloc::Global" ].
        
        (*
            fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> BTreeMap<K, V> {
                let mut inputs: Vec<_> = iter.into_iter().collect();
        
                if inputs.is_empty() {
                    return BTreeMap::new();
                }
        
                // use stable sort to preserve the insertion order.
                inputs.sort_by(|a, b| a.0.cmp(&b.0));
                BTreeMap::bulk_build_from_sorted_iter(inputs, Global)
            }
        *)
        Definition from_iter
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [ T ], [ iter ] =>
            ltac:(M.monadic
              (let iter := M.alloc (| iter |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ inputs :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::iterator::Iterator",
                            Ty.associated,
                            [],
                            "collect",
                            [
                              Ty.apply
                                (Ty.path "alloc::vec::Vec")
                                []
                                [ Ty.tuple [ K; V ]; Ty.path "alloc::alloc::Global" ]
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::iter::traits::collect::IntoIterator",
                                T,
                                [],
                                "into_iter",
                                []
                              |),
                              [ M.read (| iter |) ]
                            |)
                          ]
                        |)
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::vec::Vec")
                                          []
                                          [ Ty.tuple [ K; V ]; Ty.path "alloc::alloc::Global" ],
                                        "is_empty",
                                        []
                                      |),
                                      [ inputs ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                                            []
                                            [ K; V; Ty.path "alloc::alloc::Global" ],
                                          "new",
                                          []
                                        |),
                                        []
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "slice") [] [ Ty.tuple [ K; V ] ],
                            "sort_by",
                            [
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply (Ty.path "&") [] [ Ty.tuple [ K; V ] ];
                                      Ty.apply (Ty.path "&") [] [ Ty.tuple [ K; V ] ]
                                    ]
                                ]
                                (Ty.path "core::cmp::Ordering")
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::ops::deref::DerefMut",
                                Ty.apply
                                  (Ty.path "alloc::vec::Vec")
                                  []
                                  [ Ty.tuple [ K; V ]; Ty.path "alloc::alloc::Global" ],
                                [],
                                "deref_mut",
                                []
                              |),
                              [ inputs ]
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0; α1 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let a := M.copy (| γ |) in
                                              M.match_operator (|
                                                M.alloc (| α1 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let b := M.copy (| γ |) in
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::cmp::Ord",
                                                          K,
                                                          [],
                                                          "cmp",
                                                          []
                                                        |),
                                                        [
                                                          M.SubPointer.get_tuple_field (|
                                                            M.read (| a |),
                                                            0
                                                          |);
                                                          M.SubPointer.get_tuple_field (|
                                                            M.read (| b |),
                                                            0
                                                          |)
                                                        ]
                                                      |)))
                                                ]
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      |) in
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                            []
                            [ K; V; Ty.path "alloc::alloc::Global" ],
                          "bulk_build_from_sorted_iter",
                          [
                            Ty.apply
                              (Ty.path "alloc::vec::Vec")
                              []
                              [ Ty.tuple [ K; V ]; Ty.path "alloc::alloc::Global" ]
                          ]
                        |),
                        [ M.read (| inputs |); Value.StructTuple "alloc::alloc::Global" [] ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::FromIterator"
            (Self K V)
            (* Trait polymorphic types *) [ (* A *) Ty.tuple [ K; V ] ]
            (* Instance *) [ ("from_iter", InstanceField.Method (from_iter K V)) ].
      End Impl_core_iter_traits_collect_FromIterator_where_core_cmp_Ord_K_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
      
      Module Impl_core_iter_traits_collect_Extend_where_core_cmp_Ord_K_where_core_alloc_Allocator_A_where_core_clone_Clone_A_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
                iter.into_iter().for_each(move |(k, v)| {
                    self.insert(k, v);
                });
            }
        *)
        Definition extend
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ T ], [ self; iter ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let iter := M.alloc (| iter |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::iterator::Iterator",
                        Ty.associated,
                        [],
                        "for_each",
                        [ Ty.function [ Ty.tuple [ Ty.tuple [ K; V ] ] ] (Ty.tuple []) ]
                      |),
                      [
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::collect::IntoIterator",
                            T,
                            [],
                            "into_iter",
                            []
                          |),
                          [ M.read (| iter |) ]
                        |);
                        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
                                          M.read (|
                                            let~ _ :=
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::map::BTreeMap")
                                                      []
                                                      [ K; V; A ],
                                                    "insert",
                                                    []
                                                  |),
                                                  [
                                                    M.read (| self |);
                                                    M.read (| k |);
                                                    M.read (| v |)
                                                  ]
                                                |)
                                              |) in
                                            M.alloc (| Value.Tuple [] |)
                                          |)))
                                    ]
                                  |)))
                              | _ => M.impossible "wrong number of arguments"
                              end))
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn extend_one(&mut self, (k, v): (K, V)) {
                self.insert(k, v);
            }
        *)
        Definition extend_one
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; β1 ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let β1 := M.alloc (| β1 |) in
              M.match_operator (|
                β1,
                [
                  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
                      M.read (|
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ],
                                "insert",
                                []
                              |),
                              [ M.read (| self |); M.read (| k |); M.read (| v |) ]
                            |)
                          |) in
                        M.alloc (| Value.Tuple [] |)
                      |)))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::Extend"
            (Self K V A)
            (* Trait polymorphic types *) [ (* A *) Ty.tuple [ K; V ] ]
            (* Instance *)
            [
              ("extend", InstanceField.Method (extend K V A));
              ("extend_one", InstanceField.Method (extend_one K V A))
            ].
      End Impl_core_iter_traits_collect_Extend_where_core_cmp_Ord_K_where_core_alloc_Allocator_A_where_core_clone_Clone_A_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_iter_traits_collect_Extend_where_core_cmp_Ord_K_where_core_marker_Copy_K_where_core_marker_Copy_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_Tuple_ref__K_ref__V__for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I) {
                self.extend(iter.into_iter().map(|(&key, &value)| (key, value)));
            }
        *)
        Definition extend
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ _ as I ], [ self; iter ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let iter := M.alloc (| iter |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::iter::traits::collect::Extend",
                        Ty.apply
                          (Ty.path "alloc::collections::btree::map::BTreeMap")
                          []
                          [ K; V; A ],
                        [ Ty.tuple [ K; V ] ],
                        "extend",
                        [
                          Ty.apply
                            (Ty.path "core::iter::adapters::map::Map")
                            []
                            [
                              Ty.associated;
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.tuple
                                        [
                                          Ty.apply (Ty.path "&") [] [ K ];
                                          Ty.apply (Ty.path "&") [] [ V ]
                                        ]
                                    ]
                                ]
                                (Ty.tuple [ K; V ])
                            ]
                        ]
                      |),
                      [
                        M.read (| self |);
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::iterator::Iterator",
                            Ty.associated,
                            [],
                            "map",
                            [
                              Ty.tuple [ K; V ];
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.tuple
                                        [
                                          Ty.apply (Ty.path "&") [] [ K ];
                                          Ty.apply (Ty.path "&") [] [ V ]
                                        ]
                                    ]
                                ]
                                (Ty.tuple [ K; V ])
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_trait_method (|
                                "core::iter::traits::collect::IntoIterator",
                                I,
                                [],
                                "into_iter",
                                []
                              |),
                              [ M.read (| iter |) ]
                            |);
                            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 key := M.copy (| γ0_0 |) in
                                              let γ0_1 := M.read (| γ0_1 |) in
                                              let value := M.copy (| γ0_1 |) in
                                              Value.Tuple [ M.read (| key |); M.read (| value |) ]))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        (*
            fn extend_one(&mut self, (&k, &v): (&'a K, &'a V)) {
                self.insert(k, v);
            }
        *)
        Definition extend_one
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; β1 ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let β1 := M.alloc (| β1 |) in
              M.match_operator (|
                β1,
                [
                  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 γ0_1 := M.read (| γ0_1 |) in
                      let v := M.copy (| γ0_1 |) in
                      M.read (|
                        let~ _ :=
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ],
                                "insert",
                                []
                              |),
                              [ M.read (| self |); M.read (| k |); M.read (| v |) ]
                            |)
                          |) in
                        M.alloc (| Value.Tuple [] |)
                      |)))
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::iter::traits::collect::Extend"
            (Self K V A)
            (* Trait polymorphic types *)
            [ (* A *) Ty.tuple [ Ty.apply (Ty.path "&") [] [ K ]; Ty.apply (Ty.path "&") [] [ V ] ]
            ]
            (* Instance *)
            [
              ("extend", InstanceField.Method (extend K V A));
              ("extend_one", InstanceField.Method (extend_one K V A))
            ].
      End Impl_core_iter_traits_collect_Extend_where_core_cmp_Ord_K_where_core_marker_Copy_K_where_core_marker_Copy_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_Tuple_ref__K_ref__V__for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_hash_Hash_where_core_hash_Hash_K_where_core_hash_Hash_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn hash<H: Hasher>(&self, state: &mut H) {
                state.write_length_prefix(self.len());
                for elt in self {
                    elt.hash(state);
                }
            }
        *)
        Definition hash (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [ H ], [ self; state ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let state := M.alloc (| state |) in
              M.read (|
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::hash::Hasher",
                        H,
                        [],
                        "write_length_prefix",
                        []
                      |),
                      [
                        M.read (| state |);
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::map::BTreeMap")
                              []
                              [ K; V; A ],
                            "len",
                            []
                          |),
                          [ M.read (| self |) ]
                        |)
                      ]
                    |)
                  |) in
                M.use
                  (M.match_operator (|
                    M.alloc (|
                      M.call_closure (|
                        M.get_trait_method (|
                          "core::iter::traits::collect::IntoIterator",
                          Ty.apply
                            (Ty.path "&")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::BTreeMap")
                                []
                                [ K; V; A ]
                            ],
                          [],
                          "into_iter",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    |),
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let iter := M.copy (| γ |) in
                          M.loop (|
                            ltac:(M.monadic
                              (let~ _ :=
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_trait_method (|
                                        "core::iter::traits::iterator::Iterator",
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::map::Iter")
                                          []
                                          [ K; V ],
                                        [],
                                        "next",
                                        []
                                      |),
                                      [ iter ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let _ :=
                                          M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                        M.alloc (|
                                          M.never_to_any (| M.read (| M.break (||) |) |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ0_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::option::Option::Some",
                                            0
                                          |) in
                                        let elt := M.copy (| γ0_0 |) in
                                        let~ _ :=
                                          M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::hash::Hash",
                                                Ty.tuple
                                                  [
                                                    Ty.apply (Ty.path "&") [] [ K ];
                                                    Ty.apply (Ty.path "&") [] [ V ]
                                                  ],
                                                [],
                                                "hash",
                                                [ H ]
                                              |),
                                              [ elt; M.read (| state |) ]
                                            |)
                                          |) in
                                        M.alloc (| Value.Tuple [] |)))
                                  ]
                                |) in
                              M.alloc (| Value.Tuple [] |)))
                          |)))
                    ]
                  |))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::hash::Hash"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("hash", InstanceField.Method (hash K V A)) ].
      End Impl_core_hash_Hash_where_core_hash_Hash_K_where_core_hash_Hash_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_default_Default_for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::BTreeMap")
            []
            [ K; V; Ty.path "alloc::alloc::Global" ].
        
        (*
            fn default() -> BTreeMap<K, V> {
                BTreeMap::new()
            }
        *)
        Definition default (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [] =>
            ltac:(M.monadic
              (M.call_closure (|
                M.get_associated_function (|
                  Ty.apply
                    (Ty.path "alloc::collections::btree::map::BTreeMap")
                    []
                    [ K; V; Ty.path "alloc::alloc::Global" ],
                  "new",
                  []
                |),
                []
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::default::Default"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("default", InstanceField.Method (default K V)) ].
      End Impl_core_default_Default_for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
      
      Module Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_K_where_core_cmp_PartialEq_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
                self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
            }
        *)
        Definition eq (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              LogicalOp.and (|
                BinOp.eq (|
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "len",
                      []
                    |),
                    [ M.read (| self |) ]
                  |),
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "len",
                      []
                    |),
                    [ M.read (| other |) ]
                  |)
                |),
                ltac:(M.monadic
                  (M.call_closure (|
                    M.get_trait_method (|
                      "core::iter::traits::iterator::Iterator",
                      Ty.apply
                        (Ty.path "core::iter::adapters::zip::Zip")
                        []
                        [
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ];
                          Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]
                        ],
                      [],
                      "all",
                      [
                        Ty.function
                          [
                            Ty.tuple
                              [
                                Ty.tuple
                                  [
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ];
                                    Ty.tuple
                                      [
                                        Ty.apply (Ty.path "&") [] [ K ];
                                        Ty.apply (Ty.path "&") [] [ V ]
                                      ]
                                  ]
                              ]
                          ]
                          (Ty.path "bool")
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::iter::traits::iterator::Iterator",
                            Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                            [],
                            "zip",
                            [
                              Ty.apply
                                (Ty.path "&")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::BTreeMap")
                                    []
                                    [ K; V; A ]
                                ]
                            ]
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::map::BTreeMap")
                                  []
                                  [ K; V; A ],
                                "iter",
                                []
                              |),
                              [ M.read (| self |) ]
                            |);
                            M.read (| other |)
                          ]
                        |)
                      |);
                      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 a := M.copy (| γ0_0 |) in
                                        let b := M.copy (| γ0_1 |) in
                                        M.call_closure (|
                                          M.get_trait_method (|
                                            "core::cmp::PartialEq",
                                            Ty.tuple
                                              [
                                                Ty.apply (Ty.path "&") [] [ K ];
                                                Ty.apply (Ty.path "&") [] [ V ]
                                              ],
                                            [
                                              Ty.tuple
                                                [
                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                  Ty.apply (Ty.path "&") [] [ V ]
                                                ]
                                            ],
                                            "eq",
                                            []
                                          |),
                                          [ a; b ]
                                        |)))
                                  ]
                                |)))
                            | _ => M.impossible "wrong number of arguments"
                            end))
                    ]
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::cmp::PartialEq"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("eq", InstanceField.Method (eq K V A)) ].
      End Impl_core_cmp_PartialEq_where_core_cmp_PartialEq_K_where_core_cmp_PartialEq_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_cmp_Eq_where_core_cmp_Eq_K_where_core_cmp_Eq_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::cmp::Eq"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_cmp_Eq_where_core_cmp_Eq_K_where_core_cmp_Eq_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_cmp_PartialOrd_where_core_cmp_PartialOrd_K_where_core_cmp_PartialOrd_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn partial_cmp(&self, other: &BTreeMap<K, V, A>) -> Option<Ordering> {
                self.iter().partial_cmp(other.iter())
            }
        *)
        Definition partial_cmp
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "partial_cmp",
                  [ Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ] ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "iter",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "iter",
                      []
                    |),
                    [ M.read (| other |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::cmp::PartialOrd"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("partial_cmp", InstanceField.Method (partial_cmp K V A)) ].
      End Impl_core_cmp_PartialOrd_where_core_cmp_PartialOrd_K_where_core_cmp_PartialOrd_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_cmp_Ord_where_core_cmp_Ord_K_where_core_cmp_Ord_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn cmp(&self, other: &BTreeMap<K, V, A>) -> Ordering {
                self.iter().cmp(other.iter())
            }
        *)
        Definition cmp (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              M.call_closure (|
                M.get_trait_method (|
                  "core::iter::traits::iterator::Iterator",
                  Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ],
                  [],
                  "cmp",
                  [ Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ] ]
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "iter",
                      []
                    |),
                    [ M.read (| self |) ]
                  |);
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "iter",
                      []
                    |),
                    [ M.read (| other |) ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::cmp::Ord"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("cmp", InstanceField.Method (cmp K V A)) ].
      End Impl_core_cmp_Ord_where_core_cmp_Ord_K_where_core_cmp_Ord_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.debug_map().entries(self.iter()).finish()
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "core::fmt::builders::DebugMap",
                  "finish",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.path "core::fmt::builders::DebugMap",
                      "entries",
                      [
                        Ty.apply (Ty.path "&") [] [ K ];
                        Ty.apply (Ty.path "&") [] [ V ];
                        Ty.apply (Ty.path "alloc::collections::btree::map::Iter") [] [ K; V ]
                      ]
                    |),
                    [
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Formatter",
                            "debug_map",
                            []
                          |),
                          [ M.read (| f |) ]
                        |)
                      |);
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                            []
                            [ K; V; A ],
                          "iter",
                          []
                        |),
                        [ M.read (| self |) ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_where_core_alloc_Allocator_A_where_core_clone_Clone_A_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_ops_index_Index_where_core_marker_Sized_Q_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_borrow_Borrow_K_Q_where_core_cmp_Ord_K_where_core_cmp_Ord_Q_ref__Q_for_alloc_collections_btree_map_BTreeMap_K_V_A.
        Definition Self (K Q V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ].
        
        (*     type Output = V; *)
        Definition _Output (K Q V A : Ty.t) : Ty.t := V.
        
        (*
            fn index(&self, key: &Q) -> &V {
                self.get(key).expect("no entry found for key")
            }
        *)
        Definition index
            (K Q V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K Q V A in
          match ε, τ, α with
          | [], [], [ self; key ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "core::option::Option") [] [ Ty.apply (Ty.path "&") [] [ V ] ],
                  "expect",
                  []
                |),
                [
                  M.call_closure (|
                    M.get_associated_function (|
                      Ty.apply (Ty.path "alloc::collections::btree::map::BTreeMap") [] [ K; V; A ],
                      "get",
                      [ Q ]
                    |),
                    [ M.read (| self |); M.read (| key |) ]
                  |);
                  M.read (| Value.String "no entry found for key" |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K Q V A : Ty.t),
          M.IsTraitInstance
            "core::ops::index::Index"
            (Self K Q V A)
            (* Trait polymorphic types *) [ (* Idx *) Ty.apply (Ty.path "&") [] [ Q ] ]
            (* Instance *)
            [
              ("Output", InstanceField.Ty (_Output K Q V A));
              ("index", InstanceField.Method (index K Q V A))
            ].
      End Impl_core_ops_index_Index_where_core_marker_Sized_Q_where_core_alloc_Allocator_A_where_core_clone_Clone_A_where_core_borrow_Borrow_K_Q_where_core_cmp_Ord_K_where_core_cmp_Ord_Q_ref__Q_for_alloc_collections_btree_map_BTreeMap_K_V_A.
      
      Module Impl_core_convert_From_where_core_cmp_Ord_K_array_N_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
        Definition Self (N : Value.t) (K V : Ty.t) : Ty.t :=
          Ty.apply
            (Ty.path "alloc::collections::btree::map::BTreeMap")
            []
            [ K; V; Ty.path "alloc::alloc::Global" ].
        
        (*
            fn from(mut arr: [(K, V); N]) -> Self {
                if N == 0 {
                    return BTreeMap::new();
                }
        
                // use stable sort to preserve the insertion order.
                arr.sort_by(|a, b| a.0.cmp(&b.0));
                BTreeMap::bulk_build_from_sorted_iter(arr, Global)
            }
        *)
        Definition from
            (N : Value.t)
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self N K V in
          match ε, τ, α with
          | [], [], [ arr ] =>
            ltac:(M.monadic
              (let arr := M.alloc (| arr |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    BinOp.eq (|
                                      M.read (|
                                        M.get_constant (| "alloc::collections::btree::map::N" |)
                                      |),
                                      Value.Integer IntegerKind.Usize 0
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    M.return_ (|
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                                            []
                                            [ K; V; Ty.path "alloc::alloc::Global" ],
                                          "new",
                                          []
                                        |),
                                        []
                                      |)
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "slice") [] [ Ty.tuple [ K; V ] ],
                            "sort_by",
                            [
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply (Ty.path "&") [] [ Ty.tuple [ K; V ] ];
                                      Ty.apply (Ty.path "&") [] [ Ty.tuple [ K; V ] ]
                                    ]
                                ]
                                (Ty.path "core::cmp::Ordering")
                            ]
                          |),
                          [
                            arr;
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0; α1 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let a := M.copy (| γ |) in
                                              M.match_operator (|
                                                M.alloc (| α1 |),
                                                [
                                                  fun γ =>
                                                    ltac:(M.monadic
                                                      (let b := M.copy (| γ |) in
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::cmp::Ord",
                                                          K,
                                                          [],
                                                          "cmp",
                                                          []
                                                        |),
                                                        [
                                                          M.SubPointer.get_tuple_field (|
                                                            M.read (| a |),
                                                            0
                                                          |);
                                                          M.SubPointer.get_tuple_field (|
                                                            M.read (| b |),
                                                            0
                                                          |)
                                                        ]
                                                      |)))
                                                ]
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      |) in
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.apply
                            (Ty.path "alloc::collections::btree::map::BTreeMap")
                            []
                            [ K; V; Ty.path "alloc::alloc::Global" ],
                          "bulk_build_from_sorted_iter",
                          [ Ty.apply (Ty.path "array") [ N ] [ Ty.tuple [ K; V ] ] ]
                        |),
                        [ M.read (| arr |); Value.StructTuple "alloc::alloc::Global" [] ]
                      |)
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (N : Value.t) (K V : Ty.t),
          M.IsTraitInstance
            "core::convert::From"
            (Self N K V)
            (* Trait polymorphic types *)
            [ (* T *) Ty.apply (Ty.path "array") [ N ] [ Ty.tuple [ K; V ] ] ]
            (* Instance *) [ ("from", InstanceField.Method (from N K V)) ].
      End Impl_core_convert_From_where_core_cmp_Ord_K_array_N_Tuple_K_V__for_alloc_collections_btree_map_BTreeMap_K_V_alloc_alloc_Global.
      
      
      (* StructRecord
        {
          name := "Cursor";
          const_params := [];
          ty_params := [ "K"; "V" ];
          fields :=
            [
              ("current",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "alloc::collections::btree::node::Handle")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Immut";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                          ];
                        Ty.path "alloc::collections::btree::node::marker::Edge"
                      ]
                  ]);
              ("root",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "&")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Owned";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                          ]
                      ]
                  ])
            ];
        } *)
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_Cursor_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ].
        
        (*
            fn clone(&self) -> Self {
                let Cursor { current, root } = *self;
                Cursor { current, root }
            }
        *)
        Definition clone (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.match_operator (|
                  M.read (| self |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ0_0 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "alloc::collections::btree::map::Cursor",
                            "current"
                          |) in
                        let γ0_1 :=
                          M.SubPointer.get_struct_record_field (|
                            γ,
                            "alloc::collections::btree::map::Cursor",
                            "root"
                          |) in
                        let current := M.copy (| γ0_0 |) in
                        let root := M.copy (| γ0_1 |) in
                        M.alloc (|
                          Value.StructRecord
                            "alloc::collections::btree::map::Cursor"
                            [ ("current", M.read (| current |)); ("root", M.read (| root |)) ]
                        |)))
                  ]
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::clone::Clone"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method (clone K V)) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_Cursor_K_V.
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Cursor_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.write_str("Cursor")
            }
        *)
        Definition fmt (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
                [ M.read (| f |); M.read (| Value.String "Cursor" |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_Cursor_K_V.
      
      (* StructRecord
        {
          name := "CursorMut";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("inner",
                Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_CursorMut_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::CursorMut") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.write_str("CursorMut")
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
                [ M.read (| f |); M.read (| Value.String "CursorMut" |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_CursorMut_K_V_A.
      
      (* StructRecord
        {
          name := "CursorMutKey";
          const_params := [];
          ty_params := [ "K"; "V"; "A" ];
          fields :=
            [
              ("current",
                Ty.apply
                  (Ty.path "core::option::Option")
                  []
                  [
                    Ty.apply
                      (Ty.path "alloc::collections::btree::node::Handle")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Mut";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                          ];
                        Ty.path "alloc::collections::btree::node::marker::Edge"
                      ]
                  ]);
              ("root",
                Ty.apply
                  (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                  []
                  [
                    Ty.apply
                      (Ty.path "core::option::Option")
                      []
                      [
                        Ty.apply
                          (Ty.path "alloc::collections::btree::node::NodeRef")
                          []
                          [
                            Ty.path "alloc::collections::btree::node::marker::Owned";
                            K;
                            V;
                            Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                          ]
                      ]
                  ]);
              ("length", Ty.apply (Ty.path "&mut") [] [ Ty.path "usize" ]);
              ("alloc", Ty.apply (Ty.path "&mut") [] [ A ])
            ];
        } *)
      
      Module Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_CursorMutKey_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ].
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                f.write_str("CursorMutKey")
            }
        *)
        Definition fmt (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
                [ M.read (| f |); M.read (| Value.String "CursorMutKey" |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          forall (K V A : Ty.t),
          M.IsTraitInstance
            "core::fmt::Debug"
            (Self K V A)
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method (fmt K V A)) ].
      End Impl_core_fmt_Debug_where_core_fmt_Debug_K_where_core_fmt_Debug_V_for_alloc_collections_btree_map_CursorMutKey_K_V_A.
      
      Module Impl_alloc_collections_btree_map_Cursor_K_V.
        Definition Self (K V : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ].
        
        (*
            pub fn next(&mut self) -> Option<(&'a K, &'a V)> {
                let current = self.current.take()?;
                match current.next_kv() {
                    Ok(kv) => {
                        let result = kv.into_kv();
                        self.current = Some(kv.next_leaf_edge());
                        Some(result)
                    }
                    Err(root) => {
                        self.current = Some(root.last_leaf_edge());
                        None
                    }
                }
            }
        *)
        Definition next (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::Cursor",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&") [] [ K ];
                                                    Ty.apply (Ty.path "&") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "next_kv",
                            []
                          |),
                          [ M.read (| current |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Ok",
                                0
                              |) in
                            let kv := M.copy (| γ0_0 |) in
                            let~ result :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::KV"
                                      ],
                                    "into_kv",
                                    []
                                  |),
                                  [ M.read (| kv |) ]
                                |)
                              |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::Cursor",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "next_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| kv |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (|
                              Value.StructTuple "core::option::Option::Some" [ M.read (| result |) ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Err",
                                0
                              |) in
                            let root := M.copy (| γ0_0 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::Cursor",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "last_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_next :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "next" (next K V).
        
        (*
            pub fn prev(&mut self) -> Option<(&'a K, &'a V)> {
                let current = self.current.take()?;
                match current.next_back_kv() {
                    Ok(kv) => {
                        let result = kv.into_kv();
                        self.current = Some(kv.next_back_leaf_edge());
                        Some(result)
                    }
                    Err(root) => {
                        self.current = Some(root.first_leaf_edge());
                        None
                    }
                }
            }
        *)
        Definition prev (K V : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::Cursor",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&") [] [ K ];
                                                    Ty.apply (Ty.path "&") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "next_back_kv",
                            []
                          |),
                          [ M.read (| current |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Ok",
                                0
                              |) in
                            let kv := M.copy (| γ0_0 |) in
                            let~ result :=
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::KV"
                                      ],
                                    "into_kv",
                                    []
                                  |),
                                  [ M.read (| kv |) ]
                                |)
                              |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::Cursor",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "next_back_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| kv |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (|
                              Value.StructTuple "core::option::Option::Some" [ M.read (| result |) ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Err",
                                0
                              |) in
                            let root := M.copy (| γ0_0 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::Cursor",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path
                                              "alloc::collections::btree::node::marker::Immut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "first_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_prev :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "prev" (prev K V).
        
        (*
            pub fn peek_next(&self) -> Option<(&'a K, &'a V)> {
                self.clone().next()
            }
        *)
        Definition peek_next
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ],
                  "next",
                  []
                |),
                [
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_next :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "peek_next" (peek_next K V).
        
        (*
            pub fn peek_prev(&self) -> Option<(&'a K, &'a V)> {
                self.clone().prev()
            }
        *)
        Definition peek_prev
            (K V : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ],
                  "prev",
                  []
                |),
                [
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::clone::Clone",
                        Ty.apply (Ty.path "alloc::collections::btree::map::Cursor") [] [ K; V ],
                        [],
                        "clone",
                        []
                      |),
                      [ M.read (| self |) ]
                    |)
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_prev :
          forall (K V : Ty.t),
          M.IsAssociatedFunction (Self K V) "peek_prev" (peek_prev K V).
      End Impl_alloc_collections_btree_map_Cursor_K_V.
      
      Module Impl_alloc_collections_btree_map_CursorMut_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::CursorMut") [] [ K; V; A ].
        
        (*
            pub fn next(&mut self) -> Option<(&K, &mut V)> {
                let (k, v) = self.inner.next()?;
                Some((&*k, v))
            }
        *)
        Definition next (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      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.tuple
                                    [
                                      Ty.apply (Ty.path "&mut") [] [ K ];
                                      Ty.apply (Ty.path "&mut") [] [ V ]
                                    ]
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                    []
                                    [ K; V; A ],
                                  "next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMut",
                                    "inner"
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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.tuple
                                                [
                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                  Ty.apply (Ty.path "&mut") [] [ V ]
                                                ]
                                            ],
                                          [
                                            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))
                        ]
                      |),
                      [
                        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
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "next" (next K V A).
        
        (*
            pub fn prev(&mut self) -> Option<(&K, &mut V)> {
                let (k, v) = self.inner.prev()?;
                Some((&*k, v))
            }
        *)
        Definition prev (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      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.tuple
                                    [
                                      Ty.apply (Ty.path "&mut") [] [ K ];
                                      Ty.apply (Ty.path "&mut") [] [ V ]
                                    ]
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                    []
                                    [ K; V; A ],
                                  "prev",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMut",
                                    "inner"
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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.tuple
                                                [
                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                  Ty.apply (Ty.path "&mut") [] [ V ]
                                                ]
                                            ],
                                          [
                                            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))
                        ]
                      |),
                      [
                        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
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "prev" (prev K V A).
        
        (*
            pub fn peek_next(&mut self) -> Option<(&K, &mut V)> {
                let (k, v) = self.inner.peek_next()?;
                Some((&*k, v))
            }
        *)
        Definition peek_next
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      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.tuple
                                    [
                                      Ty.apply (Ty.path "&mut") [] [ K ];
                                      Ty.apply (Ty.path "&mut") [] [ V ]
                                    ]
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                    []
                                    [ K; V; A ],
                                  "peek_next",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMut",
                                    "inner"
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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.tuple
                                                [
                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                  Ty.apply (Ty.path "&mut") [] [ V ]
                                                ]
                                            ],
                                          [
                                            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))
                        ]
                      |),
                      [
                        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
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "peek_next" (peek_next K V A).
        
        (*
            pub fn peek_prev(&mut self) -> Option<(&K, &mut V)> {
                let (k, v) = self.inner.peek_prev()?;
                Some((&*k, v))
            }
        *)
        Definition peek_prev
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    M.match_operator (|
                      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.tuple
                                    [
                                      Ty.apply (Ty.path "&mut") [] [ K ];
                                      Ty.apply (Ty.path "&mut") [] [ V ]
                                    ]
                                ],
                              [],
                              "branch",
                              []
                            |),
                            [
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.apply
                                    (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                    []
                                    [ K; V; A ],
                                  "peek_prev",
                                  []
                                |),
                                [
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMut",
                                    "inner"
                                  |)
                                ]
                              |)
                            ]
                          |)
                        |),
                        [
                          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.tuple
                                                [
                                                  Ty.apply (Ty.path "&") [] [ K ];
                                                  Ty.apply (Ty.path "&mut") [] [ V ]
                                                ]
                                            ],
                                          [
                                            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))
                        ]
                      |),
                      [
                        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
                            M.alloc (|
                              Value.StructTuple
                                "core::option::Option::Some"
                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "peek_prev" (peek_prev K V A).
        
        (*
            pub fn as_cursor(&self) -> Cursor<'_, K, V> {
                self.inner.as_cursor()
            }
        *)
        Definition as_cursor
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "as_cursor",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_as_cursor :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "as_cursor" (as_cursor K V A).
        
        (*
            pub unsafe fn with_mutable_key(self) -> CursorMutKey<'a, K, V, A> {
                self.inner
            }
        *)
        Definition with_mutable_key
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.read (|
                M.SubPointer.get_struct_record_field (|
                  self,
                  "alloc::collections::btree::map::CursorMut",
                  "inner"
                |)
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_with_mutable_key :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "with_mutable_key" (with_mutable_key K V A).
        (*
            pub unsafe fn insert_after_unchecked(&mut self, key: K, value: V) {
                unsafe { self.inner.insert_after_unchecked(key, value) }
            }
        *)
        Definition insert_after_unchecked
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "insert_after_unchecked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |);
                  M.read (| key |);
                  M.read (| value |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_after_unchecked :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction
            (Self K V A)
            "insert_after_unchecked"
            (insert_after_unchecked K V A).
        
        (*
            pub unsafe fn insert_before_unchecked(&mut self, key: K, value: V) {
                unsafe { self.inner.insert_before_unchecked(key, value) }
            }
        *)
        Definition insert_before_unchecked
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "insert_before_unchecked",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |);
                  M.read (| key |);
                  M.read (| value |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_before_unchecked :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction
            (Self K V A)
            "insert_before_unchecked"
            (insert_before_unchecked K V A).
        
        (*
            pub fn insert_after(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError> {
                self.inner.insert_after(key, value)
            }
        *)
        Definition insert_after
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "insert_after",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |);
                  M.read (| key |);
                  M.read (| value |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_after :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "insert_after" (insert_after K V A).
        
        (*
            pub fn insert_before(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError> {
                self.inner.insert_before(key, value)
            }
        *)
        Definition insert_before
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "insert_before",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |);
                  M.read (| key |);
                  M.read (| value |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_before :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "insert_before" (insert_before K V A).
        
        (*
            pub fn remove_next(&mut self) -> Option<(K, V)> {
                self.inner.remove_next()
            }
        *)
        Definition remove_next
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "remove_next",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove_next" (remove_next K V A).
        
        (*
            pub fn remove_prev(&mut self) -> Option<(K, V)> {
                self.inner.remove_prev()
            }
        *)
        Definition remove_prev
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.call_closure (|
                M.get_associated_function (|
                  Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ],
                  "remove_prev",
                  []
                |),
                [
                  M.SubPointer.get_struct_record_field (|
                    M.read (| self |),
                    "alloc::collections::btree::map::CursorMut",
                    "inner"
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove_prev" (remove_prev K V A).
      End Impl_alloc_collections_btree_map_CursorMut_K_V_A.
      
      Module Impl_alloc_collections_btree_map_CursorMutKey_K_V_A.
        Definition Self (K V A : Ty.t) : Ty.t :=
          Ty.apply (Ty.path "alloc::collections::btree::map::CursorMutKey") [] [ K; V; A ].
        
        (*
            pub fn next(&mut self) -> Option<(&mut K, &mut V)> {
                let current = self.current.take()?;
                match current.next_kv() {
                    Ok(mut kv) => {
                        // SAFETY: The key/value pointers remain valid even after the
                        // cursor is moved forward. The lifetimes then prevent any
                        // further access to the cursor.
                        let (k, v) = unsafe { kv.reborrow_mut().into_kv_mut() };
                        let (k, v) = (k as *mut _, v as *mut _);
                        self.current = Some(kv.next_leaf_edge());
                        Some(unsafe { (&mut *k, &mut *v) })
                    }
                    Err(root) => {
                        self.current = Some(root.last_leaf_edge());
                        None
                    }
                }
            }
        *)
        Definition next (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&mut") [] [ K ];
                                                    Ty.apply (Ty.path "&mut") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "next_kv",
                            []
                          |),
                          [ M.read (| current |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Ok",
                                0
                              |) in
                            let kv := M.copy (| γ0_0 |) in
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::KV"
                                      ],
                                    "into_kv_mut",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "reborrow_mut",
                                        []
                                      |),
                                      [ kv ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                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
                                    M.match_operator (|
                                      M.alloc (|
                                        Value.Tuple
                                          [
                                            M.read (| M.use (M.alloc (| M.read (| k |) |)) |);
                                            M.read (| M.use (M.alloc (| M.read (| v |) |)) |)
                                          ]
                                      |),
                                      [
                                        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
                                            let~ _ :=
                                              M.write (|
                                                M.SubPointer.get_struct_record_field (|
                                                  M.read (| self |),
                                                  "alloc::collections::btree::map::CursorMutKey",
                                                  "current"
                                                |),
                                                Value.StructTuple
                                                  "core::option::Option::Some"
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path
                                                            "alloc::collections::btree::node::Handle")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Mut";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                                              ];
                                                            Ty.path
                                                              "alloc::collections::btree::node::marker::KV"
                                                          ],
                                                        "next_leaf_edge",
                                                        []
                                                      |),
                                                      [ M.read (| kv |) ]
                                                    |)
                                                  ]
                                              |) in
                                            M.alloc (|
                                              Value.StructTuple
                                                "core::option::Option::Some"
                                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Err",
                                0
                              |) in
                            let root := M.copy (| γ0_0 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "last_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "next" (next K V A).
        
        (*
            pub fn prev(&mut self) -> Option<(&mut K, &mut V)> {
                let current = self.current.take()?;
                match current.next_back_kv() {
                    Ok(mut kv) => {
                        // SAFETY: The key/value pointers remain valid even after the
                        // cursor is moved forward. The lifetimes then prevent any
                        // further access to the cursor.
                        let (k, v) = unsafe { kv.reborrow_mut().into_kv_mut() };
                        let (k, v) = (k as *mut _, v as *mut _);
                        self.current = Some(kv.next_back_leaf_edge());
                        Some(unsafe { (&mut *k, &mut *v) })
                    }
                    Err(root) => {
                        self.current = Some(root.first_leaf_edge());
                        None
                    }
                }
            }
        *)
        Definition prev (K V A : Ty.t) (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&mut") [] [ K ];
                                                    Ty.apply (Ty.path "&mut") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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 (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "next_back_kv",
                            []
                          |),
                          [ M.read (| current |) ]
                        |)
                      |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Ok",
                                0
                              |) in
                            let kv := M.copy (| γ0_0 |) in
                            M.match_operator (|
                              M.alloc (|
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::KV"
                                      ],
                                    "into_kv_mut",
                                    []
                                  |),
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::KV"
                                          ],
                                        "reborrow_mut",
                                        []
                                      |),
                                      [ kv ]
                                    |)
                                  ]
                                |)
                              |),
                              [
                                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
                                    M.match_operator (|
                                      M.alloc (|
                                        Value.Tuple
                                          [
                                            M.read (| M.use (M.alloc (| M.read (| k |) |)) |);
                                            M.read (| M.use (M.alloc (| M.read (| v |) |)) |)
                                          ]
                                      |),
                                      [
                                        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
                                            let~ _ :=
                                              M.write (|
                                                M.SubPointer.get_struct_record_field (|
                                                  M.read (| self |),
                                                  "alloc::collections::btree::map::CursorMutKey",
                                                  "current"
                                                |),
                                                Value.StructTuple
                                                  "core::option::Option::Some"
                                                  [
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path
                                                            "alloc::collections::btree::node::Handle")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Mut";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                                              ];
                                                            Ty.path
                                                              "alloc::collections::btree::node::marker::KV"
                                                          ],
                                                        "next_back_leaf_edge",
                                                        []
                                                      |),
                                                      [ M.read (| kv |) ]
                                                    |)
                                                  ]
                                              |) in
                                            M.alloc (|
                                              Value.StructTuple
                                                "core::option::Option::Some"
                                                [ Value.Tuple [ M.read (| k |); M.read (| v |) ] ]
                                            |)))
                                      ]
                                    |)))
                              ]
                            |)));
                        fun γ =>
                          ltac:(M.monadic
                            (let γ0_0 :=
                              M.SubPointer.get_struct_tuple_field (|
                                γ,
                                "core::result::Result::Err",
                                0
                              |) in
                            let root := M.copy (| γ0_0 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |),
                                Value.StructTuple
                                  "core::option::Option::Some"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path
                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                          ],
                                        "first_leaf_edge",
                                        []
                                      |),
                                      [ M.read (| root |) ]
                                    |)
                                  ]
                              |) in
                            M.alloc (| Value.StructTuple "core::option::Option::None" [] |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "prev" (prev K V A).
        
        (*
            pub fn peek_next(&mut self) -> Option<(&mut K, &mut V)> {
                let current = self.current.as_mut()?;
                // SAFETY: We're not using this to mutate the tree.
                let kv = unsafe { current.reborrow_mut() }.next_kv().ok()?.into_kv_mut();
                Some(kv)
            }
        *)
        Definition peek_next
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "as_mut",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&mut") [] [ K ];
                                                    Ty.apply (Ty.path "&mut") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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
                    let~ kv :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "into_kv_mut",
                            []
                          |),
                          [
                            M.read (|
                              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 "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ];
                                              Ty.path "alloc::collections::btree::node::marker::KV"
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::KV"
                                                ];
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "ok",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_kv",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::Handle")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ];
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Edge"
                                                    ],
                                                  "reborrow_mut",
                                                  []
                                                |),
                                                [ M.read (| current |) ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple
                                                        [
                                                          Ty.apply (Ty.path "&mut") [] [ K ];
                                                          Ty.apply (Ty.path "&mut") [] [ V ]
                                                        ]
                                                    ],
                                                  [
                                                    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.alloc (| Value.StructTuple "core::option::Option::Some" [ M.read (| kv |) ] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "peek_next" (peek_next K V A).
        
        (*
            pub fn peek_prev(&mut self) -> Option<(&mut K, &mut V)> {
                let current = self.current.as_mut()?;
                // SAFETY: We're not using this to mutate the tree.
                let kv = unsafe { current.reborrow_mut() }.next_back_kv().ok()?.into_kv_mut();
                Some(kv)
            }
        *)
        Definition peek_prev
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "as_mut",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple
                                                  [
                                                    Ty.apply (Ty.path "&mut") [] [ K ];
                                                    Ty.apply (Ty.path "&mut") [] [ V ]
                                                  ]
                                              ],
                                            [
                                              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
                    let~ kv :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "into_kv_mut",
                            []
                          |),
                          [
                            M.read (|
                              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 "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ];
                                              Ty.path "alloc::collections::btree::node::marker::KV"
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::KV"
                                                ];
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "ok",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_back_kv",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::Handle")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ];
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Edge"
                                                    ],
                                                  "reborrow_mut",
                                                  []
                                                |),
                                                [ M.read (| current |) ]
                                              |)
                                            ]
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple
                                                        [
                                                          Ty.apply (Ty.path "&mut") [] [ K ];
                                                          Ty.apply (Ty.path "&mut") [] [ V ]
                                                        ]
                                                    ],
                                                  [
                                                    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.alloc (| Value.StructTuple "core::option::Option::Some" [ M.read (| kv |) ] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_peek_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "peek_prev" (peek_prev K V A).
        
        (*
            pub fn as_cursor(&self) -> Cursor<'_, K, V> {
                Cursor {
                    // SAFETY: The tree is immutable while the cursor exists.
                    root: unsafe { self.root.reborrow_shared().as_ref() },
                    current: self.current.as_ref().map(|current| current.reborrow()),
                }
            }
        *)
        Definition as_cursor
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructRecord
                "alloc::collections::btree::map::Cursor"
                [
                  ("root",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::option::Option")
                          []
                          [
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::NodeRef")
                              []
                              [
                                Ty.path "alloc::collections::btree::node::marker::Owned";
                                K;
                                V;
                                Ty.path "alloc::collections::btree::node::marker::LeafOrInternal"
                              ]
                          ],
                        "as_ref",
                        []
                      |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::borrow::DormantMutRef")
                              []
                              [
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Owned";
                                        K;
                                        V;
                                        Ty.path
                                          "alloc::collections::btree::node::marker::LeafOrInternal"
                                      ]
                                  ]
                              ],
                            "reborrow_shared",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::CursorMutKey",
                              "root"
                            |)
                          ]
                        |)
                      ]
                    |));
                  ("current",
                    M.call_closure (|
                      M.get_associated_function (|
                        Ty.apply
                          (Ty.path "core::option::Option")
                          []
                          [
                            Ty.apply
                              (Ty.path "&")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::Edge"
                                  ]
                              ]
                          ],
                        "map",
                        [
                          Ty.apply
                            (Ty.path "alloc::collections::btree::node::Handle")
                            []
                            [
                              Ty.apply
                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                []
                                [
                                  Ty.path "alloc::collections::btree::node::marker::Immut";
                                  K;
                                  V;
                                  Ty.path "alloc::collections::btree::node::marker::Leaf"
                                ];
                              Ty.path "alloc::collections::btree::node::marker::Edge"
                            ];
                          Ty.function
                            [
                              Ty.tuple
                                [
                                  Ty.apply
                                    (Ty.path "&")
                                    []
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::Handle")
                                        []
                                        [
                                          Ty.apply
                                            (Ty.path "alloc::collections::btree::node::NodeRef")
                                            []
                                            [
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Mut";
                                              K;
                                              V;
                                              Ty.path
                                                "alloc::collections::btree::node::marker::Leaf"
                                            ];
                                          Ty.path "alloc::collections::btree::node::marker::Edge"
                                        ]
                                    ]
                                ]
                            ]
                            (Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Immut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ])
                        ]
                      |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "core::option::Option")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::Edge"
                                  ]
                              ],
                            "as_ref",
                            []
                          |),
                          [
                            M.SubPointer.get_struct_record_field (|
                              M.read (| self |),
                              "alloc::collections::btree::map::CursorMutKey",
                              "current"
                            |)
                          ]
                        |);
                        M.closure
                          (fun γ =>
                            ltac:(M.monadic
                              match γ with
                              | [ α0 ] =>
                                ltac:(M.monadic
                                  (M.match_operator (|
                                    M.alloc (| α0 |),
                                    [
                                      fun γ =>
                                        ltac:(M.monadic
                                          (let current := M.copy (| γ |) in
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "reborrow",
                                              []
                                            |),
                                            [ M.read (| current |) ]
                                          |)))
                                    ]
                                  |)))
                              | _ => M.impossible "wrong number of arguments"
                              end))
                      ]
                    |))
                ]))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_as_cursor :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "as_cursor" (as_cursor K V A).
        (*
            pub unsafe fn insert_after_unchecked(&mut self, key: K, value: V) {
                let edge = match self.current.take() {
                    None => {
                        // Tree is empty, allocate a new root.
                        // SAFETY: We have no other reference to the tree.
                        let root = unsafe { self.root.reborrow() };
                        debug_assert!(root.is_none());
                        let mut node = NodeRef::new_leaf(self.alloc.clone());
                        // SAFETY: We don't touch the root while the handle is alive.
                        let handle = unsafe { node.borrow_mut().push_with_handle(key, value) };
                        *root = Some(node.forget_type());
                        *self.length += 1;
                        self.current = Some(handle.left_edge());
                        return;
                    }
                    Some(current) => current,
                };
        
                let handle = edge.insert_recursing(key, value, self.alloc.clone(), |ins| {
                    drop(ins.left);
                    // SAFETY: The handle to the newly inserted value is always on a
                    // leaf node, so adding a new root node doesn't invalidate it.
                    let root = unsafe { self.root.reborrow().as_mut().unwrap() };
                    root.push_internal_level(self.alloc.clone()).push(ins.kv.0, ins.kv.1, ins.right)
                });
                self.current = Some(handle.left_edge());
                *self.length += 1;
            }
        *)
        Definition insert_after_unchecked
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ edge :=
                      M.copy (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                "take",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                M.alloc (|
                                  M.never_to_any (|
                                    M.read (|
                                      let~ root :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path
                                                  "alloc::collections::btree::borrow::DormantMutRef")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              "reborrow",
                                              []
                                            |),
                                            [
                                              M.SubPointer.get_struct_record_field (|
                                                M.read (| self |),
                                                "alloc::collections::btree::map::CursorMutKey",
                                                "root"
                                              |)
                                            ]
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.match_operator (|
                                          M.alloc (| Value.Tuple [] |),
                                          [
                                            fun γ =>
                                              ltac:(M.monadic
                                                (let γ := M.use (M.alloc (| Value.Bool true |)) in
                                                let _ :=
                                                  M.is_constant_or_break_match (|
                                                    M.read (| γ |),
                                                    Value.Bool true
                                                  |) in
                                                let~ _ :=
                                                  M.match_operator (|
                                                    M.alloc (| Value.Tuple [] |),
                                                    [
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (let γ :=
                                                            M.use
                                                              (M.alloc (|
                                                                UnOp.not (|
                                                                  M.call_closure (|
                                                                    M.get_associated_function (|
                                                                      Ty.apply
                                                                        (Ty.path
                                                                          "core::option::Option")
                                                                        []
                                                                        [
                                                                          Ty.apply
                                                                            (Ty.path
                                                                              "alloc::collections::btree::node::NodeRef")
                                                                            []
                                                                            [
                                                                              Ty.path
                                                                                "alloc::collections::btree::node::marker::Owned";
                                                                              K;
                                                                              V;
                                                                              Ty.path
                                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                            ]
                                                                        ],
                                                                      "is_none",
                                                                      []
                                                                    |),
                                                                    [ M.read (| root |) ]
                                                                  |)
                                                                |)
                                                              |)) in
                                                          let _ :=
                                                            M.is_constant_or_break_match (|
                                                              M.read (| γ |),
                                                              Value.Bool true
                                                            |) in
                                                          M.alloc (|
                                                            M.never_to_any (|
                                                              M.call_closure (|
                                                                M.get_function (|
                                                                  "core::panicking::panic",
                                                                  []
                                                                |),
                                                                [
                                                                  M.read (|
                                                                    Value.String
                                                                      "assertion failed: root.is_none()"
                                                                  |)
                                                                ]
                                                              |)
                                                            |)
                                                          |)));
                                                      fun γ =>
                                                        ltac:(M.monadic
                                                          (M.alloc (| Value.Tuple [] |)))
                                                    ]
                                                  |) in
                                                M.alloc (| Value.Tuple [] |)));
                                            fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                          ]
                                        |) in
                                      let~ node :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Leaf"
                                                ],
                                              "new_leaf",
                                              [ A ]
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::clone::Clone",
                                                  A,
                                                  [],
                                                  "clone",
                                                  []
                                                |),
                                                [
                                                  M.read (|
                                                    M.SubPointer.get_struct_record_field (|
                                                      M.read (| self |),
                                                      "alloc::collections::btree::map::CursorMutKey",
                                                      "alloc"
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |) in
                                      let~ handle :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Leaf"
                                                ],
                                              "push_with_handle",
                                              []
                                            |),
                                            [
                                              M.alloc (|
                                                M.call_closure (|
                                                  M.get_associated_function (|
                                                    Ty.apply
                                                      (Ty.path
                                                        "alloc::collections::btree::node::NodeRef")
                                                      []
                                                      [
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Owned";
                                                        K;
                                                        V;
                                                        Ty.path
                                                          "alloc::collections::btree::node::marker::Leaf"
                                                      ],
                                                    "borrow_mut",
                                                    []
                                                  |),
                                                  [ node ]
                                                |)
                                              |);
                                              M.read (| key |);
                                              M.read (| value |)
                                            ]
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.write (|
                                          M.read (| root |),
                                          Value.StructTuple
                                            "core::option::Option::Some"
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Owned";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ],
                                                  "forget_type",
                                                  []
                                                |),
                                                [ M.read (| node |) ]
                                              |)
                                            ]
                                        |) in
                                      let~ _ :=
                                        let β :=
                                          M.read (|
                                            M.SubPointer.get_struct_record_field (|
                                              M.read (| self |),
                                              "alloc::collections::btree::map::CursorMutKey",
                                              "length"
                                            |)
                                          |) in
                                        M.write (|
                                          β,
                                          BinOp.Wrap.add (|
                                            M.read (| β |),
                                            Value.Integer IntegerKind.Usize 1
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.write (|
                                          M.SubPointer.get_struct_record_field (|
                                            M.read (| self |),
                                            "alloc::collections::btree::map::CursorMutKey",
                                            "current"
                                          |),
                                          Value.StructTuple
                                            "core::option::Option::Some"
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::Handle")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ];
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::KV"
                                                    ],
                                                  "left_edge",
                                                  []
                                                |),
                                                [ M.read (| handle |) ]
                                              |)
                                            ]
                                        |) in
                                      M.return_ (| Value.Tuple [] |)
                                    |)
                                  |)
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let current := M.copy (| γ0_0 |) in
                                current))
                          ]
                        |)
                      |) in
                    let~ handle :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "insert_recursing",
                            [
                              A;
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::SplitResult")
                                        []
                                        [
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ]
                                    ]
                                ]
                                (Ty.tuple [])
                            ]
                          |),
                          [
                            M.read (| edge |);
                            M.read (| key |);
                            M.read (| value |);
                            M.call_closure (|
                              M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "alloc"
                                  |)
                                |)
                              ]
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let ins := M.copy (| γ |) in
                                              M.read (|
                                                let~ _ :=
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_function (|
                                                        "core::mem::drop",
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::NodeRef")
                                                            []
                                                            [
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Mut";
                                                              K;
                                                              V;
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                            ]
                                                        ]
                                                      |),
                                                      [
                                                        M.read (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "left"
                                                          |)
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                let~ root :=
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path "core::option::Option")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path "&mut")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::node::NodeRef")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Owned";
                                                                    K;
                                                                    V;
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                  ]
                                                              ]
                                                          ],
                                                        "unwrap",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::node::NodeRef")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Owned";
                                                                    K;
                                                                    V;
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                  ]
                                                              ],
                                                            "as_mut",
                                                            []
                                                          |),
                                                          [
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::borrow::DormantMutRef")
                                                                  []
                                                                  [
                                                                    Ty.apply
                                                                      (Ty.path
                                                                        "core::option::Option")
                                                                      []
                                                                      [
                                                                        Ty.apply
                                                                          (Ty.path
                                                                            "alloc::collections::btree::node::NodeRef")
                                                                          []
                                                                          [
                                                                            Ty.path
                                                                              "alloc::collections::btree::node::marker::Owned";
                                                                            K;
                                                                            V;
                                                                            Ty.path
                                                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                          ]
                                                                      ]
                                                                  ],
                                                                "reborrow",
                                                                []
                                                              |),
                                                              [
                                                                M.SubPointer.get_struct_record_field (|
                                                                  M.read (| self |),
                                                                  "alloc::collections::btree::map::CursorMutKey",
                                                                  "root"
                                                                |)
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Internal"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Owned";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                                              ],
                                                            "push_internal_level",
                                                            [ A ]
                                                          |),
                                                          [
                                                            M.read (| root |);
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::clone::Clone",
                                                                A,
                                                                [],
                                                                "clone",
                                                                []
                                                              |),
                                                              [
                                                                M.read (|
                                                                  M.SubPointer.get_struct_record_field (|
                                                                    M.read (| self |),
                                                                    "alloc::collections::btree::map::CursorMutKey",
                                                                    "alloc"
                                                                  |)
                                                                |)
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_tuple_field (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "kv"
                                                          |),
                                                          0
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_tuple_field (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "kv"
                                                          |),
                                                          1
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          ins,
                                                          "alloc::collections::btree::node::SplitResult",
                                                          "right"
                                                        |)
                                                      |)
                                                    ]
                                                  |)
                                                |)
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::CursorMutKey",
                          "current"
                        |),
                        Value.StructTuple
                          "core::option::Option::Some"
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::KV"
                                  ],
                                "left_edge",
                                []
                              |),
                              [ M.read (| handle |) ]
                            |)
                          ]
                      |) in
                    let~ _ :=
                      let β :=
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::map::CursorMutKey",
                            "length"
                          |)
                        |) in
                      M.write (|
                        β,
                        BinOp.Wrap.add (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                      |) in
                    M.alloc (| Value.Tuple [] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_after_unchecked :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction
            (Self K V A)
            "insert_after_unchecked"
            (insert_after_unchecked K V A).
        
        (*
            pub unsafe fn insert_before_unchecked(&mut self, key: K, value: V) {
                let edge = match self.current.take() {
                    None => {
                        // SAFETY: We have no other reference to the tree.
                        match unsafe { self.root.reborrow() } {
                            root @ None => {
                                // Tree is empty, allocate a new root.
                                let mut node = NodeRef::new_leaf(self.alloc.clone());
                                // SAFETY: We don't touch the root while the handle is alive.
                                let handle = unsafe { node.borrow_mut().push_with_handle(key, value) };
                                *root = Some(node.forget_type());
                                *self.length += 1;
                                self.current = Some(handle.right_edge());
                                return;
                            }
                            Some(root) => root.borrow_mut().last_leaf_edge(),
                        }
                    }
                    Some(current) => current,
                };
        
                let handle = edge.insert_recursing(key, value, self.alloc.clone(), |ins| {
                    drop(ins.left);
                    // SAFETY: The handle to the newly inserted value is always on a
                    // leaf node, so adding a new root node doesn't invalidate it.
                    let root = unsafe { self.root.reborrow().as_mut().unwrap() };
                    root.push_internal_level(self.alloc.clone()).push(ins.kv.0, ins.kv.1, ins.right)
                });
                self.current = Some(handle.right_edge());
                *self.length += 1;
            }
        *)
        Definition insert_before_unchecked
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ edge :=
                      M.copy (|
                        M.match_operator (|
                          M.alloc (|
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "core::option::Option")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                "take",
                                []
                              |),
                              [
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |)
                              ]
                            |)
                          |),
                          [
                            fun γ =>
                              ltac:(M.monadic
                                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                M.match_operator (|
                                  M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path
                                            "alloc::collections::btree::borrow::DormantMutRef")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "core::option::Option")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Owned";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                  ]
                                              ]
                                          ],
                                        "reborrow",
                                        []
                                      |),
                                      [
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "alloc::collections::btree::map::CursorMutKey",
                                          "root"
                                        |)
                                      ]
                                    |)
                                  |),
                                  [
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let root := M.copy (| γ |) in
                                        let γ := M.read (| γ |) in
                                        let _ :=
                                          M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                                        M.alloc (|
                                          M.never_to_any (|
                                            M.read (|
                                              let~ node :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ],
                                                      "new_leaf",
                                                      [ A ]
                                                    |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_trait_method (|
                                                          "core::clone::Clone",
                                                          A,
                                                          [],
                                                          "clone",
                                                          []
                                                        |),
                                                        [
                                                          M.read (|
                                                            M.SubPointer.get_struct_record_field (|
                                                              M.read (| self |),
                                                              "alloc::collections::btree::map::CursorMutKey",
                                                              "alloc"
                                                            |)
                                                          |)
                                                        ]
                                                      |)
                                                    ]
                                                  |)
                                                |) in
                                              let~ handle :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ],
                                                      "push_with_handle",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Owned";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Leaf"
                                                              ],
                                                            "borrow_mut",
                                                            []
                                                          |),
                                                          [ node ]
                                                        |)
                                                      |);
                                                      M.read (| key |);
                                                      M.read (| value |)
                                                    ]
                                                  |)
                                                |) in
                                              let~ _ :=
                                                M.write (|
                                                  M.read (| root |),
                                                  Value.StructTuple
                                                    "core::option::Option::Some"
                                                    [
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::NodeRef")
                                                            []
                                                            [
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Owned";
                                                              K;
                                                              V;
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Leaf"
                                                            ],
                                                          "forget_type",
                                                          []
                                                        |),
                                                        [ M.read (| node |) ]
                                                      |)
                                                    ]
                                                |) in
                                              let~ _ :=
                                                let β :=
                                                  M.read (|
                                                    M.SubPointer.get_struct_record_field (|
                                                      M.read (| self |),
                                                      "alloc::collections::btree::map::CursorMutKey",
                                                      "length"
                                                    |)
                                                  |) in
                                                M.write (|
                                                  β,
                                                  BinOp.Wrap.add (|
                                                    M.read (| β |),
                                                    Value.Integer IntegerKind.Usize 1
                                                  |)
                                                |) in
                                              let~ _ :=
                                                M.write (|
                                                  M.SubPointer.get_struct_record_field (|
                                                    M.read (| self |),
                                                    "alloc::collections::btree::map::CursorMutKey",
                                                    "current"
                                                  |),
                                                  Value.StructTuple
                                                    "core::option::Option::Some"
                                                    [
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::Handle")
                                                            []
                                                            [
                                                              Ty.apply
                                                                (Ty.path
                                                                  "alloc::collections::btree::node::NodeRef")
                                                                []
                                                                [
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::Mut";
                                                                  K;
                                                                  V;
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::Leaf"
                                                                ];
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::KV"
                                                            ],
                                                          "right_edge",
                                                          []
                                                        |),
                                                        [ M.read (| handle |) ]
                                                      |)
                                                    ]
                                                |) in
                                              M.return_ (| Value.Tuple [] |)
                                            |)
                                          |)
                                        |)));
                                    fun γ =>
                                      ltac:(M.monadic
                                        (let γ := M.read (| γ |) in
                                        let γ1_0 :=
                                          M.SubPointer.get_struct_tuple_field (|
                                            γ,
                                            "core::option::Option::Some",
                                            0
                                          |) in
                                        let root := M.alloc (| γ1_0 |) in
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ],
                                              "last_leaf_edge",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Owned";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ],
                                                  "borrow_mut",
                                                  []
                                                |),
                                                [ M.read (| root |) ]
                                              |)
                                            ]
                                          |)
                                        |)))
                                  ]
                                |)));
                            fun γ =>
                              ltac:(M.monadic
                                (let γ0_0 :=
                                  M.SubPointer.get_struct_tuple_field (|
                                    γ,
                                    "core::option::Option::Some",
                                    0
                                  |) in
                                let current := M.copy (| γ0_0 |) in
                                current))
                          ]
                        |)
                      |) in
                    let~ handle :=
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path "alloc::collections::btree::node::marker::Leaf"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::Edge"
                              ],
                            "insert_recursing",
                            [
                              A;
                              Ty.function
                                [
                                  Ty.tuple
                                    [
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::node::SplitResult")
                                        []
                                        [
                                          K;
                                          V;
                                          Ty.path
                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                        ]
                                    ]
                                ]
                                (Ty.tuple [])
                            ]
                          |),
                          [
                            M.read (| edge |);
                            M.read (| key |);
                            M.read (| value |);
                            M.call_closure (|
                              M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "alloc"
                                  |)
                                |)
                              ]
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (let ins := M.copy (| γ |) in
                                              M.read (|
                                                let~ _ :=
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_function (|
                                                        "core::mem::drop",
                                                        [
                                                          Ty.apply
                                                            (Ty.path
                                                              "alloc::collections::btree::node::NodeRef")
                                                            []
                                                            [
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::Mut";
                                                              K;
                                                              V;
                                                              Ty.path
                                                                "alloc::collections::btree::node::marker::LeafOrInternal"
                                                            ]
                                                        ]
                                                      |),
                                                      [
                                                        M.read (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "left"
                                                          |)
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                let~ root :=
                                                  M.alloc (|
                                                    M.call_closure (|
                                                      M.get_associated_function (|
                                                        Ty.apply
                                                          (Ty.path "core::option::Option")
                                                          []
                                                          [
                                                            Ty.apply
                                                              (Ty.path "&mut")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::node::NodeRef")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Owned";
                                                                    K;
                                                                    V;
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                  ]
                                                              ]
                                                          ],
                                                        "unwrap",
                                                        []
                                                      |),
                                                      [
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path "core::option::Option")
                                                              []
                                                              [
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::node::NodeRef")
                                                                  []
                                                                  [
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::Owned";
                                                                    K;
                                                                    V;
                                                                    Ty.path
                                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                  ]
                                                              ],
                                                            "as_mut",
                                                            []
                                                          |),
                                                          [
                                                            M.call_closure (|
                                                              M.get_associated_function (|
                                                                Ty.apply
                                                                  (Ty.path
                                                                    "alloc::collections::btree::borrow::DormantMutRef")
                                                                  []
                                                                  [
                                                                    Ty.apply
                                                                      (Ty.path
                                                                        "core::option::Option")
                                                                      []
                                                                      [
                                                                        Ty.apply
                                                                          (Ty.path
                                                                            "alloc::collections::btree::node::NodeRef")
                                                                          []
                                                                          [
                                                                            Ty.path
                                                                              "alloc::collections::btree::node::marker::Owned";
                                                                            K;
                                                                            V;
                                                                            Ty.path
                                                                              "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                          ]
                                                                      ]
                                                                  ],
                                                                "reborrow",
                                                                []
                                                              |),
                                                              [
                                                                M.SubPointer.get_struct_record_field (|
                                                                  M.read (| self |),
                                                                  "alloc::collections::btree::map::CursorMutKey",
                                                                  "root"
                                                                |)
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      ]
                                                    |)
                                                  |) in
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Internal"
                                                        ],
                                                      "push",
                                                      []
                                                    |),
                                                    [
                                                      M.alloc (|
                                                        M.call_closure (|
                                                          M.get_associated_function (|
                                                            Ty.apply
                                                              (Ty.path
                                                                "alloc::collections::btree::node::NodeRef")
                                                              []
                                                              [
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::Owned";
                                                                K;
                                                                V;
                                                                Ty.path
                                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                                              ],
                                                            "push_internal_level",
                                                            [ A ]
                                                          |),
                                                          [
                                                            M.read (| root |);
                                                            M.call_closure (|
                                                              M.get_trait_method (|
                                                                "core::clone::Clone",
                                                                A,
                                                                [],
                                                                "clone",
                                                                []
                                                              |),
                                                              [
                                                                M.read (|
                                                                  M.SubPointer.get_struct_record_field (|
                                                                    M.read (| self |),
                                                                    "alloc::collections::btree::map::CursorMutKey",
                                                                    "alloc"
                                                                  |)
                                                                |)
                                                              ]
                                                            |)
                                                          ]
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_tuple_field (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "kv"
                                                          |),
                                                          0
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_tuple_field (|
                                                          M.SubPointer.get_struct_record_field (|
                                                            ins,
                                                            "alloc::collections::btree::node::SplitResult",
                                                            "kv"
                                                          |),
                                                          1
                                                        |)
                                                      |);
                                                      M.read (|
                                                        M.SubPointer.get_struct_record_field (|
                                                          ins,
                                                          "alloc::collections::btree::node::SplitResult",
                                                          "right"
                                                        |)
                                                      |)
                                                    ]
                                                  |)
                                                |)
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end))
                          ]
                        |)
                      |) in
                    let~ _ :=
                      M.write (|
                        M.SubPointer.get_struct_record_field (|
                          M.read (| self |),
                          "alloc::collections::btree::map::CursorMutKey",
                          "current"
                        |),
                        Value.StructTuple
                          "core::option::Option::Some"
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::Handle")
                                  []
                                  [
                                    Ty.apply
                                      (Ty.path "alloc::collections::btree::node::NodeRef")
                                      []
                                      [
                                        Ty.path "alloc::collections::btree::node::marker::Mut";
                                        K;
                                        V;
                                        Ty.path "alloc::collections::btree::node::marker::Leaf"
                                      ];
                                    Ty.path "alloc::collections::btree::node::marker::KV"
                                  ],
                                "right_edge",
                                []
                              |),
                              [ M.read (| handle |) ]
                            |)
                          ]
                      |) in
                    let~ _ :=
                      let β :=
                        M.read (|
                          M.SubPointer.get_struct_record_field (|
                            M.read (| self |),
                            "alloc::collections::btree::map::CursorMutKey",
                            "length"
                          |)
                        |) in
                      M.write (|
                        β,
                        BinOp.Wrap.add (| M.read (| β |), Value.Integer IntegerKind.Usize 1 |)
                      |) in
                    M.alloc (| Value.Tuple [] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_before_unchecked :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction
            (Self K V A)
            "insert_before_unchecked"
            (insert_before_unchecked K V A).
        
        (*
            pub fn insert_after(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError> {
                if let Some((prev, _)) = self.peek_prev() {
                    if &key <= prev {
                        return Err(UnorderedKeyError {});
                    }
                }
                if let Some((next, _)) = self.peek_next() {
                    if &key >= next {
                        return Err(UnorderedKeyError {});
                    }
                }
                unsafe {
                    self.insert_after_unchecked(key, value);
                }
                Ok(())
            }
        *)
        Definition insert_after
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                        []
                                        [ K; V; A ],
                                      "peek_prev",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |)
                                |) in
                              let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                              let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                              let prev := M.copy (| γ1_0 |) in
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::cmp::PartialOrd",
                                                Ty.apply (Ty.path "&") [] [ K ],
                                                [ Ty.apply (Ty.path "&") [] [ K ] ],
                                                "le",
                                                []
                                              |),
                                              [ M.alloc (| key |); M.alloc (| M.read (| prev |) |) ]
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Err"
                                                [
                                                  Value.StructTuple
                                                    "alloc::collections::btree::map::UnorderedKeyError"
                                                    []
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                        []
                                        [ K; V; A ],
                                      "peek_next",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |)
                                |) in
                              let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                              let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                              let next := M.copy (| γ1_0 |) in
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::cmp::PartialOrd",
                                                Ty.apply (Ty.path "&") [] [ K ],
                                                [ Ty.apply (Ty.path "&") [] [ K ] ],
                                                "ge",
                                                []
                                              |),
                                              [ M.alloc (| key |); M.alloc (| M.read (| next |) |) ]
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Err"
                                                [
                                                  Value.StructTuple
                                                    "alloc::collections::btree::map::UnorderedKeyError"
                                                    []
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                []
                                [ K; V; A ],
                              "insert_after_unchecked",
                              []
                            |),
                            [ M.read (| self |); M.read (| key |); M.read (| value |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [] |) in
                    M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_after :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "insert_after" (insert_after K V A).
        
        (*
            pub fn insert_before(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError> {
                if let Some((prev, _)) = self.peek_prev() {
                    if &key <= prev {
                        return Err(UnorderedKeyError {});
                    }
                }
                if let Some((next, _)) = self.peek_next() {
                    if &key >= next {
                        return Err(UnorderedKeyError {});
                    }
                }
                unsafe {
                    self.insert_before_unchecked(key, value);
                }
                Ok(())
            }
        *)
        Definition insert_before
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self; key; value ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let key := M.alloc (| key |) in
              let value := M.alloc (| value |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                        []
                                        [ K; V; A ],
                                      "peek_prev",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |)
                                |) in
                              let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                              let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                              let prev := M.copy (| γ1_0 |) in
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::cmp::PartialOrd",
                                                Ty.apply (Ty.path "&") [] [ K ],
                                                [ Ty.apply (Ty.path "&") [] [ K ] ],
                                                "le",
                                                []
                                              |),
                                              [ M.alloc (| key |); M.alloc (| M.read (| prev |) |) ]
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Err"
                                                [
                                                  Value.StructTuple
                                                    "alloc::collections::btree::map::UnorderedKeyError"
                                                    []
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.alloc (|
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.apply
                                        (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                        []
                                        [ K; V; A ],
                                      "peek_next",
                                      []
                                    |),
                                    [ M.read (| self |) ]
                                  |)
                                |) in
                              let γ0_0 :=
                                M.SubPointer.get_struct_tuple_field (|
                                  γ,
                                  "core::option::Option::Some",
                                  0
                                |) in
                              let γ1_0 := M.SubPointer.get_tuple_field (| γ0_0, 0 |) in
                              let γ1_1 := M.SubPointer.get_tuple_field (| γ0_0, 1 |) in
                              let next := M.copy (| γ1_0 |) in
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ :=
                                        M.use
                                          (M.alloc (|
                                            M.call_closure (|
                                              M.get_trait_method (|
                                                "core::cmp::PartialOrd",
                                                Ty.apply (Ty.path "&") [] [ K ],
                                                [ Ty.apply (Ty.path "&") [] [ K ] ],
                                                "ge",
                                                []
                                              |),
                                              [ M.alloc (| key |); M.alloc (| M.read (| next |) |) ]
                                            |)
                                          |)) in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      M.alloc (|
                                        M.never_to_any (|
                                          M.read (|
                                            M.return_ (|
                                              Value.StructTuple
                                                "core::result::Result::Err"
                                                [
                                                  Value.StructTuple
                                                    "alloc::collections::btree::map::UnorderedKeyError"
                                                    []
                                                ]
                                            |)
                                          |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ _ :=
                      let~ _ :=
                        M.alloc (|
                          M.call_closure (|
                            M.get_associated_function (|
                              Ty.apply
                                (Ty.path "alloc::collections::btree::map::CursorMutKey")
                                []
                                [ K; V; A ],
                              "insert_before_unchecked",
                              []
                            |),
                            [ M.read (| self |); M.read (| key |); M.read (| value |) ]
                          |)
                        |) in
                      M.alloc (| Value.Tuple [] |) in
                    M.alloc (| Value.StructTuple "core::result::Result::Ok" [ Value.Tuple [] ] |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_insert_before :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "insert_before" (insert_before K V A).
        
        (*
            pub fn remove_next(&mut self) -> Option<(K, V)> {
                let current = self.current.take()?;
                if current.reborrow().next_kv().is_err() {
                    self.current = Some(current);
                    return None;
                }
                let mut emptied_internal_root = false;
                let (kv, pos) = current
                    .next_kv()
                    // This should be unwrap(), but that doesn't work because NodeRef
                    // doesn't implement Debug. The condition is checked above.
                    .ok()?
                    .remove_kv_tracking(|| emptied_internal_root = true, self.alloc.clone());
                self.current = Some(pos);
                *self.length -= 1;
                if emptied_internal_root {
                    // SAFETY: This is safe since current does not point within the now
                    // empty root node.
                    let root = unsafe { self.root.reborrow().as_mut().unwrap() };
                    root.pop_internal_level(self.alloc.clone());
                }
                Some(kv)
            }
        *)
        Definition remove_next
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple [ K; V ] ],
                                            [
                                              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
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Immut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ];
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ]
                                          ],
                                        "is_err",
                                        []
                                      |),
                                      [
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Immut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_kv",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::Handle")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ];
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Edge"
                                                    ],
                                                  "reborrow",
                                                  []
                                                |),
                                                [ current ]
                                              |)
                                            ]
                                          |)
                                        |)
                                      ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    let~ _ :=
                                      M.write (|
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "alloc::collections::btree::map::CursorMutKey",
                                          "current"
                                        |),
                                        Value.StructTuple
                                          "core::option::Option::Some"
                                          [ M.read (| current |) ]
                                      |) in
                                    M.return_ (|
                                      Value.StructTuple "core::option::Option::None" []
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ emptied_internal_root := M.alloc (| Value.Bool false |) in
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "remove_kv_tracking",
                            [ Ty.function [ Ty.tuple [] ] (Ty.tuple []); A ]
                          |),
                          [
                            M.read (|
                              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 "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ];
                                              Ty.path "alloc::collections::btree::node::marker::KV"
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::KV"
                                                ];
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "ok",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_kv",
                                              []
                                            |),
                                            [ M.read (| current |) ]
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple [ K; V ] ],
                                                  [
                                                    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))
                                ]
                              |)
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (M.read (|
                                                M.write (| emptied_internal_root, Value.Bool true |)
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end));
                            M.call_closure (|
                              M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "alloc"
                                  |)
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        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 kv := M.copy (| γ0_0 |) in
                            let pos := M.copy (| γ0_1 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |),
                                Value.StructTuple "core::option::Option::Some" [ M.read (| pos |) ]
                              |) in
                            let~ _ :=
                              let β :=
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "length"
                                  |)
                                |) in
                              M.write (|
                                β,
                                BinOp.Wrap.sub (|
                                  M.read (| β |),
                                  Value.Integer IntegerKind.Usize 1
                                |)
                              |) in
                            let~ _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ := M.use emptied_internal_root in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      let~ root :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path "&mut")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              "unwrap",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::borrow::DormantMutRef")
                                                        []
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::option::Option")
                                                            []
                                                            [
                                                              Ty.apply
                                                                (Ty.path
                                                                  "alloc::collections::btree::node::NodeRef")
                                                                []
                                                                [
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::Owned";
                                                                  K;
                                                                  V;
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                ]
                                                            ]
                                                        ],
                                                      "reborrow",
                                                      []
                                                    |),
                                                    [
                                                      M.SubPointer.get_struct_record_field (|
                                                        M.read (| self |),
                                                        "alloc::collections::btree::map::CursorMutKey",
                                                        "root"
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ],
                                              "pop_internal_level",
                                              [ A ]
                                            |),
                                            [
                                              M.read (| root |);
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::clone::Clone",
                                                  A,
                                                  [],
                                                  "clone",
                                                  []
                                                |),
                                                [
                                                  M.read (|
                                                    M.SubPointer.get_struct_record_field (|
                                                      M.read (| self |),
                                                      "alloc::collections::btree::map::CursorMutKey",
                                                      "alloc"
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [] |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            M.alloc (|
                              Value.StructTuple "core::option::Option::Some" [ M.read (| kv |) ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove_next :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove_next" (remove_next K V A).
        
        (*
            pub fn remove_prev(&mut self) -> Option<(K, V)> {
                let current = self.current.take()?;
                if current.reborrow().next_back_kv().is_err() {
                    self.current = Some(current);
                    return None;
                }
                let mut emptied_internal_root = false;
                let (kv, pos) = current
                    .next_back_kv()
                    // This should be unwrap(), but that doesn't work because NodeRef
                    // doesn't implement Debug. The condition is checked above.
                    .ok()?
                    .remove_kv_tracking(|| emptied_internal_root = true, self.alloc.clone());
                self.current = Some(pos);
                *self.length -= 1;
                if emptied_internal_root {
                    // SAFETY: This is safe since current does not point within the now
                    // empty root node.
                    let root = unsafe { self.root.reborrow().as_mut().unwrap() };
                    root.pop_internal_level(self.alloc.clone());
                }
                Some(kv)
            }
        *)
        Definition remove_prev
            (K V A : Ty.t)
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          let Self : Ty.t := Self K V A in
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              M.catch_return (|
                ltac:(M.monadic
                  (M.read (|
                    let~ current :=
                      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 "alloc::collections::btree::node::Handle")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::NodeRef")
                                          []
                                          [
                                            Ty.path "alloc::collections::btree::node::marker::Mut";
                                            K;
                                            V;
                                            Ty.path "alloc::collections::btree::node::marker::Leaf"
                                          ];
                                        Ty.path "alloc::collections::btree::node::marker::Edge"
                                      ]
                                  ],
                                [],
                                "branch",
                                []
                              |),
                              [
                                M.call_closure (|
                                  M.get_associated_function (|
                                    Ty.apply
                                      (Ty.path "core::option::Option")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::collections::btree::node::Handle")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Mut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Leaf"
                                              ];
                                            Ty.path "alloc::collections::btree::node::marker::Edge"
                                          ]
                                      ],
                                    "take",
                                    []
                                  |),
                                  [
                                    M.SubPointer.get_struct_record_field (|
                                      M.read (| self |),
                                      "alloc::collections::btree::map::CursorMutKey",
                                      "current"
                                    |)
                                  ]
                                |)
                              ]
                            |)
                          |),
                          [
                            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.tuple [ K; V ] ],
                                            [
                                              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
                    let~ _ :=
                      M.match_operator (|
                        M.alloc (| Value.Tuple [] |),
                        [
                          fun γ =>
                            ltac:(M.monadic
                              (let γ :=
                                M.use
                                  (M.alloc (|
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply
                                          (Ty.path "core::result::Result")
                                          []
                                          [
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::Handle")
                                              []
                                              [
                                                Ty.apply
                                                  (Ty.path
                                                    "alloc::collections::btree::node::NodeRef")
                                                  []
                                                  [
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::Immut";
                                                    K;
                                                    V;
                                                    Ty.path
                                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                                  ];
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::KV"
                                              ];
                                            Ty.apply
                                              (Ty.path "alloc::collections::btree::node::NodeRef")
                                              []
                                              [
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::Immut";
                                                K;
                                                V;
                                                Ty.path
                                                  "alloc::collections::btree::node::marker::LeafOrInternal"
                                              ]
                                          ],
                                        "is_err",
                                        []
                                      |),
                                      [
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Immut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_back_kv",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::Handle")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Mut";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Leaf"
                                                        ];
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Edge"
                                                    ],
                                                  "reborrow",
                                                  []
                                                |),
                                                [ current ]
                                              |)
                                            ]
                                          |)
                                        |)
                                      ]
                                    |)
                                  |)) in
                              let _ :=
                                M.is_constant_or_break_match (|
                                  M.read (| γ |),
                                  Value.Bool true
                                |) in
                              M.alloc (|
                                M.never_to_any (|
                                  M.read (|
                                    let~ _ :=
                                      M.write (|
                                        M.SubPointer.get_struct_record_field (|
                                          M.read (| self |),
                                          "alloc::collections::btree::map::CursorMutKey",
                                          "current"
                                        |),
                                        Value.StructTuple
                                          "core::option::Option::Some"
                                          [ M.read (| current |) ]
                                      |) in
                                    M.return_ (|
                                      Value.StructTuple "core::option::Option::None" []
                                    |)
                                  |)
                                |)
                              |)));
                          fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                        ]
                      |) in
                    let~ emptied_internal_root := M.alloc (| Value.Bool false |) in
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply
                              (Ty.path "alloc::collections::btree::node::Handle")
                              []
                              [
                                Ty.apply
                                  (Ty.path "alloc::collections::btree::node::NodeRef")
                                  []
                                  [
                                    Ty.path "alloc::collections::btree::node::marker::Mut";
                                    K;
                                    V;
                                    Ty.path
                                      "alloc::collections::btree::node::marker::LeafOrInternal"
                                  ];
                                Ty.path "alloc::collections::btree::node::marker::KV"
                              ],
                            "remove_kv_tracking",
                            [ Ty.function [ Ty.tuple [] ] (Ty.tuple []); A ]
                          |),
                          [
                            M.read (|
                              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 "alloc::collections::btree::node::Handle")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ];
                                              Ty.path "alloc::collections::btree::node::marker::KV"
                                            ]
                                        ],
                                      [],
                                      "branch",
                                      []
                                    |),
                                    [
                                      M.call_closure (|
                                        M.get_associated_function (|
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::LeafOrInternal"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::KV"
                                                ];
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Mut";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ]
                                            ],
                                          "ok",
                                          []
                                        |),
                                        [
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::Handle")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path
                                                      "alloc::collections::btree::node::NodeRef")
                                                    []
                                                    [
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Mut";
                                                      K;
                                                      V;
                                                      Ty.path
                                                        "alloc::collections::btree::node::marker::Leaf"
                                                    ];
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Edge"
                                                ],
                                              "next_back_kv",
                                              []
                                            |),
                                            [ M.read (| current |) ]
                                          |)
                                        ]
                                      |)
                                    ]
                                  |)
                                |),
                                [
                                  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.tuple [ K; V ] ],
                                                  [
                                                    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))
                                ]
                              |)
                            |);
                            M.closure
                              (fun γ =>
                                ltac:(M.monadic
                                  match γ with
                                  | [ α0 ] =>
                                    ltac:(M.monadic
                                      (M.match_operator (|
                                        M.alloc (| α0 |),
                                        [
                                          fun γ =>
                                            ltac:(M.monadic
                                              (M.read (|
                                                M.write (| emptied_internal_root, Value.Bool true |)
                                              |)))
                                        ]
                                      |)))
                                  | _ => M.impossible "wrong number of arguments"
                                  end));
                            M.call_closure (|
                              M.get_trait_method (| "core::clone::Clone", A, [], "clone", [] |),
                              [
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "alloc"
                                  |)
                                |)
                              ]
                            |)
                          ]
                        |)
                      |),
                      [
                        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 kv := M.copy (| γ0_0 |) in
                            let pos := M.copy (| γ0_1 |) in
                            let~ _ :=
                              M.write (|
                                M.SubPointer.get_struct_record_field (|
                                  M.read (| self |),
                                  "alloc::collections::btree::map::CursorMutKey",
                                  "current"
                                |),
                                Value.StructTuple "core::option::Option::Some" [ M.read (| pos |) ]
                              |) in
                            let~ _ :=
                              let β :=
                                M.read (|
                                  M.SubPointer.get_struct_record_field (|
                                    M.read (| self |),
                                    "alloc::collections::btree::map::CursorMutKey",
                                    "length"
                                  |)
                                |) in
                              M.write (|
                                β,
                                BinOp.Wrap.sub (|
                                  M.read (| β |),
                                  Value.Integer IntegerKind.Usize 1
                                |)
                              |) in
                            let~ _ :=
                              M.match_operator (|
                                M.alloc (| Value.Tuple [] |),
                                [
                                  fun γ =>
                                    ltac:(M.monadic
                                      (let γ := M.use emptied_internal_root in
                                      let _ :=
                                        M.is_constant_or_break_match (|
                                          M.read (| γ |),
                                          Value.Bool true
                                        |) in
                                      let~ root :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "core::option::Option")
                                                []
                                                [
                                                  Ty.apply
                                                    (Ty.path "&mut")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ]
                                                ],
                                              "unwrap",
                                              []
                                            |),
                                            [
                                              M.call_closure (|
                                                M.get_associated_function (|
                                                  Ty.apply
                                                    (Ty.path "core::option::Option")
                                                    []
                                                    [
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::node::NodeRef")
                                                        []
                                                        [
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::Owned";
                                                          K;
                                                          V;
                                                          Ty.path
                                                            "alloc::collections::btree::node::marker::LeafOrInternal"
                                                        ]
                                                    ],
                                                  "as_mut",
                                                  []
                                                |),
                                                [
                                                  M.call_closure (|
                                                    M.get_associated_function (|
                                                      Ty.apply
                                                        (Ty.path
                                                          "alloc::collections::btree::borrow::DormantMutRef")
                                                        []
                                                        [
                                                          Ty.apply
                                                            (Ty.path "core::option::Option")
                                                            []
                                                            [
                                                              Ty.apply
                                                                (Ty.path
                                                                  "alloc::collections::btree::node::NodeRef")
                                                                []
                                                                [
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::Owned";
                                                                  K;
                                                                  V;
                                                                  Ty.path
                                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                                ]
                                                            ]
                                                        ],
                                                      "reborrow",
                                                      []
                                                    |),
                                                    [
                                                      M.SubPointer.get_struct_record_field (|
                                                        M.read (| self |),
                                                        "alloc::collections::btree::map::CursorMutKey",
                                                        "root"
                                                      |)
                                                    ]
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |) in
                                      let~ _ :=
                                        M.alloc (|
                                          M.call_closure (|
                                            M.get_associated_function (|
                                              Ty.apply
                                                (Ty.path "alloc::collections::btree::node::NodeRef")
                                                []
                                                [
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::Owned";
                                                  K;
                                                  V;
                                                  Ty.path
                                                    "alloc::collections::btree::node::marker::LeafOrInternal"
                                                ],
                                              "pop_internal_level",
                                              [ A ]
                                            |),
                                            [
                                              M.read (| root |);
                                              M.call_closure (|
                                                M.get_trait_method (|
                                                  "core::clone::Clone",
                                                  A,
                                                  [],
                                                  "clone",
                                                  []
                                                |),
                                                [
                                                  M.read (|
                                                    M.SubPointer.get_struct_record_field (|
                                                      M.read (| self |),
                                                      "alloc::collections::btree::map::CursorMutKey",
                                                      "alloc"
                                                    |)
                                                  |)
                                                ]
                                              |)
                                            ]
                                          |)
                                        |) in
                                      M.alloc (| Value.Tuple [] |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            M.alloc (|
                              Value.StructTuple "core::option::Option::Some" [ M.read (| kv |) ]
                            |)))
                      ]
                    |)
                  |)))
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom AssociatedFunction_remove_prev :
          forall (K V A : Ty.t),
          M.IsAssociatedFunction (Self K V A) "remove_prev" (remove_prev K V A).
      End Impl_alloc_collections_btree_map_CursorMutKey_K_V_A.
      
      
      
      (* StructTuple
        {
          name := "UnorderedKeyError";
          const_params := [];
          ty_params := [];
          fields := [];
        } *)
      
      Module Impl_core_clone_Clone_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        (* Clone *)
        Definition clone (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.StructTuple "alloc::collections::btree::map::UnorderedKeyError" []))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::clone::Clone"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("clone", InstanceField.Method clone) ].
      End Impl_core_clone_Clone_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_marker_StructuralPartialEq_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        Axiom Implements :
          M.IsTraitInstance
            "core::marker::StructuralPartialEq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_marker_StructuralPartialEq_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_cmp_PartialEq_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        (* PartialEq *)
        Definition eq (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; other ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let other := M.alloc (| other |) in
              Value.Bool true))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::cmp::PartialEq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("eq", InstanceField.Method eq) ].
      End Impl_core_cmp_PartialEq_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_cmp_Eq_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        (* Eq *)
        Definition assert_receiver_is_total_eq
            (ε : list Value.t)
            (τ : list Ty.t)
            (α : list Value.t)
            : M :=
          match ε, τ, α with
          | [], [], [ self ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              Value.Tuple []))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::cmp::Eq"
            Self
            (* Trait polymorphic types *) []
            (* Instance *)
            [ ("assert_receiver_is_total_eq", InstanceField.Method assert_receiver_is_total_eq) ].
      End Impl_core_cmp_Eq_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_fmt_Debug_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        (* Debug *)
        Definition fmt (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_str", [] |),
                [ M.read (| f |); M.read (| Value.String "UnorderedKeyError" |) ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::fmt::Debug"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
      End Impl_core_fmt_Debug_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_fmt_Display_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        (*
            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                write!(f, "key is not properly ordered relative to neighbors")
            }
        *)
        Definition fmt (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
          match ε, τ, α with
          | [], [], [ self; f ] =>
            ltac:(M.monadic
              (let self := M.alloc (| self |) in
              let f := M.alloc (| f |) in
              M.call_closure (|
                M.get_associated_function (| Ty.path "core::fmt::Formatter", "write_fmt", [] |),
                [
                  M.read (| f |);
                  M.call_closure (|
                    M.get_associated_function (| Ty.path "core::fmt::Arguments", "new_const", [] |),
                    [
                      M.alloc (|
                        Value.Array
                          [
                            M.read (|
                              Value.String "key is not properly ordered relative to neighbors"
                            |)
                          ]
                      |)
                    ]
                  |)
                ]
              |)))
          | _, _, _ => M.impossible "wrong number of arguments"
          end.
        
        Axiom Implements :
          M.IsTraitInstance
            "core::fmt::Display"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [ ("fmt", InstanceField.Method fmt) ].
      End Impl_core_fmt_Display_for_alloc_collections_btree_map_UnorderedKeyError.
      
      Module Impl_core_error_Error_for_alloc_collections_btree_map_UnorderedKeyError.
        Definition Self : Ty.t := Ty.path "alloc::collections::btree::map::UnorderedKeyError".
        
        Axiom Implements :
          M.IsTraitInstance
            "core::error::Error"
            Self
            (* Trait polymorphic types *) []
            (* Instance *) [].
      End Impl_core_error_Error_for_alloc_collections_btree_map_UnorderedKeyError.
    End map.
  End btree.
End collections.
