:: Computation of Two Consecutive Program Blocks for SCMPDS
:: by JingChao Chen
::
:: Received June 15, 1999
:: Copyright (c) 1999 Association of Mizar Users


begin

theorem :: SCMPDS_5:1
canceled;

theorem Th2: :: SCMPDS_5:2
for x being set
for i being Instruction of holds
( x in dom (Load i) iff x = inspos 0 )
proof end;

theorem Th3: :: SCMPDS_5:3
for loc being Instruction-Location of SCMPDS
for I being Program of st loc in dom (stop I) & (stop I) . loc <> halt SCMPDS holds
loc in dom I
proof end;

theorem :: SCMPDS_5:4
for i being Instruction of holds
( dom (Load i) = {(inspos 0 )} & (Load i) . (inspos 0 ) = i ) by FUNCOP_1:19, FUNCOP_1:87;

theorem Th5: :: SCMPDS_5:5
for i being Instruction of holds inspos 0 in dom (Load i)
proof end;

theorem Th6: :: SCMPDS_5:6
for i being Instruction of holds card (Load i) = 1
proof end;

theorem :: SCMPDS_5:7
for I being Program of holds card (stop I) = (card I) + 1 by SCMPDS_4:45, SCMPDS_4:74;

theorem Th8: :: SCMPDS_5:8
for i being Instruction of holds card (stop (Load i)) = 2
proof end;

theorem Th9: :: SCMPDS_5:9
for i being Instruction of holds
( inspos 0 in dom (stop (Load i)) & inspos 1 in dom (stop (Load i)) )
proof end;

theorem Th10: :: SCMPDS_5:10
for i being Instruction of holds
( (stop (Load i)) . (inspos 0 ) = i & (stop (Load i)) . (inspos 1) = halt SCMPDS )
proof end;

theorem Th11: :: SCMPDS_5:11
for x being set
for i being Instruction of holds
( x in dom (stop (Load i)) iff ( x = inspos 0 or x = inspos 1 ) )
proof end;

theorem :: SCMPDS_5:12
for i being Instruction of holds dom (stop (Load i)) = {(inspos 0 ),(inspos 1)}
proof end;

theorem Th13: :: SCMPDS_5:13
for i being Instruction of holds
( inspos 0 in dom (Initialized (stop (Load i))) & inspos 1 in dom (Initialized (stop (Load i))) & (Initialized (stop (Load i))) . (inspos 0 ) = i & (Initialized (stop (Load i))) . (inspos 1) = halt SCMPDS )
proof end;

theorem :: SCMPDS_5:14
canceled;

theorem Th15: :: SCMPDS_5:15
for I, J being Program of holds Initialized I c= Initialized (stop (I ';' J))
proof end;

theorem Th16: :: SCMPDS_5:16
for I, J being Program of holds dom (stop I) c= dom (stop (I ';' J))
proof end;

theorem Th17: :: SCMPDS_5:17
for I, J being Program of holds (Initialized (stop I)) +* (Initialized (stop (I ';' J))) = Initialized (stop (I ';' J))
proof end;

theorem Th18: :: SCMPDS_5:18
for s being State of
for I being Program of st Initialized I c= s holds
IC s = inspos 0
proof end;

theorem Th19: :: SCMPDS_5:19
for a being Int_position
for s being State of
for I being Program of holds (s +* (Initialized I)) . a = s . a
proof end;

theorem Th20: :: SCMPDS_5:20
for s1, s2 being State of
for I being parahalting Program of st Initialized (stop I) c= s1 & Initialized (stop I) c= s2 & s1,s2 equal_outside NAT holds
for k being Element of NAT holds
( Computation s1,k, Computation s2,k equal_outside NAT & CurInstr (Computation s1,k) = CurInstr (Computation s2,k) )
proof end;

