Theorem: FreeRing.coe_eq
File: Mathlib/RingTheory/FreeCommRing.lean

tactic: funext x
state_before: α : Type u
⊢ castFreeCommRing = Functor.map fun l => ↑l
state_after: case h
α : Type u
x : FreeRing α
⊢ ↑x = (fun l => ↑l) <$> x

tactic: erw [castFreeCommRing, toFreeCommRing, FreeRing.lift, Equiv.coe_trans, Function.comp,
  FreeAbelianGroup.liftMonoid_coe (FreeMonoid.lift FreeCommRing.of)]
state_before: case h
α : Type u
x : FreeRing α
⊢ ↑x = (fun l => ↑l) <$> x
state_after: case h
α : Type u
x : FreeRing α
⊢ (FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x = (fun l => ↑l) <$> x

tactic: dsimp [Functor.map]
state_before: case h
α : Type u
x : FreeRing α
⊢ (FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x = (fun l => ↑l) <$> x
state_after: case h
α : Type u
x : FreeRing α
⊢ (FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x =
    (FreeAbelianGroup.lift ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l)) x

tactic: rw [← AddMonoidHom.coe_coe]
state_before: case h
α : Type u
x : FreeRing α
⊢ (FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x =
    (FreeAbelianGroup.lift ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l)) x
state_after: case h
α : Type u
x : FreeRing α
⊢ ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x =
    (FreeAbelianGroup.lift ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l)) x

tactic: apply FreeAbelianGroup.lift.unique
state_before: case h
α : Type u
x : FreeRing α
⊢ ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) x =
    (FreeAbelianGroup.lift ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l)) x
state_after: case h.hg
α : Type u
x : FreeRing α
⊢ ∀ (x : FreeMonoid α),
    ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) (FreeAbelianGroup.of x) =
      ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l) x

tactic: intro L
state_before: case h.hg
α : Type u
x : FreeRing α
⊢ ∀ (x : FreeMonoid α),
    ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) (FreeAbelianGroup.of x) =
      ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l) x
state_after: case h.hg
α : Type u
x : FreeRing α
L : FreeMonoid α
⊢ ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) (FreeAbelianGroup.of L) =
    ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l) L

tactic: erw [FreeAbelianGroup.lift.of, Function.comp]
state_before: case h.hg
α : Type u
x : FreeRing α
L : FreeMonoid α
⊢ ↑(FreeAbelianGroup.lift ⇑(FreeMonoid.lift FreeCommRing.of)) (FreeAbelianGroup.of L) =
    ((fun α_1 => FreeAbelianGroup.of α_1) ∘ fun l => ↑l) L
state_after: case h.hg
α : Type u
x : FreeRing α
L : FreeMonoid α
⊢ (FreeMonoid.lift FreeCommRing.of) L = (fun x => FreeAbelianGroup.of ↑x) L

tactic: exact
  FreeMonoid.recOn L rfl fun hd tl ih => by
    rw [(FreeMonoid.lift _).map_mul, FreeMonoid.lift_eval_of, ih]
    conv_lhs => reduce
    rfl
state_before: case h.hg
α : Type u
x : FreeRing α
L : FreeMonoid α
⊢ (FreeMonoid.lift FreeCommRing.of) L = (fun x => FreeAbelianGroup.of ↑x) L
state_after: no goals

tactic: rw [(FreeMonoid.lift _).map_mul, FreeMonoid.lift_eval_of, ih]
state_before: α : Type u
x : FreeRing α
L : FreeMonoid α
hd : α
tl : FreeMonoid α
ih : (FreeMonoid.lift FreeCommRing.of) tl = (fun x => FreeAbelianGroup.of ↑x) tl
⊢ (FreeMonoid.lift FreeCommRing.of) (FreeMonoid.of hd * tl) = (fun x => FreeAbelianGroup.of ↑x) (FreeMonoid.of hd * tl)
state_after: α : Type u
x : FreeRing α
L : FreeMonoid α
hd : α
tl : FreeMonoid α
ih : (FreeMonoid.lift FreeCommRing.of) tl = (fun x => FreeAbelianGroup.of ↑x) tl
⊢ FreeCommRing.of hd * (fun x => FreeAbelianGroup.of ↑x) tl = (fun x => FreeAbelianGroup.of ↑x) (FreeMonoid.of hd * tl)

