:: SCM_HALT semantic presentation

definition
let c1 be Macro-Instruction;
attr a1 is InitClosed means :Def1: :: SCM_HALT:def 1
for b1 being State of SCM+FSA
for b2 being Nat st Initialized a1 c= b1 holds
IC ((Computation b1) . b2) in dom a1;
attr a1 is InitHalting means :Def2: :: SCM_HALT:def 2
Initialized a1 is halting;
attr a1 is keepInt0_1 means :Def3: :: SCM_HALT:def 3
for b1 being State of SCM+FSA st Initialized a1 c= b1 holds
for b2 being Nat holds ((Computation b1) . b2) . (intloc 0) = 1;
end;

:: deftheorem Def1 defines InitClosed SCM_HALT:def 1 :
for b1 being Macro-Instruction holds
( b1 is InitClosed iff for b2 being State of SCM+FSA
for b3 being Nat st Initialized b1 c= b2 holds
IC ((Computation b2) . b3) in dom b1 );

:: deftheorem Def2 defines InitHalting SCM_HALT:def 2 :
for b1 being Macro-Instruction holds
( b1 is InitHalting iff Initialized b1 is halting );

:: deftheorem Def3 defines keepInt0_1 SCM_HALT:def 3 :
for b1 being Macro-Instruction holds
( b1 is keepInt0_1 iff for b2 being State of SCM+FSA st Initialized b1 c= b2 holds
for b3 being Nat holds ((Computation b2) . b3) . (intloc 0) = 1 );

theorem Th1: :: SCM_HALT:1
for b1 being set
for b2, b3, b4 being Nat holds
( not b1 in dom (((intloc b2) .--> b3) +* (Start-At (insloc b4))) or b1 = intloc b2 or b1 = IC SCM+FSA )
proof end;

theorem Th2: :: SCM_HALT:2
for b1 being Macro-Instruction
for b2, b3, b4 being Nat holds dom b1 misses dom (((intloc b2) .--> b3) +* (Start-At (insloc b4)))
proof end;

set c1 = ((intloc 0) .--> 1) +* (Start-At (insloc 0));

theorem Th3: :: SCM_HALT:3
for b1 being Macro-Instruction holds Initialized b1 = b1 +* (((intloc 0) .--> 1) +* (Start-At (insloc 0)))
proof end;

theorem Th4: :: SCM_HALT:4
Macro (halt SCM+FSA ) is InitHalting
proof end;

registration
cluster InitHalting FinPartState of SCM+FSA ;
existence
ex b1 being Macro-Instruction st b1 is InitHalting
by Th4;
end;

theorem Th5: :: SCM_HALT:5
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction st Initialized b2 c= b1 holds
b1 is halting
proof end;

theorem Th6: :: SCM_HALT:6
for b1 being Macro-Instruction holds b1 +* (Start-At (insloc 0)) c= Initialized b1
proof end;

theorem Th7: :: SCM_HALT:7
for b1 being Macro-Instruction
for b2 being State of SCM+FSA st Initialized b1 c= b2 holds
b2 . (intloc 0) = 1
proof end;

registration
cluster paraclosed -> InitClosed FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is paraclosed holds
b1 is InitClosed
proof end;
end;

registration
cluster parahalting -> InitHalting FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is parahalting holds
b1 is InitHalting
proof end;
end;

registration
cluster InitHalting -> InitClosed FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is InitHalting holds
b1 is InitClosed
proof end;
cluster keepInt0_1 -> InitClosed FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is keepInt0_1 holds
b1 is InitClosed
proof end;
cluster keeping_0 -> keepInt0_1 FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is keeping_0 holds
b1 is keepInt0_1
proof end;
end;

theorem Th8: :: SCM_HALT:8
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction
for b3 being read-write Int-Location st not b3 in UsedIntLoc b2 holds
(IExec b2,b1) . b3 = b1 . b3
proof end;

theorem Th9: :: SCM_HALT:9
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction
for b3 being FinSeq-Location st not b3 in UsedInt*Loc b2 holds
(IExec b2,b1) . b3 = b1 . b3
proof end;

registration
let c2 be InitHalting Macro-Instruction;
cluster Initialized a1 -> halting ;
coherence
Initialized c2 is halting
by Def2;
end;

registration
cluster InitHalting -> non empty FinPartState of SCM+FSA ;
coherence
for b1 being Macro-Instruction st b1 is InitHalting holds
not b1 is empty
proof end;
end;

theorem Th10: :: SCM_HALT:10
for b1 being InitHalting Macro-Instruction holds dom b1 <> {}
proof end;

theorem Th11: :: SCM_HALT:11
for b1 being InitHalting Macro-Instruction holds insloc 0 in dom b1
proof end;

