@@ -2002,7 +2002,7 @@ InAtom = InTermAtom .* TAtom
20022002
20032003public export
20042004InNat : Nat -> TermMu -> TermMu
2005- InNat = InAtom NAT
2005+ InNat = InAtom SL_NAT
20062006
20072007-- -----------------
20082008-- -- Utilities ----
@@ -2108,8 +2108,8 @@ public export
21082108FBCObjRepAlg : FinBCObjAlgRec TermMu
21092109FBCObjRepAlg =
21102110 MkFinBCObjAlg
2111- (InAtom PRODUCT 0 . InProd )
2112- (InAtom COPRODUCT 0 . InProd )
2111+ (InAtom SL_EXP 0 . InProd ) -- random replacement for PRODUCT; obsolete
2112+ (InAtom SL_EXPL 0 . InProd ) -- random replacement for COPRODUCT; obsolete
21132113
21142114public export
21152115fbcObjRep : FinBCObjMu -> TermMu
@@ -3437,48 +3437,117 @@ termToGebTerm = termCataRec termToGebTermAlg
34373437-- ---------------------------------------------------
34383438-- ---------------------------------------------------
34393439
3440+ -- ------------------
3441+ -- -- Definition ----
3442+ -- ------------------
3443+
3444+ public export
3445+ record OpFunctorPair {a : Type } (x, y : SliceObj a) where
3446+ constructor OFP
3447+ ofpOut : ParamSPF {a} x y
3448+ ofpIn : ParamSPF {a} y x
3449+
3450+ public export
3451+ ofpInAfterOut : {a : Type } -> {x, y : SliceObj a} ->
3452+ OpFunctorPair {a} x y -> ParamSPF {a} x x
3453+ ofpInAfterOut ofp = spfParamCompose (ofpIn ofp) (ofpOut ofp)
3454+
3455+ public export
3456+ ofpOutAfterIn : {a : Type } -> {x, y : SliceObj a} ->
3457+ OpFunctorPair {a} x y -> ParamSPF {a} y y
3458+ ofpOutAfterIn ofp = spfParamCompose (ofpOut ofp) (ofpIn ofp)
3459+
3460+ public export
3461+ OFPunit : {a : Type } -> {x, y : SliceObj a} -> OpFunctorPair {a} x y -> Type
3462+ OFPunit {a} {x} {y} ofp = ParamSPNatTrans (spfParamId y) (ofpOutAfterIn ofp)
3463+
3464+ public export
3465+ OFPcounit : {a : Type } -> {x, y : SliceObj a} -> OpFunctorPair {a} x y -> Type
3466+ OFPcounit {a} {x} {y} ofp = ParamSPNatTrans (ofpOutAfterIn ofp) (spfParamId y)
3467+
3468+ public export
3469+ record AdjFromUnit {a : Type } (x : SliceObj a) where
3470+ constructor AdjU
3471+ adjUsl : SliceObj a
3472+ adjUfp : OpFunctorPair {a} x adjUsl
3473+ adjUnt : OFPunit {a} adjUfp
3474+
3475+ public export
3476+ record AdjFromCounit {a : Type } (x : SliceObj a) where
3477+ constructor AdjC
3478+ adjCsl : SliceObj a
3479+ adjCfp : OpFunctorPair {a} x adjCsl
3480+ adjCnt : OFPcounit {a} adjCfp
3481+
3482+ public export
3483+ LeftAdjSet : Type -> Type -> Type
3484+ LeftAdjSet param pos =
3485+ pos -> Sigma {a= (SliceObj param)} (AdjFromUnit {a= param})
3486+
3487+ public export
3488+ RightAdjSet : Type -> Type -> Type
3489+ RightAdjSet param pos =
3490+ pos -> Sigma {a= (SliceObj param)} (AdjFromCounit {a= param})
3491+
3492+ public export
3493+ record CatFromAdj (a : Type ) where
3494+ constructor CfA
3495+ cfaLeftAdjSet : Sigma {a=Type } (LeftAdjSet a)
3496+ cfaRightAdjSet : Sigma {a=Type } (RightAdjSet a)
3497+
3498+ public export
3499+ TwoCatFromAdj : Type -> Type
3500+ TwoCatFromAdj a = a -> Sigma {a= Type } CatFromAdj
3501+
34403502-- ---------------
34413503-- -- Product ----
34423504-- ---------------
34433505
34443506public export
3445- DiagFunc : DepParamPolyFunc () Bool
3446- DiagFunc = (const Unit ** const (() , Unit ))
3507+ BoolCP : Type
3508+ BoolCP = Either Unit Unit
3509+
3510+ public export
3511+ DiagFunc : SlicePolyFunc () BoolCP
3512+ DiagFunc = SPFPolyDiag () BoolCP ()
34473513
34483514public export
3449- DiagSPF : SlicePolyFunc () Bool
3450- DiagSPF = SPFFromDPPF DiagFunc
3515+ DiagSPF : SlicePolyFunc () BoolCP
3516+ DiagSPF = DiagFunc
34513517
34523518public export
3453- DiagApp : (x : Type ) -> (b : Bool ) -> x -> InterpDPPF DiagFunc (const x) b
3519+ DiagApp : (x : Type ) -> (b : BoolCP ) -> x -> InterpSPFunc DiagFunc (const x) b
34543520DiagApp x b e = (() ** const e)
34553521
34563522public export
34573523diagTest : Nat -> (Nat , Nat )
3458- diagTest n = (snd (DiagApp Nat False n) () , snd (DiagApp Nat True n) () )
3524+ diagTest n =
3525+ (snd (DiagApp Nat (Left () ) n) () , snd (DiagApp Nat (Right () ) n) () )
34593526
34603527public export
34613528diagTestCorrect : (n : Nat ) -> diagTest n = (n, n)
34623529diagTestCorrect n = Refl
34633530
34643531public export
3465- ProductFunc : SlicePolyFunc Bool ()
3466- ProductFunc = ( const Unit ** const Bool ** DPair . snd )
3532+ ProductFunc : SlicePolyFunc BoolCP ()
3533+ ProductFunc = SPFPi BoolCP
34673534
34683535public export
3469- IProductFunc : SliceFunctor Bool ()
3536+ IProductFunc : SliceFunctor BoolCP ()
34703537IProductFunc = InterpSPFunc ProductFunc
34713538
34723539public export
34733540ProductInterp :
3474- (x, y : Type ) -> (x, y) -> IProductFunc (\b => if b then y else x) ()
3475- ProductInterp x y (ex, ey) = (() ** \ b => if b then ey else ex)
3541+ (x, y : Type ) -> (x, y) ->
3542+ IProductFunc (\b => case b of Right () => y ; Left () => x) ()
3543+ ProductInterp x y (ex, ey) =
3544+ (() ** \ b => case b of Right () => ey ; Left () => ex)
34763545
34773546public export
34783547productTest : (String, Nat ) -> (String, Nat )
34793548productTest (s, n) =
3480- (snd (ProductInterp String Nat (s, n)) False ,
3481- snd (ProductInterp String Nat (s, n)) True )
3549+ (snd (ProductInterp String Nat (s, n)) ( Left () ) ,
3550+ snd (ProductInterp String Nat (s, n)) ( Right () ) )
34823551
34833552public export
34843553productTestCorrect : (s : String) -> (n : Nat ) -> productTest (s, n) = (s, n)
@@ -3493,11 +3562,11 @@ ProdAdjRL : PolyFunc
34933562ProdAdjRL = PolyFuncFromUnitUnitSPF ProdAdjRLSPF
34943563
34953564public export
3496- ProdAdjLR : SlicePolyFunc Bool Bool
3565+ ProdAdjLR : SlicePolyFunc BoolCP BoolCP
34973566ProdAdjLR = spfCompose DiagSPF ProductFunc
34983567
34993568public export
3500- prodAdjCounit : SPNatTrans ProdAdjLR (spfId Bool )
3569+ prodAdjCounit : SPNatTrans ProdAdjLR (spfId BoolCP )
35013570prodAdjCounit =
35023571 (\ _ , _ => () ** \ (i ** (() ** _ )), () => ((() ** i) ** Refl ))
35033572
@@ -3506,35 +3575,37 @@ prodAdjUnit : PolyNatTrans PFIdentityArena ProdAdjRL
35063575prodAdjUnit = (const (() ** const () ) ** const (const () ))
35073576
35083577public export
3509- interpProdCounit : (x : SliceObj Bool ) ->
3510- SliceMorphism (InterpSPFunc ProdAdjLR x) (InterpSPFunc (spfId Bool ) x)
3511- interpProdCounit = InterpSPNT {f= ProdAdjLR } {g= (spfId Bool )} prodAdjCounit
3578+ interpProdCounit : (x : SliceObj BoolCP ) ->
3579+ SliceMorphism (InterpSPFunc ProdAdjLR x) (InterpSPFunc (spfId BoolCP ) x)
3580+ interpProdCounit = InterpSPNT {f= ProdAdjLR } {g= (spfId BoolCP )} prodAdjCounit
35123581
35133582public export
3514- testProdCounitObj : SliceObj Bool
3515- testProdCounitObj b = if b then Nat else String
3583+ testProdCounitObj : SliceObj BoolCP
3584+ testProdCounitObj b = case b of Right () => Nat ; Left () => String
35163585
35173586public export
35183587testProdCounit :
35193588 SliceMorphism
35203589 (InterpSPFunc ProdAdjLR ADTCat . testProdCounitObj)
3521- (InterpSPFunc (spfId Bool ) ADTCat . testProdCounitObj)
3590+ (InterpSPFunc (spfId BoolCP ) ADTCat . testProdCounitObj)
35223591testProdCounit = interpProdCounit testProdCounitObj
35233592
35243593public export
3525- prodCounitProj : (String, Nat ) -> (i : Bool ) -> if i then Nat else String
3594+ prodCounitProj : (String, Nat ) -> (i : BoolCP) ->
3595+ case i of Right () => Nat ; Left () => String
35263596prodCounitProj (s, n) i =
35273597 snd
35283598 (ADTCat . testProdCounit i
3529- ((() ** const () ) ** \ (() ** i') => if i' then n else s))
3599+ ((() ** const () ) ** \ (() ** i') =>
3600+ case i' of Right () => n ; Left () => s))
35303601 ()
35313602
35323603public export
3533- testProdCounitProj1 : prodCounitProj ("five", 5) False = "five"
3604+ testProdCounitProj1 : prodCounitProj ("five", 5) (Left () ) = "five"
35343605testProdCounitProj1 = Refl
35353606
35363607public export
3537- testProdCounitProj2 : prodCounitProj ("five", 5) True = 5
3608+ testProdCounitProj2 : prodCounitProj ("five", 5) (Right () ) = 5
35383609testProdCounitProj2 = Refl
35393610
35403611public export
@@ -3546,7 +3617,7 @@ interpProdUnit x ex =
35463617 (InterpPolyNT {p= PFIdentityArena } {q= ProdAdjRL }
35473618 prodAdjUnit x (() ** const ex))
35483619 in
3549- (ipnt (False ** () ), ipnt (True ** () ))
3620+ (ipnt (Left () ** () ), ipnt (Right () ** () ))
35503621
35513622-- L a -> b => a -> R b (`L a` and `b` are in the product category)
35523623-- R f . nu a
@@ -3565,11 +3636,11 @@ prodRightAdjunct a b b' g = (fst . g, snd . g)
35653636-- -----------------
35663637
35673638public export
3568- CoproductFunc : SlicePolyFunc Bool ()
3569- CoproductFunc = ( const Bool ** const Unit ** DPair . snd . DPair . fst )
3639+ CoproductFunc : SlicePolyFunc BoolCP ()
3640+ CoproductFunc = SPFSigma BoolCP
35703641
35713642public export
3572- CoprodAdjRL : SlicePolyFunc Bool Bool
3643+ CoprodAdjRL : SlicePolyFunc BoolCP BoolCP
35733644CoprodAdjRL = spfCompose DiagSPF CoproductFunc
35743645
35753646public export
@@ -3581,7 +3652,7 @@ CoprodAdjLR : PolyFunc
35813652CoprodAdjLR = PolyFuncFromUnitUnitSPF CoprodAdjLRSPF
35823653
35833654public export
3584- coprodAdjUnit : SPNatTrans (spfId Bool ) CoprodAdjRL
3655+ coprodAdjUnit : SPNatTrans (spfId BoolCP ) CoprodAdjRL
35853656coprodAdjUnit =
35863657 (\ b, () => (() ** const b) ** \ (b ** () ), (() ** () ) => (() ** Refl ))
35873658
@@ -3590,20 +3661,21 @@ coprodAdjCounit : PolyNatTrans CoprodAdjLR PFIdentityArena
35903661coprodAdjCounit = (const () ** const (const (() ** () )))
35913662
35923663public export
3593- ICoproductFunc : SliceFunctor Bool ()
3664+ ICoproductFunc : SliceFunctor BoolCP ()
35943665ICoproductFunc = InterpSPFunc CoproductFunc
35953666
35963667public export
35973668CoproductInterp :
3598- (x, y : Type ) -> Either x y -> ICoproductFunc (\b => if b then y else x) ()
3599- CoproductInterp x y (Left ex) = (False ** const ex)
3600- CoproductInterp x y (Right ey) = (True ** const ey)
3669+ (x, y : Type ) -> Either x y ->
3670+ ICoproductFunc (\b => case b of Right () => y ; Left () => x) ()
3671+ CoproductInterp x y (Left ex) = (Left () ** const ex)
3672+ CoproductInterp x y (Right ey) = (Right () ** const ey)
36013673
36023674public export
36033675coproductTest : Either String Nat -> Either String Nat
36043676coproductTest sn with (CoproductInterp String Nat sn)
3605- coproductTest sn | (False ** f) = Left $ f ()
3606- coproductTest sn | (True ** f) = Right $ f ()
3677+ coproductTest sn | (Left () ** f) = Left $ f ()
3678+ coproductTest sn | (Right () ** f) = Right $ f ()
36073679
36083680public export
36093681coproductTestCorrect : (sn : Either String Nat ) -> coproductTest sn = sn
0 commit comments