:: The Basic Properties of { \bf SCM } over Ring
:: by Artur Korni{\l}owicz
::
:: Copyright (c) 1998-2021 Association of Mizar Users

definition
let R be Ring;
func SCM R -> strict AMI-Struct over Segm 2 means :Def1: :: SCMRING2:def 1
( the carrier of it = SCM-Memory & the ZeroF of it = NAT & the InstructionsF of it = SCM-Instr R & the Object-Kind of it = SCM-OK & the ValuesF of it = SCM-VAL R & the Execution of it = SCM-Exec R );
existence
ex b1 being strict AMI-Struct over Segm 2 st
( the carrier of b1 = SCM-Memory & the ZeroF of b1 = NAT & the InstructionsF of b1 = SCM-Instr R & the Object-Kind of b1 = SCM-OK & the ValuesF of b1 = SCM-VAL R & the Execution of b1 = SCM-Exec R )
proof end;
uniqueness
for b1, b2 being strict AMI-Struct over Segm 2 st the carrier of b1 = SCM-Memory & the ZeroF of b1 = NAT & the InstructionsF of b1 = SCM-Instr R & the Object-Kind of b1 = SCM-OK & the ValuesF of b1 = SCM-VAL R & the Execution of b1 = SCM-Exec R & the carrier of b2 = SCM-Memory & the ZeroF of b2 = NAT & the InstructionsF of b2 = SCM-Instr R & the Object-Kind of b2 = SCM-OK & the ValuesF of b2 = SCM-VAL R & the Execution of b2 = SCM-Exec R holds
b1 = b2
;
end;

:: deftheorem Def1 defines SCM SCMRING2:def 1 :
for R being Ring
for b2 being strict AMI-Struct over Segm 2 holds
( b2 = SCM R iff ( the carrier of b2 = SCM-Memory & the ZeroF of b2 = NAT & the InstructionsF of b2 = SCM-Instr R & the Object-Kind of b2 = SCM-OK & the ValuesF of b2 = SCM-VAL R & the Execution of b2 = SCM-Exec R ) );

registration
let R be Ring;
cluster SCM R -> non empty strict ;
coherence
not SCM R is empty
by Def1;
end;

Lm1: now :: thesis: for R being Ring holds the_Values_of (SCM R) = () * SCM-OK
let R be Ring; :: thesis: the_Values_of (SCM R) = () * SCM-OK
thus the_Values_of (SCM R) = the ValuesF of (SCM R) * the Object-Kind of (SCM R)
.= the ValuesF of (SCM R) * SCM-OK by Def1
.= () * SCM-OK by Def1 ; :: thesis: verum
end;

registration
let R be Ring;
coherence
proof end;
end;

Lm2: for R being Ring holds the carrier of (SCM R) \ = SCM-Data-Loc
proof end;

registration
let R be Ring;
cluster Int-like for Element of the carrier of (SCM R);
existence
ex b1 being Object of (SCM R) st b1 is Int-like
proof end;
end;

definition
let R be Ring;
mode Data-Location of R is Int-like Object of (SCM R);
end;

:: deftheorem SCMRING2:def 2 :
canceled;

theorem Th1: :: SCMRING2:1
for x being set
for R being Ring holds
( x is Data-Location of R iff x in Data-Locations ) by ;

definition
let R be Ring;
let s be State of (SCM R);
let a be Data-Location of R;
:: original: .
redefine func s . a -> Element of R;
coherence
s . a is Element of R
proof end;
end;

theorem :: SCMRING2:2
for R being Ring holds [0,{},{}] is Instruction of (SCM R)
proof end;

theorem Th3: :: SCMRING2:3
for S being non empty 1-sorted
for x being set
for R being Ring
for d1, d2 being Data-Location of R st x in {1,2,3,4} holds
[x,{},<*d1,d2*>] in SCM-Instr S
proof end;

theorem Th4: :: SCMRING2:4
for S being non empty 1-sorted
for t being Element of S
for R being Ring
for d1 being Data-Location of R holds [5,{},<*d1,t*>] in SCM-Instr S
proof end;

theorem Th5: :: SCMRING2:5
for S being non empty 1-sorted
for i1 being Nat holds [6,<*i1*>,{}] in SCM-Instr S by SCMRINGI:10;

theorem Th6: :: SCMRING2:6
for S being non empty 1-sorted
for R being Ring
for d1 being Data-Location of R
for i1 being Nat holds [7,<*i1*>,<*d1*>] in SCM-Instr S
proof end;