theorem Th21: :: SCMPDS_5:21
for s1, s2 being State of
for I being parahalting Program of st Initialized (stop I) c= s1 & Initialized (stop I) c= s2 & s1,s2 equal_outside NAT holds
( LifeSpan s1 = LifeSpan s2 & Result s1, Result s2 equal_outside NAT )
proof end;

theorem Th22: :: SCMPDS_5:22
for s being State of
for I being Program of holds IC (IExec I,s) = IC (Result (s +* (Initialized (stop I))))
proof end;

theorem Th23: :: SCMPDS_5:23
for s being State of
for I being parahalting Program of
for J being Program of st Initialized (stop I) c= s holds
for m being Element of NAT st m <= LifeSpan s holds
Computation s,m, Computation (s +* (I ';' J)),m equal_outside NAT
proof end;

theorem Th24: :: SCMPDS_5:24
for s being State of
for I being parahalting Program of
for J being Program of st Initialized (stop I) c= s holds
for m being Element of NAT st m <= LifeSpan s holds
Computation s,m, Computation (s +* (Initialized (stop (I ';' J)))),m equal_outside NAT
proof end;

Lm1: Load ((DataLoc 0 ,0 ) := 0 ) is parahalting
proof end;

begin

definition
let i be Instruction of ;
attr i is No-StopCode means :Def1: :: SCMPDS_5:def 1
i <> halt SCMPDS ;
end;

:: deftheorem Def1 defines No-StopCode SCMPDS_5:def 1 :
for i being Instruction of holds
( i is No-StopCode iff i <> halt SCMPDS );

definition
let i be Instruction of ;
attr i is parahalting means :Def2: :: SCMPDS_5:def 2
Load i is parahalting ;
end;

:: deftheorem Def2 defines parahalting SCMPDS_5:def 2 :
for i being Instruction of holds
( i is parahalting iff Load i is parahalting );

registration
cluster shiftable No-StopCode parahalting Element of the Instructions of SCMPDS ;
existence
ex b1 being Instruction of st
( b1 is No-StopCode & b1 is shiftable & b1 is parahalting )
proof end;
end;

theorem :: SCMPDS_5:25
for k1 being Integer st k1 <> 0 holds
goto k1 is No-StopCode
proof end;

registration
let a be Int_position ;
cluster return a -> No-StopCode ;
coherence
return a is No-StopCode
proof end;
end;

registration
let a be Int_position ;
let k1 be Integer;
cluster a := k1 -> No-StopCode ;
coherence
a := k1 is No-StopCode
proof end;
cluster saveIC a,k1 -> No-StopCode ;
coherence
saveIC a,k1 is No-StopCode
proof end;
end;

registration
let a be Int_position ;
let k1, k2 be Integer;
cluster a,k1 <>0_goto k2 -> No-StopCode ;
coherence
a,k1 <>0_goto k2 is No-StopCode
proof end;
cluster a,k1 <=0_goto k2 -> No-StopCode ;
coherence
a,k1 <=0_goto k2 is No-StopCode
proof end;
cluster a,k1 >=0_goto k2 -> No-StopCode ;
coherence
a,k1 >=0_goto k2 is No-StopCode
proof end;
cluster a,k1 := k2 -> No-StopCode ;
coherence
a,k1 := k2 is No-StopCode
proof end;
end;

registration
let a be Int_position ;
let k1, k2 be Integer;
cluster AddTo a,k1,k2 -> No-StopCode ;
coherence
AddTo a,k1,k2 is No-StopCode
proof end;
end;

registration
let a, b be Int_position ;
let k1, k2 be Integer;
cluster AddTo a,k1,b,k2 -> No-StopCode ;
coherence
AddTo a,k1,b,k2 is No-StopCode
proof end;
cluster SubFrom a,k1,b,k2 -> No-StopCode ;
coherence
SubFrom a,k1,b,k2 is No-StopCode
proof end;
cluster MultBy a,k1,b,k2 -> No-StopCode ;
coherence
MultBy a,k1,b,k2 is No-StopCode
proof end;
cluster Divide a,k1,b,k2 -> No-StopCode ;
coherence
Divide a,k1,b,k2 is No-StopCode
proof end;
cluster a,k1 := b,k2 -> No-StopCode ;
coherence
a,k1 := b,k2 is No-StopCode
proof end;
end;