theorem Th12: :: SCM_HALT:12
for b1, b2 being State of SCM+FSA
for b3 being InitHalting Macro-Instruction st Initialized b3 c= b1 holds
for b4 being Nat st ProgramPart (Relocated b3,b4) c= b2 & IC b2 = insloc b4 & b1 | (Int-Locations \/ FinSeq-Locations ) = b2 | (Int-Locations \/ FinSeq-Locations ) holds
for b5 being Nat holds
( (IC ((Computation b1) . b5)) + b4 = IC ((Computation b2) . b5) & IncAddr (CurInstr ((Computation b1) . b5)),b4 = CurInstr ((Computation b2) . b5) & ((Computation b1) . b5) | (Int-Locations \/ FinSeq-Locations ) = ((Computation b2) . b5) | (Int-Locations \/ FinSeq-Locations ) )
proof end;

theorem Th13: :: SCM_HALT:13
for b1 being Macro-Instruction
for b2 being State of SCM+FSA st Initialized b1 c= b2 holds
b1 c= b2
proof end;

theorem Th14: :: SCM_HALT:14
for b1, b2 being State of SCM+FSA
for b3 being InitHalting Macro-Instruction st Initialized b3 c= b1 & Initialized b3 c= b2 & b1,b2 equal_outside the Instruction-Locations of SCM+FSA holds
for b4 being Nat holds
( (Computation b1) . b4,(Computation b2) . b4 equal_outside the Instruction-Locations of SCM+FSA & CurInstr ((Computation b1) . b4) = CurInstr ((Computation b2) . b4) )
proof end;

theorem Th15: :: SCM_HALT:15
for b1, b2 being State of SCM+FSA
for b3 being InitHalting Macro-Instruction st Initialized b3 c= b1 & Initialized b3 c= b2 & b1,b2 equal_outside the Instruction-Locations of SCM+FSA holds
( LifeSpan b1 = LifeSpan b2 & Result b1, Result b2 equal_outside the Instruction-Locations of SCM+FSA )
proof end;

registration
cluster non empty keeping_0 InitClosed InitHalting keepInt0_1 FinPartState of SCM+FSA ;
existence
ex b1 being Macro-Instruction st
( b1 is keeping_0 & b1 is InitHalting )
proof end;
end;

registration
cluster non empty InitClosed InitHalting keepInt0_1 FinPartState of SCM+FSA ;
existence
ex b1 being Macro-Instruction st
( b1 is keepInt0_1 & b1 is InitHalting )
proof end;
end;

theorem Th16: :: SCM_HALT:16
canceled;

theorem Th17: :: SCM_HALT:17
for b1 being State of SCM+FSA
for b2 being InitHalting keepInt0_1 Macro-Instruction holds (IExec b2,b1) . (intloc 0) = 1
proof end;

theorem Th18: :: SCM_HALT:18
for b1 being State of SCM+FSA
for b2 being InitClosed Macro-Instruction
for b3 being Macro-Instruction st Initialized b2 c= b1 & b1 is halting holds
for b4 being Nat st b4 <= LifeSpan b1 holds
(Computation b1) . b4,(Computation (b1 +* (b2 ';' b3))) . b4 equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th19: :: SCM_HALT:19
for b1 being Macro-Instruction
for b2 being State of SCM+FSA
for b3, b4, b5 being Nat holds (b2 +* b1) +* (((intloc b3) .--> b4) +* (Start-At (insloc b5))) = (b2 +* (((intloc b3) .--> b4) +* (Start-At (insloc b5)))) +* b1
proof end;

theorem Th20: :: SCM_HALT:20
for b1 being Macro-Instruction
for b2 being State of SCM+FSA st ((intloc 0) .--> 1) +* (Start-At (insloc 0)) c= b2 holds
( Initialized b1 c= b2 +* (b1 +* (((intloc 0) .--> 1) +* (Start-At (insloc 0)))) & b2 +* (b1 +* (((intloc 0) .--> 1) +* (Start-At (insloc 0)))) = b2 +* b1 & (b2 +* (b1 +* (((intloc 0) .--> 1) +* (Start-At (insloc 0))))) +* (Directed b1) = b2 +* (Directed b1) )
proof end;

theorem Th21: :: SCM_HALT:21
for b1 being State of SCM+FSA
for b2 being InitClosed Macro-Instruction st b1 +* b2 is halting & Directed b2 c= b1 & ((intloc 0) .--> 1) +* (Start-At (insloc 0)) c= b1 holds
IC ((Computation b1) . ((LifeSpan (b1 +* b2)) + 1)) = insloc (card b2)
proof end;

theorem Th22: :: SCM_HALT:22
for b1 being State of SCM+FSA
for b2 being InitClosed Macro-Instruction st b1 +* b2 is halting & Directed b2 c= b1 & ((intloc 0) .--> 1) +* (Start-At (insloc 0)) c= b1 holds
((Computation b1) . (LifeSpan (b1 +* b2))) | (Int-Locations \/ FinSeq-Locations ) = ((Computation b1) . ((LifeSpan (b1 +* b2)) + 1)) | (Int-Locations \/ FinSeq-Locations )
proof end;

theorem Th23: :: SCM_HALT:23
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction st Initialized b2 c= b1 holds
for b3 being Nat st b3 <= LifeSpan b1 holds
CurInstr ((Computation (b1 +* (Directed b2))) . b3) <> halt SCM+FSA
proof end;

