:: SCMFSA7B semantic presentation

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

theorem Th1: :: SCMFSA7B:1
for b1 being FinSequence of the Instructions of SCM+FSA holds dom (Load b1) = { (insloc b2) where B is Nat : b2 < len b1 }
proof end;

theorem Th2: :: SCMFSA7B:2
for b1 being FinSequence of the Instructions of SCM+FSA holds rng (Load b1) = rng b1
proof end;

registration
let c2 be FinSequence of the Instructions of SCM+FSA ;
cluster Load a1 -> programmed initial ;
coherence
( Load c2 is initial & Load c2 is programmed )
proof end;
end;

theorem Th3: :: SCMFSA7B:3
for b1 being Instruction of SCM+FSA holds Load <*b1*> = (insloc 0) .--> b1
proof end;

theorem Th4: :: SCMFSA7B:4
for b1 being Instruction of SCM+FSA holds dom (Macro b1) = {(insloc 0),(insloc 1)}
proof end;

theorem Th5: :: SCMFSA7B:5
for b1 being Instruction of SCM+FSA holds Macro b1 = Load <*b1,(halt SCM+FSA )*>
proof end;

theorem Th6: :: SCMFSA7B:6
for b1 being Instruction of SCM+FSA holds card (Macro b1) = 2
proof end;

theorem Th7: :: SCMFSA7B:7
for b1 being Instruction of SCM+FSA holds
( ( b1 = halt SCM+FSA implies (Directed (Macro b1)) . (insloc 0) = goto (insloc 2) ) & ( b1 <> halt SCM+FSA implies (Directed (Macro b1)) . (insloc 0) = b1 ) )
proof end;

theorem Th8: :: SCMFSA7B:8
for b1 being Instruction of SCM+FSA holds (Directed (Macro b1)) . (insloc 1) = goto (insloc 2)
proof end;

registration
let c2 be Int-Location ;
let c3 be Integer;
cluster a1 := a2 -> programmed initial ;
coherence
( c2 := c3 is initial & c2 := c3 is programmed )
proof end;
end;

Lemma6: for b1 being State of SCM+FSA st IC b1 = insloc 0 holds
for b2 being Int-Location
for b3 being Integer st b2 := b3 c= b1 holds
b1 is halting
proof end;

registration
let c2 be Int-Location ;
let c3 be Integer;
cluster a1 := a2 -> programmed initial parahalting ;
correctness
coherence
c2 := c3 is parahalting
;
proof end;
end;

theorem Th9: :: SCMFSA7B:9
for b1 being State of SCM+FSA
for b2 being read-write Int-Location
for b3 being Integer holds
( (IExec (b2 := b3),b1) . b2 = b3 & ( for b4 being read-write Int-Location st b4 <> b2 holds
(IExec (b2 := b3),b1) . b4 = b1 . b4 ) & ( for b4 being FinSeq-Location holds (IExec (b2 := b3),b1) . b4 = b1 . b4 ) )
proof end;

Lemma7: for b1, b2, b3, b4 being FinSequence holds ((b1 ^ b2) ^ b3) ^ b4 = b1 ^ ((b2 ^ b3) ^ b4)
proof end;

Lemma8: for b1, b2, b3 being FinSequence holds
( ((len b1) + (len b2)) + (len b3) = len ((b1 ^ b2) ^ b3) & ((len b1) + (len b2)) + (len b3) = len (b1 ^ (b2 ^ b3)) & (len b1) + ((len b2) + (len b3)) = len (b1 ^ (b2 ^ b3)) & (len b1) + ((len b2) + (len b3)) = len ((b1 ^ b2) ^ b3) )
proof end;

Lemma9: for b1 being State of SCM+FSA st IC b1 = insloc 0 & b1 . (intloc 0) = 1 holds
for b2 being FinSeq-Location
for b3 being FinSequence of INT st b2 := b3 c= b1 holds
( b1 is halting & (Result b1) . b2 = b3 & ( for b4 being Int-Location st b4 <> intloc 1 & b4 <> intloc 2 holds
(Result b1) . b4 = b1 . b4 ) & ( for b4 being FinSeq-Location st b4 <> b2 holds
(Result b1) . b4 = b1 . b4 ) )
proof end;