tactic: conv_lhs => reduce
state_before: α : Type u
x : FreeRing α
L : FreeMonoid α
hd : α
tl : FreeMonoid α
ih : (FreeMonoid.lift FreeCommRing.of) tl = (fun x => FreeAbelianGroup.of ↑x) tl
⊢ FreeCommRing.of hd * (fun x => FreeAbelianGroup.of ↑x) tl = (fun x => FreeAbelianGroup.of ↑x) (FreeMonoid.of hd * tl)
state_after: α : Type u
x : FreeRing α
L : FreeMonoid α
hd : α
tl : FreeMonoid α
ih : (FreeMonoid.lift FreeCommRing.of) tl = (fun x => FreeAbelianGroup.of ↑x) tl
⊢ Quot.lift
      (fun L =>
        List.foldl
          (fun x x_1 =>
            Quot.lift
              (fun a₁ =>
                Quot.lift
                  (fun y =>
                    Quot.mk
                      (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                      (Quot.lift (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯ a₁))
                  ⋯ x_1)
              ⋯ x)
          (Quot.mk (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
            (Quot.mk FreeGroup.Red.Step []))
          (List.map
            (fun x =>
              (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x.2
                (fun _ =>
                  Quot.lift
                    (fun L =>
                      List.foldl
                        (fun x x_1 =>
                          Quot.lift
                            (fun a₁ =>
                              Quot.lift
                                (fun y =>
                                  Quot.mk
                                    (fun a b =>
                                      a ∈
                                        MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                    (Quot.lift
                                      (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯
                                      a₁))
                                ⋯ x_1)
                            ⋯ x)
                        (Quot.mk
                          (fun a b =>
                            a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                          (Quot.mk FreeGroup.Red.Step []))
                        (List.map
                          (fun x_1 =>
                            (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                              (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x_1.2
                              (fun _ =>
                                Quot.mk
                                  (fun a b =>
                                    a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                  (Quot.mk FreeGroup.Red.Step
                                    [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1)
                                          ⋯ x_1.1,
                                        true)]))
                              fun _ =>
                              Quot.mk
                                (fun a b =>
                                  a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                (Quot.mk FreeGroup.Red.Step
                                  [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1) ⋯
                                        x_1.1,
                                      false)]))
                          L))
                    ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm [hd], true)]))
                fun _ =>
                Quot.lift
                  (fun x =>
                    Quot.mk
                      (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                      (Quot.lift
                        (fun x =>
                          Quot.mk FreeGroup.Red.Step
                            ((List.map
                                  (fun g =>
                                    (g.1,
                                      (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                                        (fun x => Bool) g.2 (fun _ => false) fun _ => true))
                                  x).reverseAux
                              []))
                        ⋯ x))
                  ⋯
                  (Quot.lift
                    (fun L =>
                      List.foldl
                        (fun x x_1 =>
                          Quot.lift
                            (fun a₁ =>
                              Quot.lift
                                (fun y =>
                                  Quot.mk
                                    (fun a b =>
                                      a ∈
                                        MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                    (Quot.lift
                                      (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯
                                      a₁))
                                ⋯ x_1)
                            ⋯ x)
                        (Quot.mk
                          (fun a b =>
                            a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                          (Quot.mk FreeGroup.Red.Step []))
                        (List.map
                          (fun x_1 =>
                            (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                              (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x_1.2
                              (fun _ =>
                                Quot.mk
                                  (fun a b =>
                                    a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                  (Quot.mk FreeGroup.Red.Step
                                    [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1)
                                          ⋯ x_1.1,
                                        true)]))
                              fun _ =>
                              Quot.mk
                                (fun a b =>
                                  a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                (Quot.mk FreeGroup.Red.Step
                                  [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1) ⋯
                                        x_1.1,
                                      false)]))
                          L))
                    ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm [hd], true)])))
            L))
      ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm tl, true)]) =
    (fun x => FreeAbelianGroup.of ↑x) (FreeMonoid.of hd * tl)

tactic: rfl
state_before: α : Type u
x : FreeRing α
L : FreeMonoid α
hd : α
tl : FreeMonoid α
ih : (FreeMonoid.lift FreeCommRing.of) tl = (fun x => FreeAbelianGroup.of ↑x) tl
⊢ Quot.lift
      (fun L =>
        List.foldl
          (fun x x_1 =>
            Quot.lift
              (fun a₁ =>
                Quot.lift
                  (fun y =>
                    Quot.mk
                      (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                      (Quot.lift (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯ a₁))
                  ⋯ x_1)
              ⋯ x)
          (Quot.mk (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
            (Quot.mk FreeGroup.Red.Step []))
          (List.map
            (fun x =>
              (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x.2
                (fun _ =>
                  Quot.lift
                    (fun L =>
                      List.foldl
                        (fun x x_1 =>
                          Quot.lift
                            (fun a₁ =>
                              Quot.lift
                                (fun y =>
                                  Quot.mk
                                    (fun a b =>
                                      a ∈
                                        MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                    (Quot.lift
                                      (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯
                                      a₁))
                                ⋯ x_1)
                            ⋯ x)
                        (Quot.mk
                          (fun a b =>
                            a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                          (Quot.mk FreeGroup.Red.Step []))
                        (List.map
                          (fun x_1 =>
                            (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                              (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x_1.2
                              (fun _ =>
                                Quot.mk
                                  (fun a b =>
                                    a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                  (Quot.mk FreeGroup.Red.Step
                                    [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1)
                                          ⋯ x_1.1,
                                        true)]))
                              fun _ =>
                              Quot.mk
                                (fun a b =>
                                  a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                (Quot.mk FreeGroup.Red.Step
                                  [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1) ⋯
                                        x_1.1,
                                      false)]))
                          L))
                    ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm [hd], true)]))
                fun _ =>
                Quot.lift
                  (fun x =>
                    Quot.mk
                      (fun a b => a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                      (Quot.lift
                        (fun x =>
                          Quot.mk FreeGroup.Red.Step
                            ((List.map
                                  (fun g =>
                                    (g.1,
                                      (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                                        (fun x => Bool) g.2 (fun _ => false) fun _ => true))
                                  x).reverseAux
                              []))
                        ⋯ x))
                  ⋯
                  (Quot.lift
                    (fun L =>
                      List.foldl
                        (fun x x_1 =>
                          Quot.lift
                            (fun a₁ =>
                              Quot.lift
                                (fun y =>
                                  Quot.mk
                                    (fun a b =>
                                      a ∈
                                        MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                    (Quot.lift
                                      (fun L₁ => Quot.lift (fun L₂ => Quot.mk FreeGroup.Red.Step (L₁.append L₂)) ⋯ y) ⋯
                                      a₁))
                                ⋯ x_1)
                            ⋯ x)
                        (Quot.mk
                          (fun a b =>
                            a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                          (Quot.mk FreeGroup.Red.Step []))
                        (List.map
                          (fun x_1 =>
                            (fun motive c h_1 h_2 => Bool.rec (h_2 PUnit.unit) (h_1 PUnit.unit) c)
                              (fun c => Multiplicative (FreeAbelianGroup (Multiplicative (Multiset α)))) x_1.2
                              (fun _ =>
                                Quot.mk
                                  (fun a b =>
                                    a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                  (Quot.mk FreeGroup.Red.Step
                                    [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1)
                                          ⋯ x_1.1,
                                        true)]))
                              fun _ =>
                              Quot.mk
                                (fun a b =>
                                  a ∈ MulAction.orbit (↥(commutator (FreeGroup (Multiplicative (Multiset α)))).op) b)
                                (Quot.mk FreeGroup.Red.Step
                                  [(Quot.lift (fun a₁ => Quot.lift (fun l₂ => Quot.mk List.Perm (a₁.append l₂)) ⋯ x.1) ⋯
                                        x_1.1,
                                      false)]))
                          L))
                    ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm [hd], true)])))
            L))
      ⋯ (Quot.mk FreeGroup.Red.Step [(Quot.mk List.Perm tl, true)]) =
    (fun x => FreeAbelianGroup.of ↑x) (FreeMonoid.of hd * tl)
state_after: no goals