module Core.Term.Thinned import Core.Term import Core.Thinning import Syntax.PreorderReasoning %prefix_record_projections off infix 4 =~= -- Definition ------------------------------------------------------------------ public export record Thinned (n : Nat) where constructor Over {0 m : Nat} term : Term m thin : m `Thins` n %name Thinned t, u, v %inline public export pure : Term n -> Thinned n pure = (`Over` id n) %inline public export expand : Thinned n -> Term n expand (term `Over` thin) = wkn term thin public export (=~=) : Thinned n -> Thinned n -> Type t =~= u = expand t = expand u -- Weakening ------------------------------------------------------------------- public export wkn : Thinned m -> m `Thins` n -> Thinned n wkn t thin = { thin $= (thin .) } t export wknCong : t =~= u -> (thin : m `Thins` n) -> wkn t thin =~= wkn u thin wknCong {t = t `Over` thin1, u = u `Over` thin2} prf thin = Calc $ |~ wkn t (thin . thin1) ~~ wkn (wkn t thin1) thin ...(sym $ wknHomo t thin1 thin) ~~ wkn (wkn u thin2) thin ...(cong (flip wkn thin) prf) ~~ wkn u (thin . thin2) ...(wknHomo u thin2 thin)