Qcert.Basic.Typing.TUtil


Section TUtil.



  Context {fdata:foreign_data}.
  Context {ftype:foreign_type}.
  Context {m:brand_model}.


  Definition tdot {A} (l:list (string × A)) (a:string) : option A := edot l a.


  Definition tuneither (τ:rtype) : option (rtype × rtype).

  Definition tuncoll (τ:rtype) : option rtype.

  Lemma tuncoll_correct (τ τ':rtype) :
    tuncoll τ = Some τ'
    τ = Coll τ'.

  Definition tsingleton (τ:rtype) : option rtype.

  Lemma tsingleton_correct (τ τ':rtype) :
    tsingleton τ = Some (Option τ')
    τ = Coll τ'.

  Definition tunrec (τ: rtype) : option (record_kind × (list (string × rtype))).

   Lemma tunrec_correct k (τ:rtype) {l} :
    tunrec τ = Some (k,l)
    {pf | τ = Rec k l pf}.

  Definition trecConcat τ: rtype) : option rtype.

  Definition tmergeConcat τ: rtype) : option rtype.

  Definition tunrecdot (s:string) (τ:rtype) : option rtype.

  Definition tunrecremove (s:string) (τ:rtype) : option rtype.

  Definition tunrecproject (sl:list string) (τ:rtype) : option rtype.


  Definition recConcat τ: rtype) : option rtype.

  Definition mergeConcat τ: rtype) : option rtype.

  Lemma RecMaybe_rec_concat_sort k l1 l2 :
    RecMaybe k (rec_concat_sort l1 l2) = Some (Rec k (rec_concat_sort l1 l2) (drec_concat_sort_sorted l1 l2)).

  Lemma Bottom_proj : Bottom₀ = ` Bottom.

  Lemma Top_proj : Top₀ = ` Top.

  Lemma Unit_proj : Unit₀ = ` Unit.

  Lemma Nat_proj : Nat₀ = ` Nat.

  Lemma Bool_proj : Bool₀ = ` Bool.

  Lemma String_proj : String₀ = ` String.

  Lemma Brand_canon {b} {τ:rtype} :` τ = Brand₀ b τ = Brand b.

  Lemma Bottom_canon:rtype} :` τ = Bottom₀ τ = Bottom.

  Lemma Top_canon:rtype} :` τ = Top₀ τ = Top.

  Lemma Unit_canon:rtype} :` τ = Unit₀ τ = Unit.

  Lemma Nat_canon:rtype} :` τ = Nat₀ τ = Nat.

  Lemma Bool_canon:rtype} :` τ = Bool₀ τ = Bool.

  Lemma String_canon:rtype} :` τ = String₀ τ = String.

  Lemma Coll_canon τ:rtype} :` τ = Coll₀ (` τ) τ = Coll τ.

End TUtil.