Jon Sterling, started 24th March 2023

Based on the comments of MartΓ­n EscardΓ³ on the HoTT Mailing List:
https://groups.google.com/g/homotopytypetheory/c/FfiZj1vrkmQ/m/GJETdy0AAgAJ

This module defines a "semistrict" version of the identity type, i.e. one for
which the composition is definitionally associative and unital but for which the
interchange laws are weak.

\begin{code}

{-# OPTIONS --safe --without-K #-}

module UF.SemistrictIdentity where

open import MLTT.Spartan
open import UF.Base
open import UF.Equiv
open import UF.FunExt
open import UF.IdentitySystems

module _ {A : 𝓀 Μ‡ } where
 _=ₛ_ : (x y : A) β†’ 𝓀 Μ‡
 x =ₛ y = (z : A) β†’ z = x β†’ z = y

 refl-s : {x : A} β†’ x =ₛ x
 refl-s z p = p

 _βˆ™β‚›_ : {x y z : A} (p : x =ₛ y) (q : y =ₛ z) β†’ x =ₛ z
 (p βˆ™β‚› q) _  = q _ ∘ p _
 infixl 10 _βˆ™β‚›_

 module _ {x y : A} (p : x =ₛ y) where
  refl-s-left-unit : refl-s βˆ™β‚› p = p
  refl-s-left-unit = refl

  refl-s-right-unit : p βˆ™β‚› refl-s = p
  refl-s-right-unit = refl

 module _ {u v w x : A} (p : u =ₛ v) (q : v =ₛ w) (r : w =ₛ x) where
  βˆ™β‚›-assoc : p βˆ™β‚› (q βˆ™β‚› r) = (p βˆ™β‚› q) βˆ™β‚› r
  βˆ™β‚›-assoc = refl

 module _ {x y : A} where
  to-=ₛ : x = y β†’ x =ₛ y
  to-=ₛ p z q = q βˆ™ p

  from-=ₛ : x =ₛ y β†’ x = y
  from-=ₛ p = p _ refl

  module _ (fe : funext 𝓀 𝓀) where
   to-=ₛ-is-equiv : is-equiv to-=ₛ
   pr₁ (pr₁ to-=ₛ-is-equiv) = from-=ₛ
   prβ‚‚ (pr₁ to-=ₛ-is-equiv) q =
    dfunext fe Ξ» z β†’
    dfunext fe (lem z)
    where
     lem : (z : A) (p : z = x) β†’ p βˆ™ q x refl = q z p
     lem .x refl = refl-left-neutral
   pr₁ (prβ‚‚ to-=ₛ-is-equiv) = from-=ₛ
   prβ‚‚ (prβ‚‚ to-=ₛ-is-equiv) refl = refl

   to-=ₛ-equiv : (x = y) ≃ (x =ₛ y)
   pr₁ to-=ₛ-equiv = to-=ₛ
   prβ‚‚ to-=ₛ-equiv = to-=ₛ-is-equiv

 =ₛ-id-sys : funext 𝓀 𝓀 β†’ Unbiased-Id-Sys 𝓀 A
 =ₛ-id-sys fe = from-path-characterization.id-sys _=ₛ_ (to-=ₛ-equiv fe)

\end{code}