theorem Th24: :: SCM_HALT:24
for b1 being State of SCM+FSA
for b2 being InitClosed Macro-Instruction st b1 +* (Initialized b2) is halting holds
for b3 being Macro-Instruction
for b4 being Nat st b4 <= LifeSpan (b1 +* (Initialized b2)) holds
(Computation (b1 +* (Initialized b2))) . b4,(Computation (b1 +* (Initialized (b2 ';' b3)))) . b4 equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th25: :: SCM_HALT:25
for b1 being InitHalting keepInt0_1 Macro-Instruction
for b2 being InitHalting Macro-Instruction
for b3 being State of SCM+FSA st Initialized (b1 ';' b2) c= b3 holds
( IC ((Computation b3) . ((LifeSpan (b3 +* b1)) + 1)) = insloc (card b1) & ((Computation b3) . ((LifeSpan (b3 +* b1)) + 1)) | (Int-Locations \/ FinSeq-Locations ) = (((Computation (b3 +* b1)) . (LifeSpan (b3 +* b1))) +* (Initialized b2)) | (Int-Locations \/ FinSeq-Locations ) & ProgramPart (Relocated b2,(card b1)) c= (Computation b3) . ((LifeSpan (b3 +* b1)) + 1) & ((Computation b3) . ((LifeSpan (b3 +* b1)) + 1)) . (intloc 0) = 1 & b3 is halting & LifeSpan b3 = ((LifeSpan (b3 +* b1)) + 1) + (LifeSpan ((Result (b3 +* b1)) +* (Initialized b2))) & ( b2 is keeping_0 implies (Result b3) . (intloc 0) = 1 ) )
proof end;

registration
let c2 be InitHalting keepInt0_1 Macro-Instruction;
let c3 be InitHalting Macro-Instruction;
cluster a1 ';' a2 -> non empty InitClosed InitHalting ;
coherence
c2 ';' c3 is InitHalting
proof end;
end;

theorem Th26: :: SCM_HALT:26
for b1 being State of SCM+FSA
for b2 being keepInt0_1 Macro-Instruction st b1 +* b2 is halting holds
for b3 being InitClosed Macro-Instruction st Initialized (b2 ';' b3) c= b1 holds
for b4 being Nat holds ((Computation ((Result (b1 +* b2)) +* (Initialized b3))) . b4) +* (Start-At ((IC ((Computation ((Result (b1 +* b2)) +* (Initialized b3))) . b4)) + (card b2))),(Computation (b1 +* (b2 ';' b3))) . (((LifeSpan (b1 +* b2)) + 1) + b4) equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th27: :: SCM_HALT:27
for b1 being State of SCM+FSA
for b2 being keepInt0_1 Macro-Instruction st not b1 +* (Initialized b2) is halting holds
for b3 being Macro-Instruction
for b4 being Nat holds (Computation (b1 +* (Initialized b2))) . b4,(Computation (b1 +* (Initialized (b2 ';' b3)))) . b4 equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th28: :: SCM_HALT:28
for b1 being State of SCM+FSA
for b2 being InitHalting keepInt0_1 Macro-Instruction
for b3 being InitHalting Macro-Instruction holds LifeSpan (b1 +* (Initialized (b2 ';' b3))) = ((LifeSpan (b1 +* (Initialized b2))) + 1) + (LifeSpan ((Result (b1 +* (Initialized b2))) +* (Initialized b3)))
proof end;

theorem Th29: :: SCM_HALT:29
for b1 being State of SCM+FSA
for b2 being InitHalting keepInt0_1 Macro-Instruction
for b3 being InitHalting Macro-Instruction holds IExec (b2 ';' b3),b1 = (IExec b3,(IExec b2,b1)) +* (Start-At ((IC (IExec b3,(IExec b2,b1))) + (card b2)))
proof end;

registration
let c2 be parahalting Instruction of SCM+FSA ;
cluster Macro a1 -> InitClosed InitHalting ;
coherence
Macro c2 is InitHalting
;
end;

registration
let c2 be parahalting Instruction of SCM+FSA ;
let c3 be parahalting Macro-Instruction;
cluster a1 ';' a2 -> InitClosed InitHalting ;
coherence
c2 ';' c3 is InitHalting
;
end;

registration
let c2 be parahalting keeping_0 Instruction of SCM+FSA ;
let c3 be InitHalting Macro-Instruction;
cluster a1 ';' a2 -> non empty InitClosed InitHalting ;
coherence
c2 ';' c3 is InitHalting
proof end;
end;

registration
let c2, c3 be keepInt0_1 Macro-Instruction;
cluster a1 ';' a2 -> InitClosed keepInt0_1 ;
coherence
c2 ';' c3 is keepInt0_1
proof end;
end;

registration
let c2 be parahalting keeping_0 Instruction of SCM+FSA ;
let c3 be InitHalting keepInt0_1 Macro-Instruction;
cluster a2 ';' a1 -> non empty InitClosed InitHalting keepInt0_1 ;
coherence
( c3 ';' c2 is InitHalting & c3 ';' c2 is keepInt0_1 )
proof end;
end;

