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

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

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

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

set D = Int-Locations \/ FinSeq-Locations;
assume A1: for k being Nat holds
( I is_closed_on (StepWhile>0 (a,I,P,s)) . k,P +* (while>0 (a,I)) & I is_halting_on (StepWhile>0 (a,I,P,s)) . k,P +* (while>0 (a,I)) ) ; :: thesis: ( for f being Function of (product the Object-Kind of SCM+FSA),NAT holds
not for k being Nat holds
( ( f . ((StepWhile>0 (a,I,P,s)) . (k + 1)) < f . ((StepWhile>0 (a,I,P,s)) . k) or f . ((StepWhile>0 (a,I,P,s)) . k) = 0 ) & ( f . ((StepWhile>0 (a,I,P,s)) . k) = 0 implies ((StepWhile>0 (a,I,P,s)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,I,P,s)) . k) . a <= 0 implies f . ((StepWhile>0 (a,I,P,s)) . k) = 0 ) ) or ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P ) )

set s1 = Initialize s;
set P1 = P +* (while>0 (a,I));
A4: (P +* (while>0 (a,I))) +* (while>0 (a,I)) = P +* (while>0 (a,I)) by FUNCT_4:93;
A5: (P +* (while>0 (a,I))) +* (while>0 (a,I)) = P +* (while>0 (a,I)) by FUNCT_4:93;
given f being Function of (product the Object-Kind of SCM+FSA),NAT such that A6: for k being Nat holds
( ( f . ((StepWhile>0 (a,I,P,s)) . (k + 1)) < f . ((StepWhile>0 (a,I,P,s)) . k) or f . ((StepWhile>0 (a,I,P,s)) . k) = 0 ) & ( f . ((StepWhile>0 (a,I,P,s)) . k) = 0 implies ((StepWhile>0 (a,I,P,s)) . k) . a <= 0 ) & ( ((StepWhile>0 (a,I,P,s)) . k) . a <= 0 implies f . ((StepWhile>0 (a,I,P,s)) . k) = 0 ) ) ; :: thesis: ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P )
deffunc H1( Nat) -> Element of NAT = f . ((StepWhile>0 (a,I,P,s)) . $1);
A7: for k being Nat holds
( H1(k + 1) < H1(k) or H1(k) = 0 ) by A6;
consider m being Nat such that
A8: H1(m) = 0 and
A9: for n being Nat st H1(n) = 0 holds
m <= n from NAT_1:sch 17(A7);
defpred S1[ Nat] means ( $1 + 1 <= m implies ex k being Element of NAT st (StepWhile>0 (a,I,P,s)) . ($1 + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),k) );
A10: now
let k be Element of NAT ; :: thesis: ( S1[k] implies S1[k + 1] )
assume A11: S1[k] ; :: thesis: S1[k + 1]
now
set sk1 = (StepWhile>0 (a,I,P,s)) . (k + 1);
set sk = (StepWhile>0 (a,I,P,s)) . k;
assume A12: (k + 1) + 1 <= m ; :: thesis: ex m being Element of NAT st (StepWhile>0 (a,I,P,s)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),m)
k + 0 < k + (1 + 1) by XREAL_1:6;
then k < m by A12, XXREAL_0:2;
then H1(k) <> 0 by A9;
then A13: ((StepWhile>0 (a,I,P,s)) . k) . a > 0 by A6;
A14: I is_halting_on (StepWhile>0 (a,I,P,s)) . k,P +* (while>0 (a,I)) by A1;
(k + 1) + 0 < (k + 1) + 1 by XREAL_1:6;
then consider n being Element of NAT such that
A15: (StepWhile>0 (a,I,P,s)) . (k + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),n) by A11, A12, XXREAL_0:2;
take m = n + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . (k + 1))))) + 3); :: thesis: (StepWhile>0 (a,I,P,s)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),m)
( (StepWhile>0 (a,I,P,s)) . (k + 1) = Comput ((P +* (while>0 (a,I))),(Initialize ((StepWhile>0 (a,I,P,s)) . k)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . k)))) + 3)) & I is_closed_on (StepWhile>0 (a,I,P,s)) . k,P +* (while>0 (a,I)) ) by A1, Def5;
then IC ((StepWhile>0 (a,I,P,s)) . (k + 1)) = 0 by A14, A13, Th47, A4;
hence (StepWhile>0 (a,I,P,s)) . ((k + 1) + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),m) by A15, Th52; :: thesis: verum
end;
hence S1[k + 1] ; :: thesis: verum
end;
A16: S1[ 0 ]
proof
assume 0 + 1 <= m ; :: thesis: ex k being Element of NAT st (StepWhile>0 (a,I,P,s)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),k)
take n = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3; :: thesis: (StepWhile>0 (a,I,P,s)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),n)
thus (StepWhile>0 (a,I,P,s)) . (0 + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),n) by Th51; :: thesis: verum
end;
A17: for k being Element of NAT holds S1[k] from NAT_1:sch 1(A16, A10);
now
per cases ( m = 0 or m <> 0 ) ;
suppose m = 0 ; :: thesis: ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P )
then ((StepWhile>0 (a,I,P,s)) . 0) . a <= 0 by A6, A8;
then s . a <= 0 by Def5;
hence ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P ) by Th43; :: thesis: verum
end;
suppose A18: m <> 0 ; :: thesis: ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P )
set p = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3;
set sm = (StepWhile>0 (a,I,P,s)) . m;
set sm1 = Initialize ((StepWhile>0 (a,I,P,s)) . m);
consider i being Nat such that
A19: m = i + 1 by A18, NAT_1:6;
reconsider i = i as Element of NAT by ORDINAL1:def 12;
m = i + 1 by A19;
then consider n being Element of NAT such that
A20: (StepWhile>0 (a,I,P,s)) . m = Comput ((P +* (while>0 (a,I))),(Initialize s),n) by A17;
set si = (StepWhile>0 (a,I,P,s)) . i;
i < m by A19, NAT_1:13;
then H1(i) <> 0 by A9;
then A21: ((StepWhile>0 (a,I,P,s)) . i) . a > 0 by A6;
A22: ( I is_closed_on (StepWhile>0 (a,I,P,s)) . i,P +* (while>0 (a,I)) & I is_halting_on (StepWhile>0 (a,I,P,s)) . i,P +* (while>0 (a,I)) ) by A1;
(StepWhile>0 (a,I,P,s)) . m = Comput ((P +* (while>0 (a,I))),(Initialize ((StepWhile>0 (a,I,P,s)) . i)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . i)))) + 3)) by A19, Def5;
then A24: IC ((StepWhile>0 (a,I,P,s)) . m) = 0 by A22, A21, Th47, A4;
(StepWhile>0 (a,I,P,s)) . m is 0 -started by A24, MEMSTR_0:def 9;
then Start-At (0,SCM+FSA) c= (StepWhile>0 (a,I,P,s)) . m by MEMSTR_0:29;
then A27: Initialize ((StepWhile>0 (a,I,P,s)) . m) = (StepWhile>0 (a,I,P,s)) . m by FUNCT_4:98;
A28: ((StepWhile>0 (a,I,P,s)) . m) . a <= 0 by A6, A8;
then while>0 (a,I) is_halting_on (StepWhile>0 (a,I,P,s)) . m,P +* (while>0 (a,I)) by Th43;
then (P +* (while>0 (a,I))) +* (while>0 (a,I)) halts_on Initialize ((StepWhile>0 (a,I,P,s)) . m) by SCMFSA7B:def 7;
then P +* (while>0 (a,I)) halts_on Initialize ((StepWhile>0 (a,I,P,s)) . m) by A5;
then consider j being Element of NAT such that
A29: CurInstr ((P +* (while>0 (a,I))),(Comput ((P +* (while>0 (a,I))),((StepWhile>0 (a,I,P,s)) . m),j))) = halt SCM+FSA by A27, EXTPRO_1:29;
A30: Comput ((P +* (while>0 (a,I))),(Initialize s),(n + j)) = Comput ((P +* (while>0 (a,I))),(Comput ((P +* (while>0 (a,I))),(Initialize s),n)),j) by EXTPRO_1:4;
CurInstr ((P +* (while>0 (a,I))),(Comput ((P +* (while>0 (a,I))),(Initialize s),(n + j)))) = halt SCM+FSA by A20, A29, A30;
then P +* (while>0 (a,I)) halts_on Initialize s by EXTPRO_1:29;
hence while>0 (a,I) is_halting_on s,P by SCMFSA7B:def 7; :: thesis: while>0 (a,I) is_closed_on s,P
now
let q be Element of NAT ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialize s),b1)) in dom (while>0 (a,I))
A31: 0 < m by A18;
per cases ( q <= (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3 or q > (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3 ) ;
suppose A32: q <= (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3 ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialize s),b1)) in dom (while>0 (a,I))
A33: (StepWhile>0 (a,I,P,s)) . 0 = s by Def5;
then A34: ( I is_closed_on s,P +* (while>0 (a,I)) & I is_halting_on s,P +* (while>0 (a,I)) ) by A1;
H1( 0 ) <> 0 by A9, A31;
then s . a > 0 by A6, A33;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialize s),q)) in dom (while>0 (a,I)) by A32, A34, Th47, A4; :: thesis: verum
end;
suppose A35: q > (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3 ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialize s),b1)) in dom (while>0 (a,I))
A36: now
take k = (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize s))) + 3; :: thesis: ( (StepWhile>0 (a,I,P,s)) . 1 = Comput ((P +* (while>0 (a,I))),(Initialize s),k) & k <= q )
thus ( (StepWhile>0 (a,I,P,s)) . 1 = Comput ((P +* (while>0 (a,I))),(Initialize s),k) & k <= q ) by A35, Th51; :: thesis: verum
end;
defpred S2[ Nat] means ( $1 <= m & $1 <> 0 & ex k being Element of NAT st
( (StepWhile>0 (a,I,P,s)) . $1 = Comput ((P +* (while>0 (a,I))),(Initialize s),k) & k <= q ) );
A37: for i being Nat st S2[i] holds
i <= m ;
0 + 1 < m + 1 by A31, XREAL_1:6;
then 1 <= m by NAT_1:13;
then A38: ex t being Nat st S2[t] by A36;
consider t being Nat such that
A39: ( S2[t] & ( for i being Nat st S2[i] holds
i <= t ) ) from NAT_1:sch 6(A37, A38);
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))),(Initialize s),q)) in dom (while>0 (a,I))
then consider r being Element of NAT such that
A40: (StepWhile>0 (a,I,P,s)) . m = Comput ((P +* (while>0 (a,I))),(Initialize s),r) and
A41: r <= q by A39;
consider x being Nat such that
A42: q = r + x by A41, NAT_1:10;
A43: while>0 (a,I) is_closed_on (StepWhile>0 (a,I,P,s)) . m,P +* (while>0 (a,I)) by A28, Th43;
reconsider x = x as Element of NAT by ORDINAL1:def 12;
A44: Comput ((P +* (while>0 (a,I))),(Initialize s),q) = Comput ((P +* (while>0 (a,I))),(Initialize ((StepWhile>0 (a,I,P,s)) . m)),x) by A27, A40, A42, EXTPRO_1:4;
thus IC (Comput ((P +* (while>0 (a,I))),(Initialize s),q)) in dom (while>0 (a,I)) by A43, A44, A5, SCMFSA7B:def 6; :: thesis: verum
end;
suppose A45: t <> m ; :: thesis: IC (Comput ((P +* (while>0 (a,I))),(Initialize s),q)) in dom (while>0 (a,I))
set Dt = (StepWhile>0 (a,I,P,s)) . t;
A46: t < m by A39, A45, XXREAL_0:1;
then H1(t) <> 0 by A9;
then A47: ((StepWhile>0 (a,I,P,s)) . t) . a > 0 by A6;
consider z being Element of NAT such that
A48: (StepWhile>0 (a,I,P,s)) . t = Comput ((P +* (while>0 (a,I))),(Initialize s),z) and
A49: z <= q by A39;
set z2 = z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . t)))) + 3);
consider w being Nat such that
A50: q = z + w by A49, NAT_1:10;
A51: ( I is_closed_on (StepWhile>0 (a,I,P,s)) . t,P +* (while>0 (a,I)) & I is_halting_on (StepWhile>0 (a,I,P,s)) . t,P +* (while>0 (a,I)) ) by A1;
consider y being Nat such that
A52: t = y + 1 by A39, NAT_1:6;
reconsider y = y as Element of NAT by ORDINAL1:def 12;
set Dy = (StepWhile>0 (a,I,P,s)) . y;
y + 0 < t by A52, XREAL_1:6;
then y < m by A39, XXREAL_0:2;
then H1(y) <> 0 by A9;
then A53: ((StepWhile>0 (a,I,P,s)) . y) . a > 0 by A6;
A54: ( I is_closed_on (StepWhile>0 (a,I,P,s)) . y,P +* (while>0 (a,I)) & I is_halting_on (StepWhile>0 (a,I,P,s)) . y,P +* (while>0 (a,I)) ) by A1;
reconsider w = w as Element of NAT by ORDINAL1:def 12;
(StepWhile>0 (a,I,P,s)) . t = Comput ((P +* (while>0 (a,I))),(Initialize ((StepWhile>0 (a,I,P,s)) . y)),((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . y)))) + 3)) by A52, Def5;
then A55: IC ((StepWhile>0 (a,I,P,s)) . t) = 0 by A54, A53, Th47, A4;
now
assume A56: z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . t)))) + 3) <= q ; :: thesis: contradiction
A57: now
take k = z + ((LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . t)))) + 3); :: thesis: ( (StepWhile>0 (a,I,P,s)) . (t + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),k) & k <= q )
thus ( (StepWhile>0 (a,I,P,s)) . (t + 1) = Comput ((P +* (while>0 (a,I))),(Initialize s),k) & k <= q ) by A48, A55, A56, Th52; :: thesis: verum
end;
t + 1 <= m by A46, NAT_1:13;
hence contradiction by A39, A57, XREAL_1:29; :: thesis: verum
end;
then A58: w < (LifeSpan (((P +* (while>0 (a,I))) +* I),(Initialize ((StepWhile>0 (a,I,P,s)) . t)))) + 3 by A50, XREAL_1:6;
A59: Initialize ((StepWhile>0 (a,I,P,s)) . t) = (StepWhile>0 (a,I,P,s)) . t by A48, A55, Th52;
Comput ((P +* (while>0 (a,I))),(Initialize s),q) = Comput ((P +* (while>0 (a,I))),(Initialize ((StepWhile>0 (a,I,P,s)) . t)),w) by A59, A48, A50, EXTPRO_1:4;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialize s),q)) in dom (while>0 (a,I)) by A58, A51, A47, Th47, A4; :: thesis: verum
end;
end;
end;
hence IC (Comput ((P +* (while>0 (a,I))),(Initialize s),q)) in dom (while>0 (a,I)) ; :: thesis: verum
end;
end;
end;
hence while>0 (a,I) is_closed_on s,P by SCMFSA7B:def 6; :: thesis: verum
end;
end;
end;
hence ( while>0 (a,I) is_halting_on s,P & while>0 (a,I) is_closed_on s,P ) ; :: thesis: verum