let P be Instruction-Sequence of SCM+FSA; :: thesis: for I being Program of SCM+FSA
for a being read-write Int-Location
for s being State of SCM+FSA st ex f being Function of (product the Object-Kind of SCM+FSA),NAT st
for k being Element of NAT holds
( ( f . ((StepWhile>0 (a,P,s,I)) . k) <> 0 implies ( f . ((StepWhile>0 (a,P,s,I)) . (k + 1)) < f . ((StepWhile>0 (a,P,s,I)) . k) & I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) ) ) & ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 & ( f . ((StepWhile>0 (a,P,s,I)) . k) = 0 implies ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 implies f . ((StepWhile>0 (a,P,s,I)) . k) = 0 ) ) holds
( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )

let I be Program of SCM+FSA; :: thesis: for a being read-write Int-Location
for s being State of SCM+FSA st ex f being Function of (product the Object-Kind of SCM+FSA),NAT st
for k being Element of NAT holds
( ( f . ((StepWhile>0 (a,P,s,I)) . k) <> 0 implies ( f . ((StepWhile>0 (a,P,s,I)) . (k + 1)) < f . ((StepWhile>0 (a,P,s,I)) . k) & I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) ) ) & ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 & ( f . ((StepWhile>0 (a,P,s,I)) . k) = 0 implies ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 implies f . ((StepWhile>0 (a,P,s,I)) . k) = 0 ) ) holds
( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )

let a be read-write Int-Location ; :: thesis: for s being State of SCM+FSA st ex f being Function of (product the Object-Kind of SCM+FSA),NAT st
for k being Element of NAT holds
( ( f . ((StepWhile>0 (a,P,s,I)) . k) <> 0 implies ( f . ((StepWhile>0 (a,P,s,I)) . (k + 1)) < f . ((StepWhile>0 (a,P,s,I)) . k) & I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) ) ) & ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 & ( f . ((StepWhile>0 (a,P,s,I)) . k) = 0 implies ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 implies f . ((StepWhile>0 (a,P,s,I)) . k) = 0 ) ) holds
( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )

let s be State of SCM+FSA; :: thesis: ( ex f being Function of (product the Object-Kind of SCM+FSA),NAT st
for k being Element of NAT holds
( ( f . ((StepWhile>0 (a,P,s,I)) . k) <> 0 implies ( f . ((StepWhile>0 (a,P,s,I)) . (k + 1)) < f . ((StepWhile>0 (a,P,s,I)) . k) & I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) ) ) & ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 & ( f . ((StepWhile>0 (a,P,s,I)) . k) = 0 implies ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 implies f . ((StepWhile>0 (a,P,s,I)) . k) = 0 ) ) implies ( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P ) )