registration
let c2 be parahalting keeping_0 Instruction of SCM+FSA ;
let c3 be InitHalting keepInt0_1 Macro-Instruction;
cluster a1 ';' a2 -> non empty InitClosed InitHalting keepInt0_1 ;
coherence
( c2 ';' c3 is InitHalting & c2 ';' c3 is keepInt0_1 )
proof end;
end;

registration
let c2 be parahalting Instruction of SCM+FSA ;
let c3 be parahalting Macro-Instruction;
cluster a2 ';' a1 -> InitClosed InitHalting ;
coherence
c3 ';' c2 is InitHalting
;
end;

registration
let c2, c3 be parahalting Instruction of SCM+FSA ;
cluster a1 ';' a2 -> InitClosed InitHalting ;
coherence
c2 ';' c3 is InitHalting
;
end;

theorem Th30: :: SCM_HALT:30
for b1 being State of SCM+FSA
for b2 being Int-Location
for b3 being InitHalting keepInt0_1 Macro-Instruction
for b4 being InitHalting Macro-Instruction holds (IExec (b3 ';' b4),b1) . b2 = (IExec b4,(IExec b3,b1)) . b2
proof end;

theorem Th31: :: SCM_HALT:31
for b1 being State of SCM+FSA
for b2 being FinSeq-Location
for b3 being InitHalting keepInt0_1 Macro-Instruction
for b4 being InitHalting Macro-Instruction holds (IExec (b3 ';' b4),b1) . b2 = (IExec b4,(IExec b3,b1)) . b2
proof end;

theorem Th32: :: SCM_HALT:32
for b1 being InitHalting keepInt0_1 Macro-Instruction
for b2 being State of SCM+FSA holds (Initialize (IExec b1,b2)) | (Int-Locations \/ FinSeq-Locations ) = (IExec b1,b2) | (Int-Locations \/ FinSeq-Locations )
proof end;

theorem Th33: :: SCM_HALT:33
for b1 being State of SCM+FSA
for b2 being Int-Location
for b3 being InitHalting keepInt0_1 Macro-Instruction
for b4 being parahalting Instruction of SCM+FSA holds (IExec (b3 ';' b4),b1) . b2 = (Exec b4,(IExec b3,b1)) . b2
proof end;

theorem Th34: :: SCM_HALT:34
for b1 being State of SCM+FSA
for b2 being FinSeq-Location
for b3 being InitHalting keepInt0_1 Macro-Instruction
for b4 being parahalting Instruction of SCM+FSA holds (IExec (b3 ';' b4),b1) . b2 = (Exec b4,(IExec b3,b1)) . b2
proof end;

definition
let c2 be Macro-Instruction;
let c3 be State of SCM+FSA ;
pred c1 is_closed_onInit c2 means :Def4: :: SCM_HALT:def 4
for b1 being Nat holds IC ((Computation (a2 +* (Initialized a1))) . b1) in dom a1;
pred c1 is_halting_onInit c2 means :Def5: :: SCM_HALT:def 5
a2 +* (Initialized a1) is halting;
end;

:: deftheorem Def4 defines is_closed_onInit SCM_HALT:def 4 :
for b1 being Macro-Instruction
for b2 being State of SCM+FSA holds
( b1 is_closed_onInit b2 iff for b3 being Nat holds IC ((Computation (b2 +* (Initialized b1))) . b3) in dom b1 );

:: deftheorem Def5 defines is_halting_onInit SCM_HALT:def 5 :
for b1 being Macro-Instruction
for b2 being State of SCM+FSA holds
( b1 is_halting_onInit b2 iff b2 +* (Initialized b1) is halting );

theorem Th35: :: SCM_HALT:35
for b1 being Macro-Instruction holds
( b1 is InitClosed iff for b2 being State of SCM+FSA holds b1 is_closed_onInit b2 )
proof end;

theorem Th36: :: SCM_HALT:36
for b1 being Macro-Instruction holds
( b1 is InitHalting iff for b2 being State of SCM+FSA holds b1 is_halting_onInit b2 )
proof end;

theorem Th37: :: SCM_HALT:37
for b1 being State of SCM+FSA
for b2 being Macro-Instruction
for b3 being Int-Location st b2 does_not_destroy b3 & b2 is_closed_onInit b1 & Initialized b2 c= b1 holds
for b4 being Nat holds ((Computation b1) . b4) . b3 = b1 . b3
proof end;

registration
cluster non empty good InitClosed InitHalting FinPartState of SCM+FSA ;
existence
ex b1 being Macro-Instruction st
( b1 is InitHalting & b1 is good )
proof end;
end;

registration
cluster good InitClosed -> InitClosed keepInt0_1 FinPartState of SCM+FSA ;
correctness
coherence
for b1 being Macro-Instruction st b1 is InitClosed & b1 is good holds
b1 is keepInt0_1
;
proof end;
end;

registration
cluster SCM+FSA-Stop -> good InitClosed InitHalting keepInt0_1 ;
coherence
( SCM+FSA-Stop is InitHalting & SCM+FSA-Stop is good )
;
end;

