Skip to content

Commit 178e439

Browse files
committed
wip
1 parent f279216 commit 178e439

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

systems/TreeAggregationDynamicLabeledCorrect.v

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Require Import TreeAux.
77
Require Import TreeAggregationDynamicLabeled.
88

99
Require Import AggregationDefinitions.
10+
Require Import AggregationDynamicCorrect.
1011

1112
Require Import InfSeqExt.infseq.
1213

@@ -42,6 +43,9 @@ Module TreeAggregationCorrect (Import NT : NameType)
4243
(Import TA : TAux NT NOT NSet NOTC NMap)
4344
(Import AD : ADefs NT NOT NSet NOTC NMap CFG).
4445

46+
Module AC := AggregationCorrect NT NOT NSet NOTC NMap CFG ANT AD.
47+
Import AC.
48+
4549
Module TG := TreeAggregation NT NOT NSet NOTC NMap RNT CFG ANT TA AD.
4650
Import TG.
4751

@@ -277,6 +281,36 @@ Definition correct_root_aggregate
277281
e.(evt_a).(snd).(odnwState)) =
278282
node_aggregate e.(evt_a).(snd).(odnwState) n.
279283

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+
280314
(* This lemma lets us prove stabilization once we prove that its hypotheses
281315
about the network eventually hold. *)
282316
Lemma no_noise_means_correct_root_aggregate :
@@ -293,14 +327,31 @@ Proof.
293327
unfold mass_conserved_opt_event, conserves_network_mass_opt, correct_root_aggregate.
294328
intros.
295329
break_let; simpl in *.
330+
repeat find_rewrite.
296331
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).
298333
{
299334
unfold no_fail_incoming_active_event in *.
300335
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 _.
302352
}
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).
304355
{
305356
unfold sum_aggregate_msg_incoming_active.
306357
unfold sum_aggregate_msg_incoming.
@@ -309,8 +360,7 @@ Proof.
309360
unfold aggregate_sum_fold.
310361
admit.
311362
}
312-
repeat find_rewrite.
313-
gsimpl.
363+
rewrite !H_sam; gsimpl.
314364
Admitted.
315365

316366
Theorem churn_free_stabilization :
@@ -325,6 +375,7 @@ Proof.
325375
find_copy_eapply_lem_hyp fail_msgs_stop; eauto.
326376
find_copy_eapply_lem_hyp non_root_nodes_eventually_have_unit; eauto.
327377
pose proof (continuously_and_tl H5 H6).
378+
induction H7.
328379
Admitted.
329380

330381
End TreeAggregationCorrect.

0 commit comments

Comments
 (0)