reserve i,j,k,n for Nat;
reserve x,y,z for Tuple of n, BOOLEAN;
reserve m,k,k1,k2 for FinSequence of NAT;

theorem
  for n being non zero Nat,lk being Nat, Key
being Matrix of lk,6,NAT, r being Nat holds rng compose(IDEA_Q_F(Key
,n,r),MESSAGES) c=MESSAGES & dom compose(IDEA_Q_F(Key,n,r),MESSAGES) =MESSAGES
proof
  let n be non zero Nat, lk be Nat, Key be Matrix of lk
  ,6,NAT, r be Nat;
A1: rng compose(IDEA_Q_F(Key,n,r),MESSAGES) c= MESSAGES
  proof
    per cases;
    suppose
A2:   r<>0;
      then 0+1 < r+1 by XREAL_1:6;
      then
A3:   1 <= r by NAT_1:13;
      r = len IDEA_Q_F(Key,n,r) by Def18;
      then r in Seg len IDEA_Q_F(Key,n,r) by A3,FINSEQ_1:1;
      then
A4:   r in dom IDEA_Q_F(Key,n,r) by FINSEQ_1:def 3;
      len (IDEA_Q_F(Key,n,r)) <> 0 by A2,Def18;
      then
A5:   not IDEA_Q_F(Key,n,r)=<*>MESSAGES;
      then
      lastrng IDEA_Q_F(Key,n,r) = proj2 (IDEA_Q_F(Key,n,r). len (IDEA_Q_F
      (Key,n,r))) by FUNCT_7:def 7
        .= proj2 (IDEA_Q_F(Key,n,r).r) by Def18
        .= proj2 (IDEA_Q(Line(Key,r-'r+1),n)) by A4,Def18
        .= rng IDEA_Q(Line(Key,r-'r+1),n);
      then
A6:   lastrng IDEA_Q_F(Key,n,r) c= MESSAGES by RELAT_1:def 19;
      rng compose(IDEA_Q_F(Key,n,r),MESSAGES) c= lastrng IDEA_Q_F(Key,n,r
      ) by A5,FUNCT_7:59;
      hence thesis by A6,XBOOLE_1:1;
    end;
    suppose
      r=0;
      then len IDEA_Q_F(Key,n,r) = 0 by Def18;
      then IDEA_Q_F(Key,n,r) = {};
      then compose(IDEA_Q_F(Key,n,r),MESSAGES) = id MESSAGES by FUNCT_7:39;
      hence thesis;
    end;
  end;
A7: IDEA_Q_F(Key,n,r) is FuncSequence by Th39;
  dom compose(IDEA_Q_F(Key,n,r),MESSAGES) = MESSAGES
  proof
    per cases;
    suppose
      r=0;
      then len IDEA_Q_F(Key,n,r) = 0 by Def18;
      then IDEA_Q_F(Key,n,r) = {};
      then compose(IDEA_Q_F(Key,n,r),MESSAGES) = id MESSAGES by FUNCT_7:39;
      hence thesis;
    end;
    suppose
A8:   r<>0;
      then 0+1 < r+1 by XREAL_1:6;
      then
A9:   1 <= r by NAT_1:13;
      r = len IDEA_Q_F(Key,n,r) by Def18;
      then 1 in Seg len IDEA_Q_F(Key,n,r) by A9,FINSEQ_1:1;
      then
A10:  1 in dom IDEA_Q_F(Key,n,r) by FINSEQ_1:def 3;
      len (IDEA_Q_F(Key,n,r)) <> 0 by A8,Def18;
      then not IDEA_Q_F(Key,n,r)=<*>MESSAGES;
      then firstdom IDEA_Q_F(Key,n,r) = proj1 (IDEA_Q_F(Key,n,r).1) by
FUNCT_7:def 6
        .= proj1 (IDEA_Q(Line(Key,r-'1+1),n)) by A10,Def18
        .= dom IDEA_Q(Line(Key,r-'1+1),n)
        .= MESSAGES by FUNCT_2:def 1;
      hence thesis by A7,FUNCT_7:62;
    end;
  end;
  hence thesis by A1;
end;