theorem Th38: :: SCM_HALT:38
for b1 being State of SCM+FSA
for b2 being parahalting keeping_0 Instruction of SCM+FSA
for b3 being InitHalting Macro-Instruction
for b4 being Int-Location holds (IExec (b2 ';' b3),b1) . b4 = (IExec b3,(Exec b2,(Initialize b1))) . b4
proof end;

theorem Th39: :: SCM_HALT:39
for b1 being State of SCM+FSA
for b2 being parahalting keeping_0 Instruction of SCM+FSA
for b3 being InitHalting Macro-Instruction
for b4 being FinSeq-Location holds (IExec (b2 ';' b3),b1) . b4 = (IExec b3,(Exec b2,(Initialize b1))) . b4
proof end;

theorem Th40: :: SCM_HALT:40
for b1 being State of SCM+FSA
for b2 being Macro-Instruction holds
( b2 is_closed_onInit b1 iff b2 is_closed_on Initialize b1 )
proof end;

theorem Th41: :: SCM_HALT:41
for b1 being State of SCM+FSA
for b2 being Macro-Instruction holds
( b2 is_halting_onInit b1 iff b2 is_halting_on Initialize b1 )
proof end;

theorem Th42: :: SCM_HALT:42
for b1 being Macro-Instruction
for b2 being State of SCM+FSA holds IExec b1,b2 = IExec b1,(Initialize b2)
proof end;

theorem Th43: :: SCM_HALT:43
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 = 0 & b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
( if=0 b4,b2,b3 is_closed_onInit b1 & if=0 b4,b2,b3 is_halting_onInit b1 )
proof end;

theorem Th44: :: SCM_HALT:44
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 = 0 & b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
IExec (if=0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3)))
proof end;

theorem Th45: :: SCM_HALT:45
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 <> 0 & b3 is_closed_onInit b1 & b3 is_halting_onInit b1 holds
( if=0 b4,b2,b3 is_closed_onInit b1 & if=0 b4,b2,b3 is_halting_onInit b1 )
proof end;

theorem Th46: :: SCM_HALT:46
for b1, b2 being Macro-Instruction
for b3 being read-write Int-Location
for b4 being State of SCM+FSA st b4 . b3 <> 0 & b2 is_closed_onInit b4 & b2 is_halting_onInit b4 holds
IExec (if=0 b3,b1,b2),b4 = (IExec b2,b4) +* (Start-At (insloc (((card b1) + (card b2)) + 3)))
proof end;

theorem Th47: :: SCM_HALT:47
for b1 being State of SCM+FSA
for b2, b3 being InitHalting Macro-Instruction
for b4 being read-write Int-Location holds
( if=0 b4,b2,b3 is InitHalting & ( b1 . b4 = 0 implies IExec (if=0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3))) ) & ( b1 . b4 <> 0 implies IExec (if=0 b4,b2,b3),b1 = (IExec b3,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3))) ) )
proof end;

theorem Th48: :: SCM_HALT:48
for b1 being State of SCM+FSA
for b2, b3 being InitHalting Macro-Instruction
for b4 being read-write Int-Location holds
( IC (IExec (if=0 b4,b2,b3),b1) = insloc (((card b2) + (card b3)) + 3) & ( b1 . b4 = 0 implies ( ( for b5 being Int-Location holds (IExec (if=0 b4,b2,b3),b1) . b5 = (IExec b2,b1) . b5 ) & ( for b5 being FinSeq-Location holds (IExec (if=0 b4,b2,b3),b1) . b5 = (IExec b2,b1) . b5 ) ) ) & ( b1 . b4 <> 0 implies ( ( for b5 being Int-Location holds (IExec (if=0 b4,b2,b3),b1) . b5 = (IExec b3,b1) . b5 ) & ( for b5 being FinSeq-Location holds (IExec (if=0 b4,b2,b3),b1) . b5 = (IExec b3,b1) . b5 ) ) ) )
proof end;

theorem Th49: :: SCM_HALT:49
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 > 0 & b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
( if>0 b4,b2,b3 is_closed_onInit b1 & if>0 b4,b2,b3 is_halting_onInit b1 )
proof end;

theorem Th50: :: SCM_HALT:50
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 > 0 & b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
IExec (if>0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3)))
proof end;

theorem Th51: :: SCM_HALT:51
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 <= 0 & b3 is_closed_onInit b1 & b3 is_halting_onInit b1 holds
( if>0 b4,b2,b3 is_closed_onInit b1 & if>0 b4,b2,b3 is_halting_onInit b1 )
proof end;

theorem Th52: :: SCM_HALT:52
for b1, b2 being Macro-Instruction
for b3 being read-write Int-Location
for b4 being State of SCM+FSA st b4 . b3 <= 0 & b2 is_closed_onInit b4 & b2 is_halting_onInit b4 holds
IExec (if>0 b3,b1,b2),b4 = (IExec b2,b4) +* (Start-At (insloc (((card b1) + (card b2)) + 3)))
proof end;

