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_Values_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_Values_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_Values_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_Values_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 ) )

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_Values_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));
A2: (P +* (while=0 (a,I))) +* (while=0 (a,I)) = P +* (while=0 (a,I)) ;
given f being Function of (product (the_Values_of SCM+FSA)),NAT such that A3: 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);
A4: for k being Nat holds
( H1(k + 1) < H1(k) or H1(k) = 0 ) by A3;
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);
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) );
A7: now :: thesis: for k being Element of NAT st S1[k] holds
S1[k + 1]
let k be Element of NAT ; :: thesis: ( S1[k] implies S1[k + 1] )
assume A8: S1[k] ; :: thesis: S1[k + 1]
now :: thesis: ( (k + 1) + 1 <= m implies 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) )
set sk1 = (StepWhile=0 (a,I,P,s)) . (k + 1);
set sk = (StepWhile=0 (a,I,P,s)) . k;
assume A9: (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 A9, XXREAL_0:2;
then H1(k) <> 0 by A6;
then A10: ((StepWhile=0 (a,I,P,s)) . k) . a = 0 by A3;
A11: 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
A12: (StepWhile=0 (a,I,P,s)) . (k + 1) = Comput ((P +* (while=0 (a,I))),(Initialize s),n) by A8, A9, 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)
A13: (P +* (while=0 (a,I))) +* (while=0 (a,I)) = P +* (while=0 (a,I)) ;
( (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, Def4;
then IC ((StepWhile=0 (a,I,P,s)) . (k + 1)) = 0 by A11, A10, Th22, A13;
hence (StepWhile=0 (a,I,P,s)) . ((k + 1) + 1) = Comput ((P +* (while=0 (a,I))),(Initialize s),m) by A12, Th26; :: thesis: verum
end;
hence S1[k + 1] ; :: thesis: verum
end;
A14: 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 Th25; :: thesis: verum
end;
A15: for k being Element of NAT holds S1[k] from NAT_1:sch 1(A14, A7);
now :: thesis: ( while=0 (a,I) is_halting_on s,P & while=0 (a,I) is_closed_on s,P )
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 A3, A5;
then s . a <> 0 by Def4;
hence ( while=0 (a,I) is_halting_on s,P & while=0 (a,I) is_closed_on s,P ) by Th18; :: thesis: verum
end;
suppose A16: m <> 0 ; :: thesis: ( while=0 (a,I) is_halting_on s,P & while=0 (a,I) is_closed_on s,P )
then consider i being Nat such that
A17: m = i + 1 by NAT_1:6;
reconsider m = m, i = i as Element of NAT by ORDINAL1:def 12;
set sm = (StepWhile=0 (a,I,P,s)) . m;
set si = (StepWhile=0 (a,I,P,s)) . i;
i < m by A17, NAT_1:13;
then H1(i) <> 0 by A6;
then A18: ((StepWhile=0 (a,I,P,s)) . i) . a = 0 by A3;
A19: ( 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;
A20: IC in dom ((StepWhile=0 (a,I,P,s)) . m) by MEMSTR_0:2;
(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 A17, Def4;
then IC ((StepWhile=0 (a,I,P,s)) . m) = 0 by A19, A18, Th22, A2;
then (StepWhile=0 (a,I,P,s)) . m is 0 -started by A20, MEMSTR_0:def 11;
then A21: Start-At (0,SCM+FSA) c= (StepWhile=0 (a,I,P,s)) . m by MEMSTR_0:29;
set p = (LifeSpan (((P +* (while=0 (a,I))) +* I),(Initialize s))) + 3;
set sm1 = Initialize ((StepWhile=0 (a,I,P,s)) . m);
m = i + 1 by A17;
then consider n being Element of NAT such that
A22: (StepWhile=0 (a,I,P,s)) . m = Comput ((P +* (while=0 (a,I))),(Initialize s),n) by A15;
reconsider n = n as Element of NAT ;
A23: Initialize ((StepWhile=0 (a,I,P,s)) . m) = (StepWhile=0 (a,I,P,s)) . m by A21, FUNCT_4:98;
A24: ((StepWhile=0 (a,I,P,s)) . m) . a <> 0 by A3, A5;
then while=0 (a,I) is_halting_on (StepWhile=0 (a,I,P,s)) . m,P by Th18;
then P +* (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) ;
then P +* (while=0 (a,I)) halts_on Initialize ((StepWhile=0 (a,I,P,s)) . m) ;
then consider j being Element of NAT such that
A25: CurInstr ((P +* (while=0 (a,I))),(Comput ((P +* (while=0 (a,I))),((StepWhile=0 (a,I,P,s)) . m),j))) = halt SCM+FSA by A23, EXTPRO_1:29;
A26: 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 A22, A25, A26;
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 :: thesis: for q being Element of NAT holds IC (Comput ((P +* (while=0 (a,I))),(Initialize s),q)) in dom (while=0 (a,I))
let q be Element of NAT ; :: thesis: IC (Comput ((P +* (while=0 (a,I))),(Initialize s),b1)) in dom (while=0 (a,I))
A27: 0 < m by A16;
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 A28: 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))
A29: (StepWhile=0 (a,I,P,s)) . 0 = s by Def4;
then A30: ( 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 A6, A27;
then s . a = 0 by A3, A29;
hence IC (Comput ((P +* (while=0 (a,I))),(Initialize s),q)) in dom (while=0 (a,I)) by A28, A30, Th22, A2; :: thesis: verum
end;
suppose A31: 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))
A32: now :: thesis: 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 )
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 A31, Th25; :: 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 ) );
A33: for i being Nat st S2[i] holds
i <= m ;
0 + 1 < m + 1 by A27, XREAL_1:6;
then 1 <= m by NAT_1:13;
then A34: ex t being Nat st S2[t] by A32;
consider t being Nat such that
A35: ( S2[t] & ( for i being Nat st S2[i] holds
i <= t ) ) from NAT_1:sch 6(A33, A34);
reconsider t = t as Element of NAT by ORDINAL1:def 12;
now :: thesis: IC (Comput ((P +* (while=0 (a,I))),(Initialize s),q)) in dom (while=0 (a,I))
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
A36: (StepWhile=0 (a,I,P,s)) . m = Comput ((P +* (while=0 (a,I))),(Initialize s),r) and
A37: r <= q by A35;
consider x being Nat such that
A38: q = r + x by A37, NAT_1:10;
A39: while=0 (a,I) is_closed_on (StepWhile=0 (a,I,P,s)) . m,P by A24, Th18;
reconsider x = x as Element of NAT by ORDINAL1:def 12;
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 A23, A36, A38, EXTPRO_1:4;
hence IC (Comput ((P +* (while=0 (a,I))),(Initialize s),q)) in dom (while=0 (a,I)) by A39, SCMFSA7B:def 6; :: thesis: verum
end;
suppose A40: 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;
A41: t < m by A35, A40, XXREAL_0:1;
then H1(t) <> 0 by A6;
then A42: ((StepWhile=0 (a,I,P,s)) . t) . a = 0 by A3;
consider z being Element of NAT such that
A43: (StepWhile=0 (a,I,P,s)) . t = Comput ((P +* (while=0 (a,I))),(Initialize s),z) and
A44: z <= q by A35;
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
A45: q = z + w by A44, NAT_1:10;
A46: ( 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
A47: t = y + 1 by A35, 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 A47, XREAL_1:6;
then y < m by A35, XXREAL_0:2;
then H1(y) <> 0 by A6;
then A48: ((StepWhile=0 (a,I,P,s)) . y) . a = 0 by A3;
A49: ( 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 A47, Def4;
then A50: IC ((StepWhile=0 (a,I,P,s)) . t) = 0 by A49, A48, Th22, A2;
now :: thesis: not z + ((LifeSpan (((P +* (while=0 (a,I))) +* I),(Initialize ((StepWhile=0 (a,I,P,s)) . t)))) + 3) <= q
assume A51: z + ((LifeSpan (((P +* (while=0 (a,I))) +* I),(Initialize ((StepWhile=0 (a,I,P,s)) . t)))) + 3) <= q ; :: thesis: contradiction
A52: now :: thesis: ex k being Element of NAT st
( (StepWhile=0 (a,I,P,s)) . (t + 1) = Comput ((P +* (while=0 (a,I))),(Initialize s),k) & k <= q )
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 A43, A50, A51, Th26; :: thesis: verum
end;
t + 1 <= m by A41, NAT_1:13;
hence contradiction by A35, A52, XREAL_1:29; :: thesis: verum
end;
then A53: w < (LifeSpan (((P +* (while=0 (a,I))) +* I),(Initialize ((StepWhile=0 (a,I,P,s)) . t)))) + 3 by A45, XREAL_1:6;
A54: (StepWhile=0 (a,I,P,s)) . t = Initialize ((StepWhile=0 (a,I,P,s)) . t) by A43, A50, Th26;
Comput ((P +* (while=0 (a,I))),(Initialize s),q) = Comput ((P +* (while=0 (a,I))),(((StepWhile=0 (a,I,P,s)) . t) +* (Start-At (0,SCM+FSA))),w) by A54, A43, A45, EXTPRO_1:4;
hence IC (Comput ((P +* (while=0 (a,I))),(Initialize s),q)) in dom (while=0 (a,I)) by A53, A46, A42, Th22, A2; :: 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