Library HODepEquiv

Require Import Showable String List DepEquiv HoTT.

Higher-order dependent equivalences

We enrich the dependent equivalence class with instances matching higher-order types.

Axiom FunExt : Funext.

Triggers for lifting and unlifing search:

Definition lift {A} {B: A Type} {C : A Type} {B_ C_} `{( a, B a (C a)) ≃? (B_ C_)} : ( a, B a C a) B_ C_ := fun fpe_fun (fun a bcreturn (f a b)).

Definition unlift {A} {B: A Type} {C : A Type} {B_ C_}
           {H :( a, B a (C a)) ≃? (B_ C_)} :
  (B_ C_) a, B a (C a) := fun ffpe_inv (IsPartialEquiv := pe_isequiv (CanonicalPartialEquiv := H)) (clift ff).

Definition lift2 {A A'} {B: A A' Type} {C: A A' Type} {D : A A' Type} {B_ C_ D_}
           `{( a a', B a a' C a a' D a a') ≃? (B_ C_ D_)} :
  ( a a', B a a' C a a' D a a') B_ C_ D_ :=
  fun ffpe_fun (fun a a' b ccreturn (ff a a' b c)).

Domain transformation:


Instance HODepEquiv_easy A (B: A Type) C {HC : IsHSet C} C' {HC' : IsHSet C'}
           (H:B C)
   : ( a, B a C') ≃? (C C') | 0
  :=
    {| pe_fun := Build_Mon (to_simpl_dom : (∀ a : A, B a C') C C') _ _;
       pe_isequiv := {| pe_inv := Build_Mon to_dep_dom _ _ |}|}.

Domain & co-domain transformation:


Instance HODepEquiv {A} {B: A Type} {C} {HC : IsHSet C}
           `{B C} {B': A Type} {C'} {HC' : IsHSet C'}
           `{B' C'}
  : ( a, B a (B' a)) ≃? (C C'):=
  {| pe_fun := Build_Mon (fun f to_simpl_dom (fun a b x <- f a b; to_simpl x)) _ _ ;
     pe_isequiv := {| pe_inv := Build_Mon (fun f a b x <- to_dep_dom f a b; to_dep _ x) _ _ |}|}.

Argument reordering:


Instance HODepEquiv2_sym A A' B_1 B_2 (B_3 : A A' Type) {C_1 C_2 C_3}
         {HC_1 : IsHSet C_1} {HC_2 : IsHSet C_2} {HC_3 : IsHSet C_3}
         (H: ( a a', B_2 a a' B_1 a a' B_3 a a') ≃? (C_2 C_1 C_3)) :
  ( a a', B_1 a a' B_2 a a' B_3 a a') ≃? (C_1 C_2 C_3) | 100
    :=
  {| pe_fun := Build_Mon (fun ff b_ c_ pe_fun (fun a a' c b ff a a' b c) c_ b_) _ _;
     pe_isequiv := {|pe_inv := Build_Mon (fun ff a a' b c (pe_inv (IsPartialEquiv := pe_isequiv (CanonicalPartialEquiv := H))) (fun c b ff b c) _ _ c b) _ _ |}|}.

Arity 2 types:


Hint Extern 1 (IsPartialEquiv ?f) ⇒ apply (pe_isequiv (CanonicalPartialEquiv := _)) :
             typeclass_instances.

Definition to_simpl_dom2 {A A' B_1 B_2} {B_3 : A A' Type} {C_1 C_2 C_3}
           {HC_1 : IsHSet C_1} {HC_2 : IsHSet C_2} {HC_3 : IsHSet C_3}
           `{ a, (( a':A', B_2 a a' B_3 a a') ≃? (C_2 C_3))}
           `{DepEquiv A B_1 C_1}:
         ( a a', B_1 a B_2 a a' B_3 a a') C_1 C_2 C_3 :=
  fun flet f' := fun a bpe_fun (fun a'f a a' b) in
        fun b_ cto_simpl_dom (fun a bf' a b c) b_.

Definition to_dep_dom2 {A A' B_1 B_2} {B_3 : A A' Type} {C_1 C_2 C_3 }
           {HC_1 : IsHSet C_1} {HC_2 : IsHSet C_2} {HC_3 : IsHSet C_3}
           `{ a, (( a':A', B_2 a a' B_3 a a') ≃? (C_2 C_3))} `{DepEquiv A B_1 C_1}:
         (C_1 C_2 C_3) a a', B_1 a B_2 a a' B_3 a a' :=
  fun f a a' b c
    pe_inv (IsPartialEquiv := pe_isequiv (CanonicalPartialEquiv := H a))
           (fun xc <- to_simpl b; f c x) a' c.

Instance HODepEquiv2
         A A' (B_1: A Type) (B_2: A A' Type) (B_3 : A A' Type)
         C_1 C_2 C_3
         {HC_1 : IsHSet C_1} {HC_2 : IsHSet C_2} {HC_3 : IsHSet C_3}
         (H: a, (( a':A', B_2 a a' B_3 a a') ≃? (C_2 C_3))) `{DepEquiv A B_1 C_1} :
  ( a a', B_1 a B_2 a a' B_3 a a') ≃? (C_1 C_2 C_3)
  :=
  {| pe_fun := Build_Mon to_simpl_dom2 _ _ ;
     pe_isequiv := {| pe_inv := Build_Mon to_dep_dom2 _ _ |}|}.



Instance DepEquiv_with_pe A A' B C (f : A' A) {HC : IsHSet C} {Hf: IsInjective f}
         {HP : B C} : (fun aB (f a)) C :=
  Build_DepEquiv A' (fun aB (f a)) C HC (fun a cP (f a) c)
                (fun a'total_equiv (f a'))
                (λ a : A', partial_equiv (f a))
                (fun ca <- c_to_a c; f^?-1 a) _ showC.