:: SCMFSA6C semantic presentation

set c1 = Start-At (insloc 0);

theorem Th1: :: SCMFSA6C:1
for b1 being Int-Location
for b2 being State of SCM+FSA
for b3 being parahalting keeping_0 Macro-Instruction
for b4 being parahalting Macro-Instruction holds (IExec (b3 ';' b4),b2) . b1 = (IExec b4,(IExec b3,b2)) . b1
proof end;

theorem Th2: :: SCMFSA6C:2
for b1 being FinSeq-Location
for b2 being State of SCM+FSA
for b3 being parahalting keeping_0 Macro-Instruction
for b4 being parahalting Macro-Instruction holds (IExec (b3 ';' b4),b2) . b1 = (IExec b4,(IExec b3,b2)) . b1
proof end;

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

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

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

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

Lemma4: ( 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 c2 be parahalting Instruction of SCM+FSA ;
cluster Macro a1 -> parahalting ;
coherence
Macro c2 is parahalting
by Def1;
end;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

E8: now
let c2 be parahalting keeping_0 Macro-Instruction;
let c3 be State of SCM+FSA ;
set c4 = IExec c2,c3;
set c5 = Int-Locations \/ FinSeq-Locations ;
now
E9: ( dom (Initialize (IExec c2,c3)) = the carrier of SCM+FSA & dom (IExec c2,c3) = the carrier of SCM+FSA ) by AMI_3:36;
hence E10: dom ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) = (dom (IExec c2,c3)) /\ (Int-Locations \/ FinSeq-Locations ) by RELAT_1:90;
let c6 be set ;
assume E11: c6 in dom ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) ;
dom (Initialize (IExec c2,c3)) = (Int-Locations \/ FinSeq-Locations ) \/ ({(IC SCM+FSA )} \/ the Instruction-Locations of SCM+FSA ) by E9, SCMFSA_2:8, XBOOLE_1:4;
then E12: dom ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) = Int-Locations \/ FinSeq-Locations by E9, E10, XBOOLE_1:21;
per cases ( c6 in Int-Locations or c6 in FinSeq-Locations ) by E11, E12, XBOOLE_0:def 2;
suppose c6 in Int-Locations ;
then reconsider c7 = c6 as Int-Location by SCMFSA_2:11;
hereby
per cases ( not c7 is read-only or c7 is read-only ) ;
suppose E13: not c7 is read-only ;
thus ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) . c6 = (Initialize (IExec c2,c3)) . c6 by E11, E12, FUNCT_1:72
.= (IExec c2,c3) . c6 by E13, Th3 ;
end;
suppose c7 is read-only ;
then E13: c7 = intloc 0 by SF_MASTR:def 5;
thus ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) . c6 = (Initialize (IExec c2,c3)) . c7 by E11, E12, FUNCT_1:72
.= 1 by E13, Th3
.= (IExec c2,c3) . c6 by E13, SCMFSA6B:35 ;
end;
end;
end;
end;
suppose c6 in FinSeq-Locations ;
then reconsider c7 = c6 as FinSeq-Location by SCMFSA_2:12;
thus ((Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations )) . c6 = (Initialize (IExec c2,c3)) . c7 by E11, E12, FUNCT_1:72
.= (IExec c2,c3) . c6 by Th3 ;
end;
end;
end;
hence (Initialize (IExec c2,c3)) | (Int-Locations \/ FinSeq-Locations ) = (IExec c2,c3) | (Int-Locations \/ FinSeq-Locations ) by FUNCT_1:68;
end;

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

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

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

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

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

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

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

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

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

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

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