├── .gitignore ├── README.md ├── src ├── Bwd.hs ├── Th.hs ├── Tm.hs ├── Ty.hs └── Va.hs └── tex ├── LEOG.pdf ├── LEOG.tex └── pig.sty /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | dist-* 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.hie 7 | *.chi 8 | *.chs.h 9 | *.dyn_o 10 | *.dyn_hi 11 | .hpc 12 | .hsenv 13 | .cabal-sandbox/ 14 | cabal.sandbox.config 15 | *.prof 16 | *.aux 17 | *.hp 18 | *.eventlog 19 | .stack-work/ 20 | cabal.project.local 21 | cabal.project.local~ 22 | .HTF/ 23 | .ghc.environment.* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LEOG 2 | being an implementation of the calculus of constructions 3 | -------------------------------------------------------------------------------- /src/Bwd.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DeriveTraversable #-} 2 | 3 | module Bwd where 4 | 5 | data Bwd x = B0 | Bwd x :< x deriving (Show, Eq, Functor, Foldable, Traversable) 6 | 7 | ( Int -> x 8 | (xz :< x) Bool -> Th 14 | Th th -: b = Th (2 * th + (if b then 1 else 0)) 15 | 16 | wk :: Th 17 | wk = io -: False -- a.k.a -2 18 | 19 | me :: Th 20 | me = no -: True 21 | 22 | thun :: Th -> (Th, Bool) 23 | thun (Th th) = case divMod th 2 of 24 | (th, r) -> (Th th, r /= 0) 25 | 26 | instance Monoid Th where 27 | mempty = io 28 | mappend th ph 29 | | th == io = ph 30 | | ph == io = th 31 | | th == no = no 32 | | ph == no = no 33 | | otherwise = case thun ph of 34 | (ph, False) -> mappend th ph -: False 35 | (ph, True) -> case thun th of 36 | (th, b) -> mappend th ph -: b 37 | 38 | instance Semigroup Th where (<>) = mappend 39 | 40 | combien :: Th -> Int -> Int 41 | combien _ 0 = 0 42 | combien th m = case thun th of 43 | (th, b) -> combien th (m - 1) + (if b then 1 else 0) 44 | 45 | cod :: Int -> Th 46 | cod 0 = me 47 | cod n = cod (n - 1) -: False 48 | 49 | deb :: Th -> Int -- don't do this to no 50 | deb th = case thun th of 51 | (th, True) -> 0 52 | (th, False) -> deb th + 1 53 | 54 | cop :: Th {-i,m-} -> Th {-j,m-} 55 | -> {-least n-} (Th {-i,n-}, Th {-n,m-}, Th {-j,n-}) 56 | cop th ph 57 | | th == io = (io, io, ph) 58 | | ph == io = (th, io, io) 59 | | th == no = (no, ph, io) 60 | | ph == no = (io, th, no) 61 | | otherwise = case (thun th, thun ph) of 62 | ((th, False), (ph, False)) -> case cop th ph of 63 | (th, ps, ph) -> (th, ps -: False, ph) 64 | ((th, a), (ph, b)) -> case cop th ph of 65 | (th, ps, ph) -> (th -: a, ps -: True, ph -: b) 66 | 67 | relp :: (a, Th) -> (b, Th) -> ((a, Th), Th, (b, Th)) 68 | relp (a, th) (b, ph) = case cop th ph of 69 | (th, ps, ph) -> ((a, th), ps, (b, ph)) 70 | 71 | class Selects t where 72 | ( t {-m-} -> t {-n-} 73 | 74 | instance Selects (Bwd x) where 75 | th (if b then (:< x) else id) (th Th -> t 81 | 82 | instance Thins Th where 83 | th -^ ph = th <> ph 84 | 85 | instance Thins b => Thins (a, b) where (a, b) -^ th = (a, b -^ th) 86 | instance Thins x => Thins (Bwd x) where xz -^ th = fmap (-^ th) xz 87 | instance Thins x => Thins [x] where xz -^ th = fmap (-^ th) xz 88 | instance Thins Int where 89 | i -^ th 90 | | th == io = i 91 | | th == no = error "thinning a variable with no" 92 | | otherwise = case thun th of 93 | (th, False) -> 1 + (i -^ th) 94 | (th, True) -> if i == 0 then 0 else ((i - 1) -^ th) + 1 95 | 96 | -------------------------------------------------------------------------------- /src/Tm.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds, GADTs, KindSignatures, StandaloneDeriving, 2 | PatternSynonyms, LambdaCase, PatternGuards, TypeFamilies #-} 3 | 4 | module Tm where 5 | 6 | import Th 7 | import Bwd 8 | 9 | -- directions are "checkable" and "synthesizable" 10 | data Dir = Ch | Sy deriving (Show, Eq) 11 | 12 | -- terms are free, checkable, codebruijn 13 | type Term = (Tm Ch, Th) 14 | type Type = Term -- use this synonym to document terms trudsted to be types 15 | -- computations are free, synthesizable, codebruijn 16 | type Comp = (Tm Sy, Th) 17 | 18 | data Tm (d :: Dir) :: * where 19 | A :: Atom -> Tm Ch {-0-} 20 | U :: U -> Tm Ch {-0-} 21 | B :: Sc {-n-} -> Tm Ch {-n-} 22 | V :: Tm Sy {-1-} 23 | P :: Pair a c -> (Tm a, Th) {-n-} -> (Tm Ch, Th) {-n-} -> Tm c {-n-} 24 | -- note that the left and right thinnings must constitute a covering 25 | deriving instance Show (Tm d) 26 | 27 | -- atoms are represented numerically 28 | newtype Atom = N Int deriving (Show, Eq) 29 | pattern NIL = N 0 30 | pattern PI = N 1 31 | pattern IRR = N 2 32 | pattern QQ = N 3 33 | 34 | -- sorts are prop or type 35 | data U = Prop -- impredicative, inhabits and embeds in Type 1 and above 36 | | Type Int -- predicative, starts at Type 0 37 | | TYPE -- used only for checking judgements 38 | deriving (Show, Eq) 39 | 40 | -- scopes are vacuous or otherwise 41 | data Sc {-n-} :: * where 42 | K :: Tm Ch {-n-} -> Sc {-n-} 43 | L :: Tm Ch {-n+1-} -> Sc {-n-} 44 | deriving instance Show Sc 45 | 46 | -- valid forms of pairing 47 | data Pair (a :: Dir)(c :: Dir) :: * where 48 | C :: Pair Ch Ch -- canonical form 49 | R :: Pair Ch Sy -- radical 50 | E :: Pair Sy Sy -- elimination 51 | S :: Pair Sy Ch -- syn coerced into chk by eq prf 52 | deriving instance Show (Pair a c) 53 | 54 | -- smart constructor for pairing 55 | (%) :: Pair a c -> ((Tm a, Th) {-n-}, (Tm Ch, Th) {-n-}) -> (Tm c, Th) {-n-} 56 | p % (s, t) = case relp s t of 57 | (s, ps, t) -> (P p s t, ps) 58 | 59 | -- smart constructor for binding 60 | bi :: Term {-n+1-} -> Term {-n-} 61 | bi (t, Th th) = case divMod th 2 of 62 | (th, 0) -> (B (K t), Th th) 63 | (th, 1) -> (B (L t), Th th) 64 | 65 | -- going under a binder 66 | ib :: (Sc, Th) {-n-} -> Term {-n+1-} 67 | ib (K t, th) = (t, th -: False) 68 | ib (L t, th) = (t, th -: True) 69 | 70 | -- if term is a right-nested nil-terminated tuple, make it a list 71 | tup :: Term -> Maybe [Term] 72 | tup (A NIL, _) = pure [] 73 | tup (P C s t, ps) = (-^ ps) <$> ((s :) <$> tup t) 74 | tup _ = Nothing 75 | 76 | list :: [Term] -> Term 77 | list [] = (A NIL, no) 78 | list (x : xs) = C % (x, list xs) 79 | 80 | -- pi types 81 | pI :: Type {-n-} -> Type {-n+1-} -> Type {-n-} 82 | pI sS tT = list [(A PI, no), sS, bi tT] 83 | 84 | isPi :: XTm Ch {-n-} -- presumed normalised 85 | -> Maybe (Term {-n-}, Term {-n+1-}) 86 | isPi (XC (A PI, _) st) | Just [sS, b] <- tup st, XB tT <- xt b = Just (sS, tT) 87 | isPi _ = Nothing 88 | 89 | -- irr types 90 | irr :: Term {-n-} -> Type {-n-} 91 | irr pP = list [(A IRR, no), pP] 92 | 93 | -- type equality 94 | qTy :: Type {-n-} -> Type {-n-} -> Type {-n-} 95 | qTy sS tT = irr . list $ [(A QQ, no), sS, tT] 96 | 97 | 98 | -- top-layer expansion 99 | data XTm (d :: Dir) :: * where 100 | XA :: Atom -> XTm Ch {-n-} 101 | XU :: U -> XTm Ch {-n-} 102 | XB :: Term {-n+1-} -> XTm Ch {-n-} 103 | XC :: Term {-n-} -> Term {-n-} -> XTm Ch {-n-} 104 | XS :: Comp {-n-} -> Term {-n-} -> XTm Ch {-n-} 105 | XV :: Int {- XTm Sy {-n-} 106 | XE :: Comp {-n-} -> Term {-n-} -> XTm Sy {-n-} 107 | XR :: Term {-n-} -> Term {-n-} -> XTm Sy {-n-} 108 | deriving instance Show (XTm d) 109 | 110 | xt :: (Tm d, Th) {-n-} -> XTm d 111 | xt (t, th) = case t of 112 | A a -> XA a 113 | U u -> XU u 114 | B b -> XB (ib (b, th)) 115 | P C s t -> XC (s -^ th) (t -^ th) 116 | P S e q -> XS (e -^ th) (q -^ th) 117 | V -> XV (deb th) 118 | P E e s -> XE (e -^ th) (s -^ th) 119 | P R t u -> XR (t -^ th) (u -^ th) 120 | 121 | va :: Int -> Comp 122 | va i = (V, cod i) 123 | 124 | -- uglyprinting 125 | 126 | myNames :: [String] 127 | myNames = 128 | [ y:x 129 | | x <- "" : map show [0 ..] 130 | , y <- ['a'..'z'] 131 | ] 132 | 133 | blat :: Bwd String -> [String] -> Bool{-car?-} -> (Tm d, Th) -> String 134 | blat nz ns@(n:ns') b t = case xt t of 135 | XA (N 0) -> if b then "[]" else "" 136 | XA (N n) -> (if b then id else ("|"++)) $ show n 137 | XC s t -> if b 138 | then concat ["[", blat nz ns True s, blat nz ns False t, "]"] 139 | else concat [" ", blat nz ns True s, blat nz ns False t] 140 | _ | not b -> "|" ++ blat nz ns True t 141 | XU u -> show u 142 | XB t -> concat 143 | ["\\", n, ".", blat (nz :< n) ns' True t] 144 | XS e (A NIL, _) -> blat nz ns True e 145 | XS e q -> concat [blat nz ns True e, "{", blat nz ns True q, "}"] 146 | XV i -> nz concat ["(",blat nz ns True e, "-", blat nz ns True s, ")"] 148 | XR t u -> concat ["(",blat nz ns True t, ":", blat nz ns True u, ")"] 149 | 150 | displayClosed :: (Tm d, Th) -> IO () 151 | displayClosed t = putStrLn (blat B0 myNames True t) 152 | -------------------------------------------------------------------------------- /src/Ty.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase, GADTs, PatternGuards, DataKinds #-} 2 | 3 | module Ty where 4 | 5 | import Control.Monad 6 | 7 | import Bwd 8 | import Th 9 | import Tm 10 | import Va 11 | 12 | import Debug.Trace 13 | truce = const id 14 | 15 | ------------------------------------------------------------------------------ 16 | -- the monad of knowing the types of the free variables and sometimes barfing 17 | ------------------------------------------------------------------------------ 18 | 19 | -- a context is a snoc-list of types for the variables in scope 20 | -- those types are scoped over the whole context, ready for lookup 21 | type Cx = Bwd Type 22 | 23 | newtype TC x = TC {tc :: Cx -> Maybe x} 24 | instance Monad TC where 25 | return x = TC $ \ _ -> Just x 26 | TC a >>= k = TC $ \ ga -> a ga >>= \ a -> tc (k a) ga 27 | instance Applicative TC where pure = return; (<*>) = ap 28 | instance Functor TC where fmap = ap . return 29 | 30 | -- de Bruijn index range errors are not to be confused with type errors 31 | ixty :: Int -> TC Term 32 | ixty i = TC $ \ ga -> Just (ga TC Type {-ga-} 35 | nmTy tT = TC $ \ ga -> Just (tyev ga tT) 36 | 37 | nmTm :: Type {-ga-} -> Term {-ga-} -> TC Term {-ga-} 38 | nmTm tT (t, th) = TC $ \ ga -> Just (chev ga (th TC (Comp, Type) {-ga-} 41 | nmCo (e, th) = TC $ \ ga -> Just (evsy ga (th (Comp, Type){-n-} -> TC Type{-n-} 44 | (tT, th) // s = TC $ \ ga -> 45 | pure (chev ga (th Nothing 49 | 50 | must :: Maybe x -> TC x 51 | must (Just x) = pure x 52 | must Nothing = barf 53 | 54 | class Discharge t where 55 | discharge :: Type {-n-} -- type of bound variable 56 | -> t {-n+1-} -- thing under binding 57 | -> t {-n-} -- thing pulled out from under 58 | 59 | instance Discharge () where 60 | discharge _ _ = () 61 | 62 | instance Discharge Term where 63 | discharge _ = bi 64 | 65 | (!-) :: Discharge t => Type {-n-} -> TC t {-n+1-} -> TC t {-n-} 66 | sS !- TC f = TC $ \ ga -> case f ((ga :< sS) -^ wk) of 67 | Nothing -> Nothing 68 | Just t -> Just (discharge sS t) 69 | 70 | closed :: TC t {-0-} -> Maybe t 71 | closed (TC f) = f B0 72 | 73 | 74 | ------------------------------------------------------------------------------ 75 | -- check some types? 76 | ------------------------------------------------------------------------------ 77 | 78 | ty :: Term -> TC () 79 | ty = ch (U TYPE, no) 80 | 81 | ch :: Type -> Term -> TC () 82 | ch uU t | truce ("ch " ++ show uU ++ " " ++ show t) False = undefined 83 | ch uU t = case xt t of 84 | XU v -> (xt <$> nmTy uU) >>= \case 85 | XU w | ltU v w -> pure () 86 | _ -> barf 87 | x | Just (sS, tT) <- isPi x -> do 88 | uU <- nmTy uU 89 | case xt uU of 90 | XU Prop -> do 91 | ty sS 92 | sS !- ch uU tT 93 | XU _ -> do 94 | ch uU sS 95 | sS !- ch uU tT 96 | _ -> barf 97 | XB t -> (xt <$> nmTy uU) >>= \case 98 | x | Just (sS, tT) <- isPi x -> sS !- ch tT t 99 | _ -> barf 100 | XS e q -> do 101 | sS <- sy e 102 | sS <- tg sS q 103 | cu sS uU 104 | _ -> barf 105 | 106 | sy :: Comp -> TC Type 107 | sy e | truce ("sy " ++ show e) False = undefined 108 | sy e = case xt e of 109 | XV i -> ixty i 110 | XR t tT -> do 111 | ty tT 112 | ch tT t 113 | pure tT 114 | XE e s -> do 115 | sS <- sy e >>= nmTy 116 | case xt sS of 117 | x | Just (sS, tT) <- isPi x -> do 118 | ch sS s 119 | tT // ((R % (s, sS)), sS) 120 | _ -> barf 121 | 122 | tg :: Type -> Term -> TC Type 123 | tg sS q | truce ("tg " ++ show sS ++ " " ++ show q) False = undefined 124 | tg sS q = case xt q of 125 | XA NIL -> pure sS 126 | _ -> barf 127 | 128 | cu :: Type -> Type -> TC () 129 | cu sS tT | truce ("cu " ++ show sS ++ " " ++ show tT) False = undefined 130 | cu sS tT = do 131 | sS <- nmTy sS 132 | tT <- nmTy tT 133 | case (xt sS, xt tT) of 134 | (XU v, XU w) | leU v w -> pure () 135 | (XC (A PI, _) st0, XC (A PI, _) st1) 136 | | (Just [sS0, b0], Just [sS1, b1]) <- (tup st0, tup st1) 137 | , (XB tT0, XB tT1) <- (xt b0, xt b1) 138 | -> do 139 | cu sS1 sS0 140 | sS1 !- cu tT0 tT1 141 | _ -> uq sS tT 142 | 143 | leU :: U -> U -> Bool 144 | leU Prop Prop = True 145 | leU Prop (Type i) = True 146 | leU (Type i) (Type j) = i <= j 147 | leU _ TYPE = True 148 | leU _ _ = False 149 | 150 | ltU :: U -> U -> Bool 151 | ltU Prop (Type i) = True 152 | ltU (Type i) (Type j) = i < j 153 | ltU TYPE _ = False 154 | ltU _ TYPE = True 155 | ltU _ _ = False 156 | 157 | uq :: Type -> Type -> TC () 158 | uq aA bB | truce ("uq " ++ show aA ++ " " ++ show bB) False = undefined 159 | uq aA bB = do 160 | aA <- nmTy aA -- optimize another day 161 | bB <- nmTy bB 162 | case (xt aA, xt bB) of 163 | (XU v, XU w) | v == w -> pure () 164 | (a, b) | Just (aS, aT) <- isPi a, Just (bS, bT) <- isPi b -> do 165 | uq aS bS 166 | aS !- uq aT bT 167 | (XS ea qa, XS eb qb) -> do 168 | sS <- sq ea eb 169 | aA <- tg sS qa 170 | bB <- tg sS qb 171 | uq aA bB 172 | _ -> barf 173 | 174 | sq :: Comp -> Comp -> TC Type 175 | sq ea eb | truce ("sq " ++ show ea ++ " " ++ show eb) False = undefined 176 | sq ea eb = do 177 | ea <- fst <$> nmCo ea 178 | eb <- fst <$> nmCo eb 179 | case (xt ea, xt eb) of 180 | (XV i, XV j) | i == j -> ixty i 181 | (XR at aT, XR bt bT) -> do 182 | uq aT bT 183 | cq aT at bt 184 | pure aT 185 | (XE ea sa, XE eb sb) -> do 186 | sS <- sq ea eb >>= nmTy 187 | case xt sS of 188 | x | Just (sS, tT) <- isPi x -> do 189 | cq sS sa sb 190 | tT // (R % (sa, sS), sS) 191 | _ -> barf 192 | _ -> barf 193 | 194 | cq :: Type -> Term -> Term -> TC () 195 | cq uU a b = do 196 | uU <- nmTy uU 197 | a <- nmTm uU a 198 | b <- nmTm uU b 199 | case xt uU of 200 | XU _ -> uq a b 201 | x | Just (sS, tT) <- isPi x -> sS !- do 202 | let test f = E % ((R % (f, uU)) -^ wk, S % ((V, me), (A NIL, no))) 203 | sq (test a) (test b) 204 | pure () 205 | _ -> case (xt a, xt b) of 206 | (XS ea (A NIL, _), XS eb (A NIL, _)) -> do 207 | sq ea eb 208 | pure () 209 | _ -> barf 210 | -------------------------------------------------------------------------------- /src/Va.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds, GADTs, KindSignatures, StandaloneDeriving, 2 | PatternSynonyms, LambdaCase, PatternGuards #-} 3 | 4 | module Va where 5 | 6 | import Bwd 7 | import Th 8 | import Tm 9 | import Control.Arrow ((***), first, second) 10 | 11 | import Debug.Trace 12 | track = const id 13 | 14 | tyev :: Bwd {-m-} Type{-m-} -- cx 15 | -> Type {-m-} -- type over cx 16 | -> Type {-m-} -- type, normalised 17 | tyev de (u, th) = chev de (th Bwd {-n-} (Comp, Type){-m-} -- src var vals & types over trg cx 21 | -> Type {-m-} -- type over trg cx 22 | -> Tm Ch {-n-} -- src tm 23 | -> Term{-m-} -- trg val 24 | -- if it's an embedded computation, synthesize and ship 25 | chev de ga v (P S (e, th) (q, ph)) = case evsy de (th case chev de (ph ship de e u q v 28 | chev de ga _ (U u) = (U u, no) 29 | -- otherwise, it's canonical and should have a canonical type 30 | chev de ga u t = case tyev de u of 31 | u -> case (xt u, t) of 32 | (XU _, x) 33 | | Just ((sS, th), (tT, ph)) <- isPi (xt (x, io)) -> 34 | case chev de (th case chev ((de :< sS) -^ wk) (ph pI sS tT 37 | | Just [(A IRR, _), (pP, th)] <- tup (x, io) -> 38 | case chev de (th irr pP 40 | | A IRR <- t -> (A IRR, no) 41 | (x, B b) | Just (sS, tT) <- isPi x -> case ib (b, io) of 42 | (b, th) -> bi (chev ((de :< sS) -^ wk) (th 45 | list [(A QQ, no), chev de (th (A NIL, no) 51 | z -> error (show z) 52 | 53 | evsy :: Bwd {-m-} Type{-m-} -- trg cx 54 | -> Bwd {-n-} (Comp, Type){-m-} 55 | -> Tm Sy {-n-} 56 | -> (Comp, Type){-m-} 57 | evsy de (B0 :< eS) V = eS 58 | evsy de ga (P R (t, th) (u, ph)) = case chev de (ph case chev de (th (R % (t, u), u) 61 | evsy de ga (P E (e, th) (s, ph)) = case evsy de (th case tyev de u of 63 | u -> case xt u of 64 | x | Just (sS, (tT, ch)) <- isPi x -> 65 | case chev de (ph case cxen de :< (R % (s, sS), sS) of 67 | ga -> case chev de (ch case xt e of 69 | XR f _ | XB (t, ps) <- xt f -> case chev de (ps (R % (t, tT), tT) 71 | _ -> (E % (e, s), tT) 72 | evsy de ga e = error (show (ga, e)) 73 | 74 | ship :: Bwd {-m-} Type{-m-} -- cx 75 | -> Comp {-m-} -- what to ship 76 | -> Type {-m-} -- source type (normal) 77 | -> Term {-m-} -- path 78 | -> Type {-m-} -- target type (normal) 79 | -> Term {-m-} -- result 80 | ship de e u (A NIL, _) v | XR t _ <- xt e = t 81 | ship de e _ q _ = S % (e, q) 82 | 83 | 84 | 85 | 86 | wken :: Bwd {-n-} (Comp, Type){-m-} 87 | -> Type {-m-} 88 | -> Bwd {-n+1-} (Comp, Type){-m+1-} 89 | wken ga sS = (((-^ wk) *** (-^ wk)) <$> ga) :< ((V, me), sS -^ wk) 90 | 91 | cxen :: Bwd {-n-} Type{-m-} -- cx 92 | -> Bwd {-n-} (Comp{-n-}, Type{-m-}) -- identity environment on cx 93 | cxen B0 = B0 94 | cxen (ga :< s) = (first (-^ wk) <$> cxen ga) :< ((V, me), s) 95 | 96 | 97 | -- 98 | 99 | pidty :: U -> Term {-0-} 100 | pidty u = 101 | list [(A PI, no), (U u, no), bi $ 102 | list [(A PI, no), (S % (va 0, (A NIL, no))), bi (S % (va 1, (A NIL, no))) 103 | ] ] 104 | 105 | 106 | pidfu :: Term {-0-} 107 | pidfu = bi (bi (S % (va 0, (A NIL, no)))) 108 | 109 | ptest :: U -> Comp {-0-} 110 | ptest u = 111 | E % ( E % ( R % (pidfu, pidty u) 112 | , pidty (Type 0) 113 | ) 114 | , pidfu 115 | ) -------------------------------------------------------------------------------- /tex/LEOG.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pigworker/LEOG/5dafadda0a4d6cb7fc7701de2bb9902bc23b1442/tex/LEOG.pdf -------------------------------------------------------------------------------- /tex/LEOG.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{a4} 3 | \usepackage{pig} 4 | \usepackage{latexsym} 5 | 6 | \newcommand{\lsq}{\texttt{\symbol{91}}} 7 | \newcommand{\bsl}{\texttt{\symbol{92}}} 8 | \newcommand{\rsq}{\texttt{\symbol{93}}} 9 | \newcommand{\lcu}{\texttt{\symbol{123}}} 10 | \newcommand{\lba}{\texttt{\symbol{124}}} 11 | \newcommand{\rcu}{\texttt{\symbol{125}}} 12 | 13 | \begin{document} 14 | \title{LEOG} 15 | \author{Conor Mc Bride} 16 | \maketitle 17 | 18 | \section{introduction} 19 | 20 | I'm trying to cook up a variant of the Calculus of (Inductive, etc) Constructions which is \emph{bidirectional} in Curry style, and \emph{observational} in that equality reflects what you can do with things, rather than how they are constructed (which makes a difference when the elimination form does not permit observation of construction). 21 | 22 | The purpose of this note is simply to record what I think the rules are. 23 | 24 | 25 | \section{syntax} 26 | 27 | \newcommand{\Prop}{\textbf{Prop}} 28 | \newcommand{\Type}[1]{\textbf{Type}_{#1}} 29 | \newcommand{\TYPE}{\star} 30 | 31 | \subsection{sorts} 32 | 33 | We have sorts $\Prop$ and $\Type{n}$ for natural $n$. Administratively, we have a `topsort' $\TYPE$, which should appear only as the type in a checking judgement (i.e., morally, there is a separate type formation judgement) and as the upper bound in a cumulativity judgement (because a type of any sort is a type). 34 | 35 | As in CIC, the sort $\Prop$ admits impredicative universal quantification. 36 | 37 | 38 | \subsection{canonical things} 39 | 40 | \newcommand{\A}[1]{\texttt{'#1}} 41 | \newcommand{\nil}{\lsq\rsq} 42 | \newcommand{\X}[2]{\lsq#1\lba#2\rsq} 43 | \newcommand{\B}[2]{\bsl#1\texttt{.}\,#2} 44 | \newcommand{\E}[2]{#1\lcu#2\rcu} 45 | \newcommand{\PI}[3]{\lsq\A{Pi}\;#1\;\B{#2}{#3}\rsq} 46 | 47 | We have \emph{atoms} $\A{\textit{atom}}$. We have pairs $\X st$, with the usual LISP right-bias convention that $\nil$ the syntacitcally valid name for the atom $\A{}$, and $\lba\lsq$ may be omitted along with the matching $\rsq$. 48 | 49 | Invariance up to alpha-equivalence is quite helpful, so let us not use magical atoms for abstraction. Instead, let us have $\B xt$ abstracting the \emph{variable} $x$ from $t$. 50 | 51 | Given these ingredients, we can construct canonical forms such as $\PI SxT$. Note that canonical forms are not expected to make sense in and of themselves: the best we can hope is that sense is made of them. They will always be type\emph{checked}. 52 | 53 | Of course, once we have free variables, we have \emph{noncanonical} things. They embed in the canonical things as $\E eq$, where $e$ is noncanonical and $q$ is a canonical proof that $e$ fits where it's put. We may shorten $\E e\nil$ to $e$, as $\nil$ will always serve as the proof term when judgemental cumulativity/equality is enough. 54 | 55 | 56 | \subsection{noncanonical things} 57 | 58 | \newcommand{\e}[1]{\texttt{-}#1} 59 | \newcommand{\R}[2]{#1\texttt{:}#2} 60 | 61 | We have variables $x$ within $t$ for some $\B xt$. We also have $e\e s$ for noncanonical $s$, an eliminator appropriate to the type of $e$ (e.g., if $e$ is a function, $s$ is its argument). 62 | 63 | Finally, we have $\R tT$, a \emph{radical}, allowing us to annotate a canonical term with a canonical type, and thus form redexes. 64 | 65 | 66 | \section{typing awaiting computation} 67 | 68 | \newcommand{\ch}[2]{#1 \:\ni\: #2} 69 | \newcommand{\sy}[2]{#1 \:\in\: #2} 70 | \newcommand{\hy}{\;\vdash\;} 71 | \newcommand{\CU}[2]{\lsq\A{Le}\:#1\:#2\rsq} 72 | 73 | We shall have judgement forms for checking $\ch Tt$ (\emph{relying} on $\ch\TYPE T$) and synthesis $\sy eS$ (guaranteeing that $\ch\TYPE S$). At some point, these will be closed appropriately under computation, but let's leave that to the next section. 74 | 75 | 76 | \subsection{type checking} 77 | 78 | For sorts $w$, $u$, we have 79 | 80 | \[ 81 | \Rule{w > u} {\ch wu}\qquad 82 | \Axiom{\TYPE > \Type n}\quad 83 | \Axiom{\TYPE > \Prop}\quad 84 | \Rule{m > n}{\Type m > \Type n}\quad 85 | \Axiom{\Type n > \Prop} 86 | \] 87 | I'm aware that the Coq tradition (from the days of impredicative \textbf{Set}) is to place $\Prop$ on a par with $\Type 0$ and below $\Type 1$, but the above formulation says yes to all those things and more. Besides, this system isn't called LEOG for nothing. 88 | 89 | Meanwhile, for function types, 90 | \[ 91 | \Rule{\ch wS \hg \sy xS \hy \ch uT} 92 | {\ch u \PI SxT} 93 | \;\mbox{where}\; 94 | w = \left\{\begin{array}{ll}\TYPE & \mbox{if}\;u=\Prop\\ 95 | u & \mbox{otherwise}\end{array}\right. 96 | \] 97 | making $\Prop$ impredicative. 98 | 99 | For functions, we have 100 | \[\Rule{\sy xS \hy \ch Tt}{\ch{\PI SxT}{\B xt}} 101 | \] 102 | 103 | On the checking side, that leaves us with only the shipment of synthesizable terms. 104 | \[ 105 | \Rule{e\in S \hg \CU ST \ni q} 106 | {T\ni \E eq } 107 | \] 108 | where this $\A{Le}$ thing is \emph{propositional cumulativity}. For all sorts $u$, 109 | because for $u=\Prop$ 110 | \[ 111 | \Rule{\TYPE\ni S \hg \TYPE\ni T} 112 | {u\ni\CU ST} 113 | \] 114 | Let us have 115 | \[ 116 | \Axiom{\CU\Prop{\Type n} \ni \nil}\qquad 117 | \Rule{i < j} 118 | {\CU{\Type i}{\Type j}\ni \nil} 119 | \] 120 | and the (domain contravariant!) 121 | \[ 122 | \Rule{\CU{S'}S\ni \nil \hg \sy x{S'}\hy \CU T{T'}\ni \nil} 123 | {\CU{\PI SxT}{\PI{S'}x{T'}}\ni\nil} 124 | \] 125 | along with the inclusion of judgemental equality 126 | \[ 127 | \Rule{\TYPE\ni S\equiv T} 128 | {\CU ST \ni \nil} 129 | \] 130 | Nontrivial proofs of cumulativity will arrive in due course. 131 | 132 | 133 | \subsection{type synthesis} 134 | 135 | I write a reverse turnstile to indicate an appeal to a local hypothesis, 136 | which is as close as I get to mentioning the context. Radicals are 137 | straightforward, thanks to the `topsort'. 138 | \[ 139 | \Rule{\dashv\; \sy xS} 140 | {\sy x S} 141 | \qquad 142 | \Rule{\ch\TYPE T\hg \ch Tt} 143 | {\sy{\R tT}T} 144 | \qquad 145 | \Rule{\sy e{\PI SxT}\hg \ch Ss} 146 | {\sy{e\e s}{T[\R sS]}} 147 | \] 148 | Application is unremarkable, 149 | except to note that (i) there is no need to mention $x$ by name when 150 | substituting it, because it is clear that it is $x$ which has moved out of 151 | scope, and (ii) that $s$ has to be radicalised before it can be substituted 152 | for $x$, from sheer syntactic compatibility and to create new redexes. 153 | 154 | 155 | \section{computation, na\"\i vely} 156 | 157 | \newcommand{\st}{\leadsto} 158 | 159 | The basic plan is to extend checking and synthesis with small step reduction, so 160 | \[ 161 | \ch T{t\st v} \qquad \sy{e\st u}S 162 | \] 163 | with single substitution doing the work. In practice, I use a big step environment 164 | machine, but let us at least have an executable specification. We should first of all plug 165 | computation into typing. 166 | \[ 167 | \Rule{\ch\TYPE{T\st V}\hg V\ni t} 168 | {\ch Tt} 169 | \qquad 170 | \Rule{\sy eS \hg \ch\TYPE{S\st V}} 171 | {\sy eV} 172 | \] 173 | Doing so establishes the obligation that $\st^\ast$ does enough computation to expose 174 | a head canonical form, but need not go all the way to the canonical representative 175 | of the judgemental equivalence class. The latter is certainly an option, however. 176 | 177 | Note that these computation judgements have no \emph{subjects}. They may presume 178 | that the thing to be reduced has been checked already. Observe that, above left, 179 | the rule's client is responsible for $T$ being a type, whilst above right, $S$ 180 | the rule's first premise is responsible for $S$ being a type. Of course, the 181 | computation rules are responsible for the reduced terms they output, which must 182 | serve in place of the input. For checking, that means the type which checked the 183 | input checks the output; for synthesis, that means the type synthesized for the 184 | output must be \emph{possible} for the input --- type synthesis now admits 185 | post-computation and is thus ambiguous. 186 | 187 | So far, we have two rules which matter 188 | \[ 189 | \Axiom{\sy {(\R{\B xt}{\PI SxT})\e s \st (\R{t}{T})[\R sS]}{T[\R sS]}} 190 | \qquad 191 | \Axiom{\ch T{\E{\R sS}\nil \st s}} 192 | \] 193 | together with a bunch of structural closure rules, e.g. 194 | \[ 195 | \Rule{\sy xS \hy \ch\TYPE{T \st T'}} 196 | {\ch\TYPE{\PI SxT \st \PI Sx{T'}}} 197 | \] 198 | and a problem, if we want $\CU ST$ to be judgementally proof-irrelevant. We 199 | can't very well claim that the proof doesn't matter if we keep checking to see 200 | if it's $\nil$. We should, instead, check if it \emph{could} be $\nil$, and so 201 | we shall, in due course. 202 | 203 | 204 | \section{judgemental equality} 205 | 206 | We shall have judgements for type-directed equality of chceckables and type 207 | reconstructing equality of synthesizables. 208 | \[ 209 | \ch T{t_0\equiv t_1} \qquad \sy{e_0\equiv e_1}{S} 210 | \] 211 | where the former presumes $\ch\TYPE T$, $\ch T{t_0}$ and $\ch T{t_1}$, while 212 | the latter presumes $\sy{e_0}{S_0}$, $\sy{e_1}{S_1}$ and guarantees that 213 | $\ch\TYPE S$, with $\ch\TYPE S{S_0}$ and $\ch\TYPE S{S_1}$. 214 | 215 | Of course, these judgements are closed under computation in the appropriate way: 216 | \[ 217 | \Rule{\ch\TYPE{T\st V}\hg \ch V{t_0\equiv t_1}} 218 | {\ch T{t_0\equiv t_1}} 219 | \] 220 | \[ 221 | \Rule{\ch T{t_0\st v_0}\hg \ch T{v_0\equiv t_1}} 222 | {\ch T{t_0\equiv t_1}} 223 | \qquad 224 | \Rule{\ch T{t_1\st v_1}\hg \ch T{t_0\equiv v_1}} 225 | {\ch T{t_0\equiv t_1}} 226 | \] 227 | \[ 228 | \Rule{\sy{e_0\st w_0}{S_0}\hg \sy{w_0\equiv e_1}S} 229 | {\sy{e_0\equiv e_1}S} 230 | \qquad 231 | \Rule{\sy{e_1\st w_1}{S_1}\hg \sy{e_0\equiv w_1}S} 232 | {\sy{e_0\equiv e_1}S} 233 | \] 234 | \[ 235 | \Rule{\sy{e_0\equiv e_1}S\hg \ch\TYPE{S\st V}} 236 | {\sy{e_0\equiv e_1}V} 237 | \] 238 | 239 | Now, for canonical things, we have only reflexivity. 240 | \[ 241 | \Axiom{\ch w{\Prop\equiv\Prop}}\qquad 242 | \Axiom{\ch w{\Type i\equiv\Type i}} 243 | \] 244 | For functions, we $\eta$-expand: 245 | \[ 246 | \Rule{\sy xS \hy \ch T (\R{v_0}{\PI SxT})\e x \equiv (\R{v_1}{\PI SxT})\e x} 247 | {\ch{\PI SxT}{v_0\equiv v_1}} 248 | \] 249 | For embedded neutrals, we have 250 | \[ 251 | \Rule{\sy{e_0\equiv e_1}S} 252 | {\ch T{\E{e_0}{q_0} \equiv \E{e_1}{q_1}}} 253 | \] 254 | studiously ignoring the proofs $q_0$ and $q_1$. 255 | 256 | In the other direction, we have 257 | \[ 258 | \Rule{\dashv\; \sy xS} 259 | {\sy{x\equiv x}S} 260 | \qquad 261 | \Rule{\sy{e_0\equiv e_1}{\PI SxT}\hg \ch S{s_0\equiv s_1}} 262 | {\sy{e_0\e{s_0}\equiv e_1\e{s_1}}{T[\R{s_0}S]}} 263 | \] 264 | 265 | What to do about radicals that's better than 266 | \[ 267 | \Rule{\ch\TYPE{T_0\equiv T_1}\hg \ch{T_0}{t_0\equiv t_1}} 268 | {\sy{\R{t_0}{T_0}\equiv\R{t_1}{T_1}}{T_0}} 269 | \] 270 | is something I'll sleep on. 271 | 272 | \end{document} 273 | -------------------------------------------------------------------------------- /tex/pig.sty: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %%%%%%%%%% %%%%%%%%%% 3 | %%%%%%%%%% Epigram LaTeX Style %%%%%%%%%% 4 | %%%%%%%%%% %%%%%%%%%% 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | %%% This file is intended to replace the old macros.ltx. 8 | 9 | 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | %%% Colours %%% 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | 14 | \usepackage{color} 15 | \newcommand{\redFG}[1]{\textcolor[rgb]{0.6,0,0}{#1}} 16 | \newcommand{\greenFG}[1]{\textcolor[rgb]{0,0.4,0}{#1}} 17 | \newcommand{\blueFG}[1]{\textcolor[rgb]{0,0,0.8}{#1}} 18 | \newcommand{\orangeFG}[1]{\textcolor[rgb]{0.8,0.4,0}{#1}} 19 | \newcommand{\purpleFG}[1]{\textcolor[rgb]{0.4,0,0.4}{#1}} 20 | \newcommand{\yellowFG}[1]{\textcolor{yellow}{#1}} 21 | \newcommand{\brownFG}[1]{\textcolor[rgb]{0.5,0.2,0.2}{#1}} 22 | \newcommand{\blackFG}[1]{\textcolor[rgb]{0,0,0}{#1}} 23 | \newcommand{\whiteFG}[1]{\textcolor[rgb]{1,1,1}{#1}} 24 | \newcommand{\yellowBG}[1]{\colorbox[rgb]{1,1,0.2}{#1}} 25 | \newcommand{\brownBG}[1]{\colorbox[rgb]{1.0,0.7,0.4}{#1}} 26 | 27 | \newcommand{\ColourEpigram}{ 28 | \newcommand{\red}{\redFG} 29 | \newcommand{\green}{\greenFG} 30 | \newcommand{\blue}{\blueFG} 31 | \newcommand{\orange}{\orangeFG} 32 | \newcommand{\purple}{\purpleFG} 33 | \newcommand{\yellow}{\yellowFG} 34 | \newcommand{\brown}{\brownFG} 35 | \newcommand{\black}{\blackFG} 36 | \newcommand{\white}{\whiteFG} 37 | } 38 | 39 | \newcommand{\MonochromeEpigram}{ 40 | \newcommand{\red}{\blackFG} 41 | \newcommand{\green}{\blackFG} 42 | \newcommand{\blue}{\blackFG} 43 | \newcommand{\orange}{\blackFG} 44 | \newcommand{\purple}{\blackFG} 45 | \newcommand{\yellow}{\blackFG} 46 | \newcommand{\brown}{\blackFG} 47 | \newcommand{\black}{\blackFG} 48 | \newcommand{\white}{\blackFG} 49 | } 50 | 51 | 52 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53 | %%% Inference Rules (some ancient macros by Conor) %%% 54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 55 | 56 | \newlength{\rulevgap} 57 | \setlength{\rulevgap}{0.05in} 58 | \newlength{\ruleheight} 59 | \newlength{\ruledepth} 60 | \newsavebox{\rulebox} 61 | \newlength{\GapLength} 62 | \newcommand{\gap}[1]{\settowidth{\GapLength}{#1} \hspace*{\GapLength}} 63 | \newcommand{\dotstep}[2]{\begin{tabular}[b]{@{}c@{}} 64 | #1\\$\vdots$\\#2 65 | \end{tabular}} 66 | \newlength{\fracwid} 67 | \newcommand{\dotfrac}[2]{\settowidth{\fracwid}{$\frac{#1}{#2}$} 68 | \addtolength{\fracwid}{0.1in} 69 | \begin{tabular}[b]{@{}c@{}} 70 | $#1$\\ 71 | \parbox[c][0.02in][t]{\fracwid}{\dotfill} \\ 72 | $#2$\\ 73 | \end{tabular}} 74 | \newcommand{\Rule}[2]{\savebox{\rulebox}[\width][b] % 75 | {\( \frac{\raisebox{0in} {\( #1 \)}} % 76 | {\raisebox{-0.03in}{\( #2 \)}} \)} % 77 | \settoheight{\ruleheight}{\usebox{\rulebox}} % 78 | \addtolength{\ruleheight}{\rulevgap} % 79 | \settodepth{\ruledepth}{\usebox{\rulebox}} % 80 | \addtolength{\ruledepth}{\rulevgap} % 81 | \raisebox{0in}[\ruleheight][\ruledepth] % 82 | {\usebox{\rulebox}}} 83 | \newcommand{\Case}[2]{\savebox{\rulebox}[\width][b] % 84 | {\( \dotfrac{\raisebox{0in} {\( #1 \)}} % 85 | {\raisebox{-0.03in}{\( #2 \)}} \)} % 86 | \settoheight{\ruleheight}{\usebox{\rulebox}} % 87 | \addtolength{\ruleheight}{\rulevgap} % 88 | \settodepth{\ruledepth}{\usebox{\rulebox}} % 89 | \addtolength{\ruledepth}{\rulevgap} % 90 | \raisebox{0in}[\ruleheight][\ruledepth] % 91 | {\usebox{\rulebox}}} 92 | \newcommand{\Axiom}[1]{\savebox{\rulebox}[\width][b] % 93 | {$\frac{}{\raisebox{-0.03in}{$#1$}}$} % 94 | \settoheight{\ruleheight}{\usebox{\rulebox}} % 95 | \addtolength{\ruleheight}{\rulevgap} % 96 | \settodepth{\ruledepth}{\usebox{\rulebox}} % 97 | \addtolength{\ruledepth}{\rulevgap} % 98 | \raisebox{0in}[\ruleheight][\ruledepth] % 99 | {\usebox{\rulebox}}} 100 | \newcommand{\RuleSide}[3]{\gap{\mbox{$#2$}} \hspace*{0.1in} % 101 | \Rule{#1}{#3} % 102 | \hspace*{0.1in}\mbox{$#2$}} 103 | \newcommand{\AxiomSide}[2]{\gap{\mbox{$#1$}} \hspace*{0.1in} % 104 | \Axiom{#2} % 105 | \hspace*{0.1in}\mbox{$#1$}} 106 | \newcommand{\RULE}[1]{\textbf{#1}} 107 | \newcommand{\hg}{\hspace{0.2in}} 108 | 109 | 110 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 111 | % %%% Emphasis %%% 112 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 113 | % 114 | % %%% It's good to separate definitional emphasis... 115 | % 116 | % \newcommand{\demph}{\textbf} 117 | % 118 | % %%% ...from rhetorical emphasis. 119 | % 120 | % \newcommand{\remph}{\textit} 121 | % 122 | % 123 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 124 | % %%% Identifier Fonts %%% 125 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 126 | % 127 | % \newcommand{\CN}{\textsf} 128 | % 129 | % 130 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 131 | % %%% Expressions %%% 132 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 133 | % 134 | % \usepackage{upgreek} 135 | % 136 | % \newcommand{\LAMBINDER}{\red{\uplambda}} 137 | % \newcommand{\Bhab}[2]{#1\!:\!#2} 138 | % \newcommand{\To}{\mathop{\blue{\rightarrow}}} 139 | % \newcommand{\mto}{\mathop{\red{\mapsto}}} 140 | % 141 | % \newcommand{\PI}[2]{\blue{(}\Bhab{#1}{#2}\blue{)}\To} 142 | % \newcommand{\PIS}[1]{\blue{(}#1\blue{)}\To} 143 | % \newcommand{\LLAM}[2]{\LAMBINDER\Bhab{#1}{#2}\mto} 144 | % \newcommand{\LAM}[1]{\LAMBINDER #1 \mto} 145 | % 146 | % \newcommand{\TYPE}{\blue{\star}} 147 | % \newcommand{\EQ}{\mathrel{\D{=}}} 148 | % 149 | % \newcommand{\FROG}{\mbox{\(\backslash\!\!\!\mid\!\!\!\slash\)}} 150 | % 151 | % \newcommand{\ang}[1]{\red{\left<\black{#1}\right>}} 152 | % \newcommand{\sqr}[1]{\red{\left[\black{#1}\right]}} 153 | % \newcommand{\rbar}{\red{|}} 154 | % 155 | % \DeclareMathAlphabet{\mathkw}{OT1}{cmss}{bx}{n} 156 | % \newcommand{\K}[1]{\mathkw{#1}} 157 | % \newcommand{\M}[1]{\mathit{#1}} 158 | % \newcommand{\V}[1]{\purple{\mathit{#1}}} 159 | % \newcommand{\p}{\purple{'}} 160 | % \newcommand{\D}[1]{\blue{\CN{#1}}} 161 | % \newcommand{\tag}[1]{\red{\CN{#1}}} 162 | % \newcommand{\C}[2]{\ang{\tag{#1}#2}} 163 | % \newcommand{\F}[1]{\green{\CN{#1}}} 164 | % \newcommand{\U}[1]{\orange{\CN{#1}}} 165 | % 166 | % \newcommand{\Enum}{\D{Enum}} 167 | % \newcommand{\enum}[1]{\D{enum}\:#1} 168 | % 169 | % \newcommand{\Sig}{\D{Sig}} 170 | % \newcommand{\dom}[1]{\F{dom}\:#1} 171 | % \newcommand{\sig}[1]{\D{sig}\:#1} 172 | % \newcommand{\Refl}{\overline} 173 | % 174 | % \newcommand{\Rhab}{:} 175 | % 176 | % \newcommand{\Ret}[1]{\:\FATR\:#1} 177 | % \newcommand{\By}[1]{\:\FATL\:#1} 178 | % \newcommand{\Refute}[1]{\:\FROG\:#1} 179 | % \newcommand{\With}[1]{\:\&\:#1} 180 | % 181 | % \newcommand{\refl}[1]{\purple{\overline{\black{#1}}}} 182 | % \newcommand{\coe}[4]{#4\:\green{\left[\black{#3:#1\EQ#2}\right>}} 183 | % \newcommand{\coh}[4]% 184 | % {#4\:\green{\left[\!\left[\black{#3:#1\EQ#2}\right|\!\right>}} 185 | % 186 | % \newcommand{\qcoe}[3]{#1\:\green{\F{coe}(\black{#2\EQ #3})}} 187 | % \newcommand{\qcoh}[3]{#1\:\green{\F{coh}(\black{#2\EQ #3})}} 188 | % \newcommand{\qcong}[3]{#1\:\green{\F{cong}(\black{#2:#3})}} 189 | % 190 | % \newcommand{\naughtE}[1]{#1\:\green{\FROG}} 191 | % \newcommand{\caseE}[1]{#1\:\F{case}} 192 | % \newcommand{\ExpandE}[1]{#1\:\F{Expand}} 193 | % \newcommand{\DecodeE}[1]{#1\:\F{Decode}} 194 | % \newcommand{\KitE}[2]{#1\:\F{Kit(}#2\F{)}} 195 | % \newcommand{\hd}{\green{\bullet}} 196 | % \newcommand{\tl}{\green{-}} 197 | % \newcommand{\rZ}{\red{\mathsf{0}}} 198 | % \newcommand{\rS}{\red{\mathsf{S}}} 199 | % 200 | % 201 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 202 | % %%% Grammars %%% 203 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 204 | % 205 | % \newcommand{\SC}{\textsc} %% syntactic category 206 | % \newcommand{\Grammar}[2]{ 207 | % \begin{array}[t]{rrll} 208 | % #1 & ::= & #2 209 | % \end{array} 210 | % } 211 | % \newcommand{\Gor}{\\ & | &} %% separator making new row of array 212 | % \newcommand{\GNew}[1]{\medskip \\ #1 & ::= &} 213 | % \newcommand{\Gbr}[2]{\!\left\lgroup #2 \right\rgroup^{\!\!#1}} 214 | % 215 | % \newcommand{\wbox}{\square} 216 | % \newcommand{\bbox}{\blacksquare} 217 | % 218 | % 219 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 220 | % %%% Judgments %%% 221 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 222 | % 223 | % \newcommand{\EC}{\mathcal{E}} 224 | % \newcommand{\Tn}{\vdash} 225 | % \newcommand{\Eq}{\equiv} 226 | % \newcommand{\x}{\V{x}} 227 | % \newcommand{\xS}{\Bhab{\x}{S}} 228 | % 229 | % 230 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 231 | % %%% Computation Relations %%% 232 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 233 | % 234 | % \usepackage{amssymb} 235 | % \newcommand{\step}[1]{\leadsto_{#1}} 236 | % 237 | % 238 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 239 | % %%% Meta-Computation Relations %%% 240 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 241 | % 242 | % \newcommand{\mq}{\mathrel{\Longrightarrow}} 243 | % 244 | % 245 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 246 | % %%% Nonexamples %%% 247 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 248 | % 249 | % %%% Non-examples in display math must be explicitly marked as such, in order 250 | % %%% to avoid dangerous wrong learnings. 251 | % 252 | % \newcommand{\BAD}{\mbox{\(\red{(\times)}\)}} 253 | % \newcommand{\NONEXAMPLE}[1]{ 254 | % \[ 255 | % \BAD\qquad 256 | % #1 257 | % \]% 258 | % } 259 | % 260 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 261 | % %%% Source %%% 262 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 263 | % 264 | % \newenvironment{source}{\[\begin{array}[t]{ll}}{\end{array}\]} 265 | % 266 | % \newcommand{\letH}[2]{\K{let} & #1 \quad #2} 267 | % \newcommand{\letV}[2]{\K{let} & #1 \\ #2} 268 | % 269 | % \newcommand{\sgap}{\medskip \\} 270 | % \newcommand{\X}{l@{\:}} 271 | % \newcommand{\I}{@{\!\_}l@{}} 272 | % \newcommand{\prog}[2]{\begin{array}[t]{@{}#1}#2\end{array}} 273 | % \newcommand{\dent}[2]{\multicolumn{#1}{@{\;\;}l}{#2}} 274 | % \newcommand{\UPI}[1]{\PIBINDER{#1}\FATR} 275 | % \newcommand{\ULAM}[1]{\LAMBINDER{#1}\FATR} 276 | % 277 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 278 | % %%% Vertical Arrangement %%% 279 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 280 | % 281 | % \newcommand{\STL}[1]{\begin{array}[t]{@{}l@{}}#1\end{array}} 282 | % \newcommand{\STC}[1]{\begin{array}[t]{@{}c@{}}#1\end{array}} 283 | % \newcommand{\CASES}[1]{\begin{array}[t]{@{}l@{\;\mapsto\;}l@{}}#1\end{array}} 284 | % 285 | % 286 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 287 | % %%% Ecce %%% 288 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 289 | % 290 | % \newcommand{\ecce}[1]{\begin{array}{@{}l@{\;}l}#1\end{array}} 291 | % 292 | % \newcommand{\ecDEFN}[4]{ 293 | % \F{#1}&[\\ 294 | % \multicolumn{2}{@{}l}{\quad\ecce{#2}}\\ 295 | % \;]&\FATR\;#3\;:\:#4 \\ 296 | % } 297 | % \newcommand{\ecDefn}[4]{ 298 | % \F{#1} & [#2]\;\FATR\;#3\;:\:#4 \\ 299 | % } 300 | % \newcommand{\ecdefn}[3]{ 301 | % \F{#1} & \FATR\;#2\;:\:#3 \\ 302 | % } 303 | % \newcommand{\ecHOLE}[3]{ 304 | % \U{#1} & [\\ 305 | % \multicolumn{2}{@{}l}{\quad\ecce{#2}}\\ 306 | % \;]&\FATR\;?\;:\:#3\\ 307 | % } 308 | % \newcommand{\ecHole}[3]{ 309 | % \U{#1}&[#2]\;\FATR\;?\;:\:#3 \\ 310 | % } 311 | % \newcommand{\echole}[2]{ 312 | % \U{#1} & \FATR\;?\;:\:#2 \\ 313 | % } 314 | % \newcommand{\ecpara}[2]{ 315 | % \V{#1} & :\;#2 \\ 316 | % } 317 | % 318 | --------------------------------------------------------------------------------