theorem Th53: :: SCM_HALT:53
for b1 being State of SCM+FSA
for b2, b3 being InitHalting Macro-Instruction
for b4 being read-write Int-Location holds
( if>0 b4,b2,b3 is InitHalting & ( b1 . b4 > 0 implies IExec (if>0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3))) ) & ( b1 . b4 <= 0 implies IExec (if>0 b4,b2,b3),b1 = (IExec b3,b1) +* (Start-At (insloc (((card b2) + (card b3)) + 3))) ) )
proof end;

theorem Th54: :: SCM_HALT:54
for b1 being State of SCM+FSA
for b2, b3 being InitHalting Macro-Instruction
for b4 being read-write Int-Location holds
( IC (IExec (if>0 b4,b2,b3),b1) = insloc (((card b2) + (card b3)) + 3) & ( b1 . b4 > 0 implies ( ( for b5 being Int-Location holds (IExec (if>0 b4,b2,b3),b1) . b5 = (IExec b2,b1) . b5 ) & ( for b5 being FinSeq-Location holds (IExec (if>0 b4,b2,b3),b1) . b5 = (IExec b2,b1) . b5 ) ) ) & ( b1 . b4 <= 0 implies ( ( for b5 being Int-Location holds (IExec (if>0 b4,b2,b3),b1) . b5 = (IExec b3,b1) . b5 ) & ( for b5 being FinSeq-Location holds (IExec (if>0 b4,b2,b3),b1) . b5 = (IExec b3,b1) . b5 ) ) ) )
proof end;

theorem Th55: :: SCM_HALT:55
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 < 0 & b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
IExec (if<0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc ((((card b2) + (card b3)) + (card b3)) + 7)))
proof end;

theorem Th56: :: SCM_HALT:56
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 = 0 & b3 is_closed_onInit b1 & b3 is_halting_onInit b1 holds
IExec (if<0 b4,b2,b3),b1 = (IExec b3,b1) +* (Start-At (insloc ((((card b2) + (card b3)) + (card b3)) + 7)))
proof end;

theorem Th57: :: SCM_HALT:57
for b1 being State of SCM+FSA
for b2, b3 being Macro-Instruction
for b4 being read-write Int-Location st b1 . b4 > 0 & b3 is_closed_onInit b1 & b3 is_halting_onInit b1 holds
IExec (if<0 b4,b2,b3),b1 = (IExec b3,b1) +* (Start-At (insloc ((((card b2) + (card b3)) + (card b3)) + 7)))
proof end;

theorem Th58: :: SCM_HALT:58
for b1 being State of SCM+FSA
for b2, b3 being InitHalting Macro-Instruction
for b4 being read-write Int-Location holds
( if<0 b4,b2,b3 is InitHalting & ( b1 . b4 < 0 implies IExec (if<0 b4,b2,b3),b1 = (IExec b2,b1) +* (Start-At (insloc ((((card b2) + (card b3)) + (card b3)) + 7))) ) & ( b1 . b4 >= 0 implies IExec (if<0 b4,b2,b3),b1 = (IExec b3,b1) +* (Start-At (insloc ((((card b2) + (card b3)) + (card b3)) + 7))) ) )
proof end;

registration
let c2, c3 be InitHalting Macro-Instruction;
let c4 be read-write Int-Location ;
cluster if=0 a3,a1,a2 -> non empty InitClosed InitHalting ;
correctness
coherence
if=0 c4,c2,c3 is InitHalting
;
by Th47;
cluster if>0 a3,a1,a2 -> non empty InitClosed InitHalting ;
correctness
coherence
if>0 c4,c2,c3 is InitHalting
;
by Th53;
cluster if<0 a3,a1,a2 -> non empty InitClosed InitHalting ;
correctness
coherence
if<0 c4,c2,c3 is InitHalting
;
by Th58;
end;

theorem Th59: :: SCM_HALT:59
for b1 being Macro-Instruction holds
( b1 is InitHalting iff for b2 being State of SCM+FSA holds b1 is_halting_on Initialize b2 )
proof end;

theorem Th60: :: SCM_HALT:60
for b1 being Macro-Instruction holds
( b1 is InitClosed iff for b2 being State of SCM+FSA holds b1 is_closed_on Initialize b2 )
proof end;

theorem Th61: :: SCM_HALT:61
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction
for b3 being read-write Int-Location holds (IExec b2,b1) . b3 = ((Computation ((Initialize b1) +* (b2 +* (Start-At (insloc 0))))) . (LifeSpan ((Initialize b1) +* (b2 +* (Start-At (insloc 0)))))) . b3
proof end;

theorem Th62: :: SCM_HALT:62
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction
for b3 being Int-Location
for b4 being Nat st b2 does_not_destroy b3 holds
(IExec b2,b1) . b3 = ((Computation ((Initialize b1) +* (b2 +* (Start-At (insloc 0))))) . b4) . b3
proof end;

set c2 = the Instruction-Locations of SCM+FSA ;

set c3 = Int-Locations \/ FinSeq-Locations ;

theorem Th63: :: SCM_HALT:63
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction
for b3 being Int-Location st b2 does_not_destroy b3 holds
(IExec b2,b1) . b3 = (Initialize b1) . b3
proof end;