definition
let R be Ring;
let a, b be Data-Location of R;
func a := b -> Instruction of (SCM R) equals :: SCMRING2:def 3
[1,{},<*a,b*>];
coherence
[1,{},<*a,b*>] is Instruction of (SCM R)
proof end;
func AddTo (a,b) -> Instruction of (SCM R) equals :: SCMRING2:def 4
[2,{},<*a,b*>];
coherence
[2,{},<*a,b*>] is Instruction of (SCM R)
proof end;
func SubFrom (a,b) -> Instruction of (SCM R) equals :: SCMRING2:def 5
[3,{},<*a,b*>];
coherence
[3,{},<*a,b*>] is Instruction of (SCM R)
proof end;
func MultBy (a,b) -> Instruction of (SCM R) equals :: SCMRING2:def 6
[4,{},<*a,b*>];
coherence
[4,{},<*a,b*>] is Instruction of (SCM R)
proof end;
end;

:: deftheorem defines := SCMRING2:def 3 :
for R being Ring
for a, b being Data-Location of R holds a := b = [1,{},<*a,b*>];

:: deftheorem defines AddTo SCMRING2:def 4 :
for R being Ring
for a, b being Data-Location of R holds AddTo (a,b) = [2,{},<*a,b*>];

:: deftheorem defines SubFrom SCMRING2:def 5 :
for R being Ring
for a, b being Data-Location of R holds SubFrom (a,b) = [3,{},<*a,b*>];

:: deftheorem defines MultBy SCMRING2:def 6 :
for R being Ring
for a, b being Data-Location of R holds MultBy (a,b) = [4,{},<*a,b*>];

definition
let R be Ring;
let a be Data-Location of R;
let r be Element of R;
func a := r -> Instruction of (SCM R) equals :: SCMRING2:def 7
[5,{},<*a,r*>];
coherence
[5,{},<*a,r*>] is Instruction of (SCM R)
proof end;
end;

:: deftheorem defines := SCMRING2:def 7 :
for R being Ring
for a being Data-Location of R
for r being Element of R holds a := r = [5,{},<*a,r*>];

definition
let R be Ring;
let l be Nat;
func goto (l,R) -> Instruction of (SCM R) equals :: SCMRING2:def 8
[6,<*l*>,{}];
coherence
[6,<*l*>,{}] is Instruction of (SCM R)
proof end;
end;

:: deftheorem defines goto SCMRING2:def 8 :
for R being Ring
for l being Nat holds goto (l,R) = [6,<*l*>,{}];

definition
let R be Ring;
let l be Nat;
let a be Data-Location of R;
func a =0_goto l -> Instruction of (SCM R) equals :: SCMRING2:def 9
[7,<*l*>,<*a*>];
coherence
[7,<*l*>,<*a*>] is Instruction of (SCM R)
proof end;
end;

:: deftheorem defines =0_goto SCMRING2:def 9 :
for R being Ring
for l being Nat
for a being Data-Location of R holds a =0_goto l = [7,<*l*>,<*a*>];

theorem Th7: :: SCMRING2:7
for R being Ring
for I being set holds
( I is Instruction of (SCM R) iff ( I = [0,{},{}] or ex a, b being Data-Location of R st I = a := b or ex a, b being Data-Location of R st I = AddTo (a,b) or ex a, b being Data-Location of R st I = SubFrom (a,b) or ex a, b being Data-Location of R st I = MultBy (a,b) or ex i1 being Nat st I = goto (i1,R) or ex a being Data-Location of R ex i1 being Nat st I = a =0_goto i1 or ex a being Data-Location of R ex r being Element of R st I = a := r ) )
proof end;

registration
let R be Ring;
coherence
proof end;
end;

theorem :: SCMRING2:8
for R being Ring holds IC = NAT by Def1;

theorem :: SCMRING2:9
for R being Ring
for s being State of (SCM R)
for S being SCM-State of R st S = s holds
IC s = IC S by Def1;

theorem Th10: :: SCMRING2:10
for R being Ring
for s being State of (SCM R)
for I being Instruction of (SCM R)
for i being Element of SCM-Instr R st i = I holds
for S being SCM-State of R st S = s holds
Exec (I,s) = SCM-Exec-Res (i,S)
proof end;

theorem Th11: :: SCMRING2:11
for R being Ring
for a, b being Data-Location of R
for s being State of (SCM R) holds
( (Exec ((a := b),s)) . () = (IC s) + 1 & (Exec ((a := b),s)) . a = s . b & ( for c being Data-Location of R st c <> a holds
(Exec ((a := b),s)) . c = s . c ) )
proof end;

theorem Th12: :: SCMRING2:12
for R being Ring
for a, b being Data-Location of R
for s being State of (SCM R) holds
( (Exec ((AddTo (a,b)),s)) . () = (IC s) + 1 & (Exec ((AddTo (a,b)),s)) . a = (s . a) + (s . b) & ( for c being Data-Location of R st c <> a holds
(Exec ((AddTo (a,b)),s)) . c = s . c ) )
proof end;

theorem Th13: :: SCMRING2:13
for R being Ring
for a, b being Data-Location of R
for s being State of (SCM R) holds
( (Exec ((SubFrom (a,b)),s)) . () = (IC s) + 1 & (Exec ((SubFrom (a,b)),s)) . a = (s . a) - (s . b) & ( for c being Data-Location of R st c <> a holds
(Exec ((SubFrom (a,b)),s)) . c = s . c ) )
proof end;