registration
cluster halt SCMPDS -> parahalting ;
coherence
halt SCMPDS is parahalting
proof end;
end;

registration
let i be parahalting Instruction of ;
cluster Load i -> parahalting ;
coherence
Load i is parahalting
by Def2;
end;

Lm2: for i being Instruction of st ( for s being State of holds (Exec i,s) . (IC SCMPDS ) = Next (IC s) ) holds
Load i is parahalting
proof end;

registration
let a be Int_position ;
let k1 be Integer;
cluster a := k1 -> parahalting ;
coherence
a := k1 is parahalting
proof end;
end;

registration
let a be Int_position ;
let k1, k2 be Integer;
cluster a,k1 := k2 -> parahalting ;
coherence
a,k1 := k2 is parahalting
proof end;
cluster AddTo a,k1,k2 -> parahalting ;
coherence
AddTo a,k1,k2 is parahalting
proof end;
end;

registration
let a, b be Int_position ;
let k1, k2 be Integer;
cluster AddTo a,k1,b,k2 -> parahalting ;
coherence
AddTo a,k1,b,k2 is parahalting
proof end;
cluster SubFrom a,k1,b,k2 -> parahalting ;
coherence
SubFrom a,k1,b,k2 is parahalting
proof end;
cluster MultBy a,k1,b,k2 -> parahalting ;
coherence
MultBy a,k1,b,k2 is parahalting
proof end;
cluster Divide a,k1,b,k2 -> parahalting ;
coherence
Divide a,k1,b,k2 is parahalting
proof end;
cluster a,k1 := b,k2 -> parahalting ;
coherence
a,k1 := b,k2 is parahalting
proof end;
end;

theorem Th26: :: SCMPDS_5:26
for i being Instruction of st InsCode i = 1 holds
not i is parahalting
proof end;

definition
let IT be FinPartState of ;
attr IT is No-StopCode means :Def3: :: SCMPDS_5:def 3
for x being Instruction-Location of SCMPDS st x in dom IT holds
IT . x <> halt SCMPDS ;
end;

:: deftheorem Def3 defines No-StopCode SCMPDS_5:def 3 :
for IT being FinPartState of holds
( IT is No-StopCode iff for x being Instruction-Location of SCMPDS st x in dom IT holds
IT . x <> halt SCMPDS );

registration
cluster parahalting shiftable No-StopCode Element of K185(the Object-Kind of SCMPDS );
existence
ex b1 being Program of st
( b1 is parahalting & b1 is shiftable & b1 is No-StopCode )
proof end;
end;

registration
let I, J be No-StopCode Program of ;
cluster I ';' J -> No-StopCode ;
coherence
I ';' J is No-StopCode
proof end;
end;

registration
let i be No-StopCode Instruction of ;
cluster Load i -> No-StopCode ;
coherence
Load i is No-StopCode
proof end;
end;

registration
let i be No-StopCode Instruction of ;
let J be No-StopCode Program of ;
cluster i ';' J -> No-StopCode ;
coherence
i ';' J is No-StopCode
;
end;

registration
let I be No-StopCode Program of ;
let j be No-StopCode Instruction of ;
cluster I ';' j -> No-StopCode ;
coherence
I ';' j is No-StopCode
;
end;

registration
let i, j be No-StopCode Instruction of ;
cluster i ';' j -> No-StopCode ;
coherence
i ';' j is No-StopCode
;
end;

theorem Th27: :: SCMPDS_5:27
for s being State of
for I being parahalting No-StopCode Program of st Initialized (stop I) c= s holds
IC (Computation s,(LifeSpan (s +* (Initialized (stop I))))) = inspos (card I)
proof end;

