reserve SBT for Permutation of (8-tuples_on BOOLEAN);
reserve MCFunc for Permutation of
4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN));
reserve MixColumns for
Permutation of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN));

theorem LAST05:
  for m be Nat,
  text be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN)),
  key be Element of m-tuples_on(4-tuples_on (8-tuples_on BOOLEAN)),
  dkeyi,ekeyi be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN))
  st (m = 4 or m = 6 or m = 8) & dkeyi = ((KeyExpansion(SBT,m)).(key)).1 &
  ekeyi = (Rev((KeyExpansion(SBT,m)).(key))).(7+m)
  holds AddRoundKey.(AddRoundKey.(text,ekeyi),dkeyi) = text
proof
  let m be Nat,
  text be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN)),
  key be Element of m-tuples_on(4-tuples_on (8-tuples_on BOOLEAN)),
  dkeyi,ekeyi be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN));
  assume
AS: (m = 4 or m = 6 or m = 8) & dkeyi = ((KeyExpansion(SBT,m)).(key)).1 &
  ekeyi = (Rev((KeyExpansion(SBT,m)).(key))).(7+m);
  set p = (KeyExpansion(SBT,m)).(key);
  (KeyExpansion(SBT,m)).(key) in
  (7+m)-tuples_on(4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN)));
  then
B0: ex s be Element of (4-tuples_on (4-tuples_on (8-tuples_on BOOLEAN)))*
  st (KeyExpansion(SBT,m)).(key) = s & len s = (7+m);
  1+0 < 7+m by XREAL_1:8;
  then 7+m in Seg (7+m);
  then
B1: 7+m in dom p by FINSEQ_1:def 3,B0;
A0: ekeyi = p.((len p)-(7+m)+1) by AS,FINSEQ_5:58,B1
    .= dkeyi by B0,AS;
  now let i,j be Nat;
    assume
A3: i in Seg 4 & j in Seg 4;
    then consider etextij,ekeyij be Element of 8-tuples_on BOOLEAN such that
A4: etextij = (text.i).j & ekeyij = (ekeyi.i).j &
    ((AddRoundKey.(text,ekeyi)).i).j = Op-XOR(etextij,ekeyij)
    by DefAddRoundKey;
    consider dtextij,dkeyij be Element of 8-tuples_on BOOLEAN such that
A5: dtextij = ((AddRoundKey.(text,ekeyi)).i).j & dkeyij = (dkeyi.i).j &
    ((AddRoundKey.(AddRoundKey.(text,ekeyi),dkeyi)).i).j =
    Op-XOR(dtextij,dkeyij) by DefAddRoundKey,A3;
    thus ((AddRoundKey.(AddRoundKey.(text,ekeyi),dkeyi)).i).j =
    (text.i).j by A4,A5,A0,DESCIP_1:17;
  end;
  hence AddRoundKey.(AddRoundKey.(text,ekeyi),dkeyi) = text by LM01;
end;
