:: SCMFSA6C semantic presentation

set SA0 = Start-At (insloc 0);

theorem Th1: :: SCMFSA6C:1
for a being Int-Location
for s being State of SCM+FSA
for I being parahalting keeping_0 Macro-Instruction
for J being parahalting Macro-Instruction holds (IExec (I ';' J),s) . a = (IExec J,(IExec I,s)) . a
proof end;

theorem Th2: :: SCMFSA6C:2
for f being FinSeq-Location
for s being State of SCM+FSA
for I being parahalting keeping_0 Macro-Instruction
for J being parahalting Macro-Instruction holds (IExec (I ';' J),s) . f = (IExec J,(IExec I,s)) . f
proof end;

definition
let i be Instruction of SCM+FSA ;
attr a1 is parahalting means :Def1: :: SCMFSA6C:def 1
Macro SA0 is parahalting;
attr a1 is keeping_0 means :Def2: :: SCMFSA6C:def 2
Macro SA0 is keeping_0;
end;

:: deftheorem Def1 defines parahalting SCMFSA6C:def 1 :
for i being Instruction of SCM+FSA holds
( i is parahalting iff Macro i is parahalting );

:: deftheorem Def2 defines keeping_0 SCMFSA6C:def 2 :
for i being Instruction of SCM+FSA holds
( i is keeping_0 iff Macro i is keeping_0 );

Lemma42: Macro (halt SCM+FSA ) is parahalting
proof end;

Lemma56: ( Macro (halt SCM+FSA ) is keeping_0 & Macro (halt SCM+FSA ) is parahalting )
proof end;

registration
cluster halt SCM+FSA -> parahalting keeping_0 ;
coherence
( halt SCM+FSA is keeping_0 & halt SCM+FSA is parahalting )
proof end;
end;

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

registration
let i be parahalting Instruction of SCM+FSA ;
cluster Macro a1 -> parahalting ;
coherence
Macro i is parahalting
by ;
end;

registration
let i be keeping_0 Instruction of SCM+FSA ;
cluster Macro a1 -> keeping_0 ;
coherence
Macro i is keeping_0
by ;
end;

registration
let a be Int-Location , b be Int-Location ;
cluster a1 := a2 -> parahalting ;
coherence
a := b is parahalting
proof end;
cluster AddTo a1,a2 -> parahalting ;
coherence
AddTo a,b is parahalting
proof end;
cluster SubFrom a1,a2 -> parahalting ;
coherence
SubFrom a,b is parahalting
proof end;
cluster MultBy a1,a2 -> parahalting ;
coherence
MultBy a,b is parahalting
proof end;
cluster Divide a1,a2 -> parahalting ;
coherence
Divide a,b is parahalting
proof end;
let f be FinSeq-Location ;
cluster a2 := a3,a1 -> parahalting ;
coherence
b := f,a is parahalting
proof end;
cluster a3,a1 := a2 -> parahalting keeping_0 ;
coherence
( f,a := b is parahalting & f,a := b is keeping_0 )
proof end;
end;

registration
let a be Int-Location ;
let f be FinSeq-Location ;
cluster a1 :=len a2 -> parahalting ;
coherence
a :=len f is parahalting
proof end;
cluster a2 :=<0,...,0> a1 -> parahalting keeping_0 ;
coherence
( f :=<0,...,0> a is parahalting & f :=<0,...,0> a is keeping_0 )
proof end;
end;

registration
let a be read-write Int-Location ;
let b be Int-Location ;
cluster a1 := a2 -> parahalting keeping_0 ;
coherence
a := b is keeping_0
proof end;
cluster AddTo a1,a2 -> parahalting keeping_0 ;
coherence
AddTo a,b is keeping_0
proof end;
cluster SubFrom a1,a2 -> parahalting keeping_0 ;
coherence
SubFrom a,b is keeping_0
proof end;
cluster MultBy a1,a2 -> parahalting keeping_0 ;
coherence
MultBy a,b is keeping_0
proof end;
end;

registration
let a be read-write Int-Location , b be read-write Int-Location ;
cluster Divide a1,a2 -> parahalting keeping_0 ;
coherence
Divide a,b is keeping_0
proof end;
end;

registration
let a be Int-Location ;
let f be FinSeq-Location ;
let b be read-write Int-Location ;
cluster a3 := a2,a1 -> parahalting keeping_0 ;
coherence
b := f,a is keeping_0
proof end;
end;