set D = Data-Locations ;
given f being Function of (product the Object-Kind of SCM+FSA),NAT such that A1: for k being Element of NAT holds
( ( f . ((StepWhile>0 (a,P,s,I)) . k) <> 0 implies ( f . ((StepWhile>0 (a,P,s,I)) . (k + 1)) < f . ((StepWhile>0 (a,P,s,I)) . k) & I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) ) ) & ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 & ( f . ((StepWhile>0 (a,P,s,I)) . k) = 0 implies ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,P,s,I)) . k) . a <= 0 implies f . ((StepWhile>0 (a,P,s,I)) . k) = 0 ) ) ; :: thesis: ( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )
set s1 = Initialized s;
set P1 = P +* (while>0 (a,I));
A2: (P +* (while>0 (a,I))) +* (while>0 (a,I)) = P +* (while>0 (a,I)) by FUNCT_4:93;
deffunc H1( Nat) -> Element of NAT = f . ((StepWhile>0 (a,P,s,I)) . $1);
A4: for k being Nat holds
( H1(k + 1) < H1(k) or H1(k) = 0 )
proof
let k be Nat; :: thesis: ( H1(k + 1) < H1(k) or H1(k) = 0 )
k in NAT by ORDINAL1:def 12;
hence ( H1(k + 1) < H1(k) or H1(k) = 0 ) by A1; :: thesis: verum
end;
consider m being Nat such that
A5: H1(m) = 0 and
A6: for n being Nat st H1(n) = 0 holds
m <= n from NAT_1:sch 17(A4);
reconsider m = m as Element of NAT by ORDINAL1:def 12;
defpred S1[ Element of NAT ] means ( $1 + 1 <= m implies ex k being Element of NAT st (StepWhile>0 (a,P,s,I)) . ($1 + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),k) );
A7: S1[ 0 ]
proof
assume 0 + 1 <= m ; :: thesis: ex k being Element of NAT st (StepWhile>0 (a,P,s,I)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),k)
take n = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3; :: thesis: (StepWhile>0 (a,P,s,I)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),n)
thus (StepWhile>0 (a,P,s,I)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),n) by Th26; :: thesis: verum
end;
A8: now
let i be Element of NAT ; :: thesis: ( i < m implies ( I is_closed_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) ) )
assume i < m ; :: thesis: ( I is_closed_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) )
then H1(i) <> 0 by A6;
hence ( I is_closed_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) & I is_halting_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) ) by A1; :: thesis: verum
end;
A9: now
let k be Element of NAT ; :: thesis: ( S1[k] implies S1[k + 1] )
assume A10: S1[k] ; :: thesis: S1[k + 1]
now
set sk = (StepWhile>0 (a,P,s,I)) . k;
set sk1 = (StepWhile>0 (a,P,s,I)) . (k + 1);
assume A11: (k + 1) + 1 <= m ; :: thesis: ex m being Element of NAT st (StepWhile>0 (a,P,s,I)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),m)
(k + 1) + 0 < (k + 1) + 1 by XREAL_1:6;
then consider n being Element of NAT such that
A12: (StepWhile>0 (a,P,s,I)) . (k + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),n) by A10, A11, XXREAL_0:2;
A13: ((StepWhile>0 (a,P,s,I)) . (k + 1)) . (intloc 0) = 1 by A1;
k + 0 < k + (1 + 1) by XREAL_1:6;
then A14: k < m by A11, XXREAL_0:2;
then A15: I is_halting_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) by A8;
H1(k) <> 0 by A6, A14;
then A16: ((StepWhile>0 (a,P,s,I)) . k) . a > 0 by A1;
take m = n + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . (k + 1))))) + 3); :: thesis: (StepWhile>0 (a,P,s,I)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),m)
A17: (P +* (while>0 (a,I))) +* (while>0 (a,I)) = P +* (while>0 (a,I)) by FUNCT_4:93;
A18: (StepWhile>0 (a,P,s,I)) . (k + 1) = Comput ((P +* (while>0 (a,I))),(Initialized ((StepWhile>0 (a,P,s,I)) . k)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . k)))) + 3)) by Def1;
I is_closed_onInit (StepWhile>0 (a,P,s,I)) . k,P +* (while>0 (a,I)) by A8, A14;
then IC ((StepWhile>0 (a,P,s,I)) . (k + 1)) = 0 by A18, A15, A16, Th19, A17;
then (StepWhile>0 (a,P,s,I)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),(n + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . (k + 1))))) + 3))) by A12, A13, Th27;
hence (StepWhile>0 (a,P,s,I)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),m) ; :: thesis: verum
end;
hence S1[k + 1] ; :: thesis: verum
end;
A19: for k being Element of NAT holds S1[k] from NAT_1:sch 1(A7, A9);
per cases ( m = 0 or m <> 0 ) ;
suppose m = 0 ; :: thesis: ( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )
then ((StepWhile>0 (a,P,s,I)) . 0) . a <= 0 by A1, A5;
then s . a <= 0 by Def1;
hence ( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P ) by Th16; :: thesis: verum
end;
suppose A20: m <> 0 ; :: thesis: ( while>0 (a,I) is_halting_onInit s,P & while>0 (a,I) is_closed_onInit s,P )
then consider i being Nat such that
A21: m = i + 1 by NAT_1:6;
reconsider i = i as Element of NAT by ORDINAL1:def 12;
set si = (StepWhile>0 (a,P,s,I)) . i;
set sm = (StepWhile>0 (a,P,s,I)) . m;
set sm1 = Initialized ((StepWhile>0 (a,P,s,I)) . m);
set sm2 = Initialize ((StepWhile>0 (a,P,s,I)) . m);
A22: i < m by A21, XREAL_1:29;
then A23: I is_closed_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) by A8;
i < m by A21, NAT_1:13;
then H1(i) <> 0 by A6;
then A24: ((StepWhile>0 (a,P,s,I)) . i) . a > 0 by A1;
A25: I is_halting_onInit (StepWhile>0 (a,P,s,I)) . i,P +* (while>0 (a,I)) by A8, A22;
(StepWhile>0 (a,P,s,I)) . m = Comput ((P +* (while>0 (a,I))),(Initialized ((StepWhile>0 (a,P,s,I)) . i)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . i)))) + 3)) by A21, Def1;
then IC ((StepWhile>0 (a,P,s,I)) . m) = 0 by A23, A25, A24, Th19, A2;
then B26: Start-At (0,SCM+FSA) c= (StepWhile>0 (a,P,s,I)) . m by MEMSTR_0:30;
((StepWhile>0 (a,P,s,I)) . (i + 1)) . (intloc 0) = 1 by A1;
then A27: Initialized ((StepWhile>0 (a,P,s,I)) . m) = Initialize ((StepWhile>0 (a,P,s,I)) . m) by A21, SCMFSA8C:4;
set p = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3;
m = i + 1 by A21;
then consider n being Element of NAT such that
A30: (StepWhile>0 (a,P,s,I)) . m = Comput ((P +* (while>0 (a,I))),(Initialized s),n) by A19;
A31: Initialized ((StepWhile>0 (a,P,s,I)) . m) = (StepWhile>0 (a,P,s,I)) . m by A27, B26, FUNCT_4:98;
A32: ((StepWhile>0 (a,P,s,I)) . m) . a <= 0 by A1, A5;
then while>0 (a,I) is_halting_onInit (StepWhile>0 (a,P,s,I)) . m,P +* (while>0 (a,I)) by Th16;
then P +* (while>0 (a,I)) halts_on Initialized ((StepWhile>0 (a,P,s,I)) . m) by A2, SCM_HALT:def 5;
then consider j being Element of NAT such that
A33: CurInstr ((P +* (while>0 (a,I))),(Comput ((P +* (while>0 (a,I))),((StepWhile>0 (a,P,s,I)) . m),j))) = halt SCM+FSA by A31, EXTPRO_1:29;
A34: Comput ((P +* (while>0 (a,I))),(Initialized s),(j + n)) = Comput ((P +* (while>0 (a,I))),(Comput ((P +* (while>0 (a,I))),(Initialized s),n)),j) by EXTPRO_1:4;
P +* (while>0 (a,I)) halts_on Initialized s by A30, A33, A34, EXTPRO_1:29;
hence while>0 (a,I) is_halting_onInit s,P by SCM_HALT:def 5; :: thesis: while>0 (a,I) is_closed_onInit s,P
now
let q be Element of NAT ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialized s),b1)) in dom (while>0 (a,I))
per cases ( q <= (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3 or q > (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3 ) ;
suppose A35: q <= (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3 ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialized s),b1)) in dom (while>0 (a,I))
A36: (StepWhile>0 (a,P,s,I)) . 0 = s by Def1;
then A37: I is_halting_onInit s,P +* (while>0 (a,I)) by A8, A20;
H1( 0 ) <> 0 by A6, A20;
then A38: s . a > 0 by A1, A36;
I is_closed_onInit s,P +* (while>0 (a,I)) by A8, A20, A36;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I)) by A35, A38, A37, Th19, A2; :: thesis: verum
end;
suppose A39: q > (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3 ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialized s),b1)) in dom (while>0 (a,I))
A40: now
take k = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized s))) + 3; :: thesis: ( (StepWhile>0 (a,P,s,I)) . 1 = Comput ((P +* (while>0 (a,I))),(Initialized s),k) & k <= q )
thus ( (StepWhile>0 (a,P,s,I)) . 1 = Comput ((P +* (while>0 (a,I))),(Initialized s),k) & k <= q ) by A39, Th26; :: thesis: verum
end;
defpred S2[ Nat] means ( $1 <= m & $1 <> 0 & ex k being Element of NAT st
( (StepWhile>0 (a,P,s,I)) . $1 = Comput ((P +* (while>0 (a,I))),(Initialized s),k) & k <= q ) );
A41: for i being Nat st S2[i] holds
i <= m ;
0 + 1 < m + 1 by A20, XREAL_1:6;
then 1 <= m by NAT_1:13;
then A42: ex t being Nat st S2[t] by A40;
consider t being Nat such that
A43: ( S2[t] & ( for i being Nat st S2[i] holds
i <= t ) ) from NAT_1:sch 6(A41, A42);
reconsider t = t as Element of NAT by ORDINAL1:def 12;
now
per cases ( t = m or t <> m ) ;
suppose t = m ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I))
then consider r being Element of NAT such that
A44: (StepWhile>0 (a,P,s,I)) . m = Comput ((P +* (while>0 (a,I))),(Initialized s),r) and
A45: r <= q by A43;
consider x being Nat such that
A46: q = r + x by A45, NAT_1:10;
A47: while>0 (a,I) is_closed_onInit (StepWhile>0 (a,P,s,I)) . m,P +* (while>0 (a,I)) by A32, Th16;
reconsider x = x as Element of NAT by ORDINAL1:def 12;
Comput ((P +* (while>0 (a,I))),(Initialized s),q) = Comput ((P +* (while>0 (a,I))),(Initialized ((StepWhile>0 (a,P,s,I)) . m)),x) by A31, A44, A46, EXTPRO_1:4;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I)) by A47, A2, SCM_HALT:def 4; :: thesis: verum
end;
suppose A48: t <> m ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I))
set Dt = (StepWhile>0 (a,P,s,I)) . t;
A49: t < m by A43, A48, XXREAL_0:1;
then A50: I is_closed_onInit (StepWhile>0 (a,P,s,I)) . t,P +* (while>0 (a,I)) by A8;
A51: I is_halting_onInit (StepWhile>0 (a,P,s,I)) . t,P +* (while>0 (a,I)) by A8, A49;
consider y being Nat such that
A52: t = y + 1 by A43, NAT_1:6;
reconsider y = y as Element of NAT by ORDINAL1:def 12;
t = y + 1 by A52;
then A53: ((StepWhile>0 (a,P,s,I)) . t) . (intloc 0) = 1 by A1;
H1(t) <> 0 by A6, A49;
then A54: ((StepWhile>0 (a,P,s,I)) . t) . a > 0 by A1;
consider z being Element of NAT such that
A55: (StepWhile>0 (a,P,s,I)) . t = Comput ((P +* (while>0 (a,I))),(Initialized s),z) and
A56: z <= q by A43;
set z2 = z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . t)))) + 3);
consider w being Nat such that
A57: q = z + w by A56, NAT_1:10;
set Dy = (StepWhile>0 (a,P,s,I)) . y;
y + 0 < t by A52, XREAL_1:6;
then A58: y < m by A43, XXREAL_0:2;
then A59: I is_closed_onInit (StepWhile>0 (a,P,s,I)) . y,P +* (while>0 (a,I)) by A8;
H1(y) <> 0 by A6, A58;
then A60: ((StepWhile>0 (a,P,s,I)) . y) . a > 0 by A1;
A61: I is_halting_onInit (StepWhile>0 (a,P,s,I)) . y,P +* (while>0 (a,I)) by A8, A58;
reconsider w = w as Element of NAT by ORDINAL1:def 12;
(StepWhile>0 (a,P,s,I)) . t = Comput ((P +* (while>0 (a,I))),(Initialized ((StepWhile>0 (a,P,s,I)) . y)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . y)))) + 3)) by A52, Def1;
then A62: IC ((StepWhile>0 (a,P,s,I)) . t) = 0 by A59, A61, A60, Th19, A2;
A63: (StepWhile>0 (a,P,s,I)) . t = Initialized ((StepWhile>0 (a,P,s,I)) . t) by A53, A55, A62, Th27;
now
assume A64: z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . t)))) + 3) <= q ; :: thesis: contradiction
A65: now
take k = z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . t)))) + 3); :: thesis: ( (StepWhile>0 (a,P,s,I)) . (t + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),k) & k <= q )
thus (StepWhile>0 (a,P,s,I)) . (t + 1) = Comput ((P +* (while>0 (a,I))),(Initialized s),k) by A53, A55, A62, Th27; :: thesis: k <= q
thus k <= q by A64; :: thesis: verum
end;
t + 1 <= m by A49, NAT_1:13;
hence contradiction by A43, A65, XREAL_1:29; :: thesis: verum
end;
then A66: w < (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialized ((StepWhile>0 (a,P,s,I)) . t)))) + 3 by A57, XREAL_1:6;
Comput ((P +* (while>0 (a,I))),(Initialized s),q) = Comput ((P +* (while>0 (a,I))),(Initialized ((StepWhile>0 (a,P,s,I)) . t)),w) by A63, A55, A57, EXTPRO_1:4;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I)) by A66, A50, A51, A54, Th19, A2; :: thesis: verum
end;
end;
end;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialized s),q)) in dom (while>0 (a,I)) ; :: thesis: verum
end;
end;
end;
hence while>0 (a,I) is_closed_onInit s,P by SCM_HALT:def 4; :: thesis: verum
end;
end;