:: SCMFSA_7 semantic presentation

registration
cluster -> finite FinPartState of SCM+FSA ;
coherence
for b1 being FinPartState of SCM+FSA holds b1 is finite
by AMI_1:def 24;
end;

registration
let c1 be FinSequence;
let c2, c3 be set ;
cluster a1 +* a2,a3 -> FinSequence-like ;
coherence
c1 +* c2,c3 is FinSequence-like
proof end;
end;

theorem Th1: :: SCMFSA_7:1
for b1 being natural number holds abs b1 = b1 by ABSVALUE:def 1;

Lemma2: for b1, b2, b3 being Nat st b1 >= b3 & b2 >= b3 & b1 -' b3 = b2 -' b3 holds
b1 = b2
by BINARITH:49;

Lemma3: for b1, b2 being natural number st b1 >= b2 holds
b1 -' b2 = b1 - b2
by BINARITH:50;

Lemma4: for b1, b2 being Integer st b1 < b2 holds
b1 <= b2 - 1
by INT_1:79;

scheme :: SCMFSA_7:sch 1
s1{ F1() -> set , F2() -> non empty set , F3( set ) -> set } :
F1(),{ F3(b1) where B is Element of F2() : b1 in F1() } are_equipotent
provided
E5: F1() c= F2() and
E6: for b1, b2 being Element of F2() st b1 in F1() & b2 in F1() & F3(b1) = F3(b2) holds
b1 = b2
proof end;

theorem Th2: :: SCMFSA_7:2
canceled;

theorem Th3: :: SCMFSA_7:3
canceled;

theorem Th4: :: SCMFSA_7:4
canceled;

theorem Th5: :: SCMFSA_7:5
canceled;

theorem Th6: :: SCMFSA_7:6
canceled;

theorem Th7: :: SCMFSA_7:7
canceled;

theorem Th8: :: SCMFSA_7:8
canceled;

theorem Th9: :: SCMFSA_7:9
canceled;

theorem Th10: :: SCMFSA_7:10
canceled;

Lemma5: 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;

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

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

theorem Th11: :: SCMFSA_7:11
canceled;

theorem Th12: :: SCMFSA_7:12
for b1 being FinSequence st b1 <> {} holds
len b1 in dom b1
proof end;

theorem Th13: :: SCMFSA_7:13
for b1 being set holds FlattenSeq (<*> (b1 * )) = <*> b1
proof end;

theorem Th14: :: SCMFSA_7:14
for b1 being set
for b2, b3 being FinSequence of b1 * holds FlattenSeq (b2 ^ b3) = (FlattenSeq b2) ^ (FlattenSeq b3)
proof end;

theorem Th15: :: SCMFSA_7:15
for b1 being set
for b2, b3 being Element of b1 * holds FlattenSeq <*b2,b3*> = b2 ^ b3
proof end;

theorem Th16: :: SCMFSA_7:16
for b1 being set
for b2, b3, b4 being Element of b1 * holds FlattenSeq <*b2,b3,b4*> = (b2 ^ b3) ^ b4
proof end;

theorem Th17: :: SCMFSA_7:17
for b1 being non empty set
for b2, b3 being FinSequence of b1 st b2 c= b3 holds
ex b4 being FinSequence of b1 st b2 ^ b4 = b3
proof end;

theorem Th18: :: SCMFSA_7:18
for b1 being non empty set
for b2, b3 being FinSequence of b1
for b4 being Nat st b2 c= b3 & 1 <= b4 & b4 <= len b2 holds
b3 . b4 = b2 . b4
proof end;

theorem Th19: :: SCMFSA_7:19
for b1 being set
for b2, b3 being FinSequence of b1 * st b2 c= b3 holds
FlattenSeq b2 c= FlattenSeq b3
proof end;

theorem Th20: :: SCMFSA_7:20
for b1 being FinSequence holds b1 | (Seg 0) = {}
proof end;

theorem Th21: :: SCMFSA_7:21
for b1, b2 being FinSequence holds b1 | (Seg 0) = b2 | (Seg 0)
proof end;

