@@ -7,6 +7,7 @@ Require Import TreeAux.
7
7
Require Import TreeAggregationDynamicLabeled.
8
8
9
9
Require Import AggregationDefinitions.
10
+ Require Import AggregationDynamicCorrect.
10
11
11
12
Require Import InfSeqExt.infseq.
12
13
@@ -42,6 +43,9 @@ Module TreeAggregationCorrect (Import NT : NameType)
42
43
(Import TA : TAux NT NOT NSet NOTC NMap)
43
44
(Import AD : ADefs NT NOT NSet NOTC NMap CFG).
44
45
46
+ Module AC := AggregationCorrect NT NOT NSet NOTC NMap CFG ANT AD.
47
+ Import AC.
48
+
45
49
Module TG := TreeAggregation NT NOT NSet NOTC NMap RNT CFG ANT TA AD.
46
50
Import TG.
47
51
@@ -277,6 +281,36 @@ Definition correct_root_aggregate
277
281
e.(evt_a).(snd).(odnwState)) =
278
282
node_aggregate e.(evt_a).(snd).(odnwState) n.
279
283
284
+ Lemma sum_units_is_unit :
285
+ forall (A : Type) (f : A -> m -> m) l e,
286
+ (forall a b,
287
+ In a l ->
288
+ f a b = b%g) ->
289
+ fold_right f e l = e.
290
+ Proof .
291
+ intros.
292
+ induction l as [|a l].
293
+ - easy.
294
+ - intros. simpl.
295
+ rewrite IHl; auto with datatypes.
296
+ Qed .
297
+
298
+ (* this probably belongs somewhere specific to aggregation *)
299
+ Lemma sum_fail_map_unit_when_no_fail :
300
+ forall l from adj map,
301
+ ~ In aggr_fail l \/
302
+ ~ NSet.In from adj ->
303
+ sum_fail_map l from adj map = 1%g.
304
+ Proof .
305
+ unfold sum_fail_map.
306
+ intros.
307
+ break_or_hyp.
308
+ - destruct (in_dec _ _ _); now simpl.
309
+ - destruct (NSet.mem _ _) eqn:H_set.
310
+ * exfalso; auto with set.
311
+ * now rewrite Bool.andb_false_r.
312
+ Qed .
313
+
280
314
(* This lemma lets us prove stabilization once we prove that its hypotheses
281
315
about the network eventually hold. *)
282
316
Lemma no_noise_means_correct_root_aggregate :
@@ -293,14 +327,31 @@ Proof.
293
327
unfold mass_conserved_opt_event, conserves_network_mass_opt, correct_root_aggregate.
294
328
intros.
295
329
break_let; simpl in *.
330
+ repeat find_rewrite.
296
331
remember (remove_all name_eq_dec l o.(odnwNodes)) as live_nodes.
297
- assert (sum_fail_balance_incoming_active_opt o.(odnwNodes) live_nodes o.(odnwPackets) o.(odnwState) = 1%g).
332
+ assert (H_sfb: sum_fail_balance_incoming_active_opt o.(odnwNodes) live_nodes o.(odnwPackets) o.(odnwState) = 1%g).
298
333
{
299
334
unfold no_fail_incoming_active_event in *.
300
335
unfold sum_fail_balance_incoming_active_opt.
301
- admit.
336
+ unfold non_root_nodes_have_unit in *.
337
+ eapply sum_units_is_unit; intros.
338
+ specialize (H5 a).
339
+ destruct (odnwState o a) eqn:H_st; auto.
340
+ unfold sum_fail_map_incoming.
341
+ rewrite sum_units_is_unit; gsimpl; intros.
342
+ cut (exists d : data, odnwState (snd (evt_a e)) a = Some d /\ aggregate d = 1%g);
343
+ [|by eapply _].
344
+ intros; break_exists_name d'; break_and.
345
+ repeat (simpl in *; find_rewrite).
346
+ find_injection.
347
+ rewrite sum_fail_map_unit_when_no_fail; [by gsimpl|].
348
+ simpl.
349
+ cut (~ In Fail (odnwPackets o a0 a)); [by auto|].
350
+ (* What is this, and why does it work? *)
351
+ by eapply _.
302
352
}
303
- assert (sum_aggregate_msg_incoming_active o.(odnwNodes) live_nodes o.(odnwPackets) = 1%g).
353
+ rewrite !H_sfb; gsimpl.
354
+ assert (H_sam: sum_aggregate_msg_incoming_active o.(odnwNodes) live_nodes o.(odnwPackets) = 1%g).
304
355
{
305
356
unfold sum_aggregate_msg_incoming_active.
306
357
unfold sum_aggregate_msg_incoming.
@@ -309,8 +360,7 @@ Proof.
309
360
unfold aggregate_sum_fold.
310
361
admit.
311
362
}
312
- repeat find_rewrite.
313
- gsimpl.
363
+ rewrite !H_sam; gsimpl.
314
364
Admitted .
315
365
316
366
Theorem churn_free_stabilization :
@@ -325,6 +375,7 @@ Proof.
325
375
find_copy_eapply_lem_hyp fail_msgs_stop; eauto.
326
376
find_copy_eapply_lem_hyp non_root_nodes_eventually_have_unit; eauto.
327
377
pose proof (continuously_and_tl H5 H6).
378
+ induction H7.
328
379
Admitted .
329
380
330
381
End TreeAggregationCorrect.
0 commit comments