@@ -27,6 +27,36 @@ noncomputable section
27
27
28
28
namespace SLang
29
29
30
+
31
+ /--
32
+ Stronger congruence rule for probBind: The bound-to functions have to be equal only on the support of
33
+ the bound-from function.
34
+ -/
35
+ lemma probBind_congr_strong (p : SLang T) (f : T -> SLang U) (g : T -> SLang U) (Hcong : ∀ t : T, p t ≠ 0 -> f t = g t) :
36
+ p >>= f = p >>= g := by
37
+ simp
38
+ unfold probBind
39
+ apply SLang.ext
40
+ intro u
41
+ apply Equiv.tsum_eq_tsum_of_support ?G1
42
+ case G1 =>
43
+ apply Set.BijOn.equiv (fun x => x)
44
+ simp [Function.support]
45
+ have Heq : {x | ¬p x = 0 ∧ ¬f x u = 0 } = {x | ¬p x = 0 ∧ ¬g x u = 0 } := by
46
+ apply Set.sep_ext_iff.mpr
47
+ intro t Ht
48
+ rw [Hcong]
49
+ apply Ht
50
+ rw [Heq]
51
+ apply Set.bijOn_id
52
+ simp [Function.support]
53
+ intro t ⟨ Hp, _ ⟩
54
+ simp [Set.BijOn.equiv]
55
+ rw [Hcong]
56
+ apply Hp
57
+
58
+
59
+
30
60
/--
31
61
``SLang`` value obtained by applying a loop body exactly ``n`` times to a given distribution
32
62
-/
@@ -217,61 +247,18 @@ lemma probWhileSplit_add_r' (cond : T → Bool) (body : T → SLang T) (m n : Na
217
247
rename_i m''
218
248
rw [bind_congr IH]
219
249
clear IH
220
- generalize HK : (probWhileSplit cond body (fun x => probZero) n) = K
221
250
unfold probWhileSplit
222
251
simp
223
252
split <;> simp
224
- · apply SLang.ext
225
- simp
226
- -- Monotonicity necessary here? Seems odd that I'd need it in the inductive proof but not the single step proof
227
- -- However, maybe not so weird. The step I'm getting stuck on is proving asociativity, which didn't
228
- -- need to happen in the 1 step proof.
229
- sorry
253
+ · rename_i h
254
+ apply probBind_congr_strong
255
+ intro t _
256
+ simp [probWhileSplit]
230
257
· rw [if_neg (by trivial)]
231
258
simp
232
259
233
260
234
261
235
- /--
236
- Stronger congruence rule for probBind: The bound-to functions have to be equal only on the support of
237
- the bound-from function.
238
- -/
239
- lemma probBind_congr_strong (p : SLang T) (f : T -> SLang U) (g : T -> SLang U) (Hcong : ∀ t : T, p t ≠ 0 -> f t = g t) :
240
- p >>= f = p >>= g := by
241
- simp
242
- unfold probBind
243
- apply SLang.ext
244
- intro u
245
- apply Equiv.tsum_eq_tsum_of_support ?G1
246
- case G1 =>
247
- apply Set.BijOn.equiv (fun x => x)
248
- simp [Function.support]
249
- have Heq : {x | ¬p x = 0 ∧ ¬f x u = 0 } = {x | ¬p x = 0 ∧ ¬g x u = 0 } := by
250
- apply Set.sep_ext_iff.mpr
251
- intro t Ht
252
- rw [Hcong]
253
- apply Ht
254
- rw [Heq]
255
- apply Set.bijOn_id
256
- simp [Function.support]
257
- intro t ⟨ Hp, _ ⟩
258
- simp [Set.BijOn.equiv]
259
- rw [Hcong]
260
- apply Hp
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
262
276
263
277
264
0 commit comments