Skip to content

Commit b25c333

Browse files
committed
remove simplification again
1 parent 4677360 commit b25c333

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/Util/FisherYates/Correctness.dfy

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,39 @@ module FisherYates.Correctness {
168168
var ys := Model.Swap(xs, i, j);
169169
var e' := iset s | Model.Shuffle(ys, i+1)(s).Result? && Model.Shuffle(ys, i+1)(s).value[i+1..] == p[i+1..];
170170
assert InductionHypothesis: e' in Rand.eventSpace && Rand.prob(e') == 1.0 / (NatArith.FactorialTraditional(|xs|-(i+1)) as real) by {
171-
InductionHypothesisPrecondition1(xs, ys, p, i, j);
172-
InductionHypothesisPrecondition2(xs, ys, p, i, j);
171+
assert multiset(ys[i+1..]) == multiset(p[i+1..]) by {
172+
InductionHypothesisPrecondition1(xs, ys, p, i, j);
173+
}
174+
assert forall a, b | i+1 <= a < b < |ys| :: ys[a] != ys[b] by {
175+
InductionHypothesisPrecondition2(xs, ys, p, i, j);
176+
}
177+
assert i+1 <= |ys| by {
178+
calc {
179+
i + 1;
180+
<
181+
|xs|;
182+
==
183+
|ys|;
184+
}
185+
}
186+
assert i < |p| by {
187+
calc {
188+
i;
189+
<
190+
i+1;
191+
<
192+
|xs|;
193+
==
194+
|p|;
195+
}
196+
}
197+
assert |ys| == |p| by {
198+
calc {
199+
|ys|;
200+
|xs|;
201+
|p|;
202+
}
203+
}
173204
if |ys[i+1..]| > 1 {
174205
CorrectnessFisherYatesUniqueElementsGeneralGreater1(ys, p, i+1);
175206
} else {

0 commit comments

Comments
 (0)