From PCP Require Import Definitions.

PCP to CFI


Section PCP_CFI.

  Variable P : SRS.

  Definition := sym P.
  Notation "#" := (fresh ).

  Definition (A : SRS) :=
    map ( '(x,y) x / (x [#] y [#])) A.
  Definition (A : SRS) :=
    map ( '(x,y) y / (x [#] y [#])) A.
  Fixpoint (A : SRS) :=
    match A with
    | [] []
    | x/y :: A A x [#] y [#]
    end.

  Lemma sigma_gamma1 A :
     # ( A) = A [#] A.
  Proof.
    induction A as [ | (x,y) ] ; cbn.
    - reflexivity.
    - unfold in IHA. cbn in *.
      rewrite IHA. now simpl_list.
  Qed.


  Lemma sigma_gamma2 A :
     # ( A) = A [#] A.
  Proof.
    induction A as [ | (x,y) ] ; cbn.
    - reflexivity.
    - unfold in IHA. cbn in *.
      rewrite IHA. now simpl_list.
  Qed.


  Lemma gamma1_spec B C :
    B C
     A, A C A = B.
  Proof.
    induction B as [ | (x,y)]; cbn; intros.
    - eauto.
    - assert (x/y C) by firstorder. unfold in .
      eapply in_map_iff in as ((x',y') & ? & ?). inv .
      assert (B C) as (A & Hi & He) % IHB by firstorder.
      exists (x/y' :: A). split.
      + intuition.
      + now subst.
  Qed.



  Lemma gamma2_spec B C :
    B C
     A, A C A = B.
  Proof.
    induction B as [ | (x,y)]; cbn; intros.
    - eauto.
    - assert (x/y C) by firstorder. unfold in .
      eapply in_map_iff in as ((x',y') & ? & ?). inv .
      assert (B C) as (A & Hi & He) % IHB by firstorder.
      exists (x'/x :: A). split.
      + intuition.
      + now subst.
  Qed.


  Lemma gamma_inj :
     # sym # sym
     = = .
  Proof.
    intros H.
    revert . induction as [ | (x,y) ]; cbn; intros.
    - destruct ; inv . reflexivity.
      destruct c, ( ), s; cbn in *; inv .
    - destruct as [ | (x',y')]; cbn in .
      + destruct ( ), x; inv .
      + eapply rev_eq in . repeat (autorewrite with list in ; cbn in ). inv .
        eapply list_prefix_inv in as [].
        rewrite rev_eq in . subst. assert (x = x').
        * destruct as [ | (, )], as [ | (, )]; repeat (cbn in *; autorewrite with list in ).
          -- rewrite rev_eq in . congruence.
          -- exfalso. enough ( # rev x). eapply . rewrite .
             cbn. simpl_list. cbn. eauto. intros ? % In_rev; eauto.
          -- exfalso. enough ( # rev x'). eapply . rewrite .
             cbn. simpl_list. cbn. eauto. intros ? % In_rev; eauto.
          -- eapply list_prefix_inv in as []. rewrite rev_eq in . congruence.
             intros ? % In_rev; eauto. intros ? % In_rev; eauto.
        * subst. f_equal. eapply app_inv_head in . rewrite rev_eq in .
          eapply in ; eauto.
          intros ?. eapply H. cbn. eauto.
          intros ?. eapply . cbn. eauto.
        * intros ? % In_rev. eapply H. cbn. eauto.
        * intros ? % In_rev. eapply . cbn. eauto.
  Qed.


End PCP_CFI.

Lemma reduction :
  PCP CFI.
Proof.
  exists ( P ( P P, P P, fresh (sym P))). intros P.
  split.
  - intros (A & Hi & He & H). exists ( P A), ( P A). repeat split.
    + clear He H. induction A as [ | [] ]. firstorder. intros ? [ | ].
      unfold . eapply in_map_iff. exists (s,). firstorder. firstorder.
    + clear He H. induction A as [ | [] ]. firstorder. intros ? [ | ].
      unfold . eapply in_map_iff. exists (s,). firstorder. firstorder.
    + destruct A; cbn in *; congruence.
    + destruct A; cbn in *; congruence.
    + now rewrite sigma_gamma1, sigma_gamma2, H.
  - intros ( & & ( & & ) % gamma1_spec & ( & & ) % gamma2_spec & & & H).
    rewrite sigma_gamma1, sigma_gamma2 in H.
    eapply list_prefix_inv in H as [ % gamma_inj].
    + exists . firstorder. destruct ; cbn in *; firstorder congruence.
    + intros ?. eapply sym_mono in . eapply in as ? % fresh_spec. now apply .
    + intros ?. eapply sym_mono in . eapply in as ? % fresh_spec. now apply .
    + intros ? % tau1_sym. eapply sym_mono in . eapply in as ? % fresh_spec. now apply .
    + intros ? % tau2_sym. eapply sym_mono in . eapply in as ? % fresh_spec. now apply .
Qed.