registration
let f be FinSeq-Location ;
let b be read-write Int-Location ;
cluster a2 :=len a1 -> parahalting keeping_0 ;
coherence
b :=len f is keeping_0
proof end;
end;

registration
let i be parahalting Instruction of SCM+FSA ;
let J be parahalting Macro-Instruction;
cluster a1 ';' a2 -> parahalting ;
coherence
i ';' J is parahalting
proof end;
end;

registration
let I be parahalting Macro-Instruction;
let j be parahalting Instruction of SCM+FSA ;
cluster a1 ';' a2 -> parahalting ;
coherence
I ';' j is parahalting
proof end;
end;

registration
let i be parahalting Instruction of SCM+FSA ;
let j be parahalting Instruction of SCM+FSA ;
cluster a1 ';' a2 -> parahalting ;
coherence
i ';' j is parahalting
proof end;
end;

registration
let i be keeping_0 Instruction of SCM+FSA ;
let J be keeping_0 Macro-Instruction;
cluster a1 ';' a2 -> keeping_0 ;
coherence
i ';' J is keeping_0
proof end;
end;

registration
let I be keeping_0 Macro-Instruction;
let j be keeping_0 Instruction of SCM+FSA ;
cluster a1 ';' a2 -> keeping_0 ;
coherence
I ';' j is keeping_0
proof end;
end;

registration
let i be keeping_0 Instruction of SCM+FSA , j be keeping_0 Instruction of SCM+FSA ;
cluster a1 ';' a2 -> keeping_0 ;
coherence
i ';' j is keeping_0
proof end;
end;

definition
let s be State of SCM+FSA ;
func Initialize c1 -> State of SCM+FSA equals :: SCMFSA6C:def 3
(SA0 +* ((intloc 0) .--> 1)) +* (Start-At (insloc 0));
coherence
(s +* ((intloc 0) .--> 1)) +* (Start-At (insloc 0)) is State of SCM+FSA
proof end;
end;

:: deftheorem Def3 defines Initialize SCMFSA6C:def 3 :
for s being State of SCM+FSA holds Initialize s = (s +* ((intloc 0) .--> 1)) +* (Start-At (insloc 0));

theorem Th3: :: SCMFSA6C:3
for s being State of SCM+FSA holds
( IC (Initialize s) = insloc 0 & (Initialize s) . (intloc 0) = 1 & ( for a being read-write Int-Location holds (Initialize s) . a = s . a ) & ( for f being FinSeq-Location holds (Initialize s) . f = s . f ) & ( for l being Instruction-Location of SCM+FSA holds (Initialize s) . l = s . l ) )
proof end;

theorem Th4: :: SCMFSA6C:4
for s1, s2 being State of SCM+FSA holds
( s1,s2 equal_outside the Instruction-Locations of SCM+FSA iff s1 | ((Int-Locations \/ FinSeq-Locations ) \/ {(IC SCM+FSA )}) = s2 | ((Int-Locations \/ FinSeq-Locations ) \/ {(IC SCM+FSA )}) )
proof end;

theorem Th5: :: SCMFSA6C:5
for i being Instruction of SCM+FSA
for s1, s2 being State of SCM+FSA st s1 | (Int-Locations \/ FinSeq-Locations ) = s2 | (Int-Locations \/ FinSeq-Locations ) holds
(Exec i,s1) | (Int-Locations \/ FinSeq-Locations ) = (Exec i,s2) | (Int-Locations \/ FinSeq-Locations )
proof end;