Lemma10: for b1 being State of SCM+FSA
for b2 being Nat st IC b1 = insloc b2 holds
for b3 being Int-Location
for b4 being Integer st ( for b5 being Nat st b5 < len (aSeq b3,b4) holds
(aSeq b3,b4) . (b5 + 1) = b1 . (insloc (b2 + b5)) ) holds
for b5 being Nat st b5 <= len (aSeq b3,b4) holds
IC ((Computation b1) . b5) = insloc (b2 + b5)
proof end;

Lemma11: for b1 being State of SCM+FSA st IC b1 = insloc 0 holds
for b2 being Int-Location
for b3 being Integer st Load (aSeq b2,b3) c= b1 holds
for b4 being Nat st b4 <= len (aSeq b2,b3) holds
IC ((Computation b1) . b4) = insloc b4
proof end;

Lemma12: for b1 being State of SCM+FSA st IC b1 = insloc 0 holds
for b2 being FinSeq-Location
for b3 being FinSequence of INT st b2 := b3 c= b1 holds
b1 is halting
proof end;

registration
let c2 be FinSeq-Location ;
let c3 be FinSequence of INT ;
cluster a1 := a2 -> programmed initial ;
coherence
( c2 := c3 is initial & c2 := c3 is programmed )
proof end;
end;

registration
let c2 be FinSeq-Location ;
let c3 be FinSequence of INT ;
cluster a1 := a2 -> programmed initial parahalting ;
correctness
coherence
c2 := c3 is parahalting
;
proof end;
end;

theorem Th10: :: SCMFSA7B:10
for b1 being State of SCM+FSA
for b2 being FinSeq-Location
for b3 being FinSequence of INT holds
( (IExec (b2 := b3),b1) . b2 = b3 & ( for b4 being read-write Int-Location st b4 <> intloc 1 & b4 <> intloc 2 holds
(IExec (b2 := b3),b1) . b4 = b1 . b4 ) & ( for b4 being FinSeq-Location st b4 <> b2 holds
(IExec (b2 := b3),b1) . b4 = b1 . b4 ) )
proof end;

definition
let c2 be Instruction of SCM+FSA ;
let c3 be Int-Location ;
pred c1 does_not_refer c2 means :: SCMFSA7B:def 1
for b1 being Int-Location
for b2 being Instruction-Location of SCM+FSA
for b3 being FinSeq-Location holds
( b1 := a2 <> a1 & AddTo b1,a2 <> a1 & SubFrom b1,a2 <> a1 & MultBy b1,a2 <> a1 & Divide b1,a2 <> a1 & Divide a2,b1 <> a1 & a2 =0_goto b2 <> a1 & a2 >0_goto b2 <> a1 & b1 := b3,a2 <> a1 & b3,b1 := a2 <> a1 & b3,a2 := b1 <> a1 & b3 :=<0,...,0> a2 <> a1 );
end;

:: deftheorem Def1 defines does_not_refer SCMFSA7B:def 1 :
for b1 being Instruction of SCM+FSA
for b2 being Int-Location holds
( b1 does_not_refer b2 iff for b3 being Int-Location
for b4 being Instruction-Location of SCM+FSA
for b5 being FinSeq-Location holds
( b3 := b2 <> b1 & AddTo b3,b2 <> b1 & SubFrom b3,b2 <> b1 & MultBy b3,b2 <> b1 & Divide b3,b2 <> b1 & Divide b2,b3 <> b1 & b2 =0_goto b4 <> b1 & b2 >0_goto b4 <> b1 & b3 := b5,b2 <> b1 & b5,b3 := b2 <> b1 & b5,b2 := b3 <> b1 & b5 :=<0,...,0> b2 <> b1 ) );

definition
let c2 be programmed FinPartState of SCM+FSA ;
let c3 be Int-Location ;
pred c1 does_not_refer c2 means :: SCMFSA7B:def 2
for b1 being Instruction of SCM+FSA st b1 in rng a1 holds
b1 does_not_refer a2;
end;

:: deftheorem Def2 defines does_not_refer SCMFSA7B:def 2 :
for b1 being programmed FinPartState of SCM+FSA
for b2 being Int-Location holds
( b1 does_not_refer b2 iff for b3 being Instruction of SCM+FSA st b3 in rng b1 holds
b3 does_not_refer b2 );

