reserve Q,Q1,Q2 for multLoop;
reserve x,y,z,w,u,v for Element of Q;

theorem Th28:
  for H being Subset of Q holds
  for phi being Function of bool Funcs(Q,Q),bool Funcs(Q,Q)
  st
  for X being Subset of Funcs(Q,Q) holds phi.X = MltClos1(H,X)
  holds
  for Y being Subset of Funcs(Q,Q)
  st
  for S be Subset of Funcs(Q,Q) st phi.S c= S holds Y c= S
  holds
  for f being Element of Funcs(Q,Q) st
  f in Y holds
  f is Permutation of Q
proof
  let H be Subset of Q;
  let phi be Function of bool Funcs(Q,Q),bool Funcs(Q,Q);
  assume A1: for X being Subset of Funcs(Q,Q) holds phi.X = MltClos1(H,X);
  let Y be Subset of Funcs(Q,Q);
  assume A2: for S be Subset of Funcs(Q,Q) st phi.S c= S holds Y c= S;
  set SP =  the set of all f where f is Permutation of Q;
  SP c= Funcs(Q,Q)
  proof
    let f be object;
    assume f in SP;
    then consider g being Permutation of Q such that
    A3: f = g & not contradiction;
    thus thesis by FUNCT_2:9,A3;
  end;
  then reconsider SP as Subset of Funcs(Q,Q);
  phi.(SP) c= SP
  proof
    let f be object;
    assume f in phi.(SP);
    then f in MltClos1(H,SP) by A1;
    then per cases by Def37;
    suppose ex u be Element of Q st u in H & f = (curry' (the multF of Q)).u;
      then consider u being Element of Q such that
      A4: u in H & f = (curry' (the multF of Q)).u;
      reconsider f as Function of Q,Q by A4;
      deffunc G(Element of Q) = $1 / u;
      consider g be Function of Q,Q such that
      A5: for x being Element of Q holds g.x = G(x) from FUNCT_2:sch 4;
      for x being Element of Q holds (g*f).x = (id (the carrier of Q)).x
      proof
        let x be Element of Q;
        (g * f).x = g.(f.x) by FUNCT_2:15
        .= g.(x * u) by FUNCT_5:70,A4
        .= G(x * u) by A5
        .= (id (the carrier of Q)).x;
        hence thesis;
      end;
      then A6: g * f = id (the carrier of Q) by FUNCT_2:def 8;
      for x being Element of Q holds (f*g).x = (id (the carrier of Q)).x
      proof
        let x be Element of Q;
        (f * g).x = f.(g.x) by FUNCT_2:15
        .= g.x * u by FUNCT_5:70,A4
        .= G(x) * u by A5
        .= (id (the carrier of Q)).x;
        hence thesis;
      end;
      then rng f = the carrier of Q by FUNCT_2:18,def 8;
      then f is Permutation of the carrier of Q by FUNCT_2:57,A6, FUNCT_2:31;
      hence thesis;
    end;
    suppose ex u be Element of Q st u in H & f = (curry (the multF of Q)).u;
      then consider u being Element of Q such that
      A7: u in H & f = (curry (the multF of Q)).u;
      reconsider f as Function of Q,Q by A7;
      deffunc G(Element of Q) = u \ $1;
      consider g be Function of Q,Q such that
      A8: for x being Element of Q holds g.x = G(x) from FUNCT_2:sch 4;
      A9: for x being Element of Q holds
        (g*f).x = (id (the carrier of Q)).x
      proof
        let x be Element of Q;
        (g * f).x = g.(f.x) by FUNCT_2:15
        .= g.(u * x) by FUNCT_5:69,A7
        .= G(u * x) by A8
        .= (id (the carrier of Q)).x;
        hence thesis;
      end;
      A10: for x being Element of Q holds
        (f*g).x = (id (the carrier of Q)).x
      proof
        let x be Element of Q;
        (f * g).x = f.(g.x) by FUNCT_2:15
        .= u * g.x by FUNCT_5:69,A7
        .= u * G(x) by A8
        .= (id (the carrier of Q)).x;
        hence thesis;
      end;
      A11: f is one-to-one by A9, FUNCT_2:31,FUNCT_2:def 8;
      rng f = the carrier of Q by A10, FUNCT_2:18,FUNCT_2:def 8;
      then f is Permutation of the carrier of Q by FUNCT_2:57,A11;
      hence thesis;
    end;
    suppose ex g,h be Permutation of the carrier of Q st g in SP &
        h in SP & f = g*h;
      hence thesis;
    end;
    suppose ex g be Permutation of the carrier of Q st g in SP & f = g";
      hence thesis;
    end;
  end;
  then A12: Y c= SP by A2;
  let f be Element of Funcs(Q,Q);
  assume f in Y;
  then f in SP by A12;
  then ex g being Permutation of Q st f = g;
  hence thesis;
end;