theorem Th28: :: SCMPDS_5:28
for s being State of
for I being parahalting Program of
for k being Element of NAT st k < LifeSpan (s +* (Initialized (stop I))) holds
IC (Computation (s +* (Initialized (stop I))),k) in dom I
proof end;

theorem Th29: :: SCMPDS_5:29
for s being State of
for I being parahalting Program of
for k being Element of NAT st Initialized I c= s & k <= LifeSpan (s +* (Initialized (stop I))) holds
Computation s,k, Computation (s +* (Initialized (stop I))),k equal_outside NAT
proof end;

theorem Th30: :: SCMPDS_5:30
for s being State of
for I being parahalting No-StopCode Program of st Initialized I c= s holds
IC (Computation s,(LifeSpan (s +* (Initialized (stop I))))) = inspos (card I)
proof end;

theorem Th31: :: SCMPDS_5:31
for s being State of
for I being parahalting Program of holds
( not Initialized I c= s or CurInstr (Computation s,(LifeSpan (s +* (Initialized (stop I))))) = halt SCMPDS or IC (Computation s,(LifeSpan (s +* (Initialized (stop I))))) = inspos (card I) )
proof end;

theorem Th32: :: SCMPDS_5:32
for s being State of
for I being parahalting No-StopCode Program of
for k being Element of NAT st Initialized I c= s & k < LifeSpan (s +* (Initialized (stop I))) holds
CurInstr (Computation s,k) <> halt SCMPDS
proof end;

theorem Th33: :: SCMPDS_5:33
for s being State of
for I being parahalting Program of
for J being Program of
for k being Element of NAT st k <= LifeSpan (s +* (Initialized (stop I))) holds
Computation (s +* (Initialized (stop I))),k, Computation (s +* ((I ';' J) +* (Start-At (inspos 0 )))),k equal_outside NAT
proof end;

theorem Th34: :: SCMPDS_5:34
for s being State of
for I being parahalting Program of
for J being Program of
for k being Element of NAT st k <= LifeSpan (s +* (Initialized (stop I))) holds
Computation (s +* (Initialized (stop I))),k, Computation (s +* (Initialized (stop (I ';' J)))),k equal_outside NAT
proof end;

registration
let I be parahalting Program of ;
let J be parahalting shiftable Program of ;
cluster I ';' J -> parahalting ;
coherence
I ';' J is parahalting
proof end;
end;

registration
let i be parahalting Instruction of ;
let J be parahalting shiftable Program of ;
cluster i ';' J -> parahalting ;
coherence
i ';' J is parahalting
;
end;

registration
let I be parahalting Program of ;
let j be shiftable parahalting Instruction of ;
cluster I ';' j -> parahalting ;
coherence
I ';' j is parahalting
;
end;

registration
let i be parahalting Instruction of ;
let j be shiftable parahalting Instruction of ;
cluster i ';' j -> parahalting ;
coherence
i ';' j is parahalting
;
end;

theorem Th35: :: SCMPDS_5:35
for m, n being Element of NAT
for s, s1 being State of
for J being parahalting shiftable Program of st s = Computation (s1 +* (Initialized (stop J))),m holds
Exec (CurInstr s),(s +* (Start-At ((IC s) + n))) = (Following s) +* (Start-At ((IC (Following s)) + n))
proof end;

begin

theorem :: SCMPDS_5:36
for s being State of
for I being parahalting No-StopCode Program of
for J being parahalting shiftable Program of
for k being Element of NAT st Initialized (stop (I ';' J)) c= s holds
(Computation ((Result (s +* (Initialized (stop I)))) +* (Initialized (stop J))),k) +* (Start-At ((IC (Computation ((Result (s +* (Initialized (stop I)))) +* (Initialized (stop J))),k)) + (card I))), Computation (s +* (Initialized (stop (I ';' J)))),((LifeSpan (s +* (Initialized (stop I)))) + k) equal_outside NAT
proof end;

