From Undecidability.TM Require Import Util.TM_facts Switch.

Section Composition.

  Variable n : .
  Variable sig : finType.


  Variable : finType.
  Variable : pTM sig n.

  Variable : finType.
  Variable : pTM sig n.

  Definition Seq := Switch ( _ ).

  Lemma Seq_Realise R1 R2 :
    
    
    Seq _y (( |_ y) ).
  Proof.
    intros.
    eapply Realise_monotone.
    eapply (Switch_Realise ( := ) ( := ( _ ))); eauto.
    firstorder.
  Qed.


  Lemma Seq_TerminatesIn R1 T1 T2 :
    
    
    
     Seq
           ( tin i i1 i2, tin 1 + + i
                                tout yout, tin (yout, tout) tout ).
  Proof.
    intros HRealise .
    eapply TerminatesIn_monotone.
    - eapply Switch_TerminatesIn; eauto. instantiate (1 := _ ). auto.
    - intros tin i (&&Hi&&). exists , ; repeat split; auto.
  Qed.


  Lemma Seq_TerminatesIn' R1 T1 T2 :
    
    
    
     Seq ( tin i i1, tin tout yout, tin (yout, tout) i2, 1 + + i tout ).
  Proof.
    intros HRealise .
    eapply TerminatesIn_monotone.
    - eapply Switch_TerminatesIn'; eauto. instantiate (1 := _ ). auto.
    - intros tin i (&&H). exists ; repeat split; eauto.
  Qed.


  Lemma Seq_RealiseIn (R1 : Rel _ _) (R2 : Rel _ ( * _)) k1 k2:
     c()
     c()
    Seq c(1 + + ) _y (( |_y) ).
  Proof.
    intros .
    eapply RealiseIn_monotone.
    eapply (Switch_RealiseIn).
    - eapply .
    - intros f. eapply .
    - .
    - firstorder.
  Qed.


End Composition.

Notation "A ;; B" := (Seq A B) (right associativity, at level 65).

Arguments Seq : simpl never.