definition
let c2 be Instruction of SCM+FSA ;
let c3 be Int-Location ;
pred c1 does_not_destroy c2 means :Def3: :: SCMFSA7B:def 3
for b1 being Int-Location
for b2 being FinSeq-Location holds
( a2 := b1 <> a1 & AddTo a2,b1 <> a1 & SubFrom a2,b1 <> a1 & MultBy a2,b1 <> a1 & Divide a2,b1 <> a1 & Divide b1,a2 <> a1 & a2 := b2,b1 <> a1 & a2 :=len b2 <> a1 );
end;

:: deftheorem Def3 defines does_not_destroy SCMFSA7B:def 3 :
for b1 being Instruction of SCM+FSA
for b2 being Int-Location holds
( b1 does_not_destroy b2 iff for b3 being Int-Location
for b4 being FinSeq-Location holds
( b2 := b3 <> b1 & AddTo b2,b3 <> b1 & SubFrom b2,b3 <> b1 & MultBy b2,b3 <> b1 & Divide b2,b3 <> b1 & Divide b3,b2 <> b1 & b2 := b4,b3 <> b1 & b2 :=len b4 <> b1 ) );

definition
let c2 be FinPartState of SCM+FSA ;
let c3 be Int-Location ;
pred c1 does_not_destroy c2 means :Def4: :: SCMFSA7B:def 4
for b1 being Instruction of SCM+FSA st b1 in rng a1 holds
b1 does_not_destroy a2;
end;

:: deftheorem Def4 defines does_not_destroy SCMFSA7B:def 4 :
for b1 being FinPartState of SCM+FSA
for b2 being Int-Location holds
( b1 does_not_destroy b2 iff for b3 being Instruction of SCM+FSA st b3 in rng b1 holds
b3 does_not_destroy b2 );

definition
let c2 be FinPartState of SCM+FSA ;
attr a1 is good means :Def5: :: SCMFSA7B:def 5
a1 does_not_destroy intloc 0;
end;

:: deftheorem Def5 defines good SCMFSA7B:def 5 :
for b1 being FinPartState of SCM+FSA holds
( b1 is good iff b1 does_not_destroy intloc 0 );

definition
let c2 be FinPartState of SCM+FSA ;
attr a1 is halt-free means :Def6: :: SCMFSA7B:def 6
not halt SCM+FSA in rng a1;
end;

:: deftheorem Def6 defines halt-free SCMFSA7B:def 6 :
for b1 being FinPartState of SCM+FSA holds
( b1 is halt-free iff not halt SCM+FSA in rng b1 );

registration
cluster good halt-free FinPartState of SCM+FSA ;
existence
ex b1 being Macro-Instruction st
( b1 is halt-free & b1 is good )
proof end;
end;

theorem Th11: :: SCMFSA7B:11
for b1 being Int-Location holds halt SCM+FSA does_not_destroy b1
proof end;

theorem Th12: :: SCMFSA7B:12
for b1, b2, b3 being Int-Location st b1 <> b2 holds
b2 := b3 does_not_destroy b1
proof end;

theorem Th13: :: SCMFSA7B:13
for b1, b2, b3 being Int-Location st b1 <> b2 holds
AddTo b2,b3 does_not_destroy b1
proof end;

theorem Th14: :: SCMFSA7B:14
for b1, b2, b3 being Int-Location st b1 <> b2 holds
SubFrom b2,b3 does_not_destroy b1
proof end;

theorem Th15: :: SCMFSA7B:15
for b1, b2, b3 being Int-Location st b1 <> b2 holds
MultBy b2,b3 does_not_destroy b1
proof end;

theorem Th16: :: SCMFSA7B:16
for b1, b2, b3 being Int-Location st b1 <> b2 & b1 <> b3 holds
Divide b2,b3 does_not_destroy b1
proof end;

theorem Th17: :: SCMFSA7B:17
for b1 being Int-Location
for b2 being Instruction-Location of SCM+FSA holds goto b2 does_not_destroy b1
proof end;

theorem Th18: :: SCMFSA7B:18
for b1, b2 being Int-Location
for b3 being Instruction-Location of SCM+FSA holds b2 =0_goto b3 does_not_destroy b1
proof end;

theorem Th19: :: SCMFSA7B:19
for b1, b2 being Int-Location
for b3 being Instruction-Location of SCM+FSA holds b2 >0_goto b3 does_not_destroy b1
proof end;