theorem Th14: :: SCMRING2:14
for R being Ring
for a, b being Data-Location of R
for s being State of (SCM R) holds
( (Exec ((MultBy (a,b)),s)) . () = (IC s) + 1 & (Exec ((MultBy (a,b)),s)) . a = (s . a) * (s . b) & ( for c being Data-Location of R st c <> a holds
(Exec ((MultBy (a,b)),s)) . c = s . c ) )
proof end;

theorem :: SCMRING2:15
for R being Ring
for c being Data-Location of R
for i1 being Nat
for s being State of (SCM R) holds
( (Exec ((goto (i1,R)),s)) . () = i1 & (Exec ((goto (i1,R)),s)) . c = s . c )
proof end;

theorem Th16: :: SCMRING2:16
for R being Ring
for a, c being Data-Location of R
for i1 being Nat
for s being State of (SCM R) holds
( ( s . a = 0. R implies (Exec ((a =0_goto i1),s)) . () = i1 ) & ( s . a <> 0. R implies (Exec ((a =0_goto i1),s)) . () = (IC s) + 1 ) & (Exec ((a =0_goto i1),s)) . c = s . c )
proof end;

theorem Th17: :: SCMRING2:17
for R being Ring
for r being Element of R
for a being Data-Location of R
for s being State of (SCM R) holds
( (Exec ((a := r),s)) . () = (IC s) + 1 & (Exec ((a := r),s)) . a = r & ( for c being Data-Location of R st c <> a holds
(Exec ((a := r),s)) . c = s . c ) )
proof end;

theorem Th18: :: SCMRING2:18
for R being Ring
for I being Instruction of (SCM R) st ex s being State of (SCM R) st (Exec (I,s)) . () = (IC s) + 1 holds
not I is halting
proof end;

theorem Th19: :: SCMRING2:19
for R being Ring
for I being Instruction of (SCM R) st I = [0,{},{}] holds
I is halting
proof end;

Lm3: for R being Ring
for a, b being Data-Location of R holds not a := b is halting

proof end;

Lm4: for R being Ring
for a, b being Data-Location of R holds not AddTo (a,b) is halting

proof end;

Lm5: for R being Ring
for a, b being Data-Location of R holds not SubFrom (a,b) is halting

proof end;

Lm6: for R being Ring
for a, b being Data-Location of R holds not MultBy (a,b) is halting

proof end;

Lm7: for R being Ring
for i1 being Nat holds not goto (i1,R) is halting

proof end;

Lm8: for R being Ring
for a being Data-Location of R
for i1 being Nat holds not a =0_goto i1 is halting

proof end;

Lm9: for R being Ring
for r being Element of R
for a being Data-Location of R holds not a := r is halting

proof end;

registration
let R be Ring;
let a, b be Data-Location of R;
cluster a := b -> non halting ;
coherence
not a := b is halting
by Lm3;
cluster AddTo (a,b) -> non halting ;
coherence
by Lm4;
cluster SubFrom (a,b) -> non halting ;
coherence
not SubFrom (a,b) is halting
by Lm5;
cluster MultBy (a,b) -> non halting ;
coherence
not MultBy (a,b) is halting
by Lm6;
end;

registration
let R be Ring;
let i1 be Nat;
cluster goto (i1,R) -> non halting ;
coherence
not goto (i1,R) is halting
by Lm7;
end;

registration
let R be Ring;
let a be Data-Location of R;
let i1 be Nat;
cluster a =0_goto i1 -> non halting ;
coherence
not a =0_goto i1 is halting
by Lm8;
end;

registration
let R be Ring;
let a be Data-Location of R;
let r be Element of R;
cluster a := r -> non halting ;
coherence
not a := r is halting
by Lm9;
end;

Lm10: for R being Ring
for W being Instruction of (SCM R) st W is halting holds
W = [0,{},{}]

proof end;

registration
let R be Ring;
coherence
SCM R is halting
by Th19;
end;

theorem :: SCMRING2:20
for R being Ring
for I being Instruction of (SCM R) st I is halting holds
I = halt (SCM R) by Lm10;

theorem :: SCMRING2:21
for R being Ring holds halt (SCM R) = [0,{},{}] ;

theorem Th22: :: SCMRING2:22
for R being Ring holds Data-Locations = Data-Locations
proof end;

theorem :: SCMRING2:23
for x being set
for R being Ring holds
( x is Data-Location of R iff x in Data-Locations )
proof end;

theorem :: SCMRING2:24
for R being Ring holds the_Values_of (SCM R) = () * SCM-OK by Lm1;

theorem :: SCMRING2:25
for R being Ring holds the carrier of (SCM R) \ = SCM-Data-Loc by Lm2;