reserve X for set;
reserve G for Group;
reserve H for Subgroup of G;
reserve h,x,y for object;
reserve f for Endomorphism of G;
reserve phi for Automorphism of G;
reserve K for characteristic Subgroup of G;

theorem Th45:
  for G being Group
  for A being non empty Subset of G
  st (for phi being Automorphism of G holds phi .: A = A)
  holds gr A is characteristic
proof
  let G be Group;
  let A be non empty Subset of G;
  assume A1: for phi being Automorphism of G holds phi .: A = A;
  A2: for phi being Automorphism of G for a being Element of A holds phi.a in A
  proof
    let phi be Automorphism of G;
    let a be Element of A;
    dom phi = the carrier of G by FUNCT_2:def 1;
    then phi.a in phi .: A by FUNCT_1:def 6;
    hence phi.a in A by A1;
  end;
  set H = gr A;
  for phi being Automorphism of G holds Image(phi|H) is Subgroup of H
  proof
    let phi be Automorphism of G;
    B2: for h being Element of G st h in H holds phi.h in H
    proof
      let h be Element of G;
      assume h in H;
      then consider F1 being FinSequence of the carrier of G,
                    I being FinSequence of INT such that
      C2: len F1 = len I and
      C3: rng F1 c= A and
      C4: Product(F1 |^ I) = h by GROUP_4:28;
      deffunc F(Nat) = phi.(F1/.$1);
      consider F2 being FinSequence such that
      C5: len(F2) = len F1 and
      C6: for k being Nat st k in dom F2 holds F2.k = F(k)
      from FINSEQ_1:sch 2;
      C7: dom F2 = dom F1 by C5,FINSEQ_3:29;
      C8: F2 is FinSequence of the carrier of G & rng F2 c= A
      proof
        D1: for y being object st y in rng F2 holds y in A
        proof
          let y be object;
          assume y in rng F2;
          then consider k being object such that
          E2: k in dom F2 and
          E3: y = F2.k by FUNCT_1:def 3;
          reconsider k as Element of NAT by E2;
          set x = F1.k;
          x in rng F1 by FUNCT_1:def 3, E2, C7;
          then reconsider x as Element of A by C3;
          E4: x = F1/.k by E2,C7,PARTFUN1:def 6;
          y = F(k) by E2,E3,C6
           .= phi.(F1/.k);
          hence y in A by A2,E4;
        end;
        for y being object st y in rng F2 holds y in the carrier of G
        proof
          let y be object;
          assume y in rng F2;
          then y in A by D1;
          hence y in the carrier of G;
        end;
        hence rng F2 c= the carrier of G;
        thus rng F2 c= A by D1;
      end;
      then reconsider F2 as FinSequence of the carrier of G;
      set h2 = Product(F2 |^ I);
      (for k being Nat st k in dom F1
           holds F2.k = phi.(F1.k)) & len F1 = len I & len F2 = len I
      proof
        thus (for k being Nat st k in dom F1 holds F2.k = phi.(F1.k))
        proof
          let k be Nat;
          assume D1: k in dom F1;
          then k in dom F2 by C5,FINSEQ_3:29;
          then F2.k = F(k) by C6
                   .= phi.(F1/.k);
          hence F2.k = phi.(F1.k) by D1,PARTFUN1:def 6;
        end;
        thus len F1 = len I by C2;
        thus len F2 = len I by C2,C5;
      end;
      then len F2 = len I & rng F2 c= A & Product(F2 |^ I) = phi.h
        by C4,C8,GROUP_9:125;
      hence phi.h in H by GROUP_4:28;
    end;
    for h being Element of H holds phi.h in H
    proof
      let h be Element of H;
      C1: h in H;
      h is Element of G by GROUP_2:42;
      hence phi.h in H by B2,C1;
    end;
    hence Image(phi|H) is Subgroup of H by Th44;
  end;
  hence gr A is characteristic by Th40;
end;