theorem Th20: :: SCMFSA7B:20
for b1, b2, b3 being Int-Location
for b4 being FinSeq-Location st b1 <> b2 holds
b2 := b4,b3 does_not_destroy b1
proof end;

theorem Th21: :: SCMFSA7B:21
for b1, b2, b3 being Int-Location
for b4 being FinSeq-Location holds b4,b3 := b2 does_not_destroy b1
proof end;

theorem Th22: :: SCMFSA7B:22
for b1, b2 being Int-Location
for b3 being FinSeq-Location st b1 <> b2 holds
b2 :=len b3 does_not_destroy b1
proof end;

theorem Th23: :: SCMFSA7B:23
for b1, b2 being Int-Location
for b3 being FinSeq-Location holds b3 :=<0,...,0> b2 does_not_destroy b1
proof end;

definition
let c2 be FinPartState of SCM+FSA ;
let c3 be State of SCM+FSA ;
pred c1 is_closed_on c2 means :Def7: :: SCMFSA7B:def 7
for b1 being Nat holds IC ((Computation (a2 +* (a1 +* (Start-At (insloc 0))))) . b1) in dom a1;
pred c1 is_halting_on c2 means :Def8: :: SCMFSA7B:def 8
a2 +* (a1 +* (Start-At (insloc 0))) is halting;
end;

:: deftheorem Def7 defines is_closed_on SCMFSA7B:def 7 :
for b1 being FinPartState of SCM+FSA
for b2 being State of SCM+FSA holds
( b1 is_closed_on b2 iff for b3 being Nat holds IC ((Computation (b2 +* (b1 +* (Start-At (insloc 0))))) . b3) in dom b1 );

:: deftheorem Def8 defines is_halting_on SCMFSA7B:def 8 :
for b1 being FinPartState of SCM+FSA
for b2 being State of SCM+FSA holds
( b1 is_halting_on b2 iff b2 +* (b1 +* (Start-At (insloc 0))) is halting );

theorem Th24: :: SCMFSA7B:24
for b1 being Macro-Instruction holds
( b1 is paraclosed iff for b2 being State of SCM+FSA holds b1 is_closed_on b2 )
proof end;

theorem Th25: :: SCMFSA7B:25
for b1 being Macro-Instruction holds
( b1 is parahalting iff for b2 being State of SCM+FSA holds b1 is_halting_on b2 )
proof end;

theorem Th26: :: SCMFSA7B:26
for b1 being Instruction of SCM+FSA
for b2 being Int-Location
for b3 being State of SCM+FSA st b1 does_not_destroy b2 holds
(Exec b1,b3) . b2 = b3 . b2
proof end;

theorem Th27: :: SCMFSA7B:27
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_on b1 holds
for b4 being Nat holds ((Computation (b1 +* (b2 +* (Start-At (insloc 0))))) . b4) . b3 = b1 . b3
proof end;

theorem Th28: :: SCMFSA7B:28
SCM+FSA-Stop does_not_destroy intloc 0
proof end;

Lemma27: SCM+FSA-Stop is parahalting
proof end;

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

registration
cluster SCM+FSA-Stop -> parahalting good ;
coherence
( SCM+FSA-Stop is parahalting & SCM+FSA-Stop is good )
by Def5, Lemma27, Th28;
end;

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

theorem Th29: :: SCMFSA7B:29
for b1 being Int-Location
for b2 being Integer holds rng (aSeq b1,b2) c= {(b1 := (intloc 0)),(AddTo b1,(intloc 0)),(SubFrom b1,(intloc 0))}
proof end;

theorem Th30: :: SCMFSA7B:30
for b1 being Int-Location
for b2 being Integer holds rng (b1 := b2) c= {(halt SCM+FSA ),(b1 := (intloc 0)),(AddTo b1,(intloc 0)),(SubFrom b1,(intloc 0))}
proof end;

registration
let c2 be read-write Int-Location ;
let c3 be Integer;
cluster a1 := a2 -> programmed initial parahalting keeping_0 good ;
correctness
coherence
c2 := c3 is good
;
proof end;
end;

registration
let c2 be read-write Int-Location ;
let c3 be Integer;
cluster a1 := a2 -> programmed initial parahalting keeping_0 good ;
correctness
coherence
c2 := c3 is keeping_0
;
;
end;