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 LAST08:
  for m,i 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)),
  eKeyi,dKeyi be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN))
  st (m = 4 or m = 6 or m = 8) & i <= 7+m-1 &
  eKeyi = ((KeyExpansion(SBT,m)).(Key)).(7+m-i) &
  dKeyi = (Rev((KeyExpansion(SBT,m)).(Key))).(i+1)
  holds AddRoundKey.(AddRoundKey.(text,eKeyi),dKeyi) = text
proof
  let m,i 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)),
  ekeyi,dkeyi be Element of 4-tuples_on(4-tuples_on (8-tuples_on BOOLEAN));
  assume
AS: (m = 4 or m = 6 or m = 8) & i <= 7+m-1 &
  ekeyi = ((KeyExpansion(SBT,m)).(key)).(7+m-i) &
  dkeyi = (Rev((KeyExpansion(SBT,m)).(key))).(i+1);
  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);
  i+1 <= 7+m-1+1 by AS,XREAL_1:7;
  then 1 <= i+1 & i+1 <= 7+m by NAT_1:11;
  then i+1 in Seg (7+m);
  then
B1: i+1 in dom p by FINSEQ_1:def 3,B0;
A0: dkeyi = p.((len p)-(i+1)+1) by AS,FINSEQ_5:58,B1
    .= ekeyi 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;
