:: The Construction and Computation of While-loop Programs for SCMPDS
:: by JingChao Chen
::
:: Received June 14, 2000
:: Copyright (c) 2000-2026 Association of Mizar Users
:: (Stowarzyszenie Uzytkownikow Mizara, Bialystok, Poland).
:: This code can be distributed under the GNU General Public Licence
:: version 3.0 or later, or the Creative Commons Attribution-ShareAlike
:: License version 3.0 or later, subject to the binding interpretation
:: detailed in file COPYING.interpretation.
:: See COPYING.GPL and COPYING.CC-BY-SA for the full text of these
:: licenses, or see http://www.gnu.org/licenses/gpl.html and
:: http://creativecommons.org/licenses/by-sa/3.0/.
environ
vocabularies NUMBERS, SCMPDS_2, FSM_1, AMI_2, SUBSET_1, SCMP_GCD, AMI_3,
FUNCT_1, CARD_1, AMI_1, ARYTM_3, CARD_3, XXREAL_0, INT_1, SCMFSA_9,
TURING_1, ARYTM_1, SCMPDS_4, SCMFSA_7, RELAT_1, UNIALG_2, SCMFSA7B,
FUNCT_4, CIRCUIT2, TARSKI, SCMFSA6B, MSUALG_1, GRAPHSP, STRUCT_0,
VALUED_1, NAT_1, XBOOLE_0, PARTFUN1, EXTPRO_1, SCMFSA6C, COMPOS_1,
MEMSTR_0;
notations TARSKI, XBOOLE_0, SUBSET_1, FUNCT_2, CARD_1, ORDINAL1, NUMBERS,
RELAT_1, FUNCT_1, PARTFUN1, VALUED_1, XCMPLX_0, FUNCT_4, RECDEF_1, NAT_1,
INT_1, STRUCT_0, MEMSTR_0, COMPOS_0, COMPOS_1, EXTPRO_1, AMI_2, AMI_3,
SCMPDS_2, SCMPDS_4, SCMPDS_6, SCMP_GCD, CARD_3, DOMAIN_1, XXREAL_0;
constructors DOMAIN_1, XXREAL_0, REAL_1, RECDEF_1, SCM_1, SCMPDS_4, SCMPDS_5,
SCMPDS_6, SCMP_GCD, PRE_POLY, AMI_2, MEMSTR_0, RELSET_1, SCM_INST;
registrations FUNCT_1, ORDINAL1, RELSET_1, XXREAL_0, XREAL_0, NAT_1, INT_1,
CARD_3, SCMPDS_2, SCMPDS_4, SCMPDS_5, SCMPDS_6, XBOOLE_0, VALUED_0,
COMPOS_1, AFINSQ_1, EXTPRO_1, FUNCT_4, MEMSTR_0, AMI_3, COMPOS_0;
requirements NUMERALS, REAL, SUBSET, BOOLE, ARITHM;
begin :: Preliminaries
reserve x,a
for Int_position,
s
for State
of SCMPDS;
theorem :: SCMPDS_8:1 :: see SCMPDS_3:32
for a
be Int_position
ex i
being Nat st a = intpos i;
::$CT
theorem :: SCMPDS_8:3
for t
being State
of SCMPDS,i
being Instruction
of SCMPDS st
InsCode i
in {
0,
4,
5,
6,
14}
holds Initialize(t)=Initialize(Exec(i,t));
::$CT
theorem :: SCMPDS_8:5
for a
be Int_position
holds
ex f
be Function
of product the_Values_of SCMPDS,NAT
st
for s
being State
of SCMPDS
holds (s.a <=
0
implies f.s =
0) & (s.a >
0 implies f.s=s.a);
begin :: The construction and several basic properties of while<0 program
:: while (a,i)<0 do I
definition
::$CD
let a
be Int_position, i
be Integer,I
be Program
of SCMPDS;
func while<
0(a,i,I) -> Program
of SCMPDS equals
:: SCMPDS_8:def 2
(a,i)>=
0_goto (card I +
2)
';' I ';' goto -(card I+
1);
end;
registration
let I
be shiftable Program
of SCMPDS,a
be Int_position,i
be Integer;
cluster while<
0(a,i,I) -> shiftable;
end;
registration
let I
be halt-free Program
of SCMPDS, a
be Int_position,i
be Integer;
cluster while<
0(a,i,I) -> halt-free;
end;
theorem :: SCMPDS_8:6
for a
be Int_position,i
be Integer,I
be Program
of SCMPDS
holds
card while<
0(a,i,I)= card I +
2;
theorem :: SCMPDS_8:7
for a
be Int_position,i
be Integer,m
be Nat,I
be
Program
of SCMPDS
holds m < card I+
2 iff m
in dom while<
0(a,i,I);
theorem :: SCMPDS_8:8
for a
be Int_position,i
be Integer,I
be Program
of SCMPDS
holds
while<
0(a,i,I).
0=(a,i)>=
0_goto (card I +
2) & while<
0(a,i,I). (card
I+
1)=goto -(card I+
1);
reserve P,Q
for Instruction-Sequence
of SCMPDS;
theorem :: SCMPDS_8:9
for s
being State
of SCMPDS,I
being Program
of SCMPDS,a
being
Int_position, i
being Integer st s.DataLoc(s.a,i) >=
0 holds while<
0(a,i,I)
is_closed_on s,P & while<
0(a,i,I) is_halting_on s,P;
theorem :: SCMPDS_8:10
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS,a,c
being
Int_position, i
being Integer st s.DataLoc(s.a,i) >=
0
holds IExec(while<
0(a,i,I),P,s) = s +* Start-At((card I+
2),SCMPDS);
theorem :: SCMPDS_8:11
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS,a
being
Int_position, i
being Integer st s.DataLoc(s.a,i) >=
0
holds IC IExec(while<
0(a,i,I),P,s) = card I +
2;
theorem :: SCMPDS_8:12
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS, a,b
being
Int_position , i
being Integer st s.DataLoc(s.a,i) >=
0
holds IExec(while<
0(a,i,I),P,s).b = s.b;
scheme :: SCMPDS_8:sch 1
WhileLHalt { F(State
of SCMPDS)-> Nat,
s() ->
0-started State
of SCMPDS,
P() -> Instruction-Sequence
of SCMPDS,
I() -> halt-free shiftable Program
of SCMPDS,
a() -> Int_position,i() -> Integer, P[State
of SCMPDS]}:
while<
0(a(),i(),I()) is_closed_on s(),P() &
while<
0(a(),i(),I()) is_halting_on s(), P()
provided
for t
be 0-started State
of SCMPDS st P[t] & F(t)=
0
holds t.DataLoc(s().a(),i()) >=
0 and
P[s()]
and
for t
be 0-started State
of SCMPDS, Q
st P[t] & t.a()=s().a() & t.DataLoc(s().a(),i()) <
0
holds IExec(I(),Q,t).a()=t.a() &
I() is_closed_on t,Q & I() is_halting_on t,Q &
F(Initialize IExec(I(),Q,t)) < F(t) &
P[Initialize(IExec(I(),Q,t))];
scheme :: SCMPDS_8:sch 2
WhileLExec { F(State
of SCMPDS)-> Nat,
s() ->
0-started State
of SCMPDS,
P() -> Instruction-Sequence
of SCMPDS,
I() -> halt-free shiftable Program
of SCMPDS,
a() -> Int_position,i() -> Integer, P[State
of SCMPDS]}:
IExec(while<
0(a(),i(),I()),P(),s())
= IExec(while<
0(a(),i(),I()),P(),Initialize IExec(I(),P(),s()))
provided
s().DataLoc(s().a(),i()) <
0 and
for t
be 0-started State
of SCMPDS st P[t] & F(t)=
0
holds t.DataLoc(s().a(),i()) >=
0 and
P[s()]
and
for t
be 0-started State
of SCMPDS,Q
st P[t] & t.a()=s().a() & t.DataLoc(s().a(),i()) <
0
holds IExec(I(),Q,t).a()=t.a() &
I() is_closed_on t,Q & I() is_halting_on t,Q &
F(Initialize IExec(I(),Q,t)) < F(t) & P[Initialize(IExec(I(),Q,t))];
theorem :: SCMPDS_8:13
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS , a
be Int_position, i
be Integer,X
be set,
f
being Function
of product the_Values_of SCMPDS,NAT st
(
for t
being 0-started State
of SCMPDS st f.t=
0 holds t.DataLoc(s.a,i) >=
0) &
(
for t
be 0-started State
of SCMPDS,Q st (
for x
be Int_position st x
in X
holds t.x=s.x
IExec(I,Q,t).a=t.a & f.Initialize(IExec(I,Q,t)) < f.t
& I is_closed_on t,Q & I
is_halting_on t,Q &
for x
be Int_position st x
in X
holds IExec(I,Q,t).x=t.x)
holds
while<
0(a,i,I) is_closed_on s, P & while<
0(a,i,I) is_halting_on s, P;
theorem :: SCMPDS_8:14
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS, a
be Int_position, i
be Integer,X
be set,
f
being Function
of product the_Values_of SCMPDS,NAT
st s.DataLoc(s.a,i) <
0 &
(
for t
be 0-started State
of SCMPDS st f.t=
0 holds t.DataLoc(s.a,i) >=
0 ) &
(
for t
be 0-started State
of SCMPDS,Q
st (
for x
be Int_position st x
in X
holds t.x=s.x) & t.a=s.a &
t.DataLoc(s.a,i) <
0 holds IExec(I,Q,t).a=t.a &
I is_closed_on t,Q & I
is_halting_on t,Q & f.Initialize(IExec(I,Q,t)) < f.t
&
for x
be Int_position st
x
in X
holds IExec(I,Q,t).x=t.x)
holds IExec(while<
0(a,i,I),P,s)
=IExec(while<
0(a,i,I),P,Initialize IExec(I,P,s));
theorem :: SCMPDS_8:15
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable
Program
of SCMPDS, a
be Int_position, i
be Integer,X
be set st
(
for t
be 0-started State
of SCMPDS,Q st
(
for x
be Int_position st x
in X
holds t.x=s.x) & t .a=s.a
& t.DataLoc(s.a,i) <
0
holds IExec(I,Q,t).a=t.a & IExec(I,Q,t).DataLoc(s.a,i) > t.DataLoc(s.a,i)
& I is_closed_on t,Q & I is_halting_on t,Q &
for x
be
Int_position st x
in X
holds IExec(I,Q,t).x=t.x)
holds while<
0(a,i,I) is_closed_on s, P & while<
0(a,i,I) is_halting_on s, P;
theorem :: SCMPDS_8:16
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS , a
be Int_position,i
be Integer,X
be set st s.DataLoc(s.a,i) <
0
& (
for t
be 0-started State
of SCMPDS,Q
st (
for x
be Int_position st x
in X
holds t.x
=s.x) & t.a=s.a & t.DataLoc(s.a,i) <
0 holds
IExec(I,Q,t).a=t.a & IExec(I,Q,t).
DataLoc(s.a,i) > t.DataLoc(s.a,i) & I is_closed_on t,Q & I is_halting_on t,Q
&
for x
be Int_position st x
in X
holds IExec(I,Q,t).x=t.x)
holds IExec(while<
0(a,i,I),P,s)
=IExec(while<
0(a,i,I),P,Initialize IExec(I,P,s));
begin :: The construction and basic properties of while>0 program
:: while (a,i)>0 do I
definition
let a
be Int_position, i
be Integer,I
be Program
of SCMPDS;
func while>
0(a,i,I) -> Program
of SCMPDS equals
:: SCMPDS_8:def 3
(a,i)<=
0_goto (card I +
2) ';' I ';' goto -(card I+
1);
end;
registration
let I
be shiftable Program
of SCMPDS,a
be Int_position,i
be Integer;
cluster while>
0(a,i,I) -> shiftable;
end;
registration
let I
be halt-free Program
of SCMPDS,a
be Int_position,i
be Integer;
cluster while>
0(a,i,I) -> halt-free;
end;
theorem :: SCMPDS_8:17
for a
be Int_position,i
be Integer,I
be Program
of SCMPDS
holds
card while>
0(a,i,I)= card I +
2;
theorem :: SCMPDS_8:18
for a
be Int_position,i
be Integer,m
be Nat,I
be
Program
of SCMPDS
holds m < card I+
2 iff m
in dom while>
0(a,i,I);
theorem :: SCMPDS_8:19
for a
be Int_position,i
be Integer,I
be Program
of SCMPDS
holds
while>
0(a,i,I).
0=(a,i)<=
0_goto (card I +
2) &
while>
0(a,i,I). (card I+
1)=goto -(card I+
1);
theorem :: SCMPDS_8:20
for s
being State
of SCMPDS,I
being Program
of SCMPDS,a
being
Int_position, i
being Integer st s.DataLoc(s.a,i) <=
0 holds while>
0(a,i,I)
is_closed_on s, P & while>
0(a,i,I) is_halting_on s, P;
theorem :: SCMPDS_8:21
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS,a,c
being
Int_position, i
being Integer st s.DataLoc(s.a,i) <=
0
holds IExec(while>
0(a,i,I),P,s) = s +* Start-At((card I+
2),SCMPDS);
theorem :: SCMPDS_8:22
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS,a
being
Int_position, i
being Integer st s.DataLoc(s.a,i) <=
0
holds IC IExec(while>
0(a,i,I),P,s) = (card I +
2);
theorem :: SCMPDS_8:23
for s
being 0-started State
of SCMPDS,I
being Program
of SCMPDS, a,b
being
Int_position , i
being Integer st s.DataLoc(s.a,i) <=
0
holds IExec(while>
0(a,i,I),P,s).b = s.b;
scheme :: SCMPDS_8:sch 3
WhileGHalt { F(State
of SCMPDS)-> Nat,
s() ->
0-started State
of SCMPDS,
P() -> Instruction-Sequence
of SCMPDS,
I() -> halt-free shiftable Program
of SCMPDS,
a() -> Int_position,i() -> Integer, P[State
of SCMPDS]}:
while>
0(a(),i(),I()) is_closed_on s(), P() &
while>
0(a(),i(),I()) is_halting_on s(), P()
provided
for t
be 0-started State
of SCMPDS st P[t] & F(t)=
0
holds t.DataLoc(s().a(),i()) <=
0 and
P[s()]
and
for t
be 0-started State
of SCMPDS,Q
st P[t] & t.a()=s().a() & t.DataLoc(s().a(),i()) >
0
holds IExec(I(),Q,t).a()=t.a() &
I() is_closed_on t,Q & I() is_halting_on t,Q &
F(Initialize IExec(I(),Q,t)) < F(t)
& P[Initialize(IExec(I(),Q,t))];
scheme :: SCMPDS_8:sch 4
WhileGExec { F(State
of SCMPDS)-> Nat,
s() ->
0-started State
of SCMPDS,
P() -> Instruction-Sequence
of SCMPDS,
I() -> halt-free shiftable Program
of SCMPDS,
a() -> Int_position,i() -> Integer,P[State
of SCMPDS]}:
IExec(while>
0(a(),i(),I()),P(),s()) =
IExec(while>
0(a(),i(),I()),P(),Initialize IExec(I(),P(),s()))
provided
s().DataLoc(s().a(),i()) >
0 and
for t
be 0-started State
of SCMPDS st P[t] & F(t)=
0
holds t.DataLoc(s().a(),i()) <=
0 and
P[s()]
and
for t
be 0-started State
of SCMPDS,Q
st P[t] & t.a()=s().a() & t.DataLoc(s().a(),i()) >
0
holds IExec(I(),Q,t).a()=t.a() &
I() is_closed_on t,Q & I() is_halting_on t,Q &
F(Initialize IExec(I(),Q,t)) < F(t) & P[Initialize(IExec(I(),Q,t))];
theorem :: SCMPDS_8:24
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable
Program
of SCMPDS, a
be Int_position,i,c
be Integer,X,Y
be set, f
being
Function
of product the_Values_of SCMPDS,NAT st
(
for t
be 0-started State
of SCMPDS st f.t=
0 holds t.DataLoc(s.a,i) <=
0) &
(
for x st x
in X
holds s.x >= c+s.DataLoc(s.a,i)) &
(
for t
be 0-started State
of SCMPDS,Q st
(
for x st x
in X
holds t.x >= c+t.DataLoc(s.a,i)) &
(
for x st x
in Y
holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) >
0
holds IExec(I,Q,t).a=t.a &
I is_closed_on t,Q & I is_halting_on t,Q &
f.Initialize(IExec(I,Q,t)) < f.t
& (
for x st x
in X
holds IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc(s.a,i))
&
for x st x
in Y
holds IExec(I,Q,t).x=t.x)
holds while>
0(a,i,I) is_closed_on s, P &
while>
0(a,i,I) is_halting_on s, P;
theorem :: SCMPDS_8:25
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable
Program
of SCMPDS, a
be Int_position, i,c
be Integer,X,Y
be set,f
being
Function
of product the_Values_of SCMPDS,NAT st s.DataLoc(s.a,i) >
0 &
(
for t
be 0-started State
of SCMPDS st f.t=
0 holds t.DataLoc(s.a,i) <=
0) &
(
for x st x
in X
holds s.x >= c+s.DataLoc(s.a,i)) &
(
for t
be 0-started State
of SCMPDS,Q
st (
for x st x
in X
holds t.x >= c+t.DataLoc(s.a,i)) &
(
for x st x
in Y
holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) >
0
holds IExec(I,Q,t).a=t.a & I is_closed_on t,Q & I is_halting_on t,Q &
f.Initialize(IExec(I,Q,t)) < f.t
& (
for x st x
in X
holds IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc(s.a,i))
&
for x st x
in Y
holds IExec(I,Q,t).x=t.x)
holds IExec(while>
0(a,i,I),P,s)
=IExec(while>
0(a,i,I),P,Initialize IExec(I,P,s));
theorem :: SCMPDS_8:26
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS , a
be Int_position, i
be Integer,X
be set,
f
being Function
of product the_Values_of SCMPDS,NAT st
(
for t
be 0-started State
of SCMPDS st f.t=
0 holds t.DataLoc(s.a,i) <=
0) &
(
for t
be 0-started State
of SCMPDS,Q st (
for x
st x
in X
holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) >
0
holds IExec(I,Q,t).a=t.
a & I is_closed_on t,Q & I is_halting_on t,Q
& f.Initialize(IExec(I,Q,t)) < f.t &
for x st x
in X
holds IExec(I,Q,t).x=t.x)
holds while>
0(a,i,I) is_closed_on s, P &
while>
0(a,i,I) is_halting_on s, P & (s.DataLoc(s.a,i) >
0 implies
IExec(while>
0(a,i,I),P,s)
=IExec(while>
0(a,i,I),P,Initialize IExec(I,P,s)));
theorem :: SCMPDS_8:27
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable
Program
of SCMPDS, a
be Int_position, i,c
be Integer,X,Y
be set st
(
for x st x
in X
holds s.x >= c+s.DataLoc(s.a,i)) &
(
for t
be 0-started State
of SCMPDS,Q
st (
for x st x
in X
holds t.x >= c+t.DataLoc(s.a,i)) &
(
for x st x
in Y
holds t.x=s.x) & t.a=s.a & t.DataLoc(s.a,i) >
0
holds IExec(I,Q,t).a=t.a & I
is_closed_on t,Q & I is_halting_on t,Q
& IExec(I,Q,t).DataLoc(s.a,i) < t.DataLoc(s.a,
i) & (
for x st x
in X
holds IExec(I,Q,t).x >=
c+IExec(I,Q,t).DataLoc(s.a,i))
&
for x st x
in Y
holds IExec(I,Q,t).x=t.x)
holds while>
0(a,i,I) is_closed_on s, P &
while>
0(a,i,I) is_halting_on s, P &
(s.DataLoc(s.a,i) >
0 implies IExec(while>
0(a,i,I),P,s)
=IExec(while>
0(a,i,I),P,Initialize IExec(I,P,s)));
theorem :: SCMPDS_8:28
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS , a
be Int_position, i
be Integer,X
be set st
(
for t
be 0-started State
of SCMPDS,Q
st (
for x st x
in X
holds t.x=s.x) &
t.a=s.a & t.DataLoc(s.a,i)
>
0 holds IExec(I,Q,t).a=t.a & I is_closed_on t,Q &
I is_halting_on t,Q
& IExec(I,Q,t).DataLoc(s.a,i) < t.DataLoc(s.a,i) &
for x st x
in X
holds IExec(I,Q,t).x=t.x)
holds while>
0(a,i,I) is_closed_on s, P & while>
0(a,i,I) is_halting_on s, P
& (s.DataLoc(s.a,i) >
0 implies IExec(while>
0(a,i,I),P,s)
=IExec(while>
0(a,i,I),P,Initialize IExec(I,P,s)));
theorem :: SCMPDS_8:29
for s
being 0-started State
of SCMPDS,I
being halt-free shiftable Program
of
SCMPDS , a
be Int_position, i,c
be Integer,X
be set st
(
for x st x
in X
holds s.x >= c+s.DataLoc(s.a,i)) &
(
for t
be 0-started State
of SCMPDS,Q st (
for x st
x
in X
holds t.x >= c+t.DataLoc(s.a,i)) & t.a=s.a & t.DataLoc(s.a,i) >
0 holds
IExec(I,Q,t).a=t.a & I is_closed_on t,Q & I is_halting_on t,Q
& IExec(I,Q,t).DataLoc(s.
a,i) < t.DataLoc(s.a,i) &
for x st x
in X
holds IExec(I,Q,t).x >= c+IExec(I,Q,t).DataLoc(s.a,i))
holds while>
0(a,i,I) is_closed_on s, P & while>
0(a,i,I)
is_halting_on s, P & (s.DataLoc(s.a,i) >
0
implies
IExec(while>
0(a,i,I),P,s) =IExec(while>
0(a,i,I),P,Initialize IExec(I,P,s)));