theorem Th64: :: SCM_HALT:64
for b1 being State of SCM+FSA
for b2 being InitHalting keepInt0_1 Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 holds
((Computation ((Initialize b1) +* ((b2 ';' (SubFrom b3,(intloc 0))) +* (Start-At (insloc 0))))) . (LifeSpan ((Initialize b1) +* ((b2 ';' (SubFrom b3,(intloc 0))) +* (Start-At (insloc 0)))))) . b3 = (b1 . b3) - 1
proof end;

theorem Th65: :: SCM_HALT:65
for b1 being State of SCM+FSA
for b2 being InitClosed Macro-Instruction st Initialized b2 c= b1 & b1 is halting holds
for b3 being Nat st b3 <= LifeSpan b1 holds
(Computation b1) . b3,(Computation (b1 +* (loop b2))) . b3 equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th66: :: SCM_HALT:66
for b1 being State of SCM+FSA
for b2 being InitHalting Macro-Instruction st Initialized b2 c= b1 holds
for b3 being Nat st b3 <= LifeSpan b1 holds
CurInstr ((Computation (b1 +* (loop b2))) . b3) <> halt SCM+FSA
proof end;

theorem Th67: :: SCM_HALT:67
for b1 being Macro-Instruction
for b2 being State of SCM+FSA holds b1 c= b2 +* (Initialized b1)
proof end;

theorem Th68: :: SCM_HALT:68
for b1 being State of SCM+FSA
for b2 being Macro-Instruction st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
for b3 being Nat st b3 <= LifeSpan (b1 +* (Initialized b2)) holds
(Computation (b1 +* (Initialized b2))) . b3,(Computation (b1 +* (Initialized (loop b2)))) . b3 equal_outside the Instruction-Locations of SCM+FSA
proof end;

theorem Th69: :: SCM_HALT:69
for b1 being State of SCM+FSA
for b2 being Macro-Instruction st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
for b3 being Nat st b3 < LifeSpan (b1 +* (Initialized b2)) holds
CurInstr ((Computation (b1 +* (Initialized b2))) . b3) = CurInstr ((Computation (b1 +* (Initialized (loop b2)))) . b3)
proof end;

theorem Th70: :: SCM_HALT:70
for b1 being Instruction-Location of SCM+FSA holds not b1 in dom (((intloc 0) .--> 1) +* (Start-At (insloc 0)))
proof end;

theorem Th71: :: SCM_HALT:71
for b1 being State of SCM+FSA
for b2 being Macro-Instruction st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
( CurInstr ((Computation (b1 +* (Initialized (loop b2)))) . (LifeSpan (b1 +* (Initialized b2)))) = goto (insloc 0) & ( for b3 being Nat st b3 <= LifeSpan (b1 +* (Initialized b2)) holds
CurInstr ((Computation (b1 +* (Initialized (loop b2)))) . b3) <> halt SCM+FSA ) )
proof end;

theorem Th72: :: SCM_HALT:72
for b1 being State of SCM+FSA
for b2 being Macro-Instruction st b2 is_closed_onInit b1 & b2 is_halting_onInit b1 holds
CurInstr ((Computation (b1 +* (Initialized (loop b2)))) . (LifeSpan (b1 +* (Initialized b2)))) = goto (insloc 0) by Th71;

theorem Th73: :: SCM_HALT:73
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 & b1 . (intloc 0) = 1 & b1 . b3 > 0 holds
loop (if=0 b3,(Goto (insloc 2)),(b2 ';' (SubFrom b3,(intloc 0)))) is_pseudo-closed_on b1
proof end;

theorem Th74: :: SCM_HALT:74
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 & b1 . b3 > 0 holds
Initialized (loop (if=0 b3,(Goto (insloc 2)),(b2 ';' (SubFrom b3,(intloc 0))))) is_pseudo-closed_on b1
proof end;

theorem Th75: :: SCM_HALT:75
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 & b1 . (intloc 0) = 1 holds
( Times b3,b2 is_closed_on b1 & Times b3,b2 is_halting_on b1 )
proof end;

theorem Th76: :: SCM_HALT:76
for b1 being good InitHalting Macro-Instruction
for b2 being read-write Int-Location st b1 does_not_destroy b2 holds
Initialized (Times b2,b1) is halting
proof end;

registration
let c4 be read-write Int-Location ;
let c5 be good Macro-Instruction;
cluster Times a1,a2 -> good ;
coherence
Times c4,c5 is good
proof end;
end;

theorem Th77: :: SCM_HALT:77
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 & b1 . b3 > 0 holds
ex b4 being State of SCM+FSA ex b5 being Nat st
( b4 = b1 +* (Initialized (loop (if=0 b3,(Goto (insloc 2)),(b2 ';' (SubFrom b3,(intloc 0)))))) & b5 = (LifeSpan (b1 +* (Initialized (if=0 b3,(Goto (insloc 2)),(b2 ';' (SubFrom b3,(intloc 0))))))) + 1 & ((Computation b4) . b5) . b3 = (b1 . b3) - 1 & ((Computation b4) . b5) . (intloc 0) = 1 & ( for b6 being read-write Int-Location st b6 <> b3 holds
((Computation b4) . b5) . b6 = (IExec b2,b1) . b6 ) & ( for b6 being FinSeq-Location holds ((Computation b4) . b5) . b6 = (IExec b2,b1) . b6 ) & IC ((Computation b4) . b5) = insloc 0 & ( for b6 being Nat st b6 <= b5 holds
IC ((Computation b4) . b6) in dom (loop (if=0 b3,(Goto (insloc 2)),(b2 ';' (SubFrom b3,(intloc 0))))) ) )
proof end;