E215: now
let I be parahalting keeping_0 Macro-Instruction;
let s be State of SCM+FSA ;
set IE = IExec I,s;
set IF = Int-Locations \/ FinSeq-Locations ;
now
E39: ( dom (Initialize (IExec I,s)) = the carrier of SCM+FSA & dom (IExec I,s) = the carrier of SCM+FSA ) by AMI_3:36;
hence E45: dom ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) = (dom (IExec I,s)) /\ (Int-Locations \/ FinSeq-Locations ) by RELAT_1:90;
let x be set ;
assume E46: x in dom ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) ;
dom (Initialize (IExec I,s)) = (Int-Locations \/ FinSeq-Locations ) \/ ({(IC SCM+FSA )} \/ the Instruction-Locations of SCM+FSA ) by , SCMFSA_2:8, XBOOLE_1:4;
then E47: dom ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) = Int-Locations \/ FinSeq-Locations by , , XBOOLE_1:21;
per cases ( x in Int-Locations or x in FinSeq-Locations ) by , , XBOOLE_0:def 2;
suppose x in Int-Locations ;
then reconsider x' = x as Int-Location by SCMFSA_2:11;
hereby
per cases ( not x' is read-only or x' is read-only ) ;
suppose E48: not x' is read-only ;
thus ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) . x = (Initialize (IExec I,s)) . x by , , FUNCT_1:72
.= (IExec I,s) . x by , ;
end;
suppose x' is read-only ;
then E49: x' = intloc 0 by SF_MASTR:def 5;
thus ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) . x = (Initialize (IExec I,s)) . x' by , , FUNCT_1:72
.= 1 by ,
.= (IExec I,s) . x by , SCMFSA6B:35 ;
end;
end;
end;
end;
suppose x in FinSeq-Locations ;
then reconsider x' = x as FinSeq-Location by SCMFSA_2:12;
thus ((Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations )) . x = (Initialize (IExec I,s)) . x' by , , FUNCT_1:72
.= (IExec I,s) . x by ;
end;
end;
end;
hence (Initialize (IExec I,s)) | (Int-Locations \/ FinSeq-Locations ) = (IExec I,s) | (Int-Locations \/ FinSeq-Locations ) by FUNCT_1:68;
end;

theorem Th6: :: SCMFSA6C:6
for s being State of SCM+FSA
for i being parahalting Instruction of SCM+FSA holds Exec i,(Initialize s) = IExec (Macro i),s
proof end;

theorem Th7: :: SCMFSA6C:7
for a being Int-Location
for s being State of SCM+FSA
for I being parahalting keeping_0 Macro-Instruction
for j being parahalting Instruction of SCM+FSA holds (IExec (I ';' j),s) . a = (Exec j,(IExec I,s)) . a
proof end;

theorem Th8: :: SCMFSA6C:8
for f being FinSeq-Location
for s being State of SCM+FSA
for I being parahalting keeping_0 Macro-Instruction
for j being parahalting Instruction of SCM+FSA holds (IExec (I ';' j),s) . f = (Exec j,(IExec I,s)) . f
proof end;

theorem Th9: :: SCMFSA6C:9
for a being Int-Location
for s being State of SCM+FSA
for i being parahalting keeping_0 Instruction of SCM+FSA
for j being parahalting Instruction of SCM+FSA holds (IExec (i ';' j),s) . a = (Exec j,(Exec i,(Initialize s))) . a
proof end;

theorem Th10: :: SCMFSA6C:10
for f being FinSeq-Location
for s being State of SCM+FSA
for i being parahalting keeping_0 Instruction of SCM+FSA
for j being parahalting Instruction of SCM+FSA holds (IExec (i ';' j),s) . f = (Exec j,(Exec i,(Initialize s))) . f
proof end;

definition
let a be Int-Location , b be Int-Location ;
func swap c1,c2 -> Macro-Instruction equals :: SCMFSA6C:def 4
(((FirstNotUsed (Macro (SA0 := a))) := SA0) ';' (SA0 := a)) ';' (a := (FirstNotUsed (Macro (SA0 := a))));
correctness
coherence
(((FirstNotUsed (Macro (a := b))) := a) ';' (a := b)) ';' (b := (FirstNotUsed (Macro (a := b)))) is Macro-Instruction
;
;
end;

:: deftheorem Def4 defines swap SCMFSA6C:def 4 :
for a, b being Int-Location holds swap a,b = (((FirstNotUsed (Macro (a := b))) := a) ';' (a := b)) ';' (b := (FirstNotUsed (Macro (a := b))));

registration
let a be Int-Location , b be Int-Location ;
cluster swap a1,a2 -> parahalting ;
coherence
swap a,b is parahalting
;
end;

registration
let a be read-write Int-Location , b be read-write Int-Location ;
cluster swap a1,a2 -> parahalting keeping_0 ;
coherence
swap a,b is keeping_0
;
end;

theorem Th11: :: SCMFSA6C:11
for s being State of SCM+FSA
for a, b being read-write Int-Location holds
( (IExec (swap a,b),s) . a = s . b & (IExec (swap a,b),s) . b = s . a )
proof end;

theorem Th12: :: SCMFSA6C:12
for a, b being Int-Location holds UsedInt*Loc (swap a,b) = {}
proof end;