@@ -4,14 +4,17 @@ require import AllCore Distr.
44theory ProcChangeAssignEquiv.
55 module M = {
66 proc f (x : int ) = {
7- x <- x + 0 ;
7+ x <- 0 ;
8+ x <- x + 1 ;
9+ x <- x + 2 ;
10+ x <- x + 3 ;
811 }
912 }.
1013
1114 lemma L : equiv[M.f ~ M.f: true ==> true ].
1215 proof.
1316 proc.
14- proc change {1 } 1 1 : { x <- x ; }.
17+ proc change {1 } [ 1 .. 3 ] : { x <- 3 ; }.
1518
1619 wp. skip. smt().
1720 abort.
@@ -27,7 +30,7 @@ theory ProcChangeAssignHoareEquiv.
2730 lemma L : hoare[M.f : true ==> true ].
2831 proof.
2932 proc.
30- proc change 1 1 : { x <- x ; }. wp. skip. smt().
33+ proc change [ 1 .. 1 ] : { x <- x ; }. wp. skip. smt().
3134 abort.
3235end ProcChangeAssignHoareEquiv.
3336
@@ -42,7 +45,7 @@ theory ProcChangeSampleEquiv.
4245 lemma L : equiv[M.f ~ M.f : true ==> true ].
4346 proof.
4447 proc.
45- proc change {1 } 1 1 : { x <$ (dunit x); }.
48+ proc change {1 } [ 1 .. 1 ] : { x <$ (dunit x); }.
4649 rnd. skip. smt().
4750 abort.
4851end ProcChangeSampleEquiv.
@@ -62,7 +65,7 @@ theory ProcChangeIfEquiv.
6265 lemma L : equiv[M.f ~ M.f : true ==> true ].
6366 proof.
6467 proc.
65- proc change {1 } 1 1 : {
68+ proc change {1 } [ 1 .. 1 ] : {
6669 if (x = y) {
6770 x <- y;
6871 } else {
@@ -85,15 +88,47 @@ theory ProcChangeWhileEquiv.
8588 lemma L : equiv[M.f ~ M.f : true ==> true ].
8689 proof.
8790 proc.
88- proc change {1 } 1 1 : {
91+ proc change {1 } [ 1 .. 1 ] : {
8992 while (x <> y) {
90- x <- x + 1 ;
93+ x <- x + 1 + 0 ;
9194 }
9295 }.
93- admit. (* FIXME *)
96+ proc rewrite {1 } 1 /=.
97+ proc rewrite {2 } 1.1 /=.
98+ sim.
9499 abort.
95100end ProcChangeWhileEquiv.
96101
102+
103+ (* -------------------------------------------------------------------- *)
104+ theory ProcChangeInWhileEquiv.
105+ module M = {
106+ proc f (x : int , y : int ) = {
107+ while (x + 0 <> y) {
108+ x <- 1 ;
109+ x <- x + 1 ;
110+ x <- 2 ;
111+ }
112+ }
113+ }.
114+
115+ lemma L : equiv[M.f ~ M.f : true ==> true ].
116+ proof.
117+ proc.
118+ proc change {1 } ^while .2 : {
119+ x <- x + 0 + 1 ;
120+ }.
121+ wp; skip. smt().
122+ proc change {1 } [^while .1 ..^while .2 ] : {
123+ x <- 2 ;
124+ }. wp; skip. smt().
125+ proc change {2 } [^while .1 -1 ] : {
126+ x <- 2 ;
127+ }. wp; skip. smt().
128+ abort.
129+ end ProcChangeInWhileEquiv.
130+
131+
97132(* -------------------------------------------------------------------- *)
98133theory ProcChangeAssignHoare.
99134 module M = {
@@ -105,7 +140,7 @@ theory ProcChangeAssignHoare.
105140 lemma L : hoare[M.f: true ==> true ].
106141 proof.
107142 proc.
108- proc change 1 1 : { x <- x; }.
143+ proc change [ 1 .. 1 ] : { x <- x; }.
109144 wp; skip; smt().
110145 abort.
111146end ProcChangeAssignHoare.
@@ -121,7 +156,7 @@ theory ProcChangeSampleHoare.
121156 lemma L : hoare[M.f: true ==> true ].
122157 proof.
123158 proc.
124- proc change 1 1 : { x <$ (dunit x); }.
159+ proc change 1 : { x <$ (dunit x); }.
125160 rnd; skip; smt().
126161 abort.
127162end ProcChangeSampleHoare.
@@ -141,7 +176,7 @@ theory ProcChangeIfHoare.
141176 lemma L : hoare[M.f: true ==> true ].
142177 proof.
143178 proc.
144- proc change 1 1 : {
179+ proc change 1 : {
145180 if (x = y) {
146181 x <- y;
147182 } else {
@@ -164,11 +199,33 @@ theory ProcChangeWhileHoare.
164199 lemma L : hoare[M.f: true ==> true ].
165200 proof.
166201 proc.
167- proc change 1 1 : {
202+ proc change 1 : {
168203 while (x <> y) {
169204 x <- x + 1 ;
170205 }
171206 }.
172- admit. (* FIXME *)
207+ proc rewrite { 1 } ^ while /=; sim.
173208 abort.
174209end ProcChangeWhileHoare.
210+
211+
212+ (* -------------------------------------------------------------------- *)
213+ theory ProcChangeInWhileHoare.
214+ module M = {
215+ proc f (x : int , y : int ) = {
216+ while (x + 0 <> y) {
217+ x <- x + 1 ;
218+ }
219+ }
220+ }.
221+
222+ lemma L : hoare[M.f : true ==> true ].
223+ proof.
224+ proc.
225+ proc change ^while .1 : {
226+ x <- x + 0 + 1 ;
227+ }.
228+ wp; skip. smt().
229+ abort.
230+ end ProcChangeInWhileHoare.
231+
0 commit comments