Lm3: for I being parahalting No-StopCode Program of
for J being parahalting shiftable Program of
for s, s1 being State of st Initialized (stop (I ';' J)) c= s & s1 = s +* (Initialized (stop I)) holds
( IC (Computation s,(LifeSpan s1)) = inspos (card I) & DataPart (Computation s,(LifeSpan s1)) = DataPart ((Computation s1,(LifeSpan s1)) +* (Initialized (stop J))) & Shift (stop J),(card I) c= Computation s,(LifeSpan s1) & LifeSpan s = (LifeSpan s1) + (LifeSpan ((Result s1) +* (Initialized (stop J)))) )
proof end;

theorem Th37: :: SCMPDS_5:37
for s being State of
for I being parahalting No-StopCode Program of
for J being parahalting shiftable Program of holds LifeSpan (s +* (Initialized (stop (I ';' J)))) = (LifeSpan (s +* (Initialized (stop I)))) + (LifeSpan ((Result (s +* (Initialized (stop I)))) +* (Initialized (stop J))))
proof end;

theorem Th38: :: SCMPDS_5:38
for s being State of
for I being parahalting No-StopCode Program of
for J being parahalting shiftable Program of holds IExec (I ';' J),s = (IExec J,(IExec I,s)) +* (Start-At ((IC (IExec J,(IExec I,s))) + (card I)))
proof end;

theorem :: SCMPDS_5:39
for a being Int_position
for s being State of
for I being parahalting No-StopCode Program of
for J being parahalting shiftable Program of holds (IExec (I ';' J),s) . a = (IExec J,(IExec I,s)) . a
proof end;

begin

definition
let s be State of ;
func Initialized s -> State of equals :: SCMPDS_5:def 4
s +* (Start-At (inspos 0 ));
coherence
s +* (Start-At (inspos 0 )) is State of
;
end;

:: deftheorem defines Initialized SCMPDS_5:def 4 :
for s being State of holds Initialized s = s +* (Start-At (inspos 0 ));

theorem Th40: :: SCMPDS_5:40
for a being Int_position
for s being State of
for loc being Instruction-Location of SCMPDS holds
( IC (Initialized s) = inspos 0 & (Initialized s) . a = s . a & (Initialized s) . loc = s . loc )
proof end;

theorem Th41: :: SCMPDS_5:41
for s1, s2 being State of holds
( s1,s2 equal_outside NAT iff s1 | (SCM-Data-Loc \/ {(IC SCMPDS )}) = s2 | (SCM-Data-Loc \/ {(IC SCMPDS )}) )
proof end;

theorem :: SCMPDS_5:42
canceled;

theorem Th43: :: SCMPDS_5:43
for i being Instruction of
for s1, s2 being State of st DataPart s1 = DataPart s2 & InsCode i <> 3 holds
DataPart (Exec i,s1) = DataPart (Exec i,s2)
proof end;

theorem Th44: :: SCMPDS_5:44
for s1, s2 being State of
for i being shiftable Instruction of st DataPart s1 = DataPart s2 holds
DataPart (Exec i,s1) = DataPart (Exec i,s2)
proof end;

theorem Th45: :: SCMPDS_5:45
for s being State of
for i being parahalting Instruction of holds Exec i,(Initialized s) = IExec (Load i),s
proof end;

theorem Th46: :: SCMPDS_5:46
for a being Int_position
for s being State of
for I being parahalting No-StopCode Program of
for j being shiftable parahalting Instruction of holds (IExec (I ';' j),s) . a = (Exec j,(IExec I,s)) . a
proof end;

theorem :: SCMPDS_5:47
for a being Int_position
for s being State of
for i being No-StopCode parahalting Instruction of
for j being shiftable parahalting Instruction of holds (IExec (i ';' j),s) . a = (Exec j,(Exec i,(Initialized s))) . a
proof end;