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

Module identifier.
  (*
  pub const fn is_valid_identifier_char(c: char) -> bool {
      matches!(c, '_' | 'a'..='z' | 'A'..='Z' | '0'..='9')
  }
  *)
  Definition is_valid_identifier_char (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ c ] =>
      ltac:(M.monadic
        (let c := M.alloc (| c |) in
        M.read (|
          M.match_operator (|
            c,
            [
              fun γ =>
                ltac:(M.monadic
                  (M.find_or_pattern (|
                    γ,
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let _ :=
                            M.is_constant_or_break_match (|
                              M.read (| γ |),
                              Value.UnicodeChar 95
                            |) in
                          Value.Tuple []));
                      fun γ => ltac:(M.monadic (Value.Tuple []));
                      fun γ => ltac:(M.monadic (Value.Tuple []));
                      fun γ => ltac:(M.monadic (Value.Tuple []))
                    ],
                    M.closure
                      (fun γ =>
                        ltac:(M.monadic
                          match γ with
                          | [] => ltac:(M.monadic (M.alloc (| Value.Bool true |)))
                          | _ => M.impossible "wrong number of arguments"
                          end))
                  |)));
              fun γ => ltac:(M.monadic (M.alloc (| Value.Bool false |)))
            ]
          |)
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_is_valid_identifier_char :
    M.IsFunction "move_core_types::identifier::is_valid_identifier_char" is_valid_identifier_char.
  
  (*
  const fn all_bytes_valid(b: &[u8], start_offset: usize) -> bool {
      let mut i = start_offset;
      // TODO(philiphayes): use for loop instead of while loop when it's stable in const fn's.
      while i < b.len() {
          if !is_valid_identifier_char(b[i] as char) {
              return false;
          }
          i += 1;
      }
      true
  }
  *)
  Definition all_bytes_valid (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ b; start_offset ] =>
      ltac:(M.monadic
        (let b := M.alloc (| b |) in
        let start_offset := M.alloc (| start_offset |) in
        M.catch_return (|
          ltac:(M.monadic
            (M.read (|
              let~ i := M.copy (| start_offset |) in
              let~ _ :=
                M.loop (|
                  ltac:(M.monadic
                    (M.match_operator (|
                      M.alloc (| Value.Tuple [] |),
                      [
                        fun γ =>
                          ltac:(M.monadic
                            (let γ :=
                              M.use
                                (M.alloc (|
                                  BinOp.lt (|
                                    M.read (| i |),
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                                        "len",
                                        []
                                      |),
                                      [ M.read (| b |) ]
                                    |)
                                  |)
                                |)) 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_function (|
                                                  "move_core_types::identifier::is_valid_identifier_char",
                                                  []
                                                |),
                                                [
                                                  M.rust_cast
                                                    (M.read (|
                                                      M.SubPointer.get_array_field (|
                                                        M.read (| b |),
                                                        i
                                                      |)
                                                    |))
                                                ]
                                              |)
                                            |)
                                          |)) 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.Bool false |) |)
                                        |)
                                      |)));
                                  fun γ => ltac:(M.monadic (M.alloc (| Value.Tuple [] |)))
                                ]
                              |) in
                            let~ _ :=
                              let β := i in
                              M.write (|
                                β,
                                BinOp.Wrap.add (|
                                  M.read (| β |),
                                  Value.Integer IntegerKind.Usize 1
                                |)
                              |) 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.Bool true |)
            |)))
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_all_bytes_valid :
    M.IsFunction "move_core_types::identifier::all_bytes_valid" all_bytes_valid.
  
  (*
  pub const fn is_valid(s: &str) -> bool {
      // Rust const fn's don't currently support slicing or indexing &str's, so we
      // have to operate on the underlying byte slice. This is not a problem as
      // valid identifiers are (currently) ASCII-only.
      let b = s.as_bytes();
      match b {
          b"<SELF>" => true,
          [b'a'..=b'z', ..] | [b'A'..=b'Z', ..] => all_bytes_valid(b, 1),
          [b'_', ..] if b.len() > 1 => all_bytes_valid(b, 1),
          _ => false,
      }
  }
  *)
  Definition is_valid (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
    match ε, τ, α with
    | [], [], [ s ] =>
      ltac:(M.monadic
        (let s := M.alloc (| s |) in
        M.read (|
          let~ b :=
            M.alloc (|
              M.call_closure (|
                M.get_associated_function (| Ty.path "str", "as_bytes", [] |),
                [ M.read (| s |) ]
              |)
            |) in
          M.match_operator (|
            b,
            [
              fun γ =>
                ltac:(M.monadic
                  (let γ := M.read (| γ |) in
                  let γ1_0 := M.SubPointer.get_slice_index (| γ, 0 |) in
                  let γ1_1 := M.SubPointer.get_slice_index (| γ, 1 |) in
                  let γ1_2 := M.SubPointer.get_slice_index (| γ, 2 |) in
                  let γ1_3 := M.SubPointer.get_slice_index (| γ, 3 |) in
                  let γ1_4 := M.SubPointer.get_slice_index (| γ, 4 |) in
                  let γ1_5 := M.SubPointer.get_slice_index (| γ, 5 |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_0 |),
                      Value.Integer IntegerKind.U8 60
                    |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_1 |),
                      Value.Integer IntegerKind.U8 83
                    |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_2 |),
                      Value.Integer IntegerKind.U8 69
                    |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_3 |),
                      Value.Integer IntegerKind.U8 76
                    |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_4 |),
                      Value.Integer IntegerKind.U8 70
                    |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_5 |),
                      Value.Integer IntegerKind.U8 62
                    |) in
                  M.alloc (| Value.Bool true |)));
              fun γ =>
                ltac:(M.monadic
                  (M.find_or_pattern (|
                    γ,
                    [
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.read (| γ |) in
                          let γ1_0 := M.SubPointer.get_slice_index (| γ, 0 |) in
                          let γ1_rest := M.SubPointer.get_slice_rest (| γ, 1, 0 |) in
                          Value.Tuple []));
                      fun γ =>
                        ltac:(M.monadic
                          (let γ := M.read (| γ |) in
                          let γ1_0 := M.SubPointer.get_slice_index (| γ, 0 |) in
                          let γ1_rest := M.SubPointer.get_slice_rest (| γ, 1, 0 |) in
                          Value.Tuple []))
                    ],
                    M.closure
                      (fun γ =>
                        ltac:(M.monadic
                          match γ with
                          | [] =>
                            ltac:(M.monadic
                              (M.alloc (|
                                M.call_closure (|
                                  M.get_function (|
                                    "move_core_types::identifier::all_bytes_valid",
                                    []
                                  |),
                                  [ M.read (| b |); Value.Integer IntegerKind.Usize 1 ]
                                |)
                              |)))
                          | _ => M.impossible "wrong number of arguments"
                          end))
                  |)));
              fun γ =>
                ltac:(M.monadic
                  (let γ := M.read (| γ |) in
                  let γ1_0 := M.SubPointer.get_slice_index (| γ, 0 |) in
                  let γ1_rest := M.SubPointer.get_slice_rest (| γ, 1, 0 |) in
                  let _ :=
                    M.is_constant_or_break_match (|
                      M.read (| γ1_0 |),
                      Value.Integer IntegerKind.U8 95
                    |) in
                  let γ :=
                    M.alloc (|
                      BinOp.gt (|
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.apply (Ty.path "slice") [] [ Ty.path "u8" ],
                            "len",
                            []
                          |),
                          [ M.read (| b |) ]
                        |),
                        Value.Integer IntegerKind.Usize 1
                      |)
                    |) in
                  let _ := M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "move_core_types::identifier::all_bytes_valid", [] |),
                      [ M.read (| b |); Value.Integer IntegerKind.Usize 1 ]
                    |)
                  |)));
              fun γ => ltac:(M.monadic (M.alloc (| Value.Bool false |)))
            ]
          |)
        |)))
    | _, _, _ => M.impossible "wrong number of arguments"
    end.
  
  Axiom Function_is_valid : M.IsFunction "move_core_types::identifier::is_valid" is_valid.
  
  (* StructTuple
    {
      name := "Identifier";
      const_params := [];
      ty_params := [];
      fields :=
        [
          Ty.apply
            (Ty.path "alloc::boxed::Box")
            []
            [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
        ];
    } *)
  
  Module Impl_core_clone_Clone_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* 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
            "move_core_types::identifier::Identifier"
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::clone::Clone",
                  Ty.apply
                    (Ty.path "alloc::boxed::Box")
                    []
                    [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
                  [],
                  "clone",
                  []
                |),
                [
                  M.SubPointer.get_struct_tuple_field (|
                    M.read (| self |),
                    "move_core_types::identifier::Identifier",
                    0
                  |)
                ]
              |)
            ]))
      | _, _, _ => 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_move_core_types_identifier_Identifier.
  
  Module Impl_core_fmt_Debug_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* 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",
              "debug_tuple_field1_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "Identifier" |);
              M.alloc (|
                M.SubPointer.get_struct_tuple_field (|
                  M.read (| self |),
                  "move_core_types::identifier::Identifier",
                  0
                |)
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_Identifier.
  
  Module Impl_core_cmp_Eq_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* 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
          M.read (|
            M.match_operator (|
              Value.DeclaredButUndefined,
              [ fun γ => ltac:(M.monadic (M.alloc (| 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_move_core_types_identifier_Identifier.
  
  Module Impl_core_hash_Hash_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* Hash *)
    Definition hash (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ __H ], [ self; state ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let state := M.alloc (| state |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::hash::Hash",
              Ty.apply
                (Ty.path "alloc::boxed::Box")
                []
                [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
              [],
              "hash",
              [ __H ]
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::Identifier",
                0
              |);
              M.read (| state |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::hash::Hash"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("hash", InstanceField.Method hash) ].
  End Impl_core_hash_Hash_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_cmp_Ord_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* Ord *)
    Definition cmp (ε : 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
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::Ord",
              Ty.apply
                (Ty.path "alloc::boxed::Box")
                []
                [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
              [],
              "cmp",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::Identifier",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::Identifier",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::Ord"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("cmp", InstanceField.Method cmp) ].
  End Impl_core_cmp_Ord_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_marker_StructuralPartialEq_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_cmp_PartialEq_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* 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
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialEq",
              Ty.apply
                (Ty.path "alloc::boxed::Box")
                []
                [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
              [
                Ty.apply
                  (Ty.path "alloc::boxed::Box")
                  []
                  [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
              ],
              "eq",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::Identifier",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::Identifier",
                0
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_Identifier.
  
  Module Impl_core_cmp_PartialOrd_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (* PartialOrd *)
    Definition partial_cmp (ε : 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
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialOrd",
              Ty.apply
                (Ty.path "alloc::boxed::Box")
                []
                [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
              [
                Ty.apply
                  (Ty.path "alloc::boxed::Box")
                  []
                  [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
              ],
              "partial_cmp",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::Identifier",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::Identifier",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialOrd"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ].
  End Impl_core_cmp_PartialOrd_for_move_core_types_identifier_Identifier.
  
  Module underscore.
    Module Impl_serde_ser_Serialize_for_move_core_types_identifier_Identifier.
      Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
      
      (* Serialize *)
      Definition serialize (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ __S ], [ self; __serializer ] =>
          ltac:(M.monadic
            (let self := M.alloc (| self |) in
            let __serializer := M.alloc (| __serializer |) in
            M.call_closure (|
              M.get_trait_method (|
                "serde::ser::Serializer",
                __S,
                [],
                "serialize_newtype_struct",
                [
                  Ty.apply
                    (Ty.path "alloc::boxed::Box")
                    []
                    [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
                ]
              |),
              [
                M.read (| __serializer |);
                M.read (| Value.String "Identifier" |);
                M.SubPointer.get_struct_tuple_field (|
                  M.read (| self |),
                  "move_core_types::identifier::Identifier",
                  0
                |)
              ]
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "serde::ser::Serialize"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("serialize", InstanceField.Method serialize) ].
    End Impl_serde_ser_Serialize_for_move_core_types_identifier_Identifier.
    Module Impl_serde_de_Deserialize_for_move_core_types_identifier_Identifier.
      Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
      
      (* Deserialize *)
      Definition deserialize (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
        match ε, τ, α with
        | [], [ __D ], [ __deserializer ] =>
          ltac:(M.monadic
            (let __deserializer := M.alloc (| __deserializer |) in
            M.call_closure (|
              M.get_trait_method (|
                "serde::de::Deserializer",
                __D,
                [],
                "deserialize_newtype_struct",
                [ Ty.path "move_core_types::identifier::_'2::deserialize::__Visitor" ]
              |),
              [
                M.read (| __deserializer |);
                M.read (| Value.String "Identifier" |);
                Value.StructRecord
                  "move_core_types::identifier::_'2::deserialize::__Visitor"
                  [
                    ("marker", Value.StructTuple "core::marker::PhantomData" []);
                    ("lifetime", Value.StructTuple "core::marker::PhantomData" [])
                  ]
              ]
            |)))
        | _, _, _ => M.impossible "wrong number of arguments"
        end.
      
      Axiom Implements :
        M.IsTraitInstance
          "serde::de::Deserialize"
          Self
          (* Trait polymorphic types *) []
          (* Instance *) [ ("deserialize", InstanceField.Method deserialize) ].
    End Impl_serde_de_Deserialize_for_move_core_types_identifier_Identifier.
  End underscore.
  
  
  Module Impl_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        pub fn new(s: impl Into<Box<str>>) -> Result<Self> {
            let s = s.into();
            if Self::is_valid(&s) {
                Ok(Self(s))
            } else {
                bail!("Invalid identifier '{}'", s);
            }
        }
    *)
    Definition new (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ impl_Into_Box_str__ ], [ s ] =>
        ltac:(M.monadic
          (let s := M.alloc (| s |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let~ s :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_trait_method (|
                        "core::convert::Into",
                        impl_Into_Box_str__,
                        [
                          Ty.apply
                            (Ty.path "alloc::boxed::Box")
                            []
                            [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
                        ],
                        "into",
                        []
                      |),
                      [ M.read (| s |) ]
                    |)
                  |) in
                M.match_operator (|
                  M.alloc (| Value.Tuple [] |),
                  [
                    fun γ =>
                      ltac:(M.monadic
                        (let γ :=
                          M.use
                            (M.alloc (|
                              M.call_closure (|
                                M.get_associated_function (|
                                  Ty.path "move_core_types::identifier::Identifier",
                                  "is_valid",
                                  [
                                    Ty.apply
                                      (Ty.path "&")
                                      []
                                      [
                                        Ty.apply
                                          (Ty.path "alloc::boxed::Box")
                                          []
                                          [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
                                      ]
                                  ]
                                |),
                                [ s ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              Value.StructTuple
                                "move_core_types::identifier::Identifier"
                                [ M.read (| s |) ]
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "anyhow::Error",
                                        "msg",
                                        [ Ty.path "alloc::string::String" ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::hint::must_use",
                                            [ Ty.path "alloc::string::String" ]
                                          |),
                                          [
                                            M.read (|
                                              let~ res :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_function (| "alloc::fmt::format", [] |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.path "core::fmt::Arguments",
                                                          "new_v1",
                                                          []
                                                        |),
                                                        [
                                                          M.alloc (|
                                                            Value.Array
                                                              [
                                                                M.read (|
                                                                  Value.String
                                                                    "Invalid identifier '"
                                                                |);
                                                                M.read (| Value.String "'" |)
                                                              ]
                                                          |);
                                                          M.alloc (|
                                                            Value.Array
                                                              [
                                                                M.call_closure (|
                                                                  M.get_associated_function (|
                                                                    Ty.path
                                                                      "core::fmt::rt::Argument",
                                                                    "new_display",
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path
                                                                          "alloc::boxed::Box")
                                                                        []
                                                                        [
                                                                          Ty.path "str";
                                                                          Ty.path
                                                                            "alloc::alloc::Global"
                                                                        ]
                                                                    ]
                                                                  |),
                                                                  [ s ]
                                                                |)
                                                              ]
                                                          |)
                                                        ]
                                                      |)
                                                    ]
                                                  |)
                                                |) in
                                              res
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                              |)
                            |)
                          |)
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new.
    
    (*
        pub fn is_valid(s: impl AsRef<str>) -> bool {
            is_valid(s.as_ref())
        }
    *)
    Definition is_valid (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ impl_AsRef_str_ ], [ s ] =>
        ltac:(M.monadic
          (let s := M.alloc (| s |) in
          M.call_closure (|
            M.get_function (| "move_core_types::identifier::is_valid", [] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::convert::AsRef",
                  impl_AsRef_str_,
                  [ Ty.path "str" ],
                  "as_ref",
                  []
                |),
                [ s ]
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_is_valid : M.IsAssociatedFunction Self "is_valid" is_valid.
    
    (*
        pub fn is_self(&self) -> bool {
            &*self.0 == "<SELF>"
        }
    *)
    Definition is_self (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialEq",
              Ty.apply (Ty.path "&") [] [ Ty.path "str" ],
              [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ],
              "eq",
              []
            |),
            [
              M.alloc (|
                M.read (|
                  M.SubPointer.get_struct_tuple_field (|
                    M.read (| self |),
                    "move_core_types::identifier::Identifier",
                    0
                  |)
                |)
              |);
              Value.String "<SELF>"
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_is_self : M.IsAssociatedFunction Self "is_self" is_self.
    
    (*
        pub fn from_utf8(vec: Vec<u8>) -> Result<Self> {
            let s = String::from_utf8(vec)?;
            Self::new(s)
        }
    *)
    Definition from_utf8 (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ vec ] =>
        ltac:(M.monadic
          (let vec := M.alloc (| vec |) in
          M.catch_return (|
            ltac:(M.monadic
              (M.read (|
                let~ s :=
                  M.copy (|
                    M.match_operator (|
                      M.alloc (|
                        M.call_closure (|
                          M.get_trait_method (|
                            "core::ops::try_trait::Try",
                            Ty.apply
                              (Ty.path "core::result::Result")
                              []
                              [
                                Ty.path "alloc::string::String";
                                Ty.path "alloc::string::FromUtf8Error"
                              ],
                            [],
                            "branch",
                            []
                          |),
                          [
                            M.call_closure (|
                              M.get_associated_function (|
                                Ty.path "alloc::string::String",
                                "from_utf8",
                                []
                              |),
                              [ M.read (| vec |) ]
                            |)
                          ]
                        |)
                      |),
                      [
                        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::result::Result")
                                          []
                                          [
                                            Ty.path "move_core_types::identifier::Identifier";
                                            Ty.path "anyhow::Error"
                                          ],
                                        [
                                          Ty.apply
                                            (Ty.path "core::result::Result")
                                            []
                                            [
                                              Ty.path "core::convert::Infallible";
                                              Ty.path "alloc::string::FromUtf8Error"
                                            ]
                                        ],
                                        "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.path "move_core_types::identifier::Identifier",
                      "new",
                      [ Ty.path "alloc::string::String" ]
                    |),
                    [ M.read (| s |) ]
                  |)
                |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_from_utf8 : M.IsAssociatedFunction Self "from_utf8" from_utf8.
    
    (*
        pub fn as_ident_str(&self) -> &IdentStr {
            self
        }
    *)
    Definition as_ident_str (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::ops::deref::Deref",
              Ty.path "move_core_types::identifier::Identifier",
              [],
              "deref",
              []
            |),
            [ M.read (| self |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_as_ident_str : M.IsAssociatedFunction Self "as_ident_str" as_ident_str.
    
    (*
        pub fn into_string(self) -> String {
            self.0.into()
        }
    *)
    Definition into_string (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::convert::Into",
              Ty.apply
                (Ty.path "alloc::boxed::Box")
                []
                [ Ty.path "str"; Ty.path "alloc::alloc::Global" ],
              [ Ty.path "alloc::string::String" ],
              "into",
              []
            |),
            [
              M.read (|
                M.SubPointer.get_struct_tuple_field (|
                  self,
                  "move_core_types::identifier::Identifier",
                  0
                |)
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_into_string : M.IsAssociatedFunction Self "into_string" into_string.
    
    (*
        pub fn into_bytes(self) -> Vec<u8> {
            self.into_string().into_bytes()
        }
    *)
    Definition into_bytes (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "alloc::string::String", "into_bytes", [] |),
            [
              M.call_closure (|
                M.get_associated_function (|
                  Ty.path "move_core_types::identifier::Identifier",
                  "into_string",
                  []
                |),
                [ M.read (| self |) ]
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_into_bytes : M.IsAssociatedFunction Self "into_bytes" into_bytes.
  End Impl_move_core_types_identifier_Identifier.
  
  Module Impl_core_str_traits_FromStr_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*     type Err = anyhow::Error; *)
    Definition _Err : Ty.t := Ty.path "anyhow::Error".
    
    (*
        fn from_str(data: &str) -> Result<Self> {
            Self::new(data)
        }
    *)
    Definition from_str (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ data ] =>
        ltac:(M.monadic
          (let data := M.alloc (| data |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.path "move_core_types::identifier::Identifier",
              "new",
              [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
            |),
            [ M.read (| data |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::str::traits::FromStr"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [ ("Err", InstanceField.Ty _Err); ("from_str", InstanceField.Method from_str) ].
  End Impl_core_str_traits_FromStr_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_convert_From_ref__move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        fn from(ident_str: &IdentStr) -> Self {
            ident_str.to_owned()
        }
    *)
    Definition from (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ ident_str ] =>
        ltac:(M.monadic
          (let ident_str := M.alloc (| ident_str |) in
          M.call_closure (|
            M.get_trait_method (|
              "alloc::borrow::ToOwned",
              Ty.path "move_core_types::identifier::IdentStr",
              [],
              "to_owned",
              []
            |),
            [ M.read (| ident_str |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::From"
        Self
        (* Trait polymorphic types *)
        [ (* T *) Ty.apply (Ty.path "&") [] [ Ty.path "move_core_types::identifier::IdentStr" ] ]
        (* Instance *) [ ("from", InstanceField.Method from) ].
  End Impl_core_convert_From_ref__move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_convert_AsRef_move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        fn as_ref(&self) -> &IdentStr {
            self
        }
    *)
    Definition as_ref (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::ops::deref::Deref",
              Ty.path "move_core_types::identifier::Identifier",
              [],
              "deref",
              []
            |),
            [ M.read (| self |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::convert::AsRef"
        Self
        (* Trait polymorphic types *) [ (* T *) Ty.path "move_core_types::identifier::IdentStr" ]
        (* Instance *) [ ("as_ref", InstanceField.Method as_ref) ].
  End Impl_core_convert_AsRef_move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_ops_deref_Deref_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*     type Target = IdentStr; *)
    Definition _Target : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (*
        fn deref(&self) -> &IdentStr {
            // Identifier and IdentStr maintain the same invariants, so it is safe to
            // convert.
            IdentStr::ref_cast(&self.0)
        }
    *)
    Definition deref (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "ref_cast::RefCast",
              Ty.path "move_core_types::identifier::IdentStr",
              [],
              "ref_cast",
              []
            |),
            [
              M.read (|
                M.SubPointer.get_struct_tuple_field (|
                  M.read (| self |),
                  "move_core_types::identifier::Identifier",
                  0
                |)
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::ops::deref::Deref"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [ ("Target", InstanceField.Ty _Target); ("deref", InstanceField.Method deref) ].
  End Impl_core_ops_deref_Deref_for_move_core_types_identifier_Identifier.
  
  Module Impl_core_fmt_Display_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "{}", &self.0)
        }
    *)
    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_v1", [] |),
                [
                  M.alloc (| Value.Array [ M.read (| Value.String "" |) ] |);
                  M.alloc (|
                    Value.Array
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::rt::Argument",
                            "new_display",
                            [
                              Ty.apply
                                (Ty.path "&")
                                []
                                [
                                  Ty.apply
                                    (Ty.path "alloc::boxed::Box")
                                    []
                                    [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
                                ]
                            ]
                          |),
                          [
                            M.alloc (|
                              M.SubPointer.get_struct_tuple_field (|
                                M.read (| self |),
                                "move_core_types::identifier::Identifier",
                                0
                              |)
                            |)
                          ]
                        |)
                      ]
                  |)
                ]
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_Identifier.
  
  (* StructTuple
    {
      name := "IdentStr";
      const_params := [];
      ty_params := [];
      fields := [ Ty.path "str" ];
    } *)
  
  Module Impl_core_fmt_Debug_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* 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",
              "debug_tuple_field1_finish",
              []
            |),
            [
              M.read (| f |);
              M.read (| Value.String "IdentStr" |);
              M.alloc (|
                M.SubPointer.get_struct_tuple_field (|
                  M.read (| self |),
                  "move_core_types::identifier::IdentStr",
                  0
                |)
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_IdentStr.
  
  Module Impl_core_cmp_Eq_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* 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
          M.read (|
            M.match_operator (|
              Value.DeclaredButUndefined,
              [ fun γ => ltac:(M.monadic (M.alloc (| 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_move_core_types_identifier_IdentStr.
  
  Module Impl_core_hash_Hash_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* Hash *)
    Definition hash (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ __H ], [ self; state ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          let state := M.alloc (| state |) in
          M.call_closure (|
            M.get_trait_method (| "core::hash::Hash", Ty.path "str", [], "hash", [ __H ] |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |);
              M.read (| state |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::hash::Hash"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("hash", InstanceField.Method hash) ].
  End Impl_core_hash_Hash_for_move_core_types_identifier_IdentStr.
  
  Module Impl_core_cmp_Ord_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* Ord *)
    Definition cmp (ε : 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
          M.call_closure (|
            M.get_trait_method (| "core::cmp::Ord", Ty.path "str", [], "cmp", [] |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::Ord"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("cmp", InstanceField.Method cmp) ].
  End Impl_core_cmp_Ord_for_move_core_types_identifier_IdentStr.
  
  Module Impl_core_marker_StructuralPartialEq_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    Axiom Implements :
      M.IsTraitInstance
        "core::marker::StructuralPartialEq"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [].
  End Impl_core_marker_StructuralPartialEq_for_move_core_types_identifier_IdentStr.
  
  Module Impl_core_cmp_PartialEq_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* 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
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialEq",
              Ty.path "str",
              [ Ty.path "str" ],
              "eq",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_IdentStr.
  
  Module Impl_core_cmp_PartialOrd_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* PartialOrd *)
    Definition partial_cmp (ε : 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
          M.call_closure (|
            M.get_trait_method (|
              "core::cmp::PartialOrd",
              Ty.path "str",
              [ Ty.path "str" ],
              "partial_cmp",
              []
            |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |);
              M.SubPointer.get_struct_tuple_field (|
                M.read (| other |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::cmp::PartialOrd"
        Self
        (* Trait polymorphic types *) []
        (* Instance *) [ ("partial_cmp", InstanceField.Method partial_cmp) ].
  End Impl_core_cmp_PartialOrd_for_move_core_types_identifier_IdentStr.
  
  Module Impl_ref_cast_RefCast_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (* RefCast *)
    Definition _From : Ty.t := Ty.path "str".
    
    (* RefCast *)
    Definition ref_cast (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ _from ] =>
        ltac:(M.monadic
          (let _from := M.alloc (| _from |) in
          M.read (|
            let~ _ :=
              let~ _ :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (|
                      "ref_cast::layout::assert_layout",
                      [ Ty.path "move_core_types::identifier::IdentStr"; Ty.path "str" ]
                    |),
                    [
                      M.read (| Value.String "IdentStr" |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::SIZE" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::SIZE" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::ALIGN" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::ALIGN" |) |)
                    ]
                  |)
                |) in
              M.alloc (| Value.Tuple [] |) in
            M.alloc (| M.rust_cast (M.read (| M.use (M.alloc (| M.read (| _from |) |)) |)) |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    (* RefCast *)
    Definition ref_cast_mut (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ _from ] =>
        ltac:(M.monadic
          (let _from := M.alloc (| _from |) in
          M.read (|
            let~ _ :=
              let~ _ :=
                M.alloc (|
                  M.call_closure (|
                    M.get_function (|
                      "ref_cast::layout::assert_layout",
                      [ Ty.path "move_core_types::identifier::IdentStr"; Ty.path "str" ]
                    |),
                    [
                      M.read (| Value.String "IdentStr" |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::SIZE" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::SIZE" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::ALIGN" |) |);
                      M.read (| M.get_constant (| "ref_cast::layout::LayoutUnsized::ALIGN" |) |)
                    ]
                  |)
                |) in
              M.alloc (| Value.Tuple [] |) in
            M.alloc (| M.rust_cast (M.read (| M.use (M.alloc (| M.read (| _from |) |)) |)) |)
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "ref_cast::RefCast"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [
          ("From", InstanceField.Ty _From);
          ("ref_cast", InstanceField.Method ref_cast);
          ("ref_cast_mut", InstanceField.Method ref_cast_mut)
        ].
  End Impl_ref_cast_RefCast_for_move_core_types_identifier_IdentStr.
  
  Module Impl_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (*
        pub fn new(s: &str) -> Result<&IdentStr> {
            if Self::is_valid(s) {
                Ok(IdentStr::ref_cast(s))
            } else {
                bail!("Invalid identifier '{}'", s);
            }
        }
    *)
    Definition new (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ s ] =>
        ltac:(M.monadic
          (let s := M.alloc (| s |) in
          M.catch_return (|
            ltac:(M.monadic
              (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.path "move_core_types::identifier::IdentStr",
                                  "is_valid",
                                  [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                                |),
                                [ M.read (| s |) ]
                              |)
                            |)) in
                        let _ :=
                          M.is_constant_or_break_match (| M.read (| γ |), Value.Bool true |) in
                        M.alloc (|
                          Value.StructTuple
                            "core::result::Result::Ok"
                            [
                              M.call_closure (|
                                M.get_trait_method (|
                                  "ref_cast::RefCast",
                                  Ty.path "move_core_types::identifier::IdentStr",
                                  [],
                                  "ref_cast",
                                  []
                                |),
                                [ M.read (| s |) ]
                              |)
                            ]
                        |)));
                    fun γ =>
                      ltac:(M.monadic
                        (M.alloc (|
                          M.never_to_any (|
                            M.read (|
                              M.return_ (|
                                Value.StructTuple
                                  "core::result::Result::Err"
                                  [
                                    M.call_closure (|
                                      M.get_associated_function (|
                                        Ty.path "anyhow::Error",
                                        "msg",
                                        [ Ty.path "alloc::string::String" ]
                                      |),
                                      [
                                        M.call_closure (|
                                          M.get_function (|
                                            "core::hint::must_use",
                                            [ Ty.path "alloc::string::String" ]
                                          |),
                                          [
                                            M.read (|
                                              let~ res :=
                                                M.alloc (|
                                                  M.call_closure (|
                                                    M.get_function (| "alloc::fmt::format", [] |),
                                                    [
                                                      M.call_closure (|
                                                        M.get_associated_function (|
                                                          Ty.path "core::fmt::Arguments",
                                                          "new_v1",
                                                          []
                                                        |),
                                                        [
                                                          M.alloc (|
                                                            Value.Array
                                                              [
                                                                M.read (|
                                                                  Value.String
                                                                    "Invalid identifier '"
                                                                |);
                                                                M.read (| Value.String "'" |)
                                                              ]
                                                          |);
                                                          M.alloc (|
                                                            Value.Array
                                                              [
                                                                M.call_closure (|
                                                                  M.get_associated_function (|
                                                                    Ty.path
                                                                      "core::fmt::rt::Argument",
                                                                    "new_display",
                                                                    [
                                                                      Ty.apply
                                                                        (Ty.path "&")
                                                                        []
                                                                        [ Ty.path "str" ]
                                                                    ]
                                                                  |),
                                                                  [ s ]
                                                                |)
                                                              ]
                                                          |)
                                                        ]
                                                      |)
                                                    ]
                                                  |)
                                                |) in
                                              res
                                            |)
                                          ]
                                        |)
                                      ]
                                    |)
                                  ]
                              |)
                            |)
                          |)
                        |)))
                  ]
                |)
              |)))
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_new : M.IsAssociatedFunction Self "new" new.
    
    (*
        pub fn is_valid(s: impl AsRef<str>) -> bool {
            is_valid(s.as_ref())
        }
    *)
    Definition is_valid (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [ impl_AsRef_str_ ], [ s ] =>
        ltac:(M.monadic
          (let s := M.alloc (| s |) in
          M.call_closure (|
            M.get_function (| "move_core_types::identifier::is_valid", [] |),
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::convert::AsRef",
                  impl_AsRef_str_,
                  [ Ty.path "str" ],
                  "as_ref",
                  []
                |),
                [ s ]
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_is_valid : M.IsAssociatedFunction Self "is_valid" is_valid.
    
    (*
        pub fn len(&self) -> usize {
            self.0.len()
        }
    *)
    Definition len (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "str", "len", [] |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_len : M.IsAssociatedFunction Self "len" len.
    
    (*
        pub fn is_empty(&self) -> bool {
            self.0.is_empty()
        }
    *)
    Definition is_empty (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "str", "is_empty", [] |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_is_empty : M.IsAssociatedFunction Self "is_empty" is_empty.
    
    (*
        pub fn as_str(&self) -> &str {
            &self.0
        }
    *)
    Definition as_str (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.SubPointer.get_struct_tuple_field (|
            M.read (| self |),
            "move_core_types::identifier::IdentStr",
            0
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_as_str : M.IsAssociatedFunction Self "as_str" as_str.
    
    (*
        pub fn as_bytes(&self) -> &[u8] {
            self.0.as_bytes()
        }
    *)
    Definition as_bytes (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (| Ty.path "str", "as_bytes", [] |),
            [
              M.SubPointer.get_struct_tuple_field (|
                M.read (| self |),
                "move_core_types::identifier::IdentStr",
                0
              |)
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_as_bytes : M.IsAssociatedFunction Self "as_bytes" as_bytes.
    
    (*
        pub fn abstract_size_for_gas_metering(&self) -> AbstractMemorySize {
            AbstractMemorySize::new((self.len()) as u64)
        }
    *)
    Definition abstract_size_for_gas_metering
        (ε : list Value.t)
        (τ : list Ty.t)
        (α : list Value.t)
        : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_associated_function (|
              Ty.apply
                (Ty.path "move_core_types::gas_algebra::GasQuantity")
                []
                [ Ty.path "move_core_types::gas_algebra::AbstractMemoryUnit" ],
              "new",
              []
            |),
            [
              M.rust_cast
                (M.call_closure (|
                  M.get_associated_function (|
                    Ty.path "move_core_types::identifier::IdentStr",
                    "len",
                    []
                  |),
                  [ M.read (| self |) ]
                |))
            ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom AssociatedFunction_abstract_size_for_gas_metering :
      M.IsAssociatedFunction Self "abstract_size_for_gas_metering" abstract_size_for_gas_metering.
  End Impl_move_core_types_identifier_IdentStr.
  
  Module Impl_core_borrow_Borrow_move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        fn borrow(&self) -> &IdentStr {
            self
        }
    *)
    Definition borrow (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          M.call_closure (|
            M.get_trait_method (|
              "core::ops::deref::Deref",
              Ty.path "move_core_types::identifier::Identifier",
              [],
              "deref",
              []
            |),
            [ M.read (| self |) ]
          |)))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "core::borrow::Borrow"
        Self
        (* Trait polymorphic types *)
        [ (* Borrowed *) Ty.path "move_core_types::identifier::IdentStr" ]
        (* Instance *) [ ("borrow", InstanceField.Method borrow) ].
  End Impl_core_borrow_Borrow_move_core_types_identifier_IdentStr_for_move_core_types_identifier_Identifier.
  
  Module Impl_alloc_borrow_ToOwned_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (*     type Owned = Identifier; *)
    Definition _Owned : Ty.t := Ty.path "move_core_types::identifier::Identifier".
    
    (*
        fn to_owned(&self) -> Identifier {
            Identifier(self.0.into())
        }
    *)
    Definition to_owned (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
      match ε, τ, α with
      | [], [], [ self ] =>
        ltac:(M.monadic
          (let self := M.alloc (| self |) in
          Value.StructTuple
            "move_core_types::identifier::Identifier"
            [
              M.call_closure (|
                M.get_trait_method (|
                  "core::convert::Into",
                  Ty.apply (Ty.path "&") [] [ Ty.path "str" ],
                  [
                    Ty.apply
                      (Ty.path "alloc::boxed::Box")
                      []
                      [ Ty.path "str"; Ty.path "alloc::alloc::Global" ]
                  ],
                  "into",
                  []
                |),
                [
                  M.SubPointer.get_struct_tuple_field (|
                    M.read (| self |),
                    "move_core_types::identifier::IdentStr",
                    0
                  |)
                ]
              |)
            ]))
      | _, _, _ => M.impossible "wrong number of arguments"
      end.
    
    Axiom Implements :
      M.IsTraitInstance
        "alloc::borrow::ToOwned"
        Self
        (* Trait polymorphic types *) []
        (* Instance *)
        [ ("Owned", InstanceField.Ty _Owned); ("to_owned", InstanceField.Method to_owned) ].
  End Impl_alloc_borrow_ToOwned_for_move_core_types_identifier_IdentStr.
  
  Module Impl_core_fmt_Display_for_move_core_types_identifier_IdentStr.
    Definition Self : Ty.t := Ty.path "move_core_types::identifier::IdentStr".
    
    (*
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            write!(f, "{}", &self.0)
        }
    *)
    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_v1", [] |),
                [
                  M.alloc (| Value.Array [ M.read (| Value.String "" |) ] |);
                  M.alloc (|
                    Value.Array
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::rt::Argument",
                            "new_display",
                            [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                          |),
                          [
                            M.alloc (|
                              M.SubPointer.get_struct_tuple_field (|
                                M.read (| self |),
                                "move_core_types::identifier::IdentStr",
                                0
                              |)
                            |)
                          ]
                        |)
                      ]
                  |)
                ]
              |)
            ]
          |)))
      | _, _, _ => 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_move_core_types_identifier_IdentStr.
End identifier.