theorem Th78: :: SCM_HALT:78
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b1 . (intloc 0) = 1 & b1 . b3 <= 0 holds
(IExec (Times b3,b2),b1) | (Int-Locations \/ FinSeq-Locations ) = b1 | (Int-Locations \/ FinSeq-Locations )
proof end;

Lemma71: for b1 being Int-Location
for b2 being Instruction-Location of SCM+FSA
for b3 being Instruction of SCM+FSA st ( b3 = b1 =0_goto b2 or b3 = goto b2 ) holds
b3 <> halt SCM+FSA
by SCMFSA_2:47, SCMFSA_2:48, SCMFSA_2:124;

theorem Th79: :: SCM_HALT:79
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being read-write Int-Location st b2 does_not_destroy b3 & b1 . b3 > 0 holds
( (IExec (b2 ';' (SubFrom b3,(intloc 0))),b1) . b3 = (b1 . b3) - 1 & (IExec (Times b3,b2),b1) | (Int-Locations \/ FinSeq-Locations ) = (IExec (Times b3,b2),(IExec (b2 ';' (SubFrom b3,(intloc 0))),b1)) | (Int-Locations \/ FinSeq-Locations ) )
proof end;

theorem Th80: :: SCM_HALT:80
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being FinSeq-Location
for b4 being read-write Int-Location st b1 . b4 <= 0 holds
(IExec (Times b4,b2),b1) . b3 = b1 . b3
proof end;

theorem Th81: :: SCM_HALT:81
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being Int-Location
for b4 being read-write Int-Location st b1 . b4 <= 0 holds
(IExec (Times b4,b2),b1) . b3 = (Initialize b1) . b3
proof end;

theorem Th82: :: SCM_HALT:82
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being FinSeq-Location
for b4 being read-write Int-Location st b2 does_not_destroy b4 & b1 . b4 > 0 holds
(IExec (Times b4,b2),b1) . b3 = (IExec (Times b4,b2),(IExec (b2 ';' (SubFrom b4,(intloc 0))),b1)) . b3
proof end;

theorem Th83: :: SCM_HALT:83
for b1 being State of SCM+FSA
for b2 being good InitHalting Macro-Instruction
for b3 being Int-Location
for b4 being read-write Int-Location st b2 does_not_destroy b4 & b1 . b4 > 0 holds
(IExec (Times b4,b2),b1) . b3 = (IExec (Times b4,b2),(IExec (b2 ';' (SubFrom b4,(intloc 0))),b1)) . b3
proof end;

definition
let c4 be Instruction of SCM+FSA ;
attr a1 is good means :Def6: :: SCM_HALT:def 6
a1 does_not_destroy intloc 0;
end;

:: deftheorem Def6 defines good SCM_HALT:def 6 :
for b1 being Instruction of SCM+FSA holds
( b1 is good iff b1 does_not_destroy intloc 0 );

registration
cluster parahalting good M3(the Instructions of SCM+FSA );
existence
ex b1 being Instruction of SCM+FSA st
( b1 is parahalting & b1 is good )
proof end;
end;

registration
let c4 be good Instruction of SCM+FSA ;
let c5 be good Macro-Instruction;
cluster a1 ';' a2 -> good ;
coherence
c4 ';' c5 is good
proof end;
cluster a2 ';' a1 -> good ;
coherence
c5 ';' c4 is good
proof end;
end;

registration
let c4, c5 be good Instruction of SCM+FSA ;
cluster a1 ';' a2 -> good ;
coherence
c4 ';' c5 is good
proof end;
end;

registration
let c4 be read-write Int-Location ;
let c5 be Int-Location ;
cluster a1 := a2 -> good ;
coherence
c4 := c5 is good
proof end;
cluster SubFrom a1,a2 -> good ;
coherence
SubFrom c4,c5 is good
proof end;
end;

registration
let c4 be read-write Int-Location ;
let c5 be Int-Location ;
let c6 be FinSeq-Location ;
cluster a1 := a3,a2 -> good ;
coherence
c4 := c6,c5 is good
proof end;
end;

registration
let c4, c5 be Int-Location ;
let c6 be FinSeq-Location ;
cluster a3,a1 := a2 -> good ;
coherence
c6,c4 := c5 is good
proof end;
end;

registration
let c4 be read-write Int-Location ;
let c5 be FinSeq-Location ;
cluster a1 :=len a2 -> good ;
coherence
c4 :=len c5 is good
proof end;
end;

registration
let c4 be Nat;
cluster intloc (a1 + 1) -> read-write ;
coherence
not intloc (c4 + 1) is read-only
proof end;
end;