proposition: Lemma reachable_or_marked_iff_marked: forall g roots from v, sound_gc_graph g -> no_edge2gen g from -> roots_have_no_gen roots from -> reachable_or_marked from g roots v <-> raw_mark (vlabel g v) = true /\ vvalid g v /\ vgeneration v = from.
proof: Proof. intros. unfold reachable_or_marked. split; intros; destruct H2. 2: destruct H3; split; auto. destruct H3 as [? | [? ?]]; auto. exfalso. rewrite reachable_from_roots in H3. destruct H3 as [i [r [? [? ?]]]]. red in H1. assert (vgeneration r <> from) by (apply H1; rewrite <- H4; now apply Znth_In). clear i H1 H3 H4. unfold reachable, reachable_by in H5. destruct H5 as [[? p] ?]. pose proof H1. apply reachable_by_path_head in H3. simpl in H3. subst v0. remember (length p) as n. assert (length p <= n)%nat by lia. clear Heqn. revert r p H3 H1 H6. induction n; intros. - destruct p. 2: simpl in H3; lia. destruct H1 as [[_ ?] _]. simpl in H1. subst v. now rewrite H2 in H6. - destruct p. + destruct H1 as [[_ ?] _]. simpl in H1. subst v. now rewrite H2 in H6. + pose proof H1. change (e :: p) with (nil ++ e :: p) in H1. apply reachable_by_path_app_cons in H1. destruct H1 as [_ ?]. assert (length p <= n)%nat by (simpl in H3; lia). specialize (IHn _ _ H5 H1). apply IHn. red in H0. unfold gen2gen_no_edge in H0. destruct H4 as [_ [? _]]. rewrite valid_path_cons_iff in H4. destruct H4 as [? [[? _] _]]. destruct H as [? [? [? _]]]. red in H, H8, H9. rewrite H9 in *. destruct e as [[gen vidx] eidx]. simpl in *. subst r. simpl in *. rewrite H8 in H7. apply H0; auto. Qed.
imports: Coq.ZArith.ZArith Coq.Program.Basics compcert.lib.Integers compcert.common.Values VST.veric.base VST.veric.Clight_lemmas VST.veric.val_lemmas VST.veric.shares VST.msl.seplog VST.msl.shares VST.zlist.sublist VST.floyd.coqlib3 VST.floyd.functional_base VST.floyd.data_at_rec_lemmas CertiGraph.lib.Coqlib CertiGraph.lib.EquivDec_ext CertiGraph.lib.List_ext CertiGraph.graph.graph_model CertiGraph.graph.graph_gen CertiGraph.graph.path_lemmas CertiGraph.graph.subgraph2 CertiGraph.graph.graph_relation CertiGraph.graph.graph_isomorphism CertiGraph.graph.reachable_ind CertiGraph.CertiGC.GCGraph