theorem Th22: :: SCMFSA_7:22
for b1 being non empty set
for b2 being Element of b1 holds <*b2*> is FinSequence of b1 ;

theorem Th23: :: SCMFSA_7:23
for b1 being set
for b2, b3 being FinSequence of b1 holds b2 ^ b3 is FinSequence of b1 ;

deffunc H1( Nat) -> Element of the Instruction-Locations of SCM+FSA = insloc (a1 -' 1);

definition
let c1 be FinSequence of the Instructions of SCM+FSA ;
func Load c1 -> FinPartState of SCM+FSA means :Def1: :: SCMFSA_7:def 1
( dom a2 = { (insloc (b1 -' 1)) where B is Nat : b1 in dom a1 } & ( for b1 being Nat st insloc b1 in dom a2 holds
a2 . (insloc b1) = a1 /. (b1 + 1) ) );
existence
ex b1 being FinPartState of SCM+FSA st
( dom b1 = { (insloc (b2 -' 1)) where B is Nat : b2 in dom c1 } & ( for b2 being Nat st insloc b2 in dom b1 holds
b1 . (insloc b2) = c1 /. (b2 + 1) ) )
proof end;
uniqueness
for b1, b2 being FinPartState of SCM+FSA st dom b1 = { (insloc (b3 -' 1)) where B is Nat : b3 in dom c1 } & ( for b3 being Nat st insloc b3 in dom b1 holds
b1 . (insloc b3) = c1 /. (b3 + 1) ) & dom b2 = { (insloc (b3 -' 1)) where B is Nat : b3 in dom c1 } & ( for b3 being Nat st insloc b3 in dom b2 holds
b2 . (insloc b3) = c1 /. (b3 + 1) ) holds
b1 = b2
proof end;
end;

:: deftheorem Def1 defines Load SCMFSA_7:def 1 :
for b1 being FinSequence of the Instructions of SCM+FSA
for b2 being FinPartState of SCM+FSA holds
( b2 = Load b1 iff ( dom b2 = { (insloc (b3 -' 1)) where B is Nat : b3 in dom b1 } & ( for b3 being Nat st insloc b3 in dom b2 holds
b2 . (insloc b3) = b1 /. (b3 + 1) ) ) );

theorem Th24: :: SCMFSA_7:24
canceled;

theorem Th25: :: SCMFSA_7:25
for b1 being FinSequence of the Instructions of SCM+FSA holds card (Load b1) = len b1
proof end;

theorem Th26: :: SCMFSA_7:26
for b1 being FinSequence of the Instructions of SCM+FSA
for b2 being Nat holds
( insloc b2 in dom (Load b1) iff b2 + 1 in dom b1 )
proof end;

theorem Th27: :: SCMFSA_7:27
canceled;

theorem Th28: :: SCMFSA_7:28
for b1, b2 being Nat holds
( b1 < b2 iff ( 1 <= b1 + 1 & b1 + 1 <= b2 ) )
proof end;

theorem Th29: :: SCMFSA_7:29
for b1 being FinSequence of the Instructions of SCM+FSA
for b2 being Nat holds
( insloc b2 in dom (Load b1) iff b2 < len b1 )
proof end;

theorem Th30: :: SCMFSA_7:30
for b1 being non empty FinSequence of the Instructions of SCM+FSA holds
( 1 in dom b1 & insloc 0 in dom (Load b1) )
proof end;

theorem Th31: :: SCMFSA_7:31
for b1, b2 being FinSequence of the Instructions of SCM+FSA holds Load b1 c= Load (b1 ^ b2)
proof end;

theorem Th32: :: SCMFSA_7:32
for b1, b2 being FinSequence of the Instructions of SCM+FSA st b1 c= b2 holds
Load b1 c= Load b2
proof end;

definition
let c1 be Int-Location ;
let c2 be Integer;
func c1 := c2 -> FinPartState of SCM+FSA means :Def2: :: SCMFSA_7:def 2
ex b1 being Nat st
( b1 + 1 = a2 & a3 = Load ((<*(a1 := (intloc 0))*> ^ (b1 |-> (AddTo a1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) if a2 > 0
otherwise ex b1 being Nat st
( b1 + a2 = 1 & a3 = Load ((<*(a1 := (intloc 0))*> ^ (b1 |-> (SubFrom a1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) );
existence
( ( c2 > 0 implies ex b1 being FinPartState of SCM+FSA ex b2 being Nat st
( b2 + 1 = c2 & b1 = Load ((<*(c1 := (intloc 0))*> ^ (b2 |-> (AddTo c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) ) & ( not c2 > 0 implies ex b1 being FinPartState of SCM+FSA ex b2 being Nat st
( b2 + c2 = 1 & b1 = Load ((<*(c1 := (intloc 0))*> ^ (b2 |-> (SubFrom c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) ) )
proof end;
uniqueness
for b1, b2 being FinPartState of SCM+FSA holds
( ( c2 > 0 & ex b3 being Nat st
( b3 + 1 = c2 & b1 = Load ((<*(c1 := (intloc 0))*> ^ (b3 |-> (AddTo c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) & ex b3 being Nat st
( b3 + 1 = c2 & b2 = Load ((<*(c1 := (intloc 0))*> ^ (b3 |-> (AddTo c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) implies b1 = b2 ) & ( not c2 > 0 & ex b3 being Nat st
( b3 + c2 = 1 & b1 = Load ((<*(c1 := (intloc 0))*> ^ (b3 |-> (SubFrom c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) & ex b3 being Nat st
( b3 + c2 = 1 & b2 = Load ((<*(c1 := (intloc 0))*> ^ (b3 |-> (SubFrom c1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) implies b1 = b2 ) )
;
correctness
consistency
for b1 being FinPartState of SCM+FSA holds verum
;
;
end;

:: deftheorem Def2 defines := SCMFSA_7:def 2 :
for b1 being Int-Location
for b2 being Integer
for b3 being FinPartState of SCM+FSA holds
( ( b2 > 0 implies ( b3 = b1 := b2 iff ex b4 being Nat st
( b4 + 1 = b2 & b3 = Load ((<*(b1 := (intloc 0))*> ^ (b4 |-> (AddTo b1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) ) ) & ( not b2 > 0 implies ( b3 = b1 := b2 iff ex b4 being Nat st
( b4 + b2 = 1 & b3 = Load ((<*(b1 := (intloc 0))*> ^ (b4 |-> (SubFrom b1,(intloc 0)))) ^ <*(halt SCM+FSA )*>) ) ) ) );

definition
let c1 be Int-Location ;
let c2 be Integer;
func aSeq c1,c2 -> FinSequence of the Instructions of SCM+FSA means :Def3: :: SCMFSA_7:def 3
ex b1 being Nat st
( b1 + 1 = a2 & a3 = <*(a1 := (intloc 0))*> ^ (b1 |-> (AddTo a1,(intloc 0))) ) if a2 > 0
otherwise ex b1 being Nat st
( b1 + a2 = 1 & a3 = <*(a1 := (intloc 0))*> ^ (b1 |-> (SubFrom a1,(intloc 0))) );
existence
( ( c2 > 0 implies ex b1 being FinSequence of the Instructions of SCM+FSA ex b2 being Nat st
( b2 + 1 = c2 & b1 = <*(c1 := (intloc 0))*> ^ (b2 |-> (AddTo c1,(intloc 0))) ) ) & ( not c2 > 0 implies ex b1 being FinSequence of the Instructions of SCM+FSA ex b2 being Nat st
( b2 + c2 = 1 & b1 = <*(c1 := (intloc 0))*> ^ (b2 |-> (SubFrom c1,(intloc 0))) ) ) )
proof end;
uniqueness
for b1, b2 being FinSequence of the Instructions of SCM+FSA holds
( ( c2 > 0 & ex b3 being Nat st
( b3 + 1 = c2 & b1 = <*(c1 := (intloc 0))*> ^ (b3 |-> (AddTo c1,(intloc 0))) ) & ex b3 being Nat st
( b3 + 1 = c2 & b2 = <*(c1 := (intloc 0))*> ^ (b3 |-> (AddTo c1,(intloc 0))) ) implies b1 = b2 ) & ( not c2 > 0 & ex b3 being Nat st
( b3 + c2 = 1 & b1 = <*(c1 := (intloc 0))*> ^ (b3 |-> (SubFrom c1,(intloc 0))) ) & ex b3 being Nat st
( b3 + c2 = 1 & b2 = <*(c1 := (intloc 0))*> ^ (b3 |-> (SubFrom c1,(intloc 0))) ) implies b1 = b2 ) )
;
correctness
consistency
for b1 being FinSequence of the Instructions of SCM+FSA holds verum
;
;
end;

:: deftheorem Def3 defines aSeq SCMFSA_7:def 3 :
for b1 being Int-Location
for b2 being Integer
for b3 being FinSequence of the Instructions of SCM+FSA holds
( ( b2 > 0 implies ( b3 = aSeq b1,b2 iff ex b4 being Nat st
( b4 + 1 = b2 & b3 = <*(b1 := (intloc 0))*> ^ (b4 |-> (AddTo b1,(intloc 0))) ) ) ) & ( not b2 > 0 implies ( b3 = aSeq b1,b2 iff ex b4 being Nat st
( b4 + b2 = 1 & b3 = <*(b1 := (intloc 0))*> ^ (b4 |-> (SubFrom b1,(intloc 0))) ) ) ) );

theorem Th33: :: SCMFSA_7:33
for b1 being Int-Location
for b2 being Integer holds b1 := b2 = Load ((aSeq b1,b2) ^ <*(halt SCM+FSA )*>)
proof end;

definition
let c1 be FinSeq-Location ;
let c2 be FinSequence of INT ;
func aSeq c1,c2 -> FinSequence of the Instructions of SCM+FSA means :Def4: :: SCMFSA_7:def 4
ex b1 being FinSequence of the Instructions of SCM+FSA * st
( len b1 = len a2 & ( for b2 being Nat st 1 <= b2 & b2 <= len a2 holds
ex b3 being Integer st
( b3 = a2 . b2 & b1 . b2 = ((aSeq (intloc 1),b2) ^ (aSeq (intloc 2),b3)) ^ <*(a1,(intloc 1) := (intloc 2))*> ) ) & a3 = FlattenSeq b1 );
existence
ex b1 being FinSequence of the Instructions of SCM+FSA ex b2 being FinSequence of the Instructions of SCM+FSA * st
( len b2 = len c2 & ( for b3 being Nat st 1 <= b3 & b3 <= len c2 holds
ex b4 being Integer st
( b4 = c2 . b3 & b2 . b3 = ((aSeq (intloc 1),b3) ^ (aSeq (intloc 2),b4)) ^ <*(c1,(intloc 1) := (intloc 2))*> ) ) & b1 = FlattenSeq b2 )
proof end;
uniqueness
for b1, b2 being FinSequence of the Instructions of SCM+FSA st ex b3 being FinSequence of the Instructions of SCM+FSA * st
( len b3 = len c2 & ( for b4 being Nat st 1 <= b4 & b4 <= len c2 holds
ex b5 being Integer st
( b5 = c2 . b4 & b3 . b4 = ((aSeq (intloc 1),b4) ^ (aSeq (intloc 2),b5)) ^ <*(c1,(intloc 1) := (intloc 2))*> ) ) & b1 = FlattenSeq b3 ) & ex b3 being FinSequence of the Instructions of SCM+FSA * st
( len b3 = len c2 & ( for b4 being Nat st 1 <= b4 & b4 <= len c2 holds
ex b5 being Integer st
( b5 = c2 . b4 & b3 . b4 = ((aSeq (intloc 1),b4) ^ (aSeq (intloc 2),b5)) ^ <*(c1,(intloc 1) := (intloc 2))*> ) ) & b2 = FlattenSeq b3 ) holds
b1 = b2
proof end;
correctness
;
end;

:: deftheorem Def4 defines aSeq SCMFSA_7:def 4 :
for b1 being FinSeq-Location
for b2 being FinSequence of INT
for b3 being FinSequence of the Instructions of SCM+FSA holds
( b3 = aSeq b1,b2 iff ex b4 being FinSequence of the Instructions of SCM+FSA * st
( len b4 = len b2 & ( for b5 being Nat st 1 <= b5 & b5 <= len b2 holds
ex b6 being Integer st
( b6 = b2 . b5 & b4 . b5 = ((aSeq (intloc 1),b5) ^ (aSeq (intloc 2),b6)) ^ <*(b1,(intloc 1) := (intloc 2))*> ) ) & b3 = FlattenSeq b4 ) );

definition
let c1 be FinSeq-Location ;
let c2 be FinSequence of INT ;
func c1 := c2 -> FinPartState of SCM+FSA equals :: SCMFSA_7:def 5
Load ((((aSeq (intloc 1),(len a2)) ^ <*(a1 :=<0,...,0> (intloc 1))*>) ^ (aSeq a1,a2)) ^ <*(halt SCM+FSA )*>);
correctness
coherence
Load ((((aSeq (intloc 1),(len c2)) ^ <*(c1 :=<0,...,0> (intloc 1))*>) ^ (aSeq c1,c2)) ^ <*(halt SCM+FSA )*>) is FinPartState of SCM+FSA
;
;
end;

:: deftheorem Def5 defines := SCMFSA_7:def 5 :
for b1 being FinSeq-Location
for b2 being FinSequence of INT holds b1 := b2 = Load ((((aSeq (intloc 1),(len b2)) ^ <*(b1 :=<0,...,0> (intloc 1))*>) ^ (aSeq b1,b2)) ^ <*(halt SCM+FSA )*>);

theorem Th34: :: SCMFSA_7:34
for b1 being Int-Location holds b1 := 1 = Load (<*(b1 := (intloc 0))*> ^ <*(halt SCM+FSA )*>)
proof end;

theorem Th35: :: SCMFSA_7:35
for b1 being Int-Location holds b1 := 0 = Load ((<*(b1 := (intloc 0))*> ^ <*(SubFrom b1,(intloc 0))*>) ^ <*(halt SCM+FSA )*>)
proof end;

theorem Th36: :: SCMFSA_7:36
for b1 being State of SCM+FSA st b1 . (intloc 0) = 1 holds
for b2 being Nat st IC b1 = insloc b2 holds
for b3 being Int-Location
for b4 being Integer st b3 <> intloc 0 & ( for b5 being Nat st b5 in dom (aSeq b3,b4) holds
(aSeq b3,b4) . b5 = b1 . (insloc ((b2 + b5) -' 1)) ) holds
( ( for b5 being Nat st b5 <= len (aSeq b3,b4) holds
( IC ((Computation b1) . b5) = insloc (b2 + b5) & ( for b6 being Int-Location st b6 <> b3 holds
((Computation b1) . b5) . b6 = b1 . b6 ) & ( for b6 being FinSeq-Location holds ((Computation b1) . b5) . b6 = b1 . b6 ) ) ) & ((Computation b1) . (len (aSeq b3,b4))) . b3 = b4 )
proof end;

theorem Th37: :: SCMFSA_7:37
for b1 being State of SCM+FSA st IC b1 = insloc 0 & b1 . (intloc 0) = 1 holds
for b2 being Int-Location
for b3 being Integer st Load (aSeq b2,b3) c= b1 & b2 <> intloc 0 holds
( ( for b4 being Nat st b4 <= len (aSeq b2,b3) holds
( IC ((Computation b1) . b4) = insloc b4 & ( for b5 being Int-Location st b5 <> b2 holds
((Computation b1) . b4) . b5 = b1 . b5 ) & ( for b5 being FinSeq-Location holds ((Computation b1) . b4) . b5 = b1 . b5 ) ) ) & ((Computation b1) . (len (aSeq b2,b3))) . b2 = b3 )
proof end;

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

theorem Th39: :: SCMFSA